![]() |
Gorgon Game Engine
|
Component stack is the backbone of a widget. More...
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::Drawable * | GetImageData (ComponentTemplate::DataEffect effect) |
Returns the image data. If data is not set, this will return nullptr. More... | |
Layer & | GetLayerOf (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 Template & | GetTemplate () const |
Returns the template used by this stack. More... | |
const Template * | GetTemplate (ComponentTemplate::Tag tag) |
Returns the template used by the component with given tag. More... | |
const ComponentTemplate & | GetTemplate (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... | |
Widget * | GetWidget (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... | |
![]() | |
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... | |
Layer & | operator= (const Layer &)=delete |
Copy assignment is deleted. More... | |
Layer & | operator= (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 Layer & | GetParent () const |
Returns the parent of this layer. More... | |
Layer & | GetTopLevel () 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... | |
Layer & | GetTopLevel () |
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... | |
![]() | |
virtual | ~Updatable () |
Public Attributes | |
Event< ComponentStack > | ConditionChanged |
![]() | |
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 const Geometry::Bounds | EntireRegion |
When used as layer bounds, represents the entire region its placed in. More... | |
![]() | |
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... | |
![]() | |
Geometry::Bounds | bounds |
Bounds of this layer. More... | |
Containers::Collection< Layer > | children |
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... | |
Layer * | parent |
Parent layer, could be nullptr. More... | |
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.
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.
Generators are used to create widgets for the placeholders. If a function is empty or returns nullptr, neither a substack nor a widget will be placed there.
References Layer::Add(), ComponentStack::AddCondition(), ComponentStack::AddToStack(), Gorgon::UI::Always, Gorgon::WindowManager::ClickThreshold, basic_Point< T_ >::Distance(), Gorgon::Input::Keyboard::Keycodes::Down, Template::GetCount(), Gorgon::UI::Hover, ComponentStack::IsDisabled(), Gorgon::Input::Mouse::None, ComponentTemplate::NoRepeat, ComponentTemplate::NoTag, ComponentStack::RemoveCondition(), ComponentStack::Resize(), Layer::SetDown(), Layer::SetOut(), Layer::SetOver(), Layer::SetUp(), and Gorgon::UI::Textholder.
|
explicit |
Initiates a component stack with default size.
|
virtual |
Destructor.
void AddCondition | ( | ComponentCondition | condition, |
bool | transition = true |
||
) |
Adds a condition and its associated components to the stack.
References Gorgon::UI::Always, and ComponentStack::ReplaceCondition().
void AddRepeat | ( | ComponentTemplate::RepeatMode | mode, |
float | first | ||
) |
Adds a new repeating point to the given mode. Empty values will be set as 0.
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().
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().
void AddRepeat | ( | ComponentTemplate::RepeatMode | mode, |
float | first, | ||
float | second, | ||
float | third, | ||
float | fourth | ||
) |
Adds a new repeating point to the given mode.
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.
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.
void AddRepeat | ( | ComponentTemplate::RepeatMode | mode, |
Graphics::RGBA | color | ||
) |
Adds a new repeating point to the given mode.
References ComponentStack::AddRepeat().
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.
void AddToStack | ( | const ComponentTemplate & | temp, |
bool | reversed | ||
) |
Adds the given component to the top of the stack.
This function will be called to add all components in the given template
References ComponentStack::ComponentStack(), Layer::Add(), WidgetContainer::Add(), Gorgon::UI::Always, Gorgon::UI::Container, ComponentTemplate::GetClip(), ComponentTemplate::GetCondition(), ComponentTemplate::GetIndex(), ComponentTemplate::GetRepeatMode(), ComponentStack::GetTemplate(), ComponentTemplate::GetType(), Gorgon::UI::Graphics, ComponentTemplate::NoRepeat, Gorgon::UI::Placeholder, Timer::Reset(), and Component::reversed.
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.
int ComponentAt | ( | Geometry::Point | location | ) |
Returns the index of the component at the given location.
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().
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().
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.
void DisableTagWrap | ( | ComponentTemplate::Tag | tag | ) |
Disables text wrapping on a specific tag, default is enabled.
void EnableTagWrap | ( | ComponentTemplate::Tag | tag | ) |
Enables text wrapping on a specific tag, default is enabled.
void FinalizeTransitions | ( | ) |
Finalizes on-going transitions immediately.
References Gorgon::Input::Mouse::None.
const Graphics::Drawable* GetImageData | ( | ComponentTemplate::DataEffect | effect | ) |
Returns the image data. If data is not set, this will return nullptr.
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().
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.
const Template& GetTemplate | ( | ) | const |
Returns the template used by this stack.
const Template * GetTemplate | ( | ComponentTemplate::Tag | tag | ) |
Returns the template used by the component with given tag.
References PlaceholderTemplate::GetTemplate().
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().
std::string GetTextData | ( | ComponentTemplate::DataEffect | effect | ) |
Returns the text data. If data is not set, this will return empty string.
std::array<float, 4> GetValue | ( | ) | const |
Returns the value of the stack.
Widget * GetWidget | ( | ComponentTemplate::Tag | tag | ) |
Returns the widget associated with the tag.
If such widget does not exists nullptr will be returned instead.
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.
bool HasCondition | ( | ComponentCondition | condition | ) |
Returns if the given condition is in effect.
bool HasLayer | ( | int | ind | ) | const |
Returns if the component at the given index has a layer.
References ComponentStack::GetTemplate().
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().
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.
void RemoveAllConditionsOf | ( | ComponentTemplate::RepeatMode | mode | ) |
Removes all conditions for a repeat mode.
void RemoveBeforeUpdateEvent | ( | ) |
Removes the function that will be called before every update.
void RemoveCondition | ( | ComponentCondition | condition, |
bool | transition = true |
||
) |
Removes a condition and its associated components.
References Gorgon::UI::Always, and ComponentStack::ReplaceCondition().
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().
void RemoveFrameEvent | ( | ) |
Removes the function that will be called before update check.
void RemoveRenderEvent | ( | ) |
Removes the function that will be called after every render.
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.
void RemoveTagLocation | ( | ComponentTemplate::Tag | tag | ) |
Removes the fixed location for a set tagged component.
void RemoveTagSize | ( | ComponentTemplate::Tag | tag | ) |
Removes the fixed size for a set tagged component.
void RemoveUpdateEvent | ( | ) |
Removes the function that will be called after every update before rendering.
|
overridevirtual |
Renders the current layer, default handling is to pass the request to the sub-layers. Rendering is not thread safe.
Reimplemented from Layer.
References ComponentStack::AddCondition(), Gorgon::Time::DeltaTime(), Gorgon::Time::FrameStart(), Template::GetConditionDuration(), Component::GetTemplate(), ComponentStack::GetTemplate(), ComponentTemplate::ModifyAnimation, ComponentTemplate::NoModification, Gorgon::Input::Mouse::None, ComponentStack::RemoveCondition(), Layer::Render(), ComponentStack::ReplaceCondition(), Gorgon::Sign(), and ComponentTemplate::UseTransition.
void ReplaceCondition | ( | ComponentCondition | from, |
ComponentCondition | to, | ||
bool | transition = true |
||
) |
Replaces a condition with another one.
References Gorgon::UI::Always, Gorgon::Time::FrameStart(), Template::GetConditionDuration(), and Gorgon::Input::Mouse::None.
void ResetAnimation | ( | ) |
References Timer::Reset().
virtual void Resize |
Resizes the layer to the given size.
References Layer::bounds, and basic_Bounds< T_ >::Resize().
|
overridevirtual |
Notifies the stack about a size change.
Reimplemented from Layer.
References Layer::Resize(), and ComponentStack::Update().
virtual void Resize |
Resizes the layer to the given size.
References Layer::bounds, and basic_Bounds< T_ >::Resize().
void ReturnTargetValue | ( | ) |
Whether GetValue returns the target value. This is the default mode.
void ReturnTransitionalValue | ( | ) |
Whether GetValue returns the current transitional value, this will also enable value event to be called every time transitional value is updated.
void SetBeforeUpdateEvent | ( | std::function< void()> | handler | ) |
Sets a function to be called before every update.
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.
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.
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().
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().
void SetEMSize | ( | int | value | ) |
Changes the default emsize of 10. This value can be overridden.
void SetFrameEvent | ( | std::function< void()> | handler | ) |
Sets a function to be called before update check.
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.
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.
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.
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.
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.
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.
void SetRenderEvent | ( | std::function< void()> | handler | ) |
Sets a function to be called after every render.
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
void SetTagLocation | ( | ComponentTemplate::Tag | tag, |
Geometry::Point | location | ||
) |
Set a fixed location for a tagged component.
References ComponentStack::Update().
void SetTagSize | ( | ComponentTemplate::Tag | tag, |
Geometry::Size | size | ||
) |
Set a fixed size for a tagged component.
References ComponentStack::Update().
void SetUpdateEvent | ( | std::function< void()> | handler | ) |
Sets a function to be called after every update before rendering.
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().
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().
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().
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().
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.
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.
void SetValue | ( | Graphics::RGBA | color | ) |
Sets the value for the stack using a color.
References ComponentStack::SetValue().
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().
void SetValueEvent | ( | std::function< void()> | handler | ) |
Sets the function that will be called whenever the value is changed.
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.
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
Geometry::Bounds TagBounds | ( | ComponentTemplate::Tag | tag | ) |
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.
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.
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().
Geometry::Pointf TransformCoordinates | ( | int | ind, |
Geometry::Point | location | ||
) |
Translates the given coordinates to component space from 0 to 1.
References Layer::bounds, ComponentStack::BoundsOf(), Template::Get(), basic_Bounds< T_ >::GetSize(), basic_Bounds< T_ >::Height(), basic_Bounds< T_ >::Move(), basic_Bounds< T_ >::TopLeft(), basic_Bounds< T_ >::Width(), basic_Point< T_ >::X, and basic_Point< T_ >::Y.
Geometry::Point TranslateCoordinates | ( | ComponentTemplate::Tag | tag, |
Geometry::Point | location | ||
) |
Translates the given coordinates to component space in pixels.
References ComponentTemplate::GetIndex(), and Component::GetTemplate().
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().
|
overridevirtual |
Updates the layout of the component stack.
Implements Updatable.
References ComponentStack::Update().
void Update | ( | bool | immediate | ) |
Updates the layout of the component stack.
Event<ComponentStack> ConditionChanged |