Gorgon Game Engine
ComponentStack Class Reference

Component stack is the backbone of a widget. More...

Inheritance diagram for ComponentStack:
[legend]

Public Member Functions

 ComponentStack (const Template &temp)
 Initiates a component stack with default size. More...
 
 ComponentStack (const Template &temp, Geometry::Size size, std::map< ComponentTemplate::Tag, std::function< Widget *(const Template &)>> generators={})
 Initializes a component stack with the given size. More...
 
virtual ~ComponentStack ()
 Destructor. More...
 
void AddCondition (ComponentCondition condition, bool transition=true)
 Adds a condition and its associated components to the stack. More...
 
void AddToStack (const ComponentTemplate &temp, bool reversed)
 Adds the given component to the top of the stack. More...
 
Geometry::Bounds BoundsOf (int ind)
 Returns the boundaries of the component with the given index. The bounds are from the top level. More...
 
int ComponentAt (Geometry::Point location)
 Returns the index of the component at the given location. More...
 
int ComponentAt (Geometry::Point location, Geometry::Bounds &bounds)
 Returns the index of the component at the given location while returning the bounds of the component. More...
 
bool ComponentExists (int ind) const
 Returns if a component at ind exists. More...
 
std::array< float, 4 > CoordinateToValue (ComponentTemplate::Tag tag, Geometry::Point location, bool relative=false)
 Translates the given coordinates back to values using value scaling and channel mapping. More...
 
void DisableTagWrap (ComponentTemplate::Tag tag)
 Disables text wrapping on a specific tag, default is enabled. More...
 
void EnableTagWrap (ComponentTemplate::Tag tag)
 Enables text wrapping on a specific tag, default is enabled. More...
 
void FinalizeTransitions ()
 Finalizes on-going transitions immediately. More...
 
const Graphics::DrawableGetImageData (ComponentTemplate::DataEffect effect)
 Returns the image data. If data is not set, this will return nullptr. More...
 
LayerGetLayerOf (int ind)
 Returns the layer of the given component index. More...
 
Geometry::Point GetTagLocation (ComponentTemplate::Tag tag) const
 
Geometry::Size GetTagSize (ComponentTemplate::Tag tag) const
 
std::array< float, 4 > GetTargetValue () const
 Returns the value of the stack. More...
 
const TemplateGetTemplate () const
 Returns the template used by this stack. More...
 
const TemplateGetTemplate (ComponentTemplate::Tag tag)
 Returns the template used by the component with given tag. More...
 
const ComponentTemplateGetTemplate (int ind) const
 Returns the template at the given index. More...
 
std::string GetTextData (ComponentTemplate::DataEffect effect)
 Returns the text data. If data is not set, this will return empty string. More...
 
std::array< float, 4 > GetValue () const
 Returns the value of the stack. More...
 
WidgetGetWidget (ComponentTemplate::Tag tag)
 Returns the widget associated with the tag. More...
 
void HandleMouse (Input::Mouse::Button accepted=Input::Mouse::Button::All)
 This function instructs stack to handle mouse to automatically change hover/down states, unless disabled state is active. More...
 
bool HasCondition (ComponentCondition condition)
 Returns if the given condition is in effect. More...
 
bool HasLayer (int ind) const
 Returns if the component at the given index has a layer. More...
 
int IndexOfTag (ComponentTemplate::Tag tag)
 Returns the index of the component with the specified tag. More...
 
bool IsDisabled () const
 Returns if this component stack is disabled. Both disabling and enabling animations are counted as disabled. More...
 
void RemoveBeforeUpdateEvent ()
 Removes the function that will be called before every update. More...
 
void RemoveCondition (ComponentCondition condition, bool transition=true)
 Removes a condition and its associated components. More...
 
void RemoveData (ComponentTemplate::DataEffect effect)
 Removes the data associated with data effect. More...
 
void RemoveFrameEvent ()
 Removes the function that will be called before update check. More...
 
void RemoveRenderEvent ()
 Removes the function that will be called after every render. More...
 
void RemoveTagLocation (ComponentTemplate::Tag tag)
 Removes the fixed location for a set tagged component. More...
 
void RemoveTagSize (ComponentTemplate::Tag tag)
 Removes the fixed size for a set tagged component. More...
 
void RemoveUpdateEvent ()
 Removes the function that will be called after every update before rendering. More...
 
void Render () override
 Renders the current layer, default handling is to pass the request to the sub-layers. Rendering is not thread safe. More...
 
void ReplaceCondition (ComponentCondition from, ComponentCondition to, bool transition=true)
 Replaces a condition with another one. More...
 
void ResetAnimation ()
 
virtual void Resize (const Geometry::Size &size)
 Resizes the layer to the given size. More...
 
virtual void Resize (const Geometry::Size &value) override
 Notifies the stack about a size change. More...
 
virtual void Resize (int width, int height)
 Resizes the layer to the given size. More...
 
void ReturnTargetValue ()
 Whether GetValue returns the target value. This is the default mode. More...
 
void ReturnTransitionalValue ()
 Whether GetValue returns the current transitional value, this will also enable value event to be called every time transitional value is updated. More...
 
void SetBeforeUpdateEvent (std::function< void()> handler)
 Sets a function to be called before every update. More...
 
void SetData (ComponentTemplate::DataEffect effect, const Graphics::Drawable &image)
 Sets the data for a specific data effect. More...
 
void SetData (ComponentTemplate::DataEffect effect, const std::string &text)
 Sets the data for a specific data effect. More...
 
void SetEMSize (int value)
 Changes the default emsize of 10. This value can be overridden. More...
 
void SetFrameEvent (std::function< void()> handler)
 Sets a function to be called before update check. More...
 
void SetRenderEvent (std::function< void()> handler)
 Sets a function to be called after every render. More...
 
void SetTagLocation (ComponentTemplate::Tag tag, Geometry::Point location)
 Set a fixed location for a tagged component. More...
 
void SetTagSize (ComponentTemplate::Tag tag, Geometry::Size size)
 Set a fixed size for a tagged component. More...
 
void SetUpdateEvent (std::function< void()> handler)
 Sets a function to be called after every update before rendering. More...
 
void SetValue (float first)
 Sets the value for this stack. More...
 
void SetValue (float first, float second)
 Sets the value for this stack. More...
 
void SetValue (float first, float second, float third)
 Sets the value for this stack. More...
 
void SetValue (float first, float second, float third, float fourth, bool instant=false)
 Sets the value for this stack. More...
 
void SetValue (Geometry::Point3D pos)
 Sets the value for the stack using a point in coordinate system. More...
 
void SetValue (Geometry::Pointf pos)
 Sets the value for the stack using a point in coordinate system. More...
 
void SetValue (Graphics::RGBA color)
 Sets the value for the stack using a color. More...
 
void SetValue (Graphics::RGBAf color)
 Sets the value for the stack using a color. More...
 
void SetValueEvent (std::function< void()> handler)
 Sets the function that will be called whenever the value is changed. More...
 
void SetValueToText (std::function< std::string(int, ComponentTemplate::DataEffect, const std::array< float, 4 > &)> handler)
 Sets the function that will be used to convert a value to a string. More...
 
void SetValueTransitionSpeed (std::array< float, 4 > val)
 Changes the value transition speed. More...
 
Geometry::Bounds TagBounds (ComponentTemplate::Tag tag)
 Returns the boundaries of the component marked with the given tag. More...
 
bool TagHasSubStack (ComponentTemplate::Tag tag) const
 Returns whether the component marked with the tag has a substack. More...
 
Geometry::Pointf TransformCoordinates (ComponentTemplate::Tag tag, Geometry::Point location)
 Translates the given coordinates to component space from 0 to 1. More...
 
Geometry::Pointf TransformCoordinates (int ind, Geometry::Point location)
 Translates the given coordinates to component space from 0 to 1. More...
 
Geometry::Point TranslateCoordinates (ComponentTemplate::Tag tag, Geometry::Point location)
 Translates the given coordinates to component space in pixels. More...
 
Geometry::Point TranslateCoordinates (int ind, Geometry::Point location)
 Translates the given coordinates to component space in pixels. More...
 
virtual void Update () override
 Updates the layout of the component stack. More...
 
void Update (bool immediate)
 Updates the layout of the component stack. More...
 
- Public Member Functions inherited from Layer
 Layer ()
 Constructor that sets the layer to cover entire parent, no matter how big it is. More...
 
 Layer (const Geometry::Bounds &bounds)
 Initializing constructor. More...
 
 Layer (const Geometry::Point &location)
 Constructor that places the layer to the given location. More...
 
 Layer (const Layer &)=delete
 Copy constructor is disabled. More...
 
 Layer (Layer &&other)
 Move constructor. More...
 
virtual ~Layer ()
 Destructor. More...
 
virtual void Hide ()
 Hides this layer. More...
 
virtual bool IsVisible () const
 Returns whether this layer is effectively visible. More...
 
Layeroperator= (const Layer &)=delete
 Copy assignment is deleted. More...
 
Layeroperator= (Layer &&other)
 Move assignment. More...
 
virtual bool propagate_mouseevent (Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers)
 Propagates a mouse event. More...
 
virtual void Show ()
 Displays this layer. More...
 
void Swap (Layer &other)
 Swaps two layers, mostly used for move semantics. More...
 
void Add (Layer &layer)
 Adds the given layer as a child. More...
 
void Add (Layer *layer)
 Adds the given layer as a child. More...
 
void setname (std::string value)
 For debugging. More...
 
void Insert (Layer &layer, long under)
 Inserts the given layer before the given index. More...
 
void Insert (Layer *layer, long under)
 Inserts the given layer before the given index. More...
 
void Remove (Layer &layer)
 Removes the given layer. More...
 
void Remove (Layer *layer)
 Removes the given layer. More...
 
bool HasParent () const
 Returns whether this layer has a parent. More...
 
virtual LayerGetParent () const
 Returns the parent of this layer. More...
 
LayerGetTopLevel () const
 Returns the top level layer that contains this layer. More...
 
virtual Geometry::Point TranslateToTopLevel (Geometry::Point location={0, 0}) const
 Translates the given location to the top level. More...
 
LayerGetTopLevel ()
 
Containers::Collection< Layer >::ConstIterator begin () const
 An iterator pointing to the start of the children. More...
 
Containers::Collection< Layer >::ConstIterator end () const
 An iterator pointing to the end of the children. More...
 
Containers::Collection< Layer >::ConstIterator First () const
 An iterator pointing to the start of the children. More...
 
Containers::Collection< Layer >::ConstIterator Last () const
 An iterator pointing to the last item of the children. More...
 
void PlaceBefore (int before)
 Places this layer before the given index. More...
 
void PlaceToTop ()
 Places this layer to the top of the layer stack its in. More...
 
void PlaceToBottom ()
 Places this layer to the bottom of the layer stack. More...
 
int GetOrder () const
 Gets the current order of the stack. More...
 
virtual void Move (const Geometry::Point &location)
 Moves this layer to the given location. More...
 
virtual void Move (int x, int y)
 Moves this layer to the given location. More...
 
virtual void Resize (int width, int height)
 Resizes the layer to the given size. More...
 
void SetWidth (int width)
 Resizes the layer to the given size. More...
 
void SetHeight (int height)
 Resizes the layer to the given size. More...
 
void SetBounds (const Geometry::Bounds &bounds)
 Sets the boundaries of this layer. More...
 
Geometry::Size GetSize () const
 Returns the size of the layer. More...
 
Geometry::Size GetCalculatedSize () const
 Returns the size of the layer. More...
 
int GetWidth () const
 Returns the width of the layer. More...
 
int GetHeight () const
 Returns the height of the layer. More...
 
Geometry::Point GetLocation () const
 Returns the current location of the layer. More...
 
int GetLeft () const
 Returns the current location of the layer. More...
 
int GetTop () const
 Returns the current location of the layer. More...
 
Geometry::Bounds GetBounds () const
 Returns the boundaries of the layer. More...
 
Geometry::Bounds GetEffectiveBounds () const
 Returns the effective boundaries of the layer. More...
 
- Public Member Functions inherited from Updatable
virtual ~Updatable ()
 

Public Attributes

Event< ComponentStackConditionChanged
 
- Public Attributes inherited from Layer
const Containers::Collection< Layer > & Children
 Sub-layers that this layer holds, all the sub-layers are considered to be above current layer. More...
 

Repeating components

It is possible to repeat components automatically.

For this, template should have components marked with the respective RepeatMode and you need to set the repeat points. Repeat points uses the same system as value. Repeating components should have at least Always condition to work properly. It is possible to set the condition of each repeat individually. This system uses indexes of repeat points instead of values to speed up rendering.

void SetRepeat (ComponentTemplate::RepeatMode mode, std::vector< std::array< float, 4 >> data)
 Sets the repeat with the given mode to the given vector. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, float first)
 Adds a new repeating point to the given mode. Empty values will be set as 0. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, float first, float second)
 Adds a new repeating point to the given mode. Empty values will be set as 0. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, float first, float second, float third)
 Adds a new repeating point to the given mode. Empty values will be set as 0. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, float first, float second, float third, float fourth)
 Adds a new repeating point to the given mode. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, Geometry::Pointf pos)
 Adds a new repeating point to the given mode. Empty values will be set as 0. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, Geometry::Point3D pos)
 Adds a new repeating point to the given mode. Empty values will be set as 0. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, Graphics::RGBAf color)
 Adds a new repeating point to the given mode. More...
 
void AddRepeat (ComponentTemplate::RepeatMode mode, Graphics::RGBA color)
 Adds a new repeating point to the given mode. More...
 
void RemoveRepeats (ComponentTemplate::RepeatMode mode)
 Removes all repeat points from the given mode. More...
 
void SetConditionOf (ComponentTemplate::RepeatMode mode, int index, ComponentCondition condition)
 Sets the condition of a specific repeat index. More...
 
void RemoveAllConditionsOf (ComponentTemplate::RepeatMode mode)
 Removes all conditions for a repeat mode. More...
 

Mouse Events

These function will allow handling mouse events.

If the mouse event is originating from a substack, it will have a tag other than NoTag. If the tag for the substack is set NoTag, handler will receive UnknownTag. It is possible to obtain the tag and index under the mouse using ComponentAt functions. Along with TranslateCoordinates or TransformCoordinates functions, it is possible to get the location of a mouse event on a specific component.

void SetMouseDownEvent (std::function< void(ComponentTemplate::Tag, Geometry::Point, Input::Mouse::Button)> handler)
 Sets the mouse down event. More...
 
void SetMouseUpEvent (std::function< void(ComponentTemplate::Tag, Geometry::Point, Input::Mouse::Button)> handler)
 Sets the mouse up event. More...
 
void SetClickEvent (std::function< void(ComponentTemplate::Tag, Geometry::Point, Input::Mouse::Button)> handler)
 Sets the mouse down event. More...
 
void SetMouseMoveEvent (std::function< void(ComponentTemplate::Tag, Geometry::Point)> handler)
 Sets the mouse mvoe event. More...
 
void SetMouseOverEvent (std::function< void(ComponentTemplate::Tag)> handler)
 Sets the mouse over event that is fired when the mouse moves over the component stack or a substack. More...
 
void SetMouseOutEvent (std::function< void(ComponentTemplate::Tag)> handler)
 Sets the mouse out event that is fired when the mouse moves over the component stack or a substack. More...
 
void SetOtherMouseEvent (std::function< bool(ComponentTemplate::Tag, Input::Mouse::EventType, Geometry::Point, float)> handler)
 Sets the handler for scroll (HScroll or VScroll), zoom and rotate events. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Layer
static const Geometry::Bounds EntireRegion
 When used as layer bounds, represents the entire region its placed in. More...
 
- Protected Member Functions inherited from Layer
virtual void added (Layer &layer)
 Will be called when a layer is added. More...
 
void dotransformandclip (bool inverse=false)
 Performs transformation and clipping. Use inverse for reverse mapping for mouse events. More...
 
virtual void located (Layer *parent)
 Will be called when this layer is added to another. More...
 
virtual void removed (Layer &layer)
 Will be called when a layer is removed. More...
 
void reverttransformandclip ()
 Reverts previously done transformation. More...
 
- Protected Attributes inherited from Layer
Geometry::Bounds bounds
 Bounds of this layer. More...
 
Containers::Collection< Layerchildren
 Child layers that this layer holds, all child layers are considered to be above current layer. More...
 
bool isvisible
 Whether this layer is visible, invisible layers will not be drawn or receive any events. More...
 
std::string name
 For debugging. More...
 
Layerparent
 Parent layer, could be nullptr. More...
 

Detailed Description

Component stack is the backbone of a widget.

It manages the components inside the widget by showing/hiding components depending on the current state. Additionally, component stack arranges the components by adjusting their locations and sizes.

WARNING: This class might be changed into a tiered class, allowing consumers to use the tier with the minimum necessary functionality.

Constructor & Destructor Documentation

◆ ComponentStack() [1/2]

◆ ComponentStack() [2/2]

ComponentStack ( const Template temp)
explicit

Initiates a component stack with default size.

◆ ~ComponentStack()

~ComponentStack ( )
virtual

Destructor.

Member Function Documentation

◆ AddCondition()

void AddCondition ( ComponentCondition  condition,
bool  transition = true 
)

Adds a condition and its associated components to the stack.

References Gorgon::UI::Always, and ComponentStack::ReplaceCondition().

◆ AddRepeat() [1/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
float  first 
)

Adds a new repeating point to the given mode. Empty values will be set as 0.

◆ AddRepeat() [2/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
float  first,
float  second 
)

Adds a new repeating point to the given mode. Empty values will be set as 0.

References ComponentStack::AddRepeat().

◆ AddRepeat() [3/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
float  first,
float  second,
float  third 
)

Adds a new repeating point to the given mode. Empty values will be set as 0.

References ComponentStack::AddRepeat().

◆ AddRepeat() [4/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
float  first,
float  second,
float  third,
float  fourth 
)

Adds a new repeating point to the given mode.

◆ AddRepeat() [5/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
Geometry::Point3D  pos 
)

Adds a new repeating point to the given mode. Empty values will be set as 0.

References ComponentStack::AddRepeat(), basic_Point3D< T_ >::X, basic_Point3D< T_ >::Y, and basic_Point3D< T_ >::Z.

◆ AddRepeat() [6/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
Geometry::Pointf  pos 
)

Adds a new repeating point to the given mode. Empty values will be set as 0.

References ComponentStack::AddRepeat(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.

◆ AddRepeat() [7/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
Graphics::RGBA  color 
)

Adds a new repeating point to the given mode.

References ComponentStack::AddRepeat().

◆ AddRepeat() [8/8]

void AddRepeat ( ComponentTemplate::RepeatMode  mode,
Graphics::RGBAf  color 
)

Adds a new repeating point to the given mode.

References RGBAf::A, ComponentStack::AddRepeat(), RGBAf::B, RGBAf::G, and RGBAf::R.

◆ AddToStack()

◆ BoundsOf()

Geometry::Bounds BoundsOf ( int  ind)

Returns the boundaries of the component with the given index. The bounds are from the top level.

References Component::location, and Component::parent.

◆ ComponentAt() [1/2]

int ComponentAt ( Geometry::Point  location)

Returns the index of the component at the given location.

◆ ComponentAt() [2/2]

int ComponentAt ( Geometry::Point  location,
Geometry::Bounds bounds 
)

Returns the index of the component at the given location while returning the bounds of the component.


References Layer::bounds, and Gorgon::Geometry::IsInside().

◆ ComponentExists()

bool ComponentExists ( int  ind) const

Returns if a component at ind exists.

If ind is negative or out of range, this function simply returns false.

References Gorgon::Between().

◆ CoordinateToValue()

std::array< float, 4 > CoordinateToValue ( ComponentTemplate::Tag  tag,
Geometry::Point  location,
bool  relative = false 
)

Translates the given coordinates back to values using value scaling and channel mapping.

Only works if the value affects the component location or size. If component with the specified tag does not exist, this function will simply return {0, 0, 0, 0}. If relative is set, the calculation will not take starting location into account and will return relative change in value when relative change in location happens.

References basic_Bounds< T_ >::Bottom, Gorgon::UI::BottomCenter, Gorgon::UI::BottomLeft, Gorgon::UI::BottomRight, Layer::bounds, Gorgon::UI::Convert(), ContainerTemplate::GetOrientation(), Component::GetTemplate(), basic_Bounds< T_ >::Height(), basic_Size< T_ >::Height, Gorgon::UI::IsBottom(), Gorgon::UI::IsCenter(), Gorgon::UI::IsLeft(), Gorgon::UI::IsMiddle(), Gorgon::UI::IsRight(), Gorgon::UI::IsTop(), basic_Bounds< T_ >::Left, Gorgon::UI::MiddleCenter, Gorgon::UI::MiddleLeft, Gorgon::UI::MiddleRight, ComponentTemplate::ModifyHeight, ComponentTemplate::ModifyPosition, ComponentTemplate::ModifyPositionAndSize, ComponentTemplate::ModifyRotation, ComponentTemplate::ModifySize, ComponentTemplate::ModifyWidth, ComponentTemplate::ModifyX, ComponentTemplate::ModifyY, Gorgon::NumberOfSetBits(), Component::parent, Component::range, basic_Bounds< T_ >::Right, Component::size, basic_Bounds< T_ >::Top, Gorgon::UI::TopCenter, basic_Bounds< T_ >::TopLeft(), Gorgon::UI::TopRight, ComponentTemplate::UseBA, ComponentTemplate::UseC, ComponentTemplate::UseCH, ComponentTemplate::UseFirst, ComponentTemplate::UseFourth, ComponentTemplate::UseGA, ComponentTemplate::UseGBA, ComponentTemplate::UseGray, ComponentTemplate::UseGrayAlpha, ComponentTemplate::UseH, ComponentTemplate::UseL, ComponentTemplate::UseLC, ComponentTemplate::UseLCH, ComponentTemplate::UseLCHA, ComponentTemplate::UseLH, ComponentTemplate::UseRA, ComponentTemplate::UseRBA, ComponentTemplate::UseRGA, ComponentTemplate::UseRGBA, ComponentTemplate::UseSecond, ComponentTemplate::UseThird, ComponentTemplate::UseTransition, ComponentTemplate::UseXY, ComponentTemplate::UseXYZ, ComponentTemplate::UseXZ, ComponentTemplate::UseYZ, Gorgon::Graphics::Vertical, basic_Bounds< T_ >::Width(), and basic_Size< T_ >::Width.

◆ DisableTagWrap()

void DisableTagWrap ( ComponentTemplate::Tag  tag)

Disables text wrapping on a specific tag, default is enabled.

◆ EnableTagWrap()

void EnableTagWrap ( ComponentTemplate::Tag  tag)

Enables text wrapping on a specific tag, default is enabled.

◆ FinalizeTransitions()

void FinalizeTransitions ( )

Finalizes on-going transitions immediately.

References Gorgon::Input::Mouse::None.

◆ GetImageData()

const Graphics::Drawable* GetImageData ( ComponentTemplate::DataEffect  effect)

Returns the image data. If data is not set, this will return nullptr.

◆ GetLayerOf()

Layer & GetLayerOf ( int  ind)

Returns the layer of the given component index.

If the item does not have a layer, this function will create a new one for it. In the worst case, this function will return the object itself as a layer. Layer is probably a graphics layer, you may use RTTI to query layer type.

References Component::GetTemplate(), and ComponentStack::GetTemplate().

◆ GetTagLocation()

Geometry::Point GetTagLocation ( ComponentTemplate::Tag  tag) const

◆ GetTagSize()

Geometry::Size GetTagSize ( ComponentTemplate::Tag  tag) const

◆ GetTargetValue()

std::array<float, 4> GetTargetValue ( ) const

Returns the value of the stack.

◆ GetTemplate() [1/3]

const Template& GetTemplate ( ) const

Returns the template used by this stack.

◆ GetTemplate() [2/3]

const Template * GetTemplate ( ComponentTemplate::Tag  tag)

Returns the template used by the component with given tag.

References PlaceholderTemplate::GetTemplate().

◆ GetTemplate() [3/3]

const ComponentTemplate& GetTemplate ( int  ind) const

Returns the template at the given index.

If the index does not exists, this function may crash. Use ComponentExists function to check if it is safe to use the index.

References Component::GetTemplate().

◆ GetTextData()

std::string GetTextData ( ComponentTemplate::DataEffect  effect)

Returns the text data. If data is not set, this will return empty string.

◆ GetValue()

std::array<float, 4> GetValue ( ) const

Returns the value of the stack.

◆ GetWidget()

Widget * GetWidget ( ComponentTemplate::Tag  tag)

Returns the widget associated with the tag.

If such widget does not exists nullptr will be returned instead.

◆ HandleMouse()

void HandleMouse ( Input::Mouse::Button  accepted = Input::Mouse::Button::All)

This function instructs stack to handle mouse to automatically change hover/down states, unless disabled state is active.

Propagates to substacks.

◆ HasCondition()

bool HasCondition ( ComponentCondition  condition)

Returns if the given condition is in effect.

◆ HasLayer()

bool HasLayer ( int  ind) const

Returns if the component at the given index has a layer.

References ComponentStack::GetTemplate().

◆ IndexOfTag()

int IndexOfTag ( ComponentTemplate::Tag  tag)

Returns the index of the component with the specified tag.

This function may cause update thus may take time to execute. If tag not found, this will return -1.

References ComponentTemplate::GetIndex(), and Component::GetTemplate().

◆ IsDisabled()

bool IsDisabled ( ) const

Returns if this component stack is disabled. Both disabling and enabling animations are counted as disabled.

References Gorgon::UI::Always, and Gorgon::UI::Disabled.

◆ RemoveAllConditionsOf()

void RemoveAllConditionsOf ( ComponentTemplate::RepeatMode  mode)

Removes all conditions for a repeat mode.

◆ RemoveBeforeUpdateEvent()

void RemoveBeforeUpdateEvent ( )

Removes the function that will be called before every update.

◆ RemoveCondition()

void RemoveCondition ( ComponentCondition  condition,
bool  transition = true 
)

Removes a condition and its associated components.

References Gorgon::UI::Always, and ComponentStack::ReplaceCondition().

◆ RemoveData()

void RemoveData ( ComponentTemplate::DataEffect  effect)

Removes the data associated with data effect.

This will remove all data variants together.

References Gorgon::UI::DataEffectStart, ComponentTemplate::GetDataEffect(), Component::GetTemplate(), ComponentStack::RemoveCondition(), and ComponentStack::Update().

◆ RemoveFrameEvent()

void RemoveFrameEvent ( )

Removes the function that will be called before update check.

◆ RemoveRenderEvent()

void RemoveRenderEvent ( )

Removes the function that will be called after every render.

◆ RemoveRepeats()

void RemoveRepeats ( ComponentTemplate::RepeatMode  mode)

Removes all repeat points from the given mode.

Call RemoveAllConditions along with this function if you are using conditions for repeats.

◆ RemoveTagLocation()

void RemoveTagLocation ( ComponentTemplate::Tag  tag)

Removes the fixed location for a set tagged component.

◆ RemoveTagSize()

void RemoveTagSize ( ComponentTemplate::Tag  tag)

Removes the fixed size for a set tagged component.

◆ RemoveUpdateEvent()

void RemoveUpdateEvent ( )

Removes the function that will be called after every update before rendering.

◆ Render()

◆ ReplaceCondition()

void ReplaceCondition ( ComponentCondition  from,
ComponentCondition  to,
bool  transition = true 
)

◆ ResetAnimation()

void ResetAnimation ( )

References Timer::Reset().

◆ Resize() [1/3]

virtual void Resize

Resizes the layer to the given size.

References Layer::bounds, and basic_Bounds< T_ >::Resize().

◆ Resize() [2/3]

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

Notifies the stack about a size change.

Reimplemented from Layer.

References Layer::Resize(), and ComponentStack::Update().

◆ Resize() [3/3]

virtual void Resize

Resizes the layer to the given size.

References Layer::bounds, and basic_Bounds< T_ >::Resize().

◆ ReturnTargetValue()

void ReturnTargetValue ( )

Whether GetValue returns the target value. This is the default mode.

◆ ReturnTransitionalValue()

void ReturnTransitionalValue ( )

Whether GetValue returns the current transitional value, this will also enable value event to be called every time transitional value is updated.

◆ SetBeforeUpdateEvent()

void SetBeforeUpdateEvent ( std::function< void()>  handler)

Sets a function to be called before every update.

◆ SetClickEvent()

void SetClickEvent ( std::function< void(ComponentTemplate::Tag, Geometry::Point, Input::Mouse::Button)>  handler)

Sets the mouse down event.

If HandleMouse function is called, this function will first perform mouse event transition, then it will call this handler.

References ComponentTemplate::NoTag, and ComponentTemplate::UnknownTag.

◆ SetConditionOf()

void SetConditionOf ( ComponentTemplate::RepeatMode  mode,
int  index,
ComponentCondition  condition 
)

Sets the condition of a specific repeat index.

Nothing will happen if index is out of bounds or condition does not exist. Setting condition to always will effectively remove the condition.

◆ SetData() [1/2]

void SetData ( ComponentTemplate::DataEffect  effect,
const Graphics::Drawable image 
)

Sets the data for a specific data effect.

This value will be cached by the stack for condition changes. This variant supports image based data. Ownership of the image stays with the caller.

References ComponentStack::AddCondition(), Gorgon::UI::DataEffectStart, ComponentTemplate::GetDataEffect(), Component::GetTemplate(), and ComponentStack::Update().

◆ SetData() [2/2]

void SetData ( ComponentTemplate::DataEffect  effect,
const std::string &  text 
)

Sets the data for a specific data effect.

This value will be cached by the stack for condition changes. This variant supports string based data.

References ComponentStack::AddCondition(), Gorgon::UI::DataEffectStart, ComponentTemplate::GetDataEffect(), Component::GetTemplate(), and ComponentStack::Update().

◆ SetEMSize()

void SetEMSize ( int  value)

Changes the default emsize of 10. This value can be overridden.

◆ SetFrameEvent()

void SetFrameEvent ( std::function< void()>  handler)

Sets a function to be called before update check.

◆ SetMouseDownEvent()

void SetMouseDownEvent ( std::function< void(ComponentTemplate::Tag, Geometry::Point, Input::Mouse::Button)>  handler)

Sets the mouse down event.

If HandleMouse function is called, this function will first perform mouse event transition, then it will call this handler.

◆ SetMouseMoveEvent()

void SetMouseMoveEvent ( std::function< void(ComponentTemplate::Tag, Geometry::Point)>  handler)

Sets the mouse mvoe event.

If HandleMouse function is called, this function will first perform mouse event transition, then it will call this handler. If this event is not handled mouse move event of the layer will not be handled too.

References ComponentTemplate::NoTag, Layer::SetMove(), and ComponentTemplate::UnknownTag.

◆ SetMouseOutEvent()

void SetMouseOutEvent ( std::function< void(ComponentTemplate::Tag)>  handler)

Sets the mouse out event that is fired when the mouse moves over the component stack or a substack.

it will not be fired for mouse moving over a specific component. If HandleMouse function is called, this function will first perform mouse event transition, then it will call this handler. This event will be called even if mouse over is not handled.

References ComponentTemplate::NoTag, and ComponentTemplate::UnknownTag.

◆ SetMouseOverEvent()

void SetMouseOverEvent ( std::function< void(ComponentTemplate::Tag)>  handler)

Sets the mouse over event that is fired when the mouse moves over the component stack or a substack.

it will not be fired for mouse moving over a specific component. If HandleMouse function is called, this function will first perform mouse event transition, then it will call this handler.

References ComponentTemplate::NoTag, and ComponentTemplate::UnknownTag.

◆ SetMouseUpEvent()

void SetMouseUpEvent ( std::function< void(ComponentTemplate::Tag, Geometry::Point, Input::Mouse::Button)>  handler)

Sets the mouse up event.

If HandleMouse function is called, this function will first perform mouse event transition, then it will call this handler. This event will be called even if mouse down is not handled.

References ComponentTemplate::NoTag, and ComponentTemplate::UnknownTag.

◆ SetOtherMouseEvent()

void SetOtherMouseEvent ( std::function< bool(ComponentTemplate::Tag, Input::Mouse::EventType, Geometry::Point, float)>  handler)

Sets the handler for scroll (HScroll or VScroll), zoom and rotate events.

All these events depend on specific hardware and may not be available.

References ComponentTemplate::NoTag, Gorgon::Input::Mouse::Rotate, Gorgon::Input::Mouse::Scroll_Hor, Gorgon::Input::Mouse::Scroll_Vert, Layer::SetHScroll(), Layer::SetRotate(), Layer::SetScroll(), Layer::SetZoom(), and Gorgon::Input::Mouse::Zoom.

◆ SetRenderEvent()

void SetRenderEvent ( std::function< void()>  handler)

Sets a function to be called after every render.

◆ SetRepeat()

void SetRepeat ( ComponentTemplate::RepeatMode  mode,
std::vector< std::array< float, 4 >>  data 
)

Sets the repeat with the given mode to the given vector.

Use std::move(data) for efficient transfer

◆ SetTagLocation()

void SetTagLocation ( ComponentTemplate::Tag  tag,
Geometry::Point  location 
)

Set a fixed location for a tagged component.

References ComponentStack::Update().

◆ SetTagSize()

void SetTagSize ( ComponentTemplate::Tag  tag,
Geometry::Size  size 
)

Set a fixed size for a tagged component.

References ComponentStack::Update().

◆ SetUpdateEvent()

void SetUpdateEvent ( std::function< void()>  handler)

Sets a function to be called after every update before rendering.

◆ SetValue() [1/8]

void SetValue ( float  first)

Sets the value for this stack.

Value of the stack can affect various properties of components. This will set the individual channels separately. Values should be between 0 and 1.

References ComponentStack::SetValue().

◆ SetValue() [2/8]

void SetValue ( float  first,
float  second 
)

Sets the value for this stack.

Value of the stack can affect various properties of components. This will set the individual channels separately. Values should be between 0 and 1.

References ComponentStack::SetValue().

◆ SetValue() [3/8]

void SetValue ( float  first,
float  second,
float  third 
)

Sets the value for this stack.

Value of the stack can affect various properties of components. This will set the individual channels separately. Values should be between 0 and 1.

References ComponentStack::SetValue().

◆ SetValue() [4/8]

void SetValue ( float  first,
float  second,
float  third,
float  fourth,
bool  instant = false 
)

Sets the value for this stack.

Value of the stack can affect various properties of components. This will set the individual channels separately. Values should be between 0 and 1.

References ComponentStack::AddCondition(), Gorgon::Time::DeltaTime(), Component::GetTemplate(), ComponentTemplate::GetValueModification(), ComponentTemplate::NoModification, ComponentStack::RemoveCondition(), Gorgon::Sign(), and ComponentStack::Update().

◆ SetValue() [5/8]

void SetValue ( Geometry::Point3D  pos)

Sets the value for the stack using a point in coordinate system.

References ComponentStack::SetValue(), basic_Point3D< T_ >::X, basic_Point3D< T_ >::Y, and basic_Point3D< T_ >::Z.

◆ SetValue() [6/8]

void SetValue ( Geometry::Pointf  pos)

Sets the value for the stack using a point in coordinate system.

References ComponentStack::SetValue(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.

◆ SetValue() [7/8]

void SetValue ( Graphics::RGBA  color)

Sets the value for the stack using a color.

References ComponentStack::SetValue().

◆ SetValue() [8/8]

void SetValue ( Graphics::RGBAf  color)

Sets the value for the stack using a color.

References RGBAf::A, RGBAf::B, RGBAf::G, RGBAf::R, and ComponentStack::SetValue().

◆ SetValueEvent()

void SetValueEvent ( std::function< void()>  handler)

Sets the function that will be called whenever the value is changed.

◆ SetValueToText()

void SetValueToText ( std::function< std::string(int, ComponentTemplate::DataEffect, const std::array< float, 4 > &)>  handler)

Sets the function that will be used to convert a value to a string.

The handler will receive the value channel, data effect that is causing the translation and the value that needs to be transformed.

◆ SetValueTransitionSpeed()

void SetValueTransitionSpeed ( std::array< float, 4 >  val)

Changes the value transition speed.

A speed of 0 will disable smooth transition. The unit is values per second

◆ TagBounds()

Returns the boundaries of the component marked with the given tag.

This function may cause update thus may take time to execute. The bounds are within the parent.

References Component::location, and Component::size.

◆ TagHasSubStack()

bool TagHasSubStack ( ComponentTemplate::Tag  tag) const

Returns whether the component marked with the tag has a substack.

If multiple components are marked to have substack, only the first one is considered. If the tag does not exist this function will return false.

◆ TransformCoordinates() [1/2]

Geometry::Pointf TransformCoordinates ( ComponentTemplate::Tag  tag,
Geometry::Point  location 
)

Translates the given coordinates to component space from 0 to 1.

References ComponentTemplate::GetIndex(), and Component::GetTemplate().

◆ TransformCoordinates() [2/2]

◆ TranslateCoordinates() [1/2]

Geometry::Point TranslateCoordinates ( ComponentTemplate::Tag  tag,
Geometry::Point  location 
)

Translates the given coordinates to component space in pixels.

References ComponentTemplate::GetIndex(), and Component::GetTemplate().

◆ TranslateCoordinates() [2/2]

Geometry::Point TranslateCoordinates ( int  ind,
Geometry::Point  location 
)

Translates the given coordinates to component space in pixels.

References Layer::bounds, ComponentStack::BoundsOf(), Template::Get(), basic_Bounds< T_ >::Move(), and basic_Bounds< T_ >::TopLeft().

◆ Update() [1/2]

virtual void Update ( )
overridevirtual

Updates the layout of the component stack.

Implements Updatable.

References ComponentStack::Update().

◆ Update() [2/2]

void Update ( bool  immediate)

Updates the layout of the component stack.

Member Data Documentation

◆ ConditionChanged

Event<ComponentStack> ConditionChanged

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