Gorgon Game Engine
ComponentStackWidget Class Reference

This class acts as a widget base that uses component stack to handle rendering, resizing and other operations. More...

Inheritance diagram for ComponentStackWidget:
[legend]

Public Member Functions

 ComponentStackWidget (ComponentStackWidget &&)=default
 
 ComponentStackWidget (const Template &temp, std::map< ComponentTemplate::Tag, std::function< Widget *(const Template &)>> generators={})
 
virtual ~ComponentStackWidget ()
 
virtual Geometry::Point GetLocation () const override
 Returns the location of the widget. More...
 
virtual Geometry::Size GetSize () const override
 Returns the size of the widget. More...
 
virtual bool IsEnabled () const override
 Returns whether the widget is enabled. More...
 
virtual void Move (const Geometry::Point &location) override
 Moves this widget to the given position. 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...
 
virtual void Resize (const Geometry::Size &size) override
 Changes the size of the widget. 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) override
 Sets the enabled state of the widget. More...
 
- Public Member Functions inherited from Widget
 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...
 
WidgetContainerGetParent () const
 Returns the parent of this widget, throws if it does not have a parent. 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...
 
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...
 
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 (int w, int h)
 Changes the size 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...
 

Protected Member Functions

virtual void addto (Layer &layer) override
 When called, widget should locate itself on to this layer. More...
 
virtual void focused () override
 This is called after the focus is transferred to this widget. More...
 
virtual void focuslost () override
 This is called after the focus is lost. More...
 
virtual void parentenabledchanged (bool state) override
 This function is called when the parent's enabled state changes. More...
 
virtual void removed () override
 Called after this widget is removed from its parent. More...
 
virtual void removefrom (Layer &layer) override
 When called, widget should remove itself from the given layer. More...
 
virtual void setlayerorder (Layer &, int order) override
 When called, widget should reorder itself in layer hierarchy. More...
 
- Protected Member Functions inherited from Widget
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 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 bool removingfrom ()
 Called before this widget is removed from its parent. More...
 

Protected Attributes

bool enabled
 
bool parentenabled
 
ComponentStackstack
 

Additional Inherited Members

- Public Attributes inherited from Widget
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
 

Detailed Description

This class acts as a widget base that uses component stack to handle rendering, resizing and other operations.

Constructor & Destructor Documentation

◆ ComponentStackWidget() [1/2]

ComponentStackWidget ( const Template temp,
std::map< ComponentTemplate::Tag, std::function< Widget *(const Template &)>>  generators = {} 
)

◆ ComponentStackWidget() [2/2]

◆ ~ComponentStackWidget()

virtual ~ComponentStackWidget ( )
virtual

Member Function Documentation

◆ addto()

virtual void addto ( Layer layer)
overrideprotectedvirtual

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

Implements Widget.

References Layer::Add(), and ComponentStackWidget::stack.

◆ focused()

virtual void focused ( )
overrideprotectedvirtual

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

Reimplemented from Widget.

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 > >, and 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 > >.

References ComponentStack::AddCondition(), Gorgon::UI::Focused, Widget::focused(), Widget::FocusEvent, and ComponentStackWidget::stack.

◆ focuslost()

virtual void focuslost ( )
overrideprotectedvirtual

This is called after the focus is lost.

This is called even if focus removal is forced.

Reimplemented from Widget.

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 > >, and 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 > >.

References Gorgon::UI::Focused, Widget::FocusEvent, Widget::focuslost(), ComponentStack::RemoveCondition(), and ComponentStackWidget::stack.

◆ GetLocation()

virtual Geometry::Point GetLocation ( ) const
overridevirtual

Returns the location of the widget.

Implements Widget.

References Layer::GetLocation(), and ComponentStackWidget::stack.

◆ GetSize()

virtual Geometry::Size GetSize ( ) const
overridevirtual

Returns the size of the widget.

Implements Widget.

References Layer::GetSize(), and ComponentStackWidget::stack.

◆ IsEnabled()

virtual bool IsEnabled ( ) const
overridevirtual

Returns whether the widget is enabled.

Implements Widget.

Reimplemented in Panel.

References ComponentStackWidget::enabled.

◆ Move() [1/3]

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

Moves this widget to the given position.

Implements Widget.

Reimplemented in Panel.

References Widget::boundschanged(), Widget::HasParent(), Widget::IsVisible(), Layer::Move(), and ComponentStackWidget::stack.

◆ Move() [2/3]

virtual void Move

Moves this widget to the given position.

◆ Move() [3/3]

void Move

Moves this widget to the given position.

References Widget::Move().

◆ parentenabledchanged()

virtual void parentenabledchanged ( bool  state)
overrideprotectedvirtual

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

Reimplemented from Widget.

Reimplemented in Panel.

References ComponentStack::AddCondition(), Gorgon::UI::Disabled, ComponentStackWidget::enabled, ComponentStackWidget::parentenabled, ComponentStack::RemoveCondition(), and ComponentStackWidget::stack.

◆ removed()

virtual void removed ( )
overrideprotectedvirtual

Called after this widget is removed from its parent.

Reimplemented from Widget.

References ComponentStack::FinalizeTransitions(), Widget::removed(), and ComponentStackWidget::stack.

◆ removefrom()

virtual void removefrom ( Layer layer)
overrideprotectedvirtual

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

Implements Widget.

References Layer::Remove(), and ComponentStackWidget::stack.

◆ Resize() [1/3]

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

Changes the size of the widget.

Implements Widget.

Reimplemented in Panel.

References Widget::boundschanged(), Widget::HasParent(), Widget::IsVisible(), ComponentStack::Resize(), and ComponentStackWidget::stack.

◆ Resize() [2/3]

virtual void Resize

Changes the size of the widget.

◆ Resize() [3/3]

virtual void Resize

Changes the size of the widget.

References Widget::Resize().

◆ SetEnabled()

◆ setlayerorder()

virtual void setlayerorder ( Layer layer,
int  order 
)
overrideprotectedvirtual

When called, widget should reorder itself in layer hierarchy.

Implements Widget.

References Layer::PlaceBefore(), and ComponentStackWidget::stack.

Member Data Documentation

◆ enabled

bool enabled
protected

◆ parentenabled

bool parentenabled
protected

◆ stack

ComponentStack& stack
protected

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