GUI Class Reference

#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 ()
 
- Functions inherited from Component
std::string GetTag ()
 
EntityGetHost () 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

- Public Types inherited from Component
using EventHandler = bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args)
 
- Protected Member Functions inherited from Component
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 ( )

Attempts to grab the input focus for this GUI.

If a GUI grabs the input focus, other GUI's will not have input events pushed to them.

static void UngrabInput ( )
static

Ungrabs the GUI that has grabbed input.

If no GUI has grabbed input, no action is taken.

void SetFocus ( )

Sets this GUI to be the focused widget.

Focusing has no inate effect on the GUI except for the return values from the IsFocused* set of functions.

static void Unfocus ( )
static

Unsets the current;y focused widget.

This triggers the Unfocus event for the GUI that was previously focused.

static bool IsFocusedClicked ( )
static

Convenience function to get whether the focused widget is clicked.

static bool IsFocusedHovered ( )
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.

void OnStep ( )
virtual

Function that is called upon each Run iteration. Component Run()s are run before the entity's run function.

Reimplemented from Component.

std::string GetInfo ( )
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