Midnight Blue Game and Engine
Public Member Functions | Properties | Events | List of all members
MB2D.UI.Button Class Reference

A pressable ui element with a single OnPress event More...

Inheritance diagram for MB2D.UI.Button:
Inheritance graph
Collaboration diagram for MB2D.UI.Button:
Collaboration graph

Public Member Functions

 Button (Texture2D normal, Texture2D selected, Texture2D pressed)
 Initializes a new instance of the T:MB2D.UI.Button class. More...
 
 Button ()
 Initializes a new instance of the T:MB2D.UI.Button class with no associated textures More...
 
override void Update ()
 Updates the button state. More...
 
- Public Member Functions inherited from MB2D.UI.UIControlElement
 UIControlElement (Texture2D normal, Texture2D selected, Texture2D pressed)
 Initializes a new instance of the T:MB2D.UI.UIControlElement class. More...
 
 UIControlElement ()
 Initializes a new instance of the T:MB2D.UI.UIControlElement class with no textures associated More...
 
override void Update ()
 Update the UIState of the control element based on mouse position More...
 
override void Draw (SpriteBatch spriteBatch)
 Draws the texture associated with the elements current UIState and then its TextContent on top of the texture More...
 
- Public Member Functions inherited from MB2D.UI.UIElement
void SetRelativeSize (UIContent parent, Point at, Point span)
 Sets the size of the element relative to its parent More...
 
void SetRelativeSize (UIContent parent, int atRow, int atCol, int rowSpan, int colSpan)
 Sets the size of the element relative to its parent More...
 

Properties

SoundEffectInstance PressedSound [get, set]
 Gets or sets the sound fired when transitioning to the pressed state. More...
 
- Properties inherited from MB2D.UI.UIControlElement
Color NormalTextColor [get, set]
 Gets or sets the TextContent color associated with the Normal UIState of the element. More...
 
Color HighlightedTextColor [get, set]
 Gets or sets the TextContent color associated with the Selected UIState of the element. More...
 
Texture2D NormalTexture [get, set]
 Gets or sets the normal UIState texture. More...
 
Texture2D HighlightedTexture [get, set]
 Gets or sets the selected UIState texture. More...
 
Texture2D PressedTexture [get, set]
 Gets or sets the pressed UIState texture. More...
 
SoundEffect HighlightedSound [get, set]
 Gets or sets the sound played when an element switches to the selected state. More...
 
- Properties inherited from MB2D.UI.UIElement
UIContent Content [get]
 Gets the UIContent of the element, only available in container elements More...
 
Vector2 Size [get]
 Gets the column and row count of the element More...
 
Rectangle BoundingBox [get]
 Gets the bounding box of this element More...
 
bool Fill [get, set]
 Gets or sets a value that indicates the element should be stretched or shrunk to fill its parents bounds exactly More...
 
Color BackgroundColor [get, set]
 Gets or sets the color of the elements background. More...
 
string TextContent [get, set]
 Gets or sets the string rendered by the element. More...
 
Color TextColor [get, set]
 Gets or sets the current color of the text. More...
 
SpriteFont Font [get, set]
 Gets or sets the font used in rendering the elements TextContent More...
 
bool BorderDisplayed [get, set]
 Gets or sets a value indicating whether this T:MB2D.UI.UIElement has itsborder displayed. More...
 
int BorderWidth [get, set]
 Gets or sets the width of the border. More...
 
Color BorderColor [get, set]
 Gets or sets the color of the border. More...
 
Color BorderTopColor [get, set]
 Gets or sets the color of the border top. More...
 
Color BorderRightColor [get, set]
 Gets or sets the color of the border right. More...
 
Color BorderBottomColor [get, set]
 Gets or sets the color of the border bottom. More...
 
Color BorderLeftColor [get, set]
 Gets or sets the color of the border left. More...
 
string Tag [get, set]
 Gets or sets the tag used to quickly access this element and uniquely identify it. More...
 

Events

EventHandler OnPress
 Occurs when the button has been clicked or pressed. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MB2D.UI.UIElement
 UIElement (int rows, int cols)
 Initializes a new instance of the T:MB2D.UI.UIElement class. Sets default property values More...
 
void DrawBorder (SpriteBatch spriteBatch)
 Draws the elements border to the window. Skips sides that have color set to Color.Transparent More...
 
- Protected Attributes inherited from MB2D.UI.UIControlElement
UIState _currentState
 The current UIState of the element More...
 
UIState _previousState
 The last state of the element More...
 

Detailed Description

A pressable ui element with a single OnPress event

Constructor & Destructor Documentation

§ Button() [1/2]

MB2D.UI.Button.Button ( Texture2D  normal,
Texture2D  selected,
Texture2D  pressed 
)
inline

Initializes a new instance of the T:MB2D.UI.Button class.

Parameters
normalNormal state texture
selectedSelected state texture.
pressedPressed state texture.

§ Button() [2/2]

MB2D.UI.Button.Button ( )
inline

Initializes a new instance of the T:MB2D.UI.Button class with no associated textures

Member Function Documentation

§ Update()

override void MB2D.UI.Button.Update ( )
inlinevirtual

Updates the button state.

Implements MB2D.UI.UIElement.

Property Documentation

§ PressedSound

SoundEffectInstance MB2D.UI.Button.PressedSound
getset

Gets or sets the sound fired when transitioning to the pressed state.

The pressed state sound.

Event Documentation

§ OnPress

EventHandler MB2D.UI.Button.OnPress

Occurs when the button has been clicked or pressed.


The documentation for this class was generated from the following file: