TriEngine  v0.0.16
General-purpose engine in C#/OpenGL
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
TriDevs.TriEngine.UI.Label Class Reference

A simple label to display text on the screen. More...

Inheritance diagram for TriDevs.TriEngine.UI.Label:
[legend]
Collaboration diagram for TriDevs.TriEngine.UI.Label:
[legend]

Public Member Functions

virtual void SetFont (Font font)
 Sets the font that this label uses. More...
 
override void Update ()
 Updates the object. More...
 
override void Draw ()
 Draw the object to screen. More...
 
- Public Member Functions inherited from TriDevs.TriEngine.UI.Control
virtual void Enable ()
 Enables the control. More...
 
virtual void Disable ()
 Disables the control. More...
 
virtual void Show ()
 Shows the control. More...
 
virtual void Hide ()
 Hides the control. More...
 

Protected Member Functions

virtual void UpdateTextObject ()
 
- Protected Member Functions inherited from TriDevs.TriEngine.UI.Control
virtual void OnClicked ()
 
virtual void Draw (Point< int > position)
 

Properties

override string Text [get, set]
 
override Point< int > Position [get, set]
 
virtual QFontAlignment Alignment [get, set]
 Gets or sets the QFontAlignment of this label's text. More...
 
- Properties inherited from TriDevs.TriEngine.UI.Control
virtual bool Enabled [get, set]
 
virtual bool Visible [get, set]
 
virtual Color Color [get, set]
 
virtual Point< int > Position [get, set]
 
virtual Point< int > Size [get, set]
 
virtual Rectangle Rectangle [get, set]
 
virtual string Text [get, set]
 
- Properties inherited from TriDevs.TriEngine.UI.IControl
bool Enabled [get, set]
 Gets or sets a value indicating whether this control can be interacted with. More...
 
bool Visible [get, set]
 Gets or sets a value indicating whether this control should be drawn to the screen. More...
 
Color Color [get, set]
 The color of this control. More...
 
Point< int > Position [get, set]
 The position of this control, in pixel coordinates. More...
 
Point< int > Size [get, set]
 Gets or sets the size of this control, in pixels. More...
 
Rectangle Rectangle [get, set]
 Gets the rectangular area on the screen that this control is occupying. More...
 
string Text [get, set]
 Gets or sets the text associated with this control. More...
 

Additional Inherited Members

- Events inherited from TriDevs.TriEngine.UI.Control
ControlClickedEventHandler Clicked
 Raised when this control is clicked on by the user. More...
 

Detailed Description

A simple label to display text on the screen.

Member Function Documentation

override void TriDevs.TriEngine.UI.Label.Draw ( )
virtual

Draw the object to screen.

Reimplemented from TriDevs.TriEngine.UI.Control.

135  {
136  base.Draw(_drawPosition);
137 
138  if (_textObject == null)
139  return;
140 
141  _textObject.Draw();
142  }
virtual void TriDevs.TriEngine.UI.Label.SetFont ( Font  font)
virtual

Sets the font that this label uses.

Parameters
fontThe new font instance to use.
82  {
83  _font = font;
85  }
override void TriDevs.TriEngine.UI.Label.Update ( )
virtual

Updates the object.

Reimplemented from TriDevs.TriEngine.UI.Control.

121  {
122  // Override update logic to translate mouse click
123  // positions when label is aligned in a certain way
124 
125  if (!Services.Input.MouseReleased(MouseButton.Left))
126  return;
127 
128  var mousePos = Services.Input.MousePosition;
129  if ((mousePos.X >= _drawPosition.X && mousePos.X <= (_drawPosition.X + Rectangle.Width))
130  && (mousePos.Y >= _drawPosition.Y && mousePos.Y <= (_drawPosition.Y + Rectangle.Height)))
131  OnClicked();
132  }
virtual void TriDevs.TriEngine.UI.Label.UpdateTextObject ( )
protectedvirtual
88  {
89  if (_font == null)
90  return;
91 
92  if (_textObject == null)
93  {
94  _textObject = new TextObject(_text, _font, Position, Alignment);
95  }
96  else
97  {
98  _textObject.Text = Text;
99  _textObject.Font = _font;
100  _textObject.Position = Position;
101  _textObject.Alignment = Alignment;
102  }
103 
104  Size = new Point<int>(_textObject.Bounds.Width, _textObject.Bounds.Height);
105 
106  switch (Alignment)
107  {
108  case QFontAlignment.Centre:
109  _drawPosition = new Point<int>(Position.X - Size.X / 2, Position.Y);
110  break;
111  case QFontAlignment.Right:
112  _drawPosition = new Point<int>(Position.X - Size.X, Position.Y);
113  break;
114  default:
115  _drawPosition = Position;
116  break;
117  }
118  }

Property Documentation

virtual QFontAlignment TriDevs.TriEngine.UI.Label.Alignment
getset

Gets or sets the QFontAlignment of this label's text.

override Point<int> TriDevs.TriEngine.UI.Label.Position
getset
override string TriDevs.TriEngine.UI.Label.Text
getset

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