#include <GUI.h>
Description
A component that provides managed input interaction suitable for making things like buttons, text boxes, etc.
Supported events:
- "on-click"
- "on-enter"
- "on-leave"
- "on-drag"
- "on-focus"
- "on-unfocus"
Functions | |
void | DefineRegion (int w, int h) |
bool | IsFocused () |
bool | IsHovered () |
bool | IsClicked () |
bool | IsBeingDragged () |
void | GrabInput () |
void | SetFocus () |
int | GetRegionW () |
int | GetRegionH () |
void | SetTooltipText (const std::string &tooltip) |
const std::string & | GetTooltipText () const |
void | OnStep () |
std::string | GetInfo () |
![]() | |
std::string | GetTag () |
Entity * | GetHost () const |
template<typename T > | |
T * | GetHostAs () const |
Entity::ID | GetHostID () const |
bool | EmitEvent (const std::string &eventName, Entity::ID source=Entity::ID(), const std::vector< std::string > &args={}) |
bool | CanHandleEvent (const std::string &eventName) |
void | InstallHook (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHook (const std::string &eventName, EventHandler) |
void | InstallHandler (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHandler (const std::string &eventName, EventHandler) |
std::vector< std::string > | GetKnownEvents () const |
Static Functions | |
static void | UngrabInput () |
static void | Unfocus () |
static bool | IsFocusedClicked () |
static bool | IsFocusedHovered () |
Additional Inherited Members | |
![]() | |
using | EventHandler = bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args) |
![]() | |
virtual void | OnDraw () |
virtual void | OnAttach () |
void | InstallEvent (const std::string &eventName, EventHandler mainHandler=nullptr, void *data=nullptr) |
void | UninstallEvent (const std::string &) |
Member Function Documentation
void DefineRegion | ( | int | w, |
int | h | ||
) |
Defines the input pointer region.
This is defined as a rectangle region where the given point is the topleft point of the rectangle and w and h are the width and height respectively of the rectangle
bool IsFocused | ( | ) |
Returns whether the GUI is focused view the SetFocus() function.
bool IsHovered | ( | ) |
Returns whether user's pointer is over this GUI's region this frame.
bool IsClicked | ( | ) |
Returns whether the user's pointer clicked within this GUI's region this frame.
bool IsBeingDragged | ( | ) |
Returns whether the user's pointer is attempting to drag the region.
void GrabInput | ( | ) |
|
static |
void SetFocus | ( | ) |
|
static |
Unsets the current;y focused widget.
This triggers the Unfocus event for the GUI that was previously focused.
|
static |
Convenience function to get whether the focused widget is clicked.
|
static |
Convenience function to get whether the focused widget is hovered.
int GetRegionW | ( | ) |
Returns the width of the defined region.
int GetRegionH | ( | ) |
Returns the height of the defined region.
void SetTooltipText | ( | const std::string & | tooltip | ) |
Sets text to appear if the pointer is above it.
const std::string& GetTooltipText | ( | ) | const |
Returns the currently set tooltip text. The default is the empty string.
|
virtual |
|
virtual |
Returns a string containing human-readable information on the state of the component.
Reimplemented from Component.
The documentation for this class was generated from the following file:
- /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Components/GUI.h