Gorgon Game Engine
Composer Class Reference

This object allows its users to compose widgets using other widgets. More...

Inheritance diagram for Composer:
[legend]

Public Member Functions

 ~Composer ()
 
virtual bool Activate () override
 Activates the widget. More...
 
virtual bool CharacterEvent (Char c) override
 This function should be called whenever a character is received from operating system. More...
 
bool EnsureVisible (const UI::Widget &widget) override
 Ensures the widget is visible. More...
 
virtual Geometry::Size GetInteriorSize () const override
 Should return the interior (usable) size of the container. More...
 
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 bool IsVisible () const override
 Should return whether the container is visible. More...
 
virtual bool KeyEvent (Input::Key key, float state) override
 This function should be called whenever a key is pressed or released. More...
 
virtual void Move (const Geometry::Point &location) override
 Moves this widget to the given position. More...
 
virtual UI::ExtenderRequestResponse RequestExtender (const Gorgon::Layer &self) override
 This function will return a container that will act as an extender. More...
 
virtual void Resize (const Geometry::Size &size) override
 Changes the size of the widget. More...
 
virtual bool ResizeInterior (Geometry::Size size) override
 Should resize the interior (usable) size of the container. 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 ()
 
bool AllowFocus () const
 If this widget can be focused currently. 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...
 
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

 Composer ()
 
virtual void addto (Layer &layer) override
 When called, widget should locate itself on to this layer. More...
 
virtual bool allowfocus () const override
 Should return true if the widget can be focused. More...
 
void focuschanged () override
 This function is called when the focus is changed. 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 Layergetlayer () override
 Returns the layer that will be used to place the contained widgets. 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 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 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 bool removingfrom ()
 Called before this widget is removed from its parent. More...
 
- Protected Member Functions inherited from WidgetContainer
virtual bool addingwidget (Widget &)
 This function can return false to prevent the given widget from getting added to the container. More...
 
virtual void childboundschanged (Widget *source)
 The boundary of any of the children is changed. Source could be nullptr. More...
 
bool distributecharevent (Char c)
 Distributes a pressed character to the focused widget. More...
 
bool distributekeyevent (Input::Key key, float state, bool handlestandard)
 Distributes the pressed key to the focused widget. More...
 
void distributeparentenabled (bool state)
 Distributes a enabled state to children. More...
 
virtual FocusStrategy getparentfocusstrategy () const
 If this widget is not top level, return the current strategy used by the parent. More...
 
bool handlestandardkey (Input::Key key)
 Performs the standard operations (tab/enter/escape) More...
 
virtual bool removingwidget (Widget &)
 This function is called before removing a widget. More...
 
virtual void widgetadded (Widget &)
 This function is called after a widget is added. More...
 
virtual void widgetremoved (Widget &)
 This function is called after a widget is removed. More...
 
 WidgetContainer ()=default
 
 WidgetContainer (WidgetContainer &&)=default
 
virtual ~WidgetContainer ()
 Virtual destructor. More...
 
bool Add (Widget &widget)
 Adds the given widget to this container. More...
 
void AttachOrganizer (Organizers::Base &organizer)
 Attaches an organizer to this container. More...
 
auto begin ()
 Returns the begin iterator for the contained widgets. More...
 
auto begin () const
 Returns the begin iterator for the contained widgets. More...
 
void ChangeFocusOrder (Widget &widget, int order)
 Changes the focus order of the given widget. More...
 
void ChangeZorder (Widget &widget, int order)
 Changes the z-order of the widget. More...
 
template<class O_ , class ... Args_>
O_ & CreateOrganizer (Args_ &&... args)
 Creates a new organizer that lives with this container. More...
 
FocusStrategy CurrentFocusStrategy () const
 Returns the active focus strategy. This function will not return Inherit. More...
 
void Disable ()
 Disables the container, disallowing interactions of all widgets in it. More...
 
void DisableTabSwitch ()
 Disable tab switching. More...
 
void Displaced ()
 Call this function if the container or widgets in it is moved without move function is called. More...
 
void Enable ()
 Enables the container, allowing interaction with the widgets in it. More...
 
void EnableTabSwitch ()
 Enable tab switching. More...
 
auto end ()
 Returns the end iterator for the contained widgets. More...
 
auto end () const
 Returns the end iterator for the contained widgets. More...
 
bool FocusFirst ()
 Focuses the first widget that accepts focus. More...
 
bool FocusLast ()
 Focuses the last widget in the container. More...
 
bool FocusNext ()
 Focuses the next widget that accepts focus. More...
 
bool FocusNext (const Widget &widget)
 Focuses the next widget that accepts focus starting from the given focus index. More...
 
bool FocusNext (int after)
 Focuses the next widget that accepts focus starting from the given focus index. More...
 
bool FocusPrevious ()
 Focuses the previous widget that accepts focus. More...
 
bool FocusPrevious (const Widget &widget)
 Focuses the previous widget that accepts focus. More...
 
bool FocusPrevious (int before)
 Focuses the previous widget that accepts focus. More...
 
void ForceRemove (Widget &widget)
 Forcefully removes the given widget from this container. More...
 
void ForceRemoveFocus ()
 Forcefully removes the focus from the focused widget. More...
 
virtual WidgetGetCancel () const
 Returns the cancel element of the container which is called when the use presses escape key. More...
 
int GetCount () const
 Returns the number of widgets in this container. More...
 
virtual WidgetGetDefault () const
 Returns the default element of the container. More...
 
WidgetGetFocus () const
 Returns the focused widget. More...
 
int GetFocusOrder (const Widget &widget) const
 
FocusStrategy GetFocusStrategy () const
 Returns the focus strategy set to this container. More...
 
Organizers::BaseGetOrganizer () const
 Returns the organizer controlling this container. More...
 
virtual bool HasCancel () const
 Returns if this container has a cancel widget. More...
 
virtual bool HasDefault () const
 Returns if this container has a default object. More...
 
bool HasFocusedWidget () const
 Returns if this container has a focused widget. More...
 
bool HasOrganizer () const
 Returns if this container has an organizer. More...
 
bool Insert (Widget &widget, int index)
 Add the given widget to this container. More...
 
virtual bool IsTabSwitchEnabled () const
 Check if tab switch is enabled. More...
 
WidgetContaineroperator= (WidgetContainer &&)=default
 
Widgetoperator[] (int ind)
 Returns the widget at the given index. More...
 
const Widgetoperator[] (int ind) const
 Returns the widget at the given index. More...
 
bool Remove (Widget &widget)
 Removes the given widget from this container. More...
 
virtual void RemoveCancel ()
 Removes the cancel widget of this container. More...
 
virtual void RemoveDefault ()
 Removes the default widget of this container. More...
 
bool RemoveFocus ()
 Removes the focus from the focused widget. More...
 
void RemoveOrganizer ()
 Removes the organizer from this container. More...
 
virtual void SetCancel (Widget &widget)
 Sets the cancel widget of the container. More...
 
virtual void SetDefault (Widget &widget)
 Sets the default object of the container. More...
 
void SetFocusStrategy (FocusStrategy value)
 Sets the focus strategy, see FocusStrategy. More...
 
bool SetFocusTo (Widget &widget)
 Sets the focus to the given widget. More...
 
virtual void SetTabSwitchEnabledState (bool state)
 Sets the state of tab switching. More...
 
void ToggleEnabled ()
 Toggles the enabled state of this container. More...
 
void ToggleTabSwitchEnabledState ()
 Toggles the state of tab switching. More...
 

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
 
- Protected Types inherited from WidgetContainer
enum  FocusStrategy {
  Inherit, AllowAll, Selective, Strict,
  Deny
}
 Defines focus strategy for the container. Default is Inherit. More...
 
- Protected Attributes inherited from WidgetContainer
Containers::Collection< Widgetwidgets
 This container is sorted by the focus order. More...
 

Detailed Description

This object allows its users to compose widgets using other widgets.

It is designed to be inherited. Derived classes can be use this object as a container, which allows widgets on top of it. However, container side is not public. Therefore, users of the derived widget cannot add more widgets to the derived widget. Widget Composer handles focus, keyboard and all necessary functions to build a widget container and a widget. It does not require any templates to build, however, you may request templates to use in widgets in the composer. This object does not support scrolling, however, you may place a panel in it to have that functionality.

Constructor & Destructor Documentation

◆ ~Composer()

~Composer ( )

◆ Composer()

Composer ( )
protected

Member Function Documentation

◆ Activate()

bool Activate ( )
overridevirtual

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.

Implements Widget.

References Widget::Focus(), and WidgetContainer::FocusFirst().

◆ addto()

virtual void addto ( Layer layer)
overrideprotectedvirtual

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

Implements Widget.

References Layer::Add().

◆ allowfocus()

bool allowfocus ( ) const
overrideprotectedvirtual

Should return true if the widget can be focused.

Reimplemented from Widget.

References WidgetContainer::CurrentFocusStrategy(), WidgetContainer::Deny, and WidgetContainer::widgets.

◆ CharacterEvent()

virtual bool CharacterEvent ( Char  c)
overridevirtual

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

Reimplemented from Widget.

References WidgetContainer::distributecharevent().

◆ EnsureVisible()

bool EnsureVisible ( const UI::Widget widget)
overridevirtual

Ensures the widget is visible.

Returns true if the container can be scroll to make sure the given widget is visible. This function cannot be expected to take outside factors into account, such as occlusion. This function does not change the visibility of the widget and will return false if the widget is not visible.

Implements WidgetContainer.

◆ focuschanged()

void focuschanged ( )
overrideprotectedvirtual

This function is called when the focus is changed.

Reimplemented from WidgetContainer.

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

◆ focused()

void focused ( )
overrideprotectedvirtual

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

Reimplemented from Widget.

References WidgetContainer::FocusFirst(), and WidgetContainer::HasFocusedWidget().

◆ focuslost()

void focuslost ( )
overrideprotectedvirtual

This is called after the focus is lost.

This is called even if focus removal is forced.

Reimplemented from Widget.

References WidgetContainer::RemoveFocus().

◆ GetInteriorSize()

virtual Geometry::Size GetInteriorSize ( ) const
overridevirtual

Should return the interior (usable) size of the container.

Implements WidgetContainer.

References Layer::GetSize().

◆ getlayer()

virtual Layer& getlayer ( )
overrideprotectedvirtual

Returns the layer that will be used to place the contained widgets.

Implements WidgetContainer.

◆ GetLocation()

virtual Geometry::Point GetLocation ( ) const
overridevirtual

Returns the location of the widget.

Implements Widget.

References Layer::GetLocation().

◆ GetSize()

virtual Geometry::Size GetSize ( ) const
overridevirtual

Returns the size of the widget.

Implements Widget.

References Layer::GetSize().

◆ IsEnabled()

virtual bool IsEnabled ( ) const
overridevirtual

Returns whether the widget is enabled.

Implements Widget.

◆ IsVisible()

virtual bool IsVisible ( ) const
overridevirtual

Should return whether the container is visible.

Due to different container designs and capabilities, setting visibility depends on the particular container

Implements WidgetContainer.

References Layer::IsVisible().

◆ KeyEvent()

virtual bool KeyEvent ( Input::Key  key,
float  state 
)
overridevirtual

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

Reimplemented from Widget.

References WidgetContainer::distributekeyevent().

◆ Move()

void Move ( const Geometry::Point location)
overridevirtual

Moves this widget to the given position.

Implements Widget.

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

◆ removefrom()

virtual void removefrom ( Layer layer)
overrideprotectedvirtual

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

Implements Widget.

References Layer::Remove().

◆ RequestExtender()

UI::ExtenderRequestResponse RequestExtender ( const Gorgon::Layer self)
overridevirtual

This function will return a container that will act as an extender.

Implements WidgetContainer.

References ExtenderRequestResponse::CoordinatesInExtender, Composer::GetLocation(), Widget::GetParent(), Widget::HasParent(), and WidgetContainer::RequestExtender().

◆ Resize()

void Resize ( const Geometry::Size size)
overridevirtual

Changes the size of the widget.

Implements Widget.

References Widget::boundschanged(), Widget::HasParent(), Composer::IsVisible(), and Layer::Resize().

◆ ResizeInterior()

virtual bool ResizeInterior ( Geometry::Size  size)
overridevirtual

Should resize the interior (usable) size of the container.

If resize operation cannot set the size exactly to the requested size, this function returns false.

Implements WidgetContainer.

References Composer::Resize().

◆ SetEnabled()

virtual void SetEnabled ( bool  value)
overridevirtual

Sets the enabled state of the widget.

Implements Widget.

References WidgetContainer::distributeparentenabled(), and Composer::IsEnabled().

◆ setlayerorder()

virtual void setlayerorder ( Layer layer,
int  order 
)
overrideprotectedvirtual

When called, widget should reorder itself in layer hierarchy.

Implements Widget.

References Layer::PlaceBefore().


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