![]() |
Gorgon Game Engine
|
This class is the base for all widgets. More...
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... | |
WidgetContainer & | GetParent () 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< Widget > | BoundsChangedEvent |
This event will be fired when the area that the widget occupies on its container is changed. More... | |
std::string | dbgname |
Event< Widget > | FocusEvent |
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... | |
This class is the base for all widgets.
Widget | ( | ) |
|
virtual |
|
pure virtual |
Activates the widget.
This might perform the action if the widget is a button, forward the focus if it is a label or focus if it is an input field.
Implemented in SliderBase< T_, DIV_, VAL_, P_, interactive, valuemapping >, SliderBase< T_, DIV_, VAL_, Gorgon::NumericProperty, interactive, valuemapping >, SliderBase< T_, FloatDivider< T_ >, FloatToValue< T_ >, Gorgon::NumericProperty, internal::SliderInteractivity::None, internal::SliderValueMapping::OneValue >, SliderBase< T_, FloatDivider< T_ >, FloatToValue< T_ >, Gorgon::NumericProperty, internal::SliderInteractivity::HandleAndPage, internal::SliderValueMapping::ValueAndRange >, SliderBase< int, FloatDivider< int >, FloatToValue< int >, Gorgon::NumericProperty, internal::SliderInteractivity::None, internal::SliderValueMapping::OneValue >, SliderBase< int, DIV_, VAL_, Gorgon::NumericProperty, interactive, valuemapping >, RadioButtons< T_, W_ >, Panel, ListItem, Layerbox, Label, Composer, Checkbox, Button, MultiCollectionbox< T_, TW_ >, SimpleCollectionbox< T_, TW_ >, MultiListbox< T_, TW_ >, and SimpleListbox< T_, TW_ >.
|
protectedvirtual |
Called when this widget added to the given container.
References Widget::boundschanged(), WidgetContainer::IsEnabled(), Widget::IsVisible(), and Widget::parentenabledchanged().
|
protectedvirtual |
Called when it is about to be added to the given container.
|
protectedpure virtual |
When called, widget should locate itself on to this layer.
Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.
bool AllowFocus | ( | ) | const |
If this widget can be focused currently.
References Widget::allowfocus().
|
protectedvirtual |
Should return true if the widget can be focused.
Reimplemented in SliderBase< T_, DIV_, VAL_, P_, interactive, valuemapping >, Scrollbar< T_, DIV_, VAL_, P_, defaultregistry >, RadioButtons< T_, W_ >, Progressor< T_, DIV_, VAL_, P_ >, Panel, ListItem, Layerbox, Label, Composer, Checkbox, and Button.
|
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().
|
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.
|
virtual |
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().
void Disable | ( | ) |
Disables the widget so that the user cannot interact with it.
References Widget::SetEnabled().
|
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_ >.
|
virtual |
For widgets that supports it, this will trigger finalization the user interaction.
This may cause widget fire change event or reorganize itself.
void Enable | ( | ) |
Enables the widget so that the user can interact with it.
References Widget::SetEnabled().
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().
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().
|
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.
|
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.
Geometry::Bounds GetBounds | ( | ) | const |
Returns the bounds of the widget.
References Widget::GetLocation(), and Widget::GetSize().
int GetHeight | ( | ) | const |
Returns the height of the widget.
References Widget::GetSize(), and basic_Size< T_ >::Height.
|
pure virtual |
Returns the location of the widget.
Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.
WidgetContainer & GetParent | ( | ) | const |
Returns the parent of this widget, throws if it does not have a parent.
|
pure virtual |
Returns the size of the widget.
Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.
int GetWidth | ( | ) | const |
Returns the width of the widget.
References Widget::GetSize(), and basic_Size< T_ >::Width.
bool HasParent | ( | ) | const |
Returns if this widget has a parent.
void Hide | ( | ) |
Hides this widget, when hidden, widgets cannot gain focus.
References Widget::SetVisible().
|
pure virtual |
Returns whether the widget is enabled.
Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.
bool IsFloating | ( | ) | const |
Returns floating status of this widget.
Floating widgets will not be moved or resized by organizers.
bool IsFocused | ( | ) | const |
Returns if this widget is focused.
bool IsVisible | ( | ) | const |
Returns if the widget is visible.
|
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.
|
pure virtual |
Moves this widget to the given position.
Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.
void Move | ( | int | x, |
int | y | ||
) |
Moves this widget to the given position.
|
protectedvirtual |
This function is called when the parent's enabled state changes.
Reimplemented in RadioButtons< T_, W_ >, Panel, and ComponentStackWidget.
bool Remove | ( | ) |
Removes the widget from its parent.
Returns true if the widget has no parent after the operation.
References WidgetContainer::Remove().
|
protectedvirtual |
Called after this widget is removed from its parent.
Reimplemented in ComponentStackWidget.
References Widget::boundschanged(), WidgetContainer::childboundschanged(), and Widget::IsVisible().
|
protectedpure virtual |
When called, widget should remove itself from the given layer.
Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.
|
protectedvirtual |
Called before this widget is removed from its parent.
|
pure virtual |
Changes the size of the widget.
Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.
|
virtual |
Changes the size of the widget.
|
pure virtual |
Sets the enabled state of the widget.
Implemented in RadioButtons< T_, W_ >, Panel, Composer, and ComponentStackWidget.
void SetHeight | ( | int | height | ) |
Sets the height of the widget.
References Widget::GetWidth(), and Widget::Resize().
|
virtual |
Sets floating status of this widget.
Floating widgets will not be moved or resized by organizers.
References Widget::boundschanged().
|
protectedpure virtual |
When called, widget should reorder itself in layer hierarchy.
Implemented in RadioButtons< T_, W_ >, Composer, and ComponentStackWidget.
void setname | ( | std::string | value | ) |
This is a debug feature.
References Widget::dbgname.
void SetVisible | ( | bool | value | ) |
Changes the visibility of the widget.
References WidgetContainer::childboundschanged(), and Widget::Defocus().
void SetWidth | ( | int | width | ) |
Sets the width of the widget.
References Widget::GetHeight(), and Widget::Resize().
void Show | ( | ) |
Shows this widget, widgets are visible by default.
References Widget::SetVisible().
void ToggleEnabled | ( | ) |
Toggles enabled state of the widget.
References Widget::IsEnabled(), and Widget::SetEnabled().
void ToggleVisible | ( | ) |
Toggles the visibility state of the widget.
References Widget::IsVisible(), and Widget::SetVisible().
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.
std::string dbgname |
Geometry::PointProperty<Widget, &Widget::getlocation, &Widget::move> Location |
Geometry::SizeProperty<Widget, &Widget::getsize, &Widget::resize> Size |