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

Base control class that all other controls inherits from. Defines basic UI control behaviour. More...

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

Public Member Functions

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...
 
virtual void Update ()
 Updates the object. More...
 
virtual void Draw ()
 Draw the object to screen. More...
 

Protected Member Functions

virtual void OnClicked ()
 
virtual void Draw (Point< int > position)
 

Properties

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...
 

Events

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

Detailed Description

Base control class that all other controls inherits from. Defines basic UI control behaviour.

Member Function Documentation

virtual void TriDevs.TriEngine.UI.Control.Disable ( )
virtual

Disables the control.

Implements TriDevs.TriEngine.UI.IControl.

86  {
87  Enabled = false;
88  }
virtual void TriDevs.TriEngine.UI.Control.Draw ( )
virtual

Draw the object to screen.

Implements TriDevs.TriEngine.Interfaces.IDrawable.

Reimplemented in TriDevs.TriEngine.UI.Label.

116  {
117  Draw(Position);
118  }
virtual void TriDevs.TriEngine.UI.Control.Draw ( Point< int >  position)
protectedvirtual
121  {
122  // Placeholder drawing,
123  // we should replace this with proper control drawing
124  GL.Disable(EnableCap.Texture2D);
125  var color = Color.ToVector3();
126  GL.Color3(color);
127  GL.Begin(BeginMode.Quads);
128  GL.Vertex2(position.X, position.Y);
129  GL.Vertex2(position.X + Size.X, position.Y);
130  GL.Vertex2(position.X + Size.X, position.Y + Size.Y);
131  GL.Vertex2(position.X, position.Y + Size.Y);
132  GL.End();
133  }

Here is the call graph for this function:

virtual void TriDevs.TriEngine.UI.Control.Enable ( )
virtual

Enables the control.

Implements TriDevs.TriEngine.UI.IControl.

81  {
82  Enabled = true;
83  }
virtual void TriDevs.TriEngine.UI.Control.Hide ( )
virtual

Hides the control.

Implements TriDevs.TriEngine.UI.IControl.

96  {
97  Visible = false;
98  }
virtual void TriDevs.TriEngine.UI.Control.OnClicked ( )
protectedvirtual

Reimplemented in TriDevs.TriEngine.UI.LinkLabel.

64  {
65  var func = Clicked;
66  if (func != null)
67  func(this, null);
68  }

Here is the caller graph for this function:

virtual void TriDevs.TriEngine.UI.Control.Show ( )
virtual

Shows the control.

Implements TriDevs.TriEngine.UI.IControl.

91  {
92  Visible = true;
93  }
virtual void TriDevs.TriEngine.UI.Control.Update ( )
virtual

Updates the object.

Implements TriDevs.TriEngine.Interfaces.IUpdatable.

Reimplemented in TriDevs.TriEngine.UI.Label.

101  {
102  // Return immediately if there is no mouse click
103  // We only run the click handlers if the user has is releasing
104  // the mouse button while on a control, to mimic how most UIs
105  // handle click events.
106  if (!Services.Input.MouseReleased(MouseButton.Left))
107  return;
108 
109  var mousePos = Services.Input.MousePosition;
110  if ((mousePos.X >= Rectangle.X && mousePos.X <= (Rectangle.X + Rectangle.Width))
111  && (mousePos.Y >= Rectangle.Y && mousePos.Y <= (Rectangle.Y + Rectangle.Height)))
112  OnClicked();
113  }

Property Documentation

virtual Color TriDevs.TriEngine.UI.Control.Color
getset
virtual bool TriDevs.TriEngine.UI.Control.Enabled
getset
virtual Point<int> TriDevs.TriEngine.UI.Control.Position
getset
virtual Rectangle TriDevs.TriEngine.UI.Control.Rectangle
getset
virtual Point<int> TriDevs.TriEngine.UI.Control.Size
getset
virtual string TriDevs.TriEngine.UI.Control.Text
getset
virtual bool TriDevs.TriEngine.UI.Control.Visible
getset

Event Documentation

ControlClickedEventHandler TriDevs.TriEngine.UI.Control.Clicked

Raised when this control is clicked on by the user.


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