Gorgon Game Engine
Widget Class Referenceabstract

This class is the base for all widgets. More...

Inheritance diagram for Widget:
[legend]

Public Member Functions

 Widget ()
 
 Widget (Widget &&)=default
 
virtual ~Widget ()
 
virtual bool Activate ()=0
 Activates the widget. More...
 
bool AllowFocus () const
 If this widget can be focused currently. More...
 
virtual bool CharacterEvent (Char)
 This function should be called whenever a character is received from operating system. More...
 
bool Defocus ()
 Removes the focus from this widget if this widget is focused. More...
 
void Disable ()
 Disables the widget so that the user cannot interact with it. More...
 
virtual bool Done ()
 For widgets that supports it, this will trigger finalization the user interaction. More...
 
void Enable ()
 Enables the widget so that the user can interact with it. More...
 
bool EnsureVisible () const
 Ensures this widget is visible in its container by scrolling it into view. More...
 
bool Focus ()
 Transfers the focus to this widget. More...
 
Geometry::Bounds GetBounds () const
 Returns the bounds of the widget. More...
 
int GetHeight () const
 Returns the height of the widget. More...
 
virtual Geometry::Point GetLocation () const =0
 Returns the location of the widget. More...
 
WidgetContainerGetParent () const
 Returns the parent of this widget, throws if it does not have a parent. More...
 
virtual Geometry::Size GetSize () const =0
 Returns the size of the widget. More...
 
int GetWidth () const
 Returns the width of the widget. More...
 
bool HasParent () const
 Returns if this widget has a parent. More...
 
void Hide ()
 Hides this widget, when hidden, widgets cannot gain focus. More...
 
virtual bool IsEnabled () const =0
 Returns whether the widget is enabled. More...
 
bool IsFloating () const
 Returns floating status of this widget. More...
 
bool IsFocused () const
 Returns if this widget is focused. More...
 
bool IsVisible () const
 Returns if the widget is visible. More...
 
virtual bool KeyEvent (Input::Key, float)
 This function should be called whenever a key is pressed or released. More...
 
virtual void Move (const Geometry::Point &location)=0
 Moves this widget to the given position. More...
 
void Move (int x, int y)
 Moves this widget to the given position. More...
 
bool Remove ()
 Removes the widget from its parent. More...
 
virtual void Resize (const Geometry::Size &size)=0
 Changes the size of the widget. More...
 
virtual void Resize (int w, int h)
 Changes the size of the widget. More...
 
virtual void SetEnabled (bool value)=0
 Sets the enabled state of the widget. More...
 
void SetHeight (int height)
 Sets the height of the widget. More...
 
virtual void SetIsFloating (bool value)
 Sets floating status of this widget. More...
 
void setname (std::string value)
 This is a debug feature. More...
 
void SetVisible (bool value)
 Changes the visibility of the widget. More...
 
void SetWidth (int width)
 Sets the width of the widget. More...
 
void Show ()
 Shows this widget, widgets are visible by default. More...
 
void ToggleEnabled ()
 Toggles enabled state of the widget. More...
 
void ToggleVisible ()
 Toggles the visibility state of the widget. More...
 

Public Attributes

Event< WidgetBoundsChangedEvent
 This event will be fired when the area that the widget occupies on its container is changed. More...
 
std::string dbgname
 
Event< WidgetFocusEvent
 This event will be fired when the widget receives or looses focus. More...
 
Geometry::PointProperty< Widget, &Widget::getlocation, &Widget::move > Location
 
Geometry::SizeProperty< Widget, &Widget::getsize, &Widget::resize > Size
 

Protected Member Functions

virtual void addedto (WidgetContainer &container)
 Called when this widget added to the given container. More...
 
virtual bool addingto (WidgetContainer &)
 Called when it is about to be added to the given container. More...
 
virtual void addto (Layer &layer)=0
 When called, widget should locate itself on to this layer. More...
 
virtual bool allowfocus () const
 Should return true if the widget can be focused. More...
 
virtual void boundschanged ()
 Call this function when the widget bounds is changed. More...
 
virtual bool canloosefocus () const
 Should return true if the widget can loose the focus right now. More...
 
virtual void displaced ()
 Call this function when the widget container causes it to be displaced. More...
 
virtual void focused ()
 This is called after the focus is transferred to this widget. More...
 
virtual void focuslost ()
 This is called after the focus is lost. More...
 
virtual void parentenabledchanged (bool state)
 This function is called when the parent's enabled state changes. More...
 
virtual void removed ()
 Called after this widget is removed from its parent. More...
 
virtual void removefrom (Layer &layer)=0
 When called, widget should remove itself from the given layer. More...
 
virtual bool removingfrom ()
 Called before this widget is removed from its parent. More...
 
virtual void setlayerorder (Layer &layer, int order)=0
 When called, widget should reorder itself in layer hierarchy. More...
 

Detailed Description

This class is the base for all widgets.

Constructor & Destructor Documentation

◆ Widget() [1/2]

Widget ( )

◆ Widget() [2/2]

Widget ( Widget &&  )
default

◆ ~Widget()

virtual ~Widget ( )
virtual

Member Function Documentation

◆ Activate()

◆ addedto()

void addedto ( WidgetContainer container)
protectedvirtual

Called when this widget added to the given container.

References Widget::boundschanged(), WidgetContainer::IsEnabled(), Widget::IsVisible(), and Widget::parentenabledchanged().

◆ addingto()

virtual bool addingto ( WidgetContainer )
protectedvirtual

Called when it is about to be added to the given container.

◆ addto()

virtual void addto ( Layer layer)
protectedpure virtual

When called, widget should locate itself on to this layer.

Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.

◆ AllowFocus()

bool AllowFocus ( ) const

If this widget can be focused currently.

References Widget::allowfocus().

◆ allowfocus()

virtual bool allowfocus ( ) const
protectedvirtual

◆ boundschanged()

void boundschanged ( )
protectedvirtual

Call this function when the widget bounds is changed.

Reimplemented in ListboxWidgetBase< T_, W_, TRF_, STR_, SELTR_, useisvisible, TW_ >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, and DropdownBase< T_, TW_, L_ >.

References Widget::BoundsChangedEvent, and WidgetContainer::childboundschanged().

◆ canloosefocus()

virtual bool canloosefocus ( ) const
protectedvirtual

Should return true if the widget can loose the focus right now.

Even if you return false, you still might be forced to loose focus, even without this function getting called.

◆ CharacterEvent()

virtual bool CharacterEvent ( Char  )
virtual

This function should be called whenever a character is received from operating system.

Reimplemented in Panel, and Composer.

◆ Defocus()

bool Defocus ( )

Removes the focus from this widget if this widget is focused.

This function will not transfer the focus to another widget.

References Widget::IsFocused(), and WidgetContainer::RemoveFocus().

◆ Disable()

void Disable ( )

Disables the widget so that the user cannot interact with it.

References Widget::SetEnabled().

◆ displaced()

virtual void displaced ( )
protectedvirtual

Call this function when the widget container causes it to be displaced.

This function will not be called when the widget is moved on parent.

Reimplemented in DropdownBase< T_, TW_, L_ >.

◆ Done()

virtual bool Done ( )
virtual

For widgets that supports it, this will trigger finalization the user interaction.

This may cause widget fire change event or reorganize itself.

◆ Enable()

void Enable ( )

Enables the widget so that the user can interact with it.

References Widget::SetEnabled().

◆ EnsureVisible()

bool EnsureVisible ( ) const

Ensures this widget is visible in its container by scrolling it into view.

This function will not change visibility of the widget and will return false if the widget is not visible. This function cannot be expected to take outside factors into account, such as occlusion.

References WidgetContainer::EnsureVisible().

◆ Focus()

bool Focus ( )

Transfers the focus to this widget.

Returns true if the focus is actually transferred to this widget

References Widget::allowfocus(), and WidgetContainer::SetFocusTo().

◆ focused()

void focused ( )
protectedvirtual

This is called after the focus is transferred to this widget.

Reimplemented in RadioButtons< T_, W_ >, Panel, ListboxWidgetBase< T_, W_, TRF_, STR_, SELTR_, useisvisible, TW_ >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, Composer, and ComponentStackWidget.

References Widget::FocusEvent.

◆ focuslost()

void focuslost ( )
protectedvirtual

This is called after the focus is lost.

This is called even if focus removal is forced.

Reimplemented in Panel, ListboxWidgetBase< T_, W_, TRF_, STR_, SELTR_, useisvisible, TW_ >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, Composer, and ComponentStackWidget.

References Widget::FocusEvent.

◆ GetBounds()

Geometry::Bounds GetBounds ( ) const

Returns the bounds of the widget.

References Widget::GetLocation(), and Widget::GetSize().

◆ GetHeight()

int GetHeight ( ) const

Returns the height of the widget.

References Widget::GetSize(), and basic_Size< T_ >::Height.

◆ GetLocation()

virtual Geometry::Point GetLocation ( ) const
pure virtual

Returns the location of the widget.

Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.

◆ GetParent()

WidgetContainer & GetParent ( ) const

Returns the parent of this widget, throws if it does not have a parent.

◆ GetSize()

virtual Geometry::Size GetSize ( ) const
pure virtual

Returns the size of the widget.

Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.

◆ GetWidth()

int GetWidth ( ) const

Returns the width of the widget.

References Widget::GetSize(), and basic_Size< T_ >::Width.

◆ HasParent()

bool HasParent ( ) const

Returns if this widget has a parent.

◆ Hide()

void Hide ( )

Hides this widget, when hidden, widgets cannot gain focus.

References Widget::SetVisible().

◆ IsEnabled()

virtual bool IsEnabled ( ) const
pure virtual

Returns whether the widget is enabled.

Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.

◆ IsFloating()

bool IsFloating ( ) const

Returns floating status of this widget.

Floating widgets will not be moved or resized by organizers.

◆ IsFocused()

bool IsFocused ( ) const

Returns if this widget is focused.

◆ IsVisible()

bool IsVisible ( ) const

Returns if the widget is visible.

◆ KeyEvent()

virtual bool KeyEvent ( Input::Key  ,
float   
)
virtual

This function should be called whenever a key is pressed or released.

Reimplemented in Panel, RadioButtons< T_, W_ >, ListboxWidgetBase< T_, W_, TRF_, STR_, SELTR_, useisvisible, TW_ >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_STLVector< T_, ListItem, std::vector< T_ >, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Multi< T_, ListItem, MultiListbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, ListboxWidgetBase< T_, ListItem, internal::LBTRF_ListItem< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSTR_Collection< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, internal::LBSELTR_Single< T_, ListItem, SimpleCollectionbox< T_, internal::SetTextUsingFrom< T_, ListItem > > >, false, internal::SetTextUsingFrom< T_, ListItem > >, Composer, Checkbox, and Button.

◆ Move() [1/2]

virtual void Move ( const Geometry::Point location)
pure virtual

Moves this widget to the given position.

Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.

◆ Move() [2/2]

void Move ( int  x,
int  y 
)

Moves this widget to the given position.

◆ parentenabledchanged()

virtual void parentenabledchanged ( bool  state)
protectedvirtual

This function is called when the parent's enabled state changes.

Reimplemented in RadioButtons< T_, W_ >, Panel, and ComponentStackWidget.

◆ Remove()

bool Remove ( )

Removes the widget from its parent.

Returns true if the widget has no parent after the operation.

References WidgetContainer::Remove().

◆ removed()

void removed ( )
protectedvirtual

Called after this widget is removed from its parent.

Reimplemented in ComponentStackWidget.

References Widget::boundschanged(), WidgetContainer::childboundschanged(), and Widget::IsVisible().

◆ removefrom()

virtual void removefrom ( Layer layer)
protectedpure virtual

When called, widget should remove itself from the given layer.

Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.

◆ removingfrom()

virtual bool removingfrom ( )
protectedvirtual

Called before this widget is removed from its parent.

◆ Resize() [1/2]

virtual void Resize ( const Geometry::Size size)
pure virtual

Changes the size of the widget.

Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.

◆ Resize() [2/2]

virtual void Resize ( int  w,
int  h 
)
virtual

Changes the size of the widget.

◆ SetEnabled()

virtual void SetEnabled ( bool  value)
pure virtual

Sets the enabled state of the widget.

Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.

◆ SetHeight()

void SetHeight ( int  height)

Sets the height of the widget.

References Widget::GetWidth(), and Widget::Resize().

◆ SetIsFloating()

virtual void SetIsFloating ( bool  value)
virtual

Sets floating status of this widget.

Floating widgets will not be moved or resized by organizers.

References Widget::boundschanged().

◆ setlayerorder()

virtual void setlayerorder ( Layer layer,
int  order 
)
protectedpure virtual

When called, widget should reorder itself in layer hierarchy.

Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.

◆ setname()

void setname ( std::string  value)

This is a debug feature.

References Widget::dbgname.

◆ SetVisible()

void SetVisible ( bool  value)

Changes the visibility of the widget.

References WidgetContainer::childboundschanged(), and Widget::Defocus().

◆ SetWidth()

void SetWidth ( int  width)

Sets the width of the widget.

References Widget::GetHeight(), and Widget::Resize().

◆ Show()

void Show ( )

Shows this widget, widgets are visible by default.

References Widget::SetVisible().

◆ ToggleEnabled()

void ToggleEnabled ( )

Toggles enabled state of the widget.

References Widget::IsEnabled(), and Widget::SetEnabled().

◆ ToggleVisible()

void ToggleVisible ( )

Toggles the visibility state of the widget.

References Widget::IsVisible(), and Widget::SetVisible().

Member Data Documentation

◆ BoundsChangedEvent

Event<Widget> BoundsChangedEvent

This event will be fired when the area that the widget occupies on its container is changed.

It will be fired when the widget is hidden or shown or its parent is changed. Movement, resize and parent change will not trigger this event if the widget is not visible. Similarly, if the object does not have a parent movement and resize will not trigger this event. Organizers use this event to rearrange widgets, thus it is not advisable to remove all handlers from this event.

◆ dbgname

std::string dbgname

◆ FocusEvent

Event<Widget> FocusEvent

This event will be fired when the widget receives or looses focus.

◆ Location

Geometry::PointProperty<Widget, &Widget::getlocation, &Widget::move> Location

◆ Size

Geometry::SizeProperty<Widget, &Widget::getsize, &Widget::resize> Size

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