Magnum::Ui::AbstractVisualLayer::Shared class

Base shared state for visual data layers.

Stores style transition functions.

Derived classes

class Magnum::Ui::BaseLayer::Shared
Shared state for the base layer.
class Magnum::Ui::TextLayer::Shared
Shared state for the text layer.

Constructors, destructors, conversion operators

Shared(const Shared&) deleted
Copying is not allowed.
Shared(Shared&&) noexcept
Move constructor.

Public functions

auto operator=(const Shared&) -> Shared& deleted
Copying is not allowed.
auto operator=(Shared&&) -> Shared& noexcept
Move assignment.
auto styleCount() const -> UnsignedInt
Style count.
auto dynamicStyleCount() const -> UnsignedInt
Dynamic style count.
auto totalStyleCount() const -> UnsignedInt
Total style count.
auto setStyleTransition(UnsignedInt(*)(UnsignedInt) toInactiveOut, UnsignedInt(*)(UnsignedInt) toInactiveOver, UnsignedInt(*)(UnsignedInt) toFocusedOut, UnsignedInt(*)(UnsignedInt) toFocusedOver, UnsignedInt(*)(UnsignedInt) toPressedOut, UnsignedInt(*)(UnsignedInt) toPressedOver, UnsignedInt(*)(UnsignedInt) toDisabled) -> Shared&
Set type-erased style transition functions.
template<class StyleIndex, StyleIndex(*)(StyleIndex) toInactiveOut, StyleIndex(*)(StyleIndex) toInactiveOver, StyleIndex(*)(StyleIndex) toFocusedOut, StyleIndex(*)(StyleIndex) toFocusedOver, StyleIndex(*)(StyleIndex) toPressedOut, StyleIndex(*)(StyleIndex) toPressedOver, StyleIndex(*)(StyleIndex) toDisabled>
auto setStyleTransition() -> Shared&
Set style transition functions.
auto setStyleTransition(UnsignedInt(*)(UnsignedInt) toInactive, UnsignedInt(*)(UnsignedInt) toFocused, UnsignedInt(*)(UnsignedInt) toPressed, UnsignedInt(*)(UnsignedInt) toDisabled) -> Shared&
Set style transition functions without hover state.
template<class StyleIndex, StyleIndex(*)(StyleIndex) toInactive, StyleIndex(*)(StyleIndex) toFocused, StyleIndex(*)(StyleIndex) toPressed, StyleIndex(*)(StyleIndex) toDisabled>
auto setStyleTransition() -> Shared&
Set style transition functions.

Function documentation

Magnum::Ui::AbstractVisualLayer::Shared::Shared(Shared&&) noexcept

Move constructor.

Performs a destructive move, i.e. the original object isn't usable afterwards anymore.

UnsignedInt Magnum::Ui::AbstractVisualLayer::Shared::styleCount() const

Style count.

Count of styles used by all layer instances referencing this Shared instance. IDs greater than styleCount() are then dynamic styles, with their count specified by dynamicStyleCount().

UnsignedInt Magnum::Ui::AbstractVisualLayer::Shared::dynamicStyleCount() const

Dynamic style count.

Count of dynamic styles appearing after the initial styleCount() styles, i.e. having IDs greater or equal to styleCount() and less than totalStyleCount(). The dynamic styles are local to every layer instance and are meant to be used mainly for style transition animations.

UnsignedInt Magnum::Ui::AbstractVisualLayer::Shared::totalStyleCount() const

Total style count.

A sum of styleCount() and dynamicStyleCount(). Styles with IDs less than styleCount() are the shared ones, styles with IDs greater or equal to styleCount() and less than totalStyleCount() are the dynamic ones.

Shared& Magnum::Ui::AbstractVisualLayer::Shared::setStyleTransition(UnsignedInt(*)(UnsignedInt) toInactiveOut, UnsignedInt(*)(UnsignedInt) toInactiveOver, UnsignedInt(*)(UnsignedInt) toFocusedOut, UnsignedInt(*)(UnsignedInt) toFocusedOver, UnsignedInt(*)(UnsignedInt) toPressedOut, UnsignedInt(*)(UnsignedInt) toPressedOver, UnsignedInt(*)(UnsignedInt) toDisabled)

Set type-erased style transition functions.

Returns Reference to self (for method chaining)

The toInactiveOut and toInactiveOver change a non-disabled style index to an inactive one with the pointer outside or over the node, for example when a mouse enters or leaves an area of otherwise inactive (neither focused nor pressed) button, but also when a button is released again or an input is no longer focused.

The toFocusedOut and toFocusedOver change a non-disabled style index to a focused one with the pointer outside or over the node. Note that, to reduce the amount of combinations, a pressed state has a priority over focused, so these two transitions are picked only when hovering a focused node or when the pointer is released after a node was focused by a pointer press. These transitions only ever happen for data attached to NodeFlag::Focusable nodes.

The toPressedOut and toPressedOver change a non-disabled style index to a pressed one with the pointer outside or over the node, for example after a pointer was pressed on a hovered button, after an activated but non-hovered button was pressed via a keyboard, but also after a pointer leaves a pressed button, making it no longer hovered or re-enters it, making it hovered again.

The toDisabled changes a style index to a disabled one, which happens when a NodeFlag::Disabled is set on a node. Such a node then doesn't receive any events until enabled again, meaning the disabled style index cannot transition into any other.

If any of the functions is nullptr, given transition is a no-op, keeping the same index. All transition functions are nullptr initially.

For correct behavior, the toInactiveOut, toInactiveOver, toFocusedOut, toFocusedOver, toPressedOut and toPressedOver functions should be mutually invertible, e.g. toPressedOver(toInactiveOut(style)) == style if the style was a pressed over style to begin with (and both transition functions were defined). The toDisabled function doesn't have to be, i.e. it can conflate multiple styles into one, as a disabled style is internally never transitioned back to a non-disabled one. If the style doesn't handle hover in any way, for example for touch-only interfaces, you can use setStyleTransition(UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt)) instead, which doesn't make any distinction between the over and out states and uses the same transition function for both.

All functions are passed an index that's less than styleCount() and are expected to return an index that's less than styleCount() as well. Not totalStyleCount() — the style transition functions are not allowed to use the dynamic style indices. Data with a dynamic style index are not transitioned in any way.

Setting (and subsequently changing) the toDisabled function causes LayerState::NeedsDataUpdate to be set on all layers that are constructed using this shared instance. The other transition functions don't cause any LayerState to be set, as they're only used directly in event handlers.

template<class StyleIndex, StyleIndex(*)(StyleIndex) toInactiveOut, StyleIndex(*)(StyleIndex) toInactiveOver, StyleIndex(*)(StyleIndex) toFocusedOut, StyleIndex(*)(StyleIndex) toFocusedOver, StyleIndex(*)(StyleIndex) toPressedOut, StyleIndex(*)(StyleIndex) toPressedOver, StyleIndex(*)(StyleIndex) toDisabled>
Shared& Magnum::Ui::AbstractVisualLayer::Shared::setStyleTransition()

Set style transition functions.

Returns Reference to self (for method chaining)

Like setStyleTransition(UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt)), but allows to use a concrete enum type instead of a typeless index. Same as with the type-erased variant, if any of the function template parameters is nullptr, given transition is a no-op, keeping the same index. Example usage:

enum StyleIndex {
    
};

StyleIndex styleIndexTransitionToInactiveBlur(StyleIndex index) {
    
}
StyleIndex styleIndexTransitionToInactiveHover(StyleIndex index) {
    
}
StyleIndex styleIndexTransitionToFocusedBlur(StyleIndex index) {
    
}
StyleIndex styleIndexTransitionToFocusedHover(StyleIndex index) {
    
}
StyleIndex styleIndexTransitionToPressedBlur(StyleIndex index) {
    
}
StyleIndex styleIndexTransitionToPressedHover(StyleIndex index) {
    
}
StyleIndex styleIndexTransitionToDisabled(StyleIndex index) {
    
}



Ui::AbstractVisualLayer::Shared& shared = ;
shared.setStyleTransition<StyleIndex,
    styleIndexTransitionToInactiveBlur,
    styleIndexTransitionToInactiveHover,
    styleIndexTransitionToFocusedBlur,
    styleIndexTransitionToFocusedHover,
    styleIndexTransitionToPressedBlur,
    styleIndexTransitionToPressedHover,
    styleIndexTransitionToDisabled>();

Shared& Magnum::Ui::AbstractVisualLayer::Shared::setStyleTransition(UnsignedInt(*)(UnsignedInt) toInactive, UnsignedInt(*)(UnsignedInt) toFocused, UnsignedInt(*)(UnsignedInt) toPressed, UnsignedInt(*)(UnsignedInt) toDisabled)

Set style transition functions without hover state.

Returns Reference to self (for method chaining)

Same as calling setStyleTransition(UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt), UnsignedInt(*)(UnsignedInt)) with toInactive used for both toInactiveOut and toInactiveOver, toFocused used for both toFocusedOut and toFocusedOver and toPressed used for both toPressedOut and toPressedOver. Useful in case the style doesn't handle hover in any way, for example for touch-only interfaces.

template<class StyleIndex, StyleIndex(*)(StyleIndex) toInactive, StyleIndex(*)(StyleIndex) toFocused, StyleIndex(*)(StyleIndex) toPressed, StyleIndex(*)(StyleIndex) toDisabled>
Shared& Magnum::Ui::AbstractVisualLayer::Shared::setStyleTransition()

Set style transition functions.

Returns Reference to self (for method chaining)

Same as calling setStyleTransition() with toInactive used for both toInactiveOut and toInactiveOver, toFocused used for both toFocusedOut and toFocusedOver and toPressed used for both toPressedOut and toPressedOver. Useful in case the style doesn't handle hover in any way, for example for touch-only interfaces.