class new in Git master
#include <Magnum/Ui/AbstractLayer.h>
AbstractLayer Base for data layers.
Derived classes
- class AbstractVisualLayer new in Git master
- Base for visual data layers.
- class EventLayer new in Git master
- Event handling layer.
Constructors, destructors, conversion operators
- AbstractLayer(LayerHandle handle) explicit
- Constructor.
- AbstractLayer(const AbstractLayer&) deleted
- Copying is not allowed.
- AbstractLayer(AbstractLayer&&) noexcept
- Move constructor.
Public functions
- auto operator=(const AbstractLayer&) -> AbstractLayer& deleted
- Copying is not allowed.
- auto operator=(AbstractLayer&&) -> AbstractLayer& noexcept
- Move assignment.
- auto handle() const -> LayerHandle
- Layer handle.
- auto features() const -> LayerFeatures
- Features exposed by a layer.
- auto state() const -> LayerStates
- Layer state.
- void setNeedsUpdate(LayerStates state)
- Mark the layer as needing an update.
-
auto capacity() const -> std::
size_t - Current capacity of the data storage.
-
auto usedCount() const -> std::
size_t - Count of used items in the data storage.
- auto isHandleValid(LayerDataHandle handle) const -> bool
- Whether a data handle is valid.
- auto isHandleValid(DataHandle handle) const -> bool
- Whether a data handle is valid.
- void attach(DataHandle data, NodeHandle node)
- Attach data to a node.
- void attach(LayerDataHandle data, NodeHandle node)
- Attach data to a node assuming it belongs to this layer.
- auto node(DataHandle data) const -> NodeHandle
- Node attachment for given data.
- auto node(LayerDataHandle data) const -> NodeHandle
- Node attachment for given data assuming it belongs to this layer.
-
auto nodes() const -> Containers::
StridedArrayView1D<const NodeHandle> - Node attachments for all data.
-
auto generations() const -> Containers::
StridedArrayView1D<const UnsignedShort> - Generation counters for all data.
- void setSize(const Vector2& size, const Vector2i& framebufferSize)
- Set user interface size.
-
void cleanNodes(const Containers::
StridedArrayView1D<const UnsignedShort>& nodeHandleGenerations) - Clean data attached to no longer valid nodes.
-
void cleanData(const Containers::
Iterable<AbstractAnimator>& animators) - Clean animations attached to no longer valid data.
-
void advanceAnimations(Nanoseconds time,
Containers::
MutableBitArrayView activeStorage, const Containers:: StridedArrayView1D<Float>& factorStorage, Containers:: MutableBitArrayView removeStorage, const Containers:: Iterable<AbstractDataAnimator>& animators) - Advance data animations in animators assigned to this layer.
-
void advanceAnimations(Nanoseconds time,
Containers::
MutableBitArrayView activeStorage, const Containers:: StridedArrayView1D<Float>& factorStorage, Containers:: MutableBitArrayView removeStorage, const Containers:: Iterable<AbstractStyleAnimator>& animators) - Advance style animations in animators assigned to this layer.
-
void update(LayerStates state,
const Containers::
StridedArrayView1D<const UnsignedInt>& dataIds, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts, const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets, const Containers:: StridedArrayView1D<const Vector2>& nodeSizes, const Containers:: StridedArrayView1D<const Float>& nodeOpacities, Containers:: BitArrayView nodesEnabled, const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets, const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes, const Containers:: StridedArrayView1D<const Vector2>& compositeRectOffsets, const Containers:: StridedArrayView1D<const Vector2>& compositeRectSizes) - Update visible layer data to given offsets and positions.
-
void composite(AbstractRenderer& renderer,
const Containers::
StridedArrayView1D<const Vector2>& rectOffsets, const Containers:: StridedArrayView1D<const Vector2>& rectSizes, std:: size_t offset, std:: size_t count) - Composite previously rendered contents.
-
void draw(const Containers::
StridedArrayView1D<const UnsignedInt>& dataIds, std:: size_t offset, std:: size_t count, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts, std:: size_t clipRectOffset, std:: size_t clipRectCount, const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets, const Containers:: StridedArrayView1D<const Vector2>& nodeSizes, const Containers:: StridedArrayView1D<const Float>& nodeOpacities, Containers:: BitArrayView nodesEnabled, const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets, const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes) - Draw a sub-range of visible layer data.
- void pointerPressEvent(UnsignedInt dataId, PointerEvent& event)
- Handle a pointer press event.
- void pointerReleaseEvent(UnsignedInt dataId, PointerEvent& event)
- Handle a pointer release event.
- void pointerTapOrClickEvent(UnsignedInt dataId, PointerEvent& event)
- Handle a pointer tap or click event.
- void pointerMoveEvent(UnsignedInt dataId, PointerMoveEvent& event)
- Handle a pointer move event.
- void pointerEnterEvent(UnsignedInt dataId, PointerMoveEvent& event)
- Handle a pointer enter event.
- void pointerLeaveEvent(UnsignedInt dataId, PointerMoveEvent& event)
- Handle a pointer leave event.
- void focusEvent(UnsignedInt dataId, FocusEvent& event)
- Handle a focus event.
- void blurEvent(UnsignedInt dataId, FocusEvent& event)
- Handle a blur event.
- void keyPressEvent(UnsignedInt dataId, KeyEvent& event)
- Handle a key press event.
- void keyReleaseEvent(UnsignedInt dataId, KeyEvent& event)
- Handle a key release event.
- void textInputEvent(UnsignedInt dataId, TextInputEvent& event)
- Handle a text input event.
- void visibilityLostEvent(UnsignedInt dataId, VisibilityLostEvent& event)
- Handle a visibility lost event.
Protected functions
-
auto create(NodeHandle node = NodeHandle::
Null) -> DataHandle - Create a data.
- void remove(DataHandle handle)
- Remove a data.
- void remove(LayerDataHandle handle)
- Remove a data assuming it belongs to this layer.
- void assignAnimator(AbstractDataAnimator& animator) const
- Assign a data animator to this layer.
- void assignAnimator(AbstractStyleAnimator& animator) const
- Assign a style animator to this layer.
Private functions
- auto doFeatures() const -> LayerFeatures pure virtual
- Implementation for features()
- auto doState() const -> LayerStates virtual
- Query layer state.
- void doSetSize(const Vector2& size, const Vector2i& framebufferSize) virtual
- Set user interface size.
-
void doClean(Containers::
BitArrayView dataIdsToRemove) virtual - Clean no longer valid layer data.
-
void doAdvanceAnimations(Nanoseconds time,
Containers::
MutableBitArrayView activeStorage, const Containers:: StridedArrayView1D<Float>& factorStorage, Containers:: MutableBitArrayView removeStorage, const Containers:: Iterable<AbstractDataAnimator>& animators) virtual - Advance data animations in animators assigned to this layer.
-
void doAdvanceAnimations(Nanoseconds time,
Containers::
MutableBitArrayView activeStorage, const Containers:: StridedArrayView1D<Float>& factorStorage, Containers:: MutableBitArrayView removeStorage, const Containers:: Iterable<AbstractStyleAnimator>& animators) virtual - Advance style animations in animators assigned to this layer.
-
void doUpdate(LayerStates state,
const Containers::
StridedArrayView1D<const UnsignedInt>& dataIds, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts, const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets, const Containers:: StridedArrayView1D<const Vector2>& nodeSizes, const Containers:: StridedArrayView1D<const Float>& nodeOpacities, Containers:: BitArrayView nodesEnabled, const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets, const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes, const Containers:: StridedArrayView1D<const Vector2>& compositeRectOffsets, const Containers:: StridedArrayView1D<const Vector2>& compositeRectSizes) virtual - Update visible layer data to given offsets and positions.
-
void doComposite(AbstractRenderer& renderer,
const Containers::
StridedArrayView1D<const Vector2>& compositeRectOffsets, const Containers:: StridedArrayView1D<const Vector2>& compositeRectSizes, std:: size_t offset, std:: size_t count) virtual - Composite previously rendered contents.
-
void doDraw(const Containers::
StridedArrayView1D<const UnsignedInt>& dataIds, std:: size_t offset, std:: size_t count, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds, const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts, std:: size_t clipRectOffset, std:: size_t clipRectCount, const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets, const Containers:: StridedArrayView1D<const Vector2>& nodeSizes, const Containers:: StridedArrayView1D<const Float>& nodeOpacities, Containers:: BitArrayView nodesEnabled, const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets, const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes) virtual - Draw a sub-range of visible layer data.
- void doPointerPressEvent(UnsignedInt dataId, PointerEvent& event) virtual
- Handle a pointer press event.
- void doPointerReleaseEvent(UnsignedInt dataId, PointerEvent& event) virtual
- Handle a pointer release event.
- void doPointerTapOrClickEvent(UnsignedInt dataId, PointerEvent& event) virtual
- Handle a pointer tap or click event.
- void doPointerMoveEvent(UnsignedInt dataId, PointerMoveEvent& event) virtual
- Handle a pointer move event.
- void doPointerEnterEvent(UnsignedInt dataId, PointerMoveEvent& event) virtual
- Handle a pointer enter event.
- void doPointerLeaveEvent(UnsignedInt dataId, PointerMoveEvent& event) virtual
- Handle a pointer leave event.
- void doFocusEvent(UnsignedInt dataId, FocusEvent& event) virtual
- Handle a focus event.
- void doBlurEvent(UnsignedInt dataId, FocusEvent& event) virtual
- Handle a blur event.
- void doKeyPressEvent(UnsignedInt dataId, KeyEvent& event) virtual
- Handle a key press event.
- void doKeyReleaseEvent(UnsignedInt dataId, KeyEvent& event) virtual
- Handle a pointer release event.
- void doTextInputEvent(UnsignedInt dataId, TextInputEvent& event) virtual
- Handle a text input event.
- void doVisibilityLostEvent(UnsignedInt dataId, VisibilityLostEvent& event) virtual
- Handle a visibility lost event.
Function documentation
Magnum:: Ui:: AbstractLayer:: AbstractLayer(LayerHandle handle) explicit
Constructor.
Parameters | |
---|---|
handle | Handle returned by AbstractUserInterface:: |
Magnum:: Ui:: AbstractLayer:: AbstractLayer(AbstractLayer&&) noexcept
Move constructor.
Performs a destructive move, i.e. the original object isn't usable afterwards anymore.
LayerHandle Magnum:: Ui:: AbstractLayer:: handle() const
Layer handle.
Returns the handle passed to the constructor.
LayerStates Magnum:: Ui:: AbstractLayer:: state() const
Layer state.
See the LayerState enum for more information. By default no flags are set.
void Magnum:: Ui:: AbstractLayer:: setNeedsUpdate(LayerStates state)
Mark the layer as needing an update.
Meant to be called by layer implementations when the data get modified. Expects that state
is a non-empty subset of LayerState::
std:: size_t Magnum:: Ui:: AbstractLayer:: capacity() const
Current capacity of the data storage.
Can be at most 1048576. If create() is called and there's no free slots left, the internal storage gets grown.
std:: size_t Magnum:: Ui:: AbstractLayer:: usedCount() const
Count of used items in the data storage.
Always at most capacity(). Expired handles are counted among used as well. The operation is done with a complexity where is capacity().
bool Magnum:: Ui:: AbstractLayer:: isHandleValid(LayerDataHandle handle) const
Whether a data handle is valid.
A handle is valid if it has been returned from create() before and remove() wasn't called on it yet. For LayerDataHandle::false
.
bool Magnum:: Ui:: AbstractLayer:: isHandleValid(DataHandle handle) const
Whether a data handle is valid.
A shorthand for extracting a LayerHandle from handle
using dataHandleLayer(), comparing it to handle() and if it's the same, calling isHandleValid(LayerDataHandle) const with a LayerDataHandle extracted from handle
using dataHandleData(). See these functions for more information. For DataHandle::false
.
void Magnum:: Ui:: AbstractLayer:: attach(DataHandle data,
NodeHandle node)
Attach data to a node.
Makes the data
handle tied to a particular node
, meaning it gets included in draw or event processing depending on node position and visibility. Also, AbstractUserInterface::node
or any parent node will then mean that the data
gets scheduled for removal during the next cleanNodes() call.
Expects that data
is valid. The node
can be anything including NodeHandle::data
is already attached to some node, this will overwrite the previous attachment — i.e., it's not possible to have the same data attached to multiple nodes. The inverse, attaching multiple different data handles to a single node, is supported however.
If data
wasn't attached to node
before, calling this function causes LayerState::node
isn't NodeHandle::
void Magnum:: Ui:: AbstractLayer:: attach(LayerDataHandle data,
NodeHandle node)
Attach data to a node assuming it belongs to this layer.
Like attach(DataHandle, NodeHandle) but without checking that data
indeed belongs to this layer. See its documentation for more information.
NodeHandle Magnum:: Ui:: AbstractLayer:: node(DataHandle data) const
Node attachment for given data.
Expects that data
is valid. If given data isn't attached to any node, returns NodeHandle::
The returned handle may be invalid if either the data got attached to an invalid node in the first place or the node or any of its parents were removed and AbstractUserInterface::
NodeHandle Magnum:: Ui:: AbstractLayer:: node(LayerDataHandle data) const
Node attachment for given data assuming it belongs to this layer.
Like node(DataHandle) const but without checking that data
indeed belongs to this layer. See its documentation for more information.
Containers:: StridedArrayView1D<const NodeHandle> Magnum:: Ui:: AbstractLayer:: nodes() const
Node attachments for all data.
Used internally from AbstractUserInterface::
Containers:: StridedArrayView1D<const UnsignedShort> Magnum:: Ui:: AbstractLayer:: generations() const
Generation counters for all data.
Meant to be used by code that only gets data IDs or masks but needs the full DataHandle / LayerDataHandle. Size of the returned view is the same as capacity().
void Magnum:: Ui:: AbstractLayer:: setSize(const Vector2& size,
const Vector2i& framebufferSize)
Set user interface size.
Used internally from AbstractUserInterface::
void Magnum:: Ui:: AbstractLayer:: cleanNodes(const Containers:: StridedArrayView1D<const UnsignedShort>& nodeHandleGenerations)
Clean data attached to no longer valid nodes.
Used internally from AbstractUserInterface::nodeHandleGenerations
contains handle generation counters for all nodes, where the index is implicitly the handle ID. They're used to decide about node attachment validity, data with invalid node attachments are then removed. Delegates to doClean(), see its documentation for more information about the arguments.
void Magnum:: Ui:: AbstractLayer:: cleanData(const Containers:: Iterable<AbstractAnimator>& animators)
Clean animations attached to no longer valid data.
Used internally from AbstractUserInterface::animators
expose AnimatorFeature::
Calling this function resets LayerState::
void Magnum:: Ui:: AbstractLayer:: advanceAnimations(Nanoseconds time,
Containers:: MutableBitArrayView activeStorage,
const Containers:: StridedArrayView1D<Float>& factorStorage,
Containers:: MutableBitArrayView removeStorage,
const Containers:: Iterable<AbstractDataAnimator>& animators)
Advance data animations in animators assigned to this layer.
Used internally from AbstractUserInterface::
Expects that activeStorage
, factorStorage
and removeStorage
have the same size, which is at least as large as the largest capacity of all animators
, and that all animators
expose AnimatorFeature::
void Magnum:: Ui:: AbstractLayer:: advanceAnimations(Nanoseconds time,
Containers:: MutableBitArrayView activeStorage,
const Containers:: StridedArrayView1D<Float>& factorStorage,
Containers:: MutableBitArrayView removeStorage,
const Containers:: Iterable<AbstractStyleAnimator>& animators)
Advance style animations in animators assigned to this layer.
Used internally from AbstractUserInterface::
Expects that activeStorage
, factorStorage
and removeStorage
have the same size, which is at least as large as the largest capacity of all animators
, and that all animators
expose AnimatorFeature::
void Magnum:: Ui:: AbstractLayer:: update(LayerStates state,
const Containers:: StridedArrayView1D<const UnsignedInt>& dataIds,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts,
const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets,
const Containers:: StridedArrayView1D<const Vector2>& nodeSizes,
const Containers:: StridedArrayView1D<const Float>& nodeOpacities,
Containers:: BitArrayView nodesEnabled,
const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes,
const Containers:: StridedArrayView1D<const Vector2>& compositeRectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& compositeRectSizes)
Update visible layer data to given offsets and positions.
Used internally from AbstractUserInterface::
Expects that states
isn't empty and is a subset of LayerState::clipRectIds
and clipRectDataCounts
views have the same size, nodeOffsets
, nodeSizes
, nodeOpacities
and nodesEnabled
have the same size, clipRectOffsets
and clipRectOffset
have the same size and compositeRectOffsets
and compositeRectSizes
have the same size. If LayerFeature::compositeRectOffsets
and compositeRectSizes
are expected to be empty. The nodeOffsets
, nodeSizes
, nodeOpacities
and nodesEnabled
views should be large enough to contain any valid node ID. If the layer advertises LayerFeature::
Calling this function resets LayerStates present in state
, however note that behavior of this function is independent of state() — it performs the update only based on what's passed in state
.
void Magnum:: Ui:: AbstractLayer:: composite(AbstractRenderer& renderer,
const Containers:: StridedArrayView1D<const Vector2>& rectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& rectSizes,
std:: size_t offset,
std:: size_t count)
Composite previously rendered contents.
Used internally from AbstractUserInterface::rectOffsets
and rectSizes
views have the same size and that offset
and count
fits into their size. Delegates to doComposite(), see its documentation for more information about the arguments.
void Magnum:: Ui:: AbstractLayer:: draw(const Containers:: StridedArrayView1D<const UnsignedInt>& dataIds,
std:: size_t offset,
std:: size_t count,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts,
std:: size_t clipRectOffset,
std:: size_t clipRectCount,
const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets,
const Containers:: StridedArrayView1D<const Vector2>& nodeSizes,
const Containers:: StridedArrayView1D<const Float>& nodeOpacities,
Containers:: BitArrayView nodesEnabled,
const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes)
Draw a sub-range of visible layer data.
Used internally from AbstractUserInterface::offset
and count
fits into dataIds
size, that the clipRectIds
and clipRectDataCounts
views have the same size, nodeOffsets
, nodeSizes
, nodeOpacities
and nodesEnabled
have the same size and clipRectOffsets
and clipRectOffset
have the same size. The nodeOffsets
, nodeSizes
, nodeOpacities
and nodesEnabled
views should be large enough to contain any valid node ID. Delegates to doDraw(), see its documentation for more information about the arguments.
void Magnum:: Ui:: AbstractLayer:: pointerPressEvent(UnsignedInt dataId,
PointerEvent& event)
Handle a pointer press event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data and PointerEvent::
void Magnum:: Ui:: AbstractLayer:: pointerReleaseEvent(UnsignedInt dataId,
PointerEvent& event)
Handle a pointer release event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data and PointerEvent::
void Magnum:: Ui:: AbstractLayer:: pointerTapOrClickEvent(UnsignedInt dataId,
PointerEvent& event)
Handle a pointer tap or click event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data and PointerEvent::
void Magnum:: Ui:: AbstractLayer:: pointerMoveEvent(UnsignedInt dataId,
PointerMoveEvent& event)
Handle a pointer move event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data and PointerMoveEvent::
void Magnum:: Ui:: AbstractLayer:: pointerEnterEvent(UnsignedInt dataId,
PointerMoveEvent& event)
Handle a pointer enter event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data and PointerMoveEvent::
void Magnum:: Ui:: AbstractLayer:: pointerLeaveEvent(UnsignedInt dataId,
PointerMoveEvent& event)
Handle a pointer leave event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data and PointerMoveEvent::
void Magnum:: Ui:: AbstractLayer:: focusEvent(UnsignedInt dataId,
FocusEvent& event)
Handle a focus event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data. The event is expected to not be accepted yet. Delegates to doFocusEvent(), see its documentation for more information.
void Magnum:: Ui:: AbstractLayer:: blurEvent(UnsignedInt dataId,
FocusEvent& event)
Handle a blur event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data. The event is expected to not be accepted yet. Delegates to doBlurEvent(), see its documentation for more information.
void Magnum:: Ui:: AbstractLayer:: keyPressEvent(UnsignedInt dataId,
KeyEvent& event)
Handle a key press event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data. The event is expected to not be accepted yet. Delegates to doKeyPressEvent(), see its documentation for more information.
void Magnum:: Ui:: AbstractLayer:: keyReleaseEvent(UnsignedInt dataId,
KeyEvent& event)
Handle a key release event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data. The event is expected to not be accepted yet. Delegates to doKeyReleaseEvent(), see its documentation for more information.
void Magnum:: Ui:: AbstractLayer:: textInputEvent(UnsignedInt dataId,
TextInputEvent& event)
Handle a text input event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data. The event is expected to not be accepted yet. Delegates to doTextInputEvent(), see its documentation for more information.
void Magnum:: Ui:: AbstractLayer:: visibilityLostEvent(UnsignedInt dataId,
VisibilityLostEvent& event)
Handle a visibility lost event.
Used internally from AbstractUserInterface::dataId
is less than capacity(), with the assumption that the ID points to a valid data. Delegates to doVisibilityLostEvent(), see its documentation for more information.
DataHandle Magnum:: Ui:: AbstractLayer:: create(NodeHandle node = NodeHandle:: Null) protected
Create a data.
Parameters | |
---|---|
node | Node to attach to |
Returns | New data handle |
Allocates a new handle in a free slot in the internal storage or grows the storage if there's no free slots left. Expects that there's at most 1048576 data. The returned handle can be removed again with remove(). If node
is not NodeHandle::
Calling this function causes LayerState::node
is not NodeHandle::
void Magnum:: Ui:: AbstractLayer:: remove(DataHandle handle) protected
Remove a data.
Expects that handle
is valid. After this call, isHandleValid(DataHandle) const returns false
for handle
. See also remove(LayerDataHandle) which is a simpler operation if the data is already known to belong to this layer.
Calling this function causes LayerState::handle
is attached to a node, calling this function also causes LayerState::
void Magnum:: Ui:: AbstractLayer:: remove(LayerDataHandle handle) protected
Remove a data assuming it belongs to this layer.
Expects that handle
is valid. After this call, isHandleValid(LayerDataHandle) const returns false
for handle
. See also remove(DataHandle) which additionally checks that the data belongs to this layer.
Calling this function causes LayerState::handle
is attached to a node, calling this function also causes LayerState::
void Magnum:: Ui:: AbstractLayer:: assignAnimator(AbstractDataAnimator& animator) const protected
Assign a data animator to this layer.
Expects that the layer supports LayerFeature::animator
wasn't passed to assignAnimator(AbstractDataAnimator&) const on any layer yet. On the other hand, it's possible to assign multiple different animators to the same layer. Saves handle() into AbstractAnimator::animator
to advanceAnimations(Nanoseconds, Containers::
A concrete layer implementation is meant to wrap this function in a public API, restricting to a more concrete animator type, in order to be able to safely cast back to that type in doAdvanceAnimations(Nanoseconds, Containers::
See assignAnimator(AbstractStyleAnimator&) const for style animators, a corresponding API for an AbstractGenericAnimator is AbstractGenericAnimator::
void Magnum:: Ui:: AbstractLayer:: assignAnimator(AbstractStyleAnimator& animator) const protected
Assign a style animator to this layer.
Expects that the layer supports LayerFeature::animator
wasn't passed to assignAnimator(AbstractStyleAnimator&) const on any layer yet. On the other hand, it's possible to assign multiple different animators to the same layer. Saves handle() into AbstractAnimator::animator
to advanceAnimations(Nanoseconds, Containers::
A concrete layer implementation is meant to wrap this function in a public API, restricting to a more concrete animator type, in order to be able to safely cast back to that type in doAdvanceAnimations(Nanoseconds, Containers::
See assignAnimator(AbstractDataAnimator&) const for data animators, a corresponding API for an AbstractGenericAnimator is AbstractGenericAnimator::
LayerStates Magnum:: Ui:: AbstractLayer:: doState() const virtual private
Query layer state.
Called by state() to retrieve additional state bits that might have changed without layer's direct involvement, such as data shared between multiple layers getting modified by another layer. The implementation is expected to return a subset of LayerState::
Default implementation returns an empty set.
void Magnum:: Ui:: AbstractLayer:: doSetSize(const Vector2& size,
const Vector2i& framebufferSize) virtual private
Set user interface size.
Parameters | |
---|---|
size | Size of the user interface to which everything including events is positioned |
framebufferSize | Size of the window framebuffer |
Implementation for setSize(), which is called from AbstractUserInterface::
Default implementation does nothing.
void Magnum:: Ui:: AbstractLayer:: doClean(Containers:: BitArrayView dataIdsToRemove) virtual private
Clean no longer valid layer data.
Parameters | |
---|---|
dataIdsToRemove | Data IDs to remove |
Implementation for cleanNodes(), which is called from AbstractUserInterface::
The dataIdsToRemove
view has the same size as capacity() and is guaranteed to have bits set only for valid data IDs, i.e. data IDs that are already removed are not set.
This function may get also called with dataIdsToRemove
having all bits zero.
Default implementation does nothing.
void Magnum:: Ui:: AbstractLayer:: doAdvanceAnimations(Nanoseconds time,
Containers:: MutableBitArrayView activeStorage,
const Containers:: StridedArrayView1D<Float>& factorStorage,
Containers:: MutableBitArrayView removeStorage,
const Containers:: Iterable<AbstractDataAnimator>& animators) virtual private
Advance data animations in animators assigned to this layer.
Parameters | |
---|---|
time in | Time to which to advance |
activeStorage in/out | Storage for animators to put a mask of active animations into |
factorStorage in/out | Storage for animators to put animation interpolation factors into |
removeStorage in/out | Storage for animators to put a mask of animations to remove into |
animators in | Animators to advance |
Implementation for advanceAnimations(), which is called from AbstractUserInterface::
The activeStorage
, factorStorage
and removeStorage
are guaranteed to be at least as large as the largest capacity of all animators
. The animators
are all guaranteed to support AnimatorFeature::
For each animator in animators
the implementation is expected to call AbstractAnimator::activeStorage
, factorStorage
and removeStorage
; then, if the returned value says advance is needed, pass the slices of activeStorage
, factorStorage
and removeStorage
to the animator-specific advance function; and then, if the returned value says clean is needed, pass the slice of removeStorage
to AbstractAnimator::
Assuming the layer implementation publicizes assignAnimator(AbstractDataAnimator&) const with a restricted type, the animators can then be safely cast back to that type in order to call a concrete layer-specific advance function.
void Magnum:: Ui:: AbstractLayer:: doAdvanceAnimations(Nanoseconds time,
Containers:: MutableBitArrayView activeStorage,
const Containers:: StridedArrayView1D<Float>& factorStorage,
Containers:: MutableBitArrayView removeStorage,
const Containers:: Iterable<AbstractStyleAnimator>& animators) virtual private
Advance style animations in animators assigned to this layer.
Parameters | |
---|---|
time in | Time to which to advance |
activeStorage in/out | Storage for animators to put a mask of active animations into |
factorStorage in/out | Storage for animators to put animation interpolation factors into |
removeStorage in/out | Storage for animators to put a mask of animations to remove into |
animators in | Animators to advance |
Implementation for advanceAnimations(), which is called from AbstractUserInterface::
The activeStorage
, factorStorage
and removeStorage
are guaranteed to be at least as large as the largest capacity of all animators
. The animators
are all guaranteed to support AnimatorFeature::
For each animator in animators
the implementation is expected to call AbstractAnimator::activeStorage
, factorStorage
and removeStorage
; then, if the returned value says advance is needed, pass the slices of activeStorage
, factorStorage
and removeStorage
to the animator-specific advance function; and then, if the returned value says clean is needed, pass the slice of removeStorage
to AbstractAnimator::
Assuming the layer implementation publicizes assignAnimator(AbstractStyleAnimator&) const with a restricted type, the animators can then be safely cast back to that type in order to call a concrete layer-specific advance function.
void Magnum:: Ui:: AbstractLayer:: doUpdate(LayerStates state,
const Containers:: StridedArrayView1D<const UnsignedInt>& dataIds,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts,
const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets,
const Containers:: StridedArrayView1D<const Vector2>& nodeSizes,
const Containers:: StridedArrayView1D<const Float>& nodeOpacities,
Containers:: BitArrayView nodesEnabled,
const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes,
const Containers:: StridedArrayView1D<const Vector2>& compositeRectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& compositeRectSizes) virtual private
Update visible layer data to given offsets and positions.
Parameters | |
---|---|
state | State that's needed to be updated |
dataIds | Data IDs to update, in order that matches the draw order |
clipRectIds | IDs of clip rects to use for dataIds |
clipRectDataCounts | Counts of dataIds to use for each clip rect from clipRectIds |
nodeOffsets | Absolute node offsets indexed by node ID |
nodeSizes | Node sizes indexed by node ID |
nodeOpacities | Absolute node opacities (i.e., inheriting parent node opacities as well) indexed by node ID |
nodesEnabled | Which visible nodes are enabled, i.e. which don't have NodeFlag:: |
clipRectOffsets | Absolute clip rect offsets referenced by clipRectIds |
clipRectSizes | Clip rect sizes referenced by clipRectIds |
compositeRectOffsets | Offsets of framebuffer rectangles to composite |
compositeRectSizes | Sizes of framebuffer rectangles to composite |
Implementation for update(), which is called from AbstractUserInterface::
The state
is guaranteed to be a subset of LayerState::
Node handles corresponding to dataIds
are available in nodes(), node IDs can be then extracted from the handles using nodeHandleId(). The node IDs then index into the nodeOffsets
, nodeSizes
, nodeOpacities
and nodesEnabled
views. The nodeOffsets
, nodeSizes
, nodeOpacities
and nodesEnabled
have the same size and are guaranteed to be large enough to contain any valid node ID.
All nodes() at indices corresponding to dataIds
are guaranteed to not be NodeHandle::nodeOffsets
, nodeSizes
, nodeOpacities
and nodesDisabled
arrays may contain random or uninitialized values for nodes different than those referenced from dataIds
, such as for nodes that are not currently visible or freed node handles.
The node data are meant to be clipped by rects defined in clipRectOffsets
and clipRectSizes
. The clipRectIds
and clipRectDataCounts
have the same size and specify which of these rects is used for which data. For example, a sequence of {3, 2}, {0, 4}, {1, 7}
means clipping the first two data with clip rect 3, then the next four data with clip rect 0 and then the next seven data with clip rect 1. The sum of all clipRectDataCounts
is equal to the size of the dataIds
array. The clipRectOffsets
and clipRectSizes
have the same size and are guaranteed to be large enough to contain any ID from clipRectIds
. They're in the same coordinate system as nodeOffsets
and nodeSizes
, a zero offset and a zero size denotes that no clipping is needed. Tt's up to the implementation whether it clips the actual data directly or whether it performs clipping at draw time.
The compositeRectOffsets
and compositeRectOffsets
have the same size and define rectangles to be used by compositing operations, i.e. intersections of node rectangles with corresponding clip rectangles. If the layer doesn't advertise LayerFeature::
This function may get also called with dataIds
being empty, for example when setNeedsUpdate() was called but the layer doesn't have any data currently visible.
Default implementation does nothing. Data passed to this function are subsequently passed to doComposite() / doDraw() calls as well, the only difference is that doUpdate() gets called just once with all data to update, while doComposite() / doDraw() is called several times with different sub-ranges of the data based on desired draw order.
void Magnum:: Ui:: AbstractLayer:: doComposite(AbstractRenderer& renderer,
const Containers:: StridedArrayView1D<const Vector2>& compositeRectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& compositeRectSizes,
std:: size_t offset,
std:: size_t count) virtual private
Composite previously rendered contents.
Parameters | |
---|---|
renderer | Renderer instance containing the previously rendered contents |
compositeRectOffsets | Offsets of framebuffer rectangles to composite. Same as the view passed to doUpdate() earlier. |
compositeRectSizes | Sizes of framebuffer rectangles to composite. Same as the view passed to doUpdate() earlier. |
offset | Offset into compositeRectOffsets and compositeRectSizes |
count | Count of compositeRectOffsets and compositeRectSizes to composite |
Implementation for composite(), which is called from AbstractUserInterface::compositeRectOffsets
and compositeRectSizes
, see its documentation for their relations and constraints. This function is called after drawing contents of all layers earlier in the top-level node and layer draw order. It's guaranteed that doDraw() will get called after this function.
This function usually gets called several times with the same views but different offset
and count
. The range of compositeRectOffsets
and compositeRectSizes
views defined by offset
and count
contains rectangles that correspond to the layer data and can be used to restrict the compositing operation to only the area that's actually subsequently drawn.)
void Magnum:: Ui:: AbstractLayer:: doDraw(const Containers:: StridedArrayView1D<const UnsignedInt>& dataIds,
std:: size_t offset,
std:: size_t count,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectIds,
const Containers:: StridedArrayView1D<const UnsignedInt>& clipRectDataCounts,
std:: size_t clipRectOffset,
std:: size_t clipRectCount,
const Containers:: StridedArrayView1D<const Vector2>& nodeOffsets,
const Containers:: StridedArrayView1D<const Vector2>& nodeSizes,
const Containers:: StridedArrayView1D<const Float>& nodeOpacities,
Containers:: BitArrayView nodesEnabled,
const Containers:: StridedArrayView1D<const Vector2>& clipRectOffsets,
const Containers:: StridedArrayView1D<const Vector2>& clipRectSizes) virtual private
Draw a sub-range of visible layer data.
Parameters | |
---|---|
dataIds | Data IDs to update, in order that matches the draw order. Same as the view passed to doUpdate() earlier. |
offset | Offset into dataIds |
count | Count of dataIds to draw |
clipRectIds | IDs of clip rects to use for dataIds . Same as the view passed to doUpdate() earlier. |
clipRectDataCounts | Counts of dataIds to use for each clip rect from clipRectIds . Same as the view passed to doUpdate() earlier. |
clipRectOffset | Offset into clipRectIds and clipRectDataCounts |
clipRectCount | Count of clipRectIds and clipRectDataCounts to use |
nodeOffsets | Absolute node offsets. Same as the view passed to doUpdate() earlier. |
nodeSizes | Node sizes. Same as the view passed to doUpdate() earlier. |
nodeOpacities | Absolute node opacities. Same as the view passed to doUpdate() earlier. |
nodesEnabled | Which visible nodes are enabled, i.e. which don't have NodeFlag:: |
clipRectOffsets | Absolute clip rect offsets. Same as the view passed to doUpdate() earlier. |
clipRectSizes | Clip rect sizes. Same as the view passed to doUpdate() earlier. |
Implementation for draw(), which is called from AbstractUserInterface::dataIds
, clipRectIds
, clipRectDataCounts
, nodeOffsets
, nodeSizes
, nodeOpacities
, nodesEnabled
, clipRectOffsets
and clipRectSizes
, see its documentation for their relations and constraints. If LayerFeature::
Like with doUpdate(), the clipRectOffsets
and clipRectSizes
are in the same coordinate system as nodeOffsets
and nodeSizes
. If performing the clipping at draw time (instead of clipping the actual data directly in doDraw()
), the implementation may need to scale these to match actual framebuffer pixels, i.e. by multiplying them with Vector2{framebufferSize}/size
inside doSetSize().
This function usually gets called several times with the same views but different offset
, count
, clipRectOffset
and clipRectCount
values in order to interleave the draws for a correct back-to-front order. In each call, the sum of all clipRectDataCounts
in the range given by clipRectOffset
and clipRectCount
is equal to count
. Unlike doUpdate() or doClean(), this function is never called with an empty count
.
void Magnum:: Ui:: AbstractLayer:: doPointerPressEvent(UnsignedInt dataId,
PointerEvent& event) virtual private
Handle a pointer press event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data, with PointerEvent:: |
Implementation for pointerPressEvent(), which is called from AbstractUserInterface::dataId
.
If the implementation handles the event, it's expected to call PointerEvent::
Default implementation does nothing, i.e. the event
gets implicitly propagated further.
void Magnum:: Ui:: AbstractLayer:: doPointerReleaseEvent(UnsignedInt dataId,
PointerEvent& event) virtual private
Handle a pointer release event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data, with PointerEvent:: |
Implementation for pointerReleaseEvent(), which is called from AbstractUserInterface::dataId
.
If the implementation handles the event, it's expected to call PointerEvent::
Default implementation does nothing, i.e. the event
gets implicitly propagated further.
void Magnum:: Ui:: AbstractLayer:: doPointerTapOrClickEvent(UnsignedInt dataId,
PointerEvent& event) virtual private
Handle a pointer tap or click event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data, with PointerEvent:: |
Implementation for pointerTapOrClickEvent(), which is called from AbstractUserInterface::dataId
, the event
is guaranteed to be always primary.
Unlike doPointerReleaseEvent(), the accept status is ignored for this event, as the event isn't propagated anywhere if it's not handled. Thus calling PointerEvent::
Default implementation does nothing.
void Magnum:: Ui:: AbstractLayer:: doPointerMoveEvent(UnsignedInt dataId,
PointerMoveEvent& event) virtual private
Handle a pointer move event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data, with PointerMoveEvent:: |
Implementation for pointerMoveEvent(), which is called from AbstractUserInterface::dataId
.
If the implementation handles the event, it's expected to call PointerEvent::
Default implementation does nothing, i.e. the event
gets implicitly propagated further. That also implies the node is never marked as hovered for primary events and enter / leave events are not emitted for it.
void Magnum:: Ui:: AbstractLayer:: doPointerEnterEvent(UnsignedInt dataId,
PointerMoveEvent& event) virtual private
Handle a pointer enter event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data, with PointerMoveEvent:: |
Implementation for pointerEnterEvent(), which is called from AbstractUserInterface::dataId
. See its documentation for more information about relation of pointer enter/leave events to doPointerMoveEvent(). It's guaranteed that doUpdate() was called before this function with up-to-date data for dataId
, the event
is guaranteed to be always primary.
Unlike doPointerMoveEvent(), the accept status is ignored for enter and leave events, as the event isn't propagated anywhere if it's not handled. Thus calling PointerEvent::
Default implementation does nothing.
void Magnum:: Ui:: AbstractLayer:: doPointerLeaveEvent(UnsignedInt dataId,
PointerMoveEvent& event) virtual private
Handle a pointer leave event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data, with PointerMoveEvent:: |
Implementation for pointerEnterEvent(), which is called from AbstractUserInterface::dataId
. See its documentation for more information about relation of pointer enter/leave events to doPointerMoveEvent(). It's guaranteed that doUpdate() was called before this function with up-to-date data for dataId
, the event
is guaranteed to be always primary.
Unlike doPointerMoveEvent(), the accept status is ignored for enter and leave events, as the event isn't propagated anywhere if it's not handled. Thus calling PointerEvent::
Default implementation does nothing.
void Magnum:: Ui:: AbstractLayer:: doFocusEvent(UnsignedInt dataId,
FocusEvent& event) virtual private
Handle a focus event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data |
Implementation for focusEvent(), which is called from AbstractUserInterface::dataId
.
If the implementation handles the event, it's expected to call FocusEvent::
Default implementation does nothing.
void Magnum:: Ui:: AbstractLayer:: doBlurEvent(UnsignedInt dataId,
FocusEvent& event) virtual private
Handle a blur event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data |
Implementation for blurEvent(), which is called from AbstractUserInterface::dataId
.
Unlike doFocusEvent(), the accept status is ignored for blur events, as the node is still unmarked as focused if the event is not handled. Thus calling FocusEvent::
Default implementation does nothing.
void Magnum:: Ui:: AbstractLayer:: doKeyPressEvent(UnsignedInt dataId,
KeyEvent& event) virtual private
Handle a key press event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data |
Implementation for keyPressEvent(), which is called from AbstractUserInterface::dataId
.
If the implementation handles the event, it's expected to call KeyEvent::
Default implementation does nothing, i.e. the event
gets implicitly propagated further.
void Magnum:: Ui:: AbstractLayer:: doKeyReleaseEvent(UnsignedInt dataId,
KeyEvent& event) virtual private
Handle a pointer release event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data |
Implementation for keyReleaseEvent(), which is called from AbstractUserInterface::dataId
.
If the implementation handles the event, it's expected to call KeyEvent::
Default implementation does nothing, i.e. the event
gets implicitly propagated further.
void Magnum:: Ui:: AbstractLayer:: doTextInputEvent(UnsignedInt dataId,
TextInputEvent& event) virtual private
Handle a text input event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data |
Implementation for textInputEvent(), which is called from AbstractUserInterface::dataId
.
If the implementation handles the event, it's expected to call TextInputEvent::
Default implementation does nothing, i.e. the event
gets implicitly propagated further.
void Magnum:: Ui:: AbstractLayer:: doVisibilityLostEvent(UnsignedInt dataId,
VisibilityLostEvent& event) virtual private
Handle a visibility lost event.
Parameters | |
---|---|
dataId | Data ID the event happens on. Guaranteed to be less than capacity() and point to a valid data. |
event | Event data |
Implementation for visibilityLostEvent(), which is called from AbstractUserInterface::dataId
can no longer receive events due to NodeFlag::
Default implementation does nothing.