SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
UIAttorney.h
1#ifndef UIAttorney_H
2#define UIAttorney_H
3
4#include "Button.h"
5#include "Canvas.h"
6
21{
22public:
34 {
35 private:
36 friend class UIComponent;
37 friend class Canvas;
38 friend class Dropdown;
39 friend class ScrollList;
40
45 static void Render(UIComponent* p) { p->Render(); };
46
54 static bool IsMouseOver(UIComponent* p, float xPos, float yPos) { return p->IsMouseOver(xPos, yPos); };
55
60 static void OnPress(UIComponent* p) { p->OnPress(); };
61
66 static UIComponentType GetType(UIComponent* p) { return p->GetType(); };
67
72 static void OnButtonHover(UIComponent* p) { static_cast<Button*>(p)->OnHover(); };
73
78 static void OnButtonHold(UIComponent* p) { static_cast<Button*>(p)->OnHold(); };
79
84 static void OnButtonRelease(UIComponent* p) { static_cast<Button*>(p)->OnRelease(); };
85
90 static bool IsEnabled(UIComponent* p) { return p->IsEnabled(); };
91
97 static void OnComponentLayerChanged(UIComponent* p, int oldLayer, int newLayer)
98 {
99 if (p->pOwningCanvas)
100 {
101 p->pOwningCanvas->OnComponentLayerChanged(p, oldLayer, newLayer);
102 }
103 };
104
105 };
106};
107
108#endif
A clickable UI button component.
Definition Button.h:30
Attorney for game loop access to UIComponent methods.
Definition UIAttorney.h:34
static void OnButtonRelease(UIComponent *p)
Calls the OnRelease method of the Button object.
Definition UIAttorney.h:84
static void OnComponentLayerChanged(UIComponent *p, int oldLayer, int newLayer)
Sets the enabled state of the UIComponent.
Definition UIAttorney.h:97
static void Render(UIComponent *p)
Calls the Render method of the UIComponent object.
Definition UIAttorney.h:45
static void OnButtonHover(UIComponent *p)
Calls the OnPress method of the Button object.
Definition UIAttorney.h:72
static bool IsEnabled(UIComponent *p)
Checks if the UIComponent is enabled.
Definition UIAttorney.h:90
static bool IsMouseOver(UIComponent *p, float xPos, float yPos)
Checks if the mouse is over the UIComponent object.
Definition UIAttorney.h:54
static void OnPress(UIComponent *p)
Calls the OnPress method of the UIComponent object.
Definition UIAttorney.h:60
static void OnButtonHold(UIComponent *p)
Calls the OnHold method of the Button object.
Definition UIAttorney.h:78
static UIComponentType GetType(UIComponent *p)
Calls the OnRelease method of the UIComponent object.
Definition UIAttorney.h:66
Attorney class for controlled access to UIComponent internals.
Definition UIAttorney.h:21
virtual bool IsMouseOver(float xPos, float yPos)=0
Checks if the mouse is over the component. Must be implemented by derived classes.
UIComponentType GetType() const
Gets the type of the UI component.
Definition UIComponent.h:55
Canvas * pOwningCanvas
Pointer to the owning canvas, if any.
Definition UIComponent.h:79
virtual void Render()=0
Renders the UI component. Must be implemented by derived classes.
bool IsEnabled() const
Returns whether the component is enabled or not.
Definition UIComponent.h:61
virtual void OnPress()=0
Handles press events on the component. Must be implemented by derived classes.