Magnum::Ui::AbstractSnapLayout class new in Git master

Base for SnapLayouter layout creation helpers.

Combines SnapLayouter together with a reference to AbstractUserInterface in order to create AbstractAnchor instances to directly feed into AbstractWidget constructors. Similarly to Anchor and Widget, the BasicSnapLayout template and the SnapLayout typedef then restrict the type to a concrete user interface instance such as UserInterface.

This class is just a transient helper to aid with laying out nodes relative to each other. After they're created, the AbstractSnapLayout instance isn't needed for anything anymore and can be removed. For snapping individual nodes you can use the stateless snap() functions instead.

Derived classes

template<class UserInterface>
class BasicSnapLayout new in Git master
Templated base for SnapLayouter layout creation helpers.

Constructors, destructors, conversion operators

AbstractSnapLayout(AbstractUserInterface& ui, SnapLayouter& layouter, Snaps snapFirst, NodeHandle target, Snaps snapNext) explicit
Constructor.
AbstractSnapLayout(const AbstractSnapLayout&) deleted
Copying is not allowed.
AbstractSnapLayout(AbstractSnapLayout&&) defaulted noexcept
Move constructor.

Public functions

auto operator=(const AbstractSnapLayout&) -> AbstractSnapLayout& deleted
Copying is not allowed.
auto operator=(AbstractSnapLayout&&) -> AbstractSnapLayout& defaulted noexcept
Move assignment.
auto ui() const -> AbstractUserInterface&
User interface instance the nodes are created in.
auto layouter() const -> SnapLayouter&
Layouter instance.
auto parent() const -> NodeHandle
Node to which all created nodes are parented.
auto snapFirst() const -> Snaps
How to snap the first layout.
auto snapNext() const -> Snaps
How to snap the next layouts.
auto targetFirst() const -> NodeHandle
Target node for the first layout.
auto targetNext() const -> NodeHandle
Target node for the next layout.
auto operator()(const Vector2& size, NodeFlags flags = {}) -> AbstractAnchor
Create a layouted node.
auto operator()(const Vector2& offset, const Vector2& size, NodeFlags flags = {}) -> AbstractAnchor
Create a layouted node with custom offset.

Function documentation

Magnum::Ui::AbstractSnapLayout::AbstractSnapLayout(AbstractUserInterface& ui, SnapLayouter& layouter, Snaps snapFirst, NodeHandle target, Snaps snapNext) explicit

Constructor.

Parameters
ui User interface instance
layouter Layouter instance
snapFirst How to snap the first layout
target Target to which to snap the first layout
snapNext How to snap the next layouts

The snapFirst is used for creating the first ever layout, relative to target. After that, the following layouts are all snapped to the previous created one according to snapNext.

Since it makes little sense to layout multiple root nodes relative to each other, the target is expected to be a valid non-null handle. If snapFirst snaps inside of the node, the target is used as a parent of the newly created nodes, if snapFirst snaps outside of the node, the parent of target is used as a parent of the newly created nodes, in which case target is also expected to not be a root node.

Layouting a root node relative to the user interface itself is possible with snap(AbstractUserInterface&, SnapLayouter&, Snaps, const Vector2&, const Vector2&, NodeFlags) and overloads.

NodeHandle Magnum::Ui::AbstractSnapLayout::parent() const

Node to which all created nodes are parented.

Never a NodeHandle::Null.

Snaps Magnum::Ui::AbstractSnapLayout::snapFirst() const

How to snap the first layout.

Snaps Magnum::Ui::AbstractSnapLayout::snapNext() const

How to snap the next layouts.

NodeHandle Magnum::Ui::AbstractSnapLayout::targetFirst() const

Target node for the first layout.

Used as a target for layouting the first node according to snapFirst(). Each subsequent nodes is then targeted to the previously created one, which is exposed in targetNext(). Never a NodeHandle::Null.

NodeHandle Magnum::Ui::AbstractSnapLayout::targetNext() const

Target node for the next layout.

Contains a handle of the latest created node, which is then used as a target for layouting the next node according to snapNext(). If NodeHandle::Null, no nodes were created yet, and the first one is layouted against targetFirst() according to snapFirst().

AbstractAnchor Magnum::Ui::AbstractSnapLayout::operator()(const Vector2& size, NodeFlags flags = {})

Create a layouted node.

Parameters
size Desired node size
flags Flags to create the node with
Returns Anchor containing the new node and associated layout

Creates a node parented to parent() with an associated layout. The size is ignored in horizontal / vertical direction if the layout is snapped to the whole width / height of the target node. Calls AbstractUserInterface::createNode() and AbstractLayouter::add() internally.

AbstractAnchor Magnum::Ui::AbstractSnapLayout::operator()(const Vector2& offset, const Vector2& size, NodeFlags flags = {})

Create a layouted node with custom offset.

Compared to operator()(const Vector2&, NodeFlags) the offset is added to the offset calculated by the layout.