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

Base layer.

Draws quads with a color gradient, variable rounded corners and outline. You'll most likely instantiate the class through BaseLayerGL, which contains a concrete OpenGL implementation.

Base classes

class AbstractVisualLayer new in Git master
Base for visual data layers.

Derived classes

class BaseLayerGL new in Git master
OpenGL implementation of the base layer.

Public types

class Shared
Shared state for the base layer.

Public functions

auto shared() -> Shared&
Shared state used by this layer.
auto shared() const -> const Shared&
auto backgroundBlurPassCount() const -> UnsignedInt
Background blur pass count.
auto setBackgroundBlurPassCount(UnsignedInt count) -> BaseLayer&
Set background blur pass count.
auto assignAnimator(BaseLayerStyleAnimator& animator) -> BaseLayer&
Assign a style animator to this layer.
auto defaultStyleAnimator() const -> BaseLayerStyleAnimator*
Default style animator for this layer.
auto setDefaultStyleAnimator(BaseLayerStyleAnimator* animator) -> BaseLayer&
Set a default style animator for this layer.
auto dynamicStyleUniforms() const -> Containers::ArrayView<const BaseLayerStyleUniform>
Dynamic style uniforms.
auto dynamicStylePaddings() const -> Containers::StridedArrayView1D<const Vector4>
Dynamic style paddings.
void setDynamicStyle(UnsignedInt id, const BaseLayerStyleUniform& uniform, const Vector4& padding)
Set a dynamic style.
auto create(UnsignedInt style, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad.
template<class StyleIndex>
auto create(StyleIndex style, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad with a style index in a concrete enum type.
auto create(UnsignedInt style, const Color3& color, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad with a custom base color.
template<class StyleIndex>
auto create(StyleIndex style, const Color3& color, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad with a style index in a concrete enum type and with a custom base color.
auto create(UnsignedInt style, const Color3& color, const Vector4& outlineWidth, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad with a custom base color and outline width.
template<class StyleIndex>
auto create(StyleIndex style, const Color3& color, const Vector4& outlineWidth, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad with a style index in a concrete enum type and with a custom base color and outline width.
auto create(UnsignedInt style, const Color3& color, Float outlineWidth, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad with a custom base color and outline width with all edges having the same value.
template<class StyleIndex>
auto create(StyleIndex style, const Color3& color, Float outlineWidth, NodeHandle node = NodeHandle::Null) -> DataHandle
Create a quad with a style index in a concrete enum type and a custom base color and outline width with all edges having the same value.
void remove(DataHandle handle)
Remove a quad.
void remove(LayerDataHandle handle)
Remove a quad assuming it belongs to this layer.
auto color(DataHandle handle) const -> Color3
Quad custom base color.
auto color(LayerDataHandle handle) const -> Color3
Quad custom base color assuming it belongs to this layer.
void setColor(DataHandle handle, const Color3& color)
Set quad custom base color.
void setColor(LayerDataHandle handle, const Color3& color)
Set quad custom base color assuming it belongs to this layer.
auto outlineWidth(DataHandle handle) const -> Vector4
Quad custom outline width.
auto outlineWidth(LayerDataHandle handle) const -> Vector4
Quad custom outline width assuming it belongs to this layer.
void setOutlineWidth(DataHandle handle, const Vector4& width)
Set quad custom outline width.
void setOutlineWidth(DataHandle handle, Float width)
Set quad custom outline width with all edges having the same value.
void setOutlineWidth(LayerDataHandle handle, const Vector4& width)
Set quad custom outline width assuming it belongs to this layer.
void setOutlineWidth(LayerDataHandle handle, Float width)
Set quad custom outline width with all edges having the same value assuming it belongs to this layer.
auto padding(DataHandle handle) const -> Vector4
Quad custom padding.
auto padding(LayerDataHandle handle) const -> Vector4
Quad custom padding assuming it belongs to this layer.
void setPadding(DataHandle handle, const Vector4& padding)
Set quad custom padding.
void setPadding(LayerDataHandle handle, const Vector4& padding)
Set quad custom padding assuming it belongs to this layer.
void setPadding(DataHandle handle, Float padding)
Set quad custom padding with all edges having the same value.
void setPadding(LayerDataHandle handle, Float padding)
Set quad custom padding with all edges having the same value assuming it belongs to this layer.
auto textureCoordinateOffset(DataHandle handle) const -> Vector3
Quad texture coordinate offset.
auto textureCoordinateOffset(LayerDataHandle handle) const -> Vector3
Quad texture coordinate offset assuming it belongs to this layer.
auto textureCoordinateSize(DataHandle handle) const -> Vector2
Quad texture coordinate size.
auto textureCoordinateSize(LayerDataHandle handle) const -> Vector2
Quad texture coordinate size assuming it belongs to this layer.
void setTextureCoordinates(DataHandle handle, const Vector3& offset, const Vector2& size)
Set quad texture coordinates.
void setTextureCoordinates(LayerDataHandle handle, const Vector3& offset, const Vector2& size)
Set quad texture coordinates assuming it belongs to this layer.

Function documentation

Shared& Magnum::Ui::BaseLayer::shared()

Shared state used by this layer.

Reference to the instance passed to BaseLayerGL::BaseLayerGL(LayerHandle, Shared&).

const Shared& Magnum::Ui::BaseLayer::shared() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Ui::BaseLayer::backgroundBlurPassCount() const

Background blur pass count.

Expects that BaseLayerSharedFlag::BackgroundBlur was enabled for the shared state the layer was created with.

BaseLayer& Magnum::Ui::BaseLayer::setBackgroundBlurPassCount(UnsignedInt count)

Set background blur pass count.

Returns Reference to self (for method chaining)

Expects that BaseLayerSharedFlag::BackgroundBlur was enabled for the shared state the layer was created with and that count is at least 1. Higher values will perform the blurring process several times, which has the same effect as applying a single, larger, Gaussian blur. With $ r $ being the radius configured by Shared::Configuration::setBackgroundBlurRadius() and $ n $ being the count, the relation to the larger radius $ l $ is as follows:

\[ l = \sqrt{nr^2} \]

Thus by combining the radius and pass count it's possible to achieve blurring in radii larger than the limit of 31 in Shared::Configuration::setBackgroundBlurRadius(), or alternatively tune the operation based on whether the GPU is faster with few passes and many texture samples each or many passes with few (localized) texture samples each. For example, a radius of 36 can be achieved with 16 passes of radius 9, or with 4 passes of radius 18, or other combinations.

Default pass count is 1.

Calling this function causes LayerState::NeedsCompositeOffsetSizeUpdate to be set.

BaseLayer& Magnum::Ui::BaseLayer::assignAnimator(BaseLayerStyleAnimator& animator)

Assign a style animator to this layer.

Returns Reference to self (for method chaining)

Expects that Shared::dynamicStyleCount() is non-zero and that given animator wasn't passed to assignAnimator() on any layer yet. On the other hand, it's possible to associate multiple different animators with the same layer.

BaseLayerStyleAnimator* Magnum::Ui::BaseLayer::defaultStyleAnimator() const

Default style animator for this layer.

If a style animator haven't been set, returns nullptr. If not nullptr, the returned animator is guaranteed to be assigned to this layer, i.e. that BaseLayerStyleAnimator::layer() is equal to handle().

BaseLayer& Magnum::Ui::BaseLayer::setDefaultStyleAnimator(BaseLayerStyleAnimator* animator)

Set a default style animator for this layer.

Returns Reference to self (for method chaining)

Makes animator used in style transitions in response to events. Expects that animator is either nullptr or is already assigned to this layer, i.e. that assignAnimator() was called on this layer with animator before. Calling this function again with a different animator or with nullptr replaces the previous one.

Containers::ArrayView<const BaseLayerStyleUniform> Magnum::Ui::BaseLayer::dynamicStyleUniforms() const

Dynamic style uniforms.

Size of the returned view is Shared::dynamicStyleCount(). These uniforms are used by style indices greater than or equal to Shared::styleCount().

Containers::StridedArrayView1D<const Vector4> Magnum::Ui::BaseLayer::dynamicStylePaddings() const

Dynamic style paddings.

Size of the returned view is Shared::dynamicStyleCount(). These paddings are used by style indices greater than or equal to Shared::styleCount().

void Magnum::Ui::BaseLayer::setDynamicStyle(UnsignedInt id, const BaseLayerStyleUniform& uniform, const Vector4& padding)

Set a dynamic style.

Parameters
id Dynamic style ID
uniform Style uniform
padding Padding inside the node in order left, top, right, bottom

Expects that the id is less than Shared::dynamicStyleCount(). Shared::styleCount() plus id is then a style index that can be passed to create() or setStyle() in order to use this style. Compared to Shared::setStyle() the mapping between dynamic styles and uniforms is implicit. All dynamic styles are initially default-constructed BaseLayerStyleUniform instances and zero padding vectors.

Calling this function causes LayerState::NeedsCommonDataUpdate to be set to trigger an upload of changed dynamic style uniform data. If padding changed, LayerState::NeedsDataUpdate gets set as well.

DataHandle Magnum::Ui::BaseLayer::create(UnsignedInt style, NodeHandle node = NodeHandle::Null)

Create a quad.

Parameters
style Style index
node Node to attach to
Returns New data handle

Expects that style is less than Shared::totalStyleCount(). All styling is driven from the BaseLayerStyleUniform at index style. Use create(UnsignedInt, const Color3&, NodeHandle) or create(UnsignedInt, const Color3&, const Vector4&, NodeHandle) for creating a quad with a custom color and outline width. This function is equivalent to calling them with 0xffffff_srgbf for the base color and a zero vector for the outline width.

template<class StyleIndex>
DataHandle Magnum::Ui::BaseLayer::create(StyleIndex style, NodeHandle node = NodeHandle::Null)

Create a quad with a style index in a concrete enum type.

Casts style to UnsignedInt and delegates to create(UnsignedInt, NodeHandle).

DataHandle Magnum::Ui::BaseLayer::create(UnsignedInt style, const Color3& color, NodeHandle node = NodeHandle::Null)

Create a quad with a custom base color.

Parameters
style Style index
color Custom base color
node Node to attach to
Returns New data handle

Expects that style is less than Shared::totalStyleCount(). Styling is driven from the BaseLayerStyleUniform at index style, in addition BaseLayerStyleUniform::topColor and bottomColor is multiplied with color. Use create(UnsignedInt, const Color3&, const Vector4&, NodeHandle) for creating a quad with a custom color and outline width. This function is equivalent to calling it with a zero vector for the outline width.

template<class StyleIndex>
DataHandle Magnum::Ui::BaseLayer::create(StyleIndex style, const Color3& color, NodeHandle node = NodeHandle::Null)

Create a quad with a style index in a concrete enum type and with a custom base color.

Casts style to UnsignedInt and delegates to create(UnsignedInt, const Color3&, NodeHandle).

DataHandle Magnum::Ui::BaseLayer::create(UnsignedInt style, const Color3& color, const Vector4& outlineWidth, NodeHandle node = NodeHandle::Null)

Create a quad with a custom base color and outline width.

Parameters
style Style index
color Custom base color
outlineWidth Custom outline width in order left, top, right, bottom
node Node to attach to
Returns New data handle

Expects that style is less than Shared::totalStyleCount(). Styling is driven from the BaseLayerStyleUniform at index style, in addition BaseLayerStyleUniform::topColor and bottomColor is multiplied with color and outlineWidth is added to BaseLayerStyleUniform::outlineWidth.

template<class StyleIndex>
DataHandle Magnum::Ui::BaseLayer::create(StyleIndex style, const Color3& color, const Vector4& outlineWidth, NodeHandle node = NodeHandle::Null)

Create a quad with a style index in a concrete enum type and with a custom base color and outline width.

Casts style to UnsignedInt and delegates to create(UnsignedInt, const Color3&, const Vector4&, NodeHandle).

DataHandle Magnum::Ui::BaseLayer::create(UnsignedInt style, const Color3& color, Float outlineWidth, NodeHandle node = NodeHandle::Null)

Create a quad with a custom base color and outline width with all edges having the same value.

See create(UnsignedInt, const Color3&, const Vector4&, NodeHandle) for more information.

template<class StyleIndex>
DataHandle Magnum::Ui::BaseLayer::create(StyleIndex style, const Color3& color, Float outlineWidth, NodeHandle node = NodeHandle::Null)

Create a quad with a style index in a concrete enum type and a custom base color and outline width with all edges having the same value.

Casts style to UnsignedInt and delegates to create(UnsignedInt, const Color3&, Float, NodeHandle).

void Magnum::Ui::BaseLayer::remove(DataHandle handle)

Remove a quad.

Delegates to AbstractLayer::remove(DataHandle).

void Magnum::Ui::BaseLayer::remove(LayerDataHandle handle)

Remove a quad assuming it belongs to this layer.

Delegates to AbstractLayer::remove(LayerDataHandle).

Color3 Magnum::Ui::BaseLayer::color(DataHandle handle) const

Quad custom base color.

Expects that handle is valid.

Color3 Magnum::Ui::BaseLayer::color(LayerDataHandle handle) const

Quad custom base color assuming it belongs to this layer.

Expects that handle is valid.

void Magnum::Ui::BaseLayer::setColor(DataHandle handle, const Color3& color)

Set quad custom base color.

Expects that handle is valid. BaseLayerStyleUniform::topColor and bottomColor is multiplied with color. By default, unless specified in create() already, the custom color is 0xffffff_srgbf, i.e. not affecting the style in any way.

Calling this function causes LayerState::NeedsDataUpdate to be set.

void Magnum::Ui::BaseLayer::setColor(LayerDataHandle handle, const Color3& color)

Set quad custom base color assuming it belongs to this layer.

Like setColor(DataHandle, const Color3&) but without checking that handle indeed belongs to this layer. See its documentation for more information.

Vector4 Magnum::Ui::BaseLayer::outlineWidth(DataHandle handle) const

Quad custom outline width.

In order left, top. right, bottom. Expects that handle is valid.

Vector4 Magnum::Ui::BaseLayer::outlineWidth(LayerDataHandle handle) const

Quad custom outline width assuming it belongs to this layer.

In order left, top. right, bottom. Expects that handle is valid.

void Magnum::Ui::BaseLayer::setOutlineWidth(DataHandle handle, const Vector4& width)

Set quad custom outline width.

Expects that handle is valid. The width is in order left, top, right, bottom and is added to BaseLayerStyleUniform::outlineWidth. By default, unless specified in create() already, the custom outline width is a zero vector, i.e. not affecting the style in any way. Has no visual effect if BaseLayerSharedFlag::NoOutline is enabled.

Calling this function causes LayerState::NeedsDataUpdate to be set.

void Magnum::Ui::BaseLayer::setOutlineWidth(DataHandle handle, Float width)

Set quad custom outline width with all edges having the same value.

Expects that handle is valid. The width is added to BaseLayerStyleUniform::outlineWidth. By default, unless specified in create() already, the custom outline width is zero, i.e. not affecting the style in any way. Has no visual effect if BaseLayerSharedFlag::NoOutline is enabled.

Calling this function causes LayerState::NeedsDataUpdate to be set.

void Magnum::Ui::BaseLayer::setOutlineWidth(LayerDataHandle handle, const Vector4& width)

Set quad custom outline width assuming it belongs to this layer.

Like setOutlineWidth(DataHandle, const Vector4&) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::BaseLayer::setOutlineWidth(LayerDataHandle handle, Float width)

Set quad custom outline width with all edges having the same value assuming it belongs to this layer.

Like setOutlineWidth(DataHandle, Float) but without checking that handle indeed belongs to this layer. See its documentation for more information.

Vector4 Magnum::Ui::BaseLayer::padding(DataHandle handle) const

Quad custom padding.

In order left, top. right, bottom. Expects that handle is valid.

Vector4 Magnum::Ui::BaseLayer::padding(LayerDataHandle handle) const

Quad custom padding assuming it belongs to this layer.

In order left, top. right, bottom. Expects that handle is valid.

void Magnum::Ui::BaseLayer::setPadding(DataHandle handle, const Vector4& padding)

Set quad custom padding.

Expects that handle is valid. The padding is in order left, top, right, bottom and is added to the per-style padding values specified in Shared::setStyle(). By default the padding is a zero vector, i.e. the quad fills the node area completely.

Calling this function causes LayerState::NeedsDataUpdate to be set.

void Magnum::Ui::BaseLayer::setPadding(LayerDataHandle handle, const Vector4& padding)

Set quad custom padding assuming it belongs to this layer.

Like setPadding(DataHandle, const Vector4&) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::BaseLayer::setPadding(DataHandle handle, Float padding)

Set quad custom padding with all edges having the same value.

Expects that handle is valid. The padding is added to the per-style padding values specified in Shared::setStyle(). By default there's zero padding, i.e. the quad fills the node area completely.

Calling this function causes LayerState::NeedsDataUpdate to be set.

void Magnum::Ui::BaseLayer::setPadding(LayerDataHandle handle, Float padding)

Set quad custom padding with all edges having the same value assuming it belongs to this layer.

Like setPadding(DataHandle, Float) but without checking that handle indeed belongs to this layer. See its documentation for more information.

Vector3 Magnum::Ui::BaseLayer::textureCoordinateOffset(DataHandle handle) const

Quad texture coordinate offset.

The third coordinate is array layer. Expects that handle is valid and that BaseLayerSharedFlag::Textured was enabled for the shared state the layer was created with.

Vector3 Magnum::Ui::BaseLayer::textureCoordinateOffset(LayerDataHandle handle) const

Quad texture coordinate offset assuming it belongs to this layer.

The third coordinate is array layer. Expects that handle is valid and that BaseLayerSharedFlag::Textured was enabled for the shared state the layer was created with.

Vector2 Magnum::Ui::BaseLayer::textureCoordinateSize(DataHandle handle) const

Quad texture coordinate size.

Expects that handle is valid and that BaseLayerSharedFlag::Textured was enabled for the shared state the layer was created with.

Vector2 Magnum::Ui::BaseLayer::textureCoordinateSize(LayerDataHandle handle) const

Quad texture coordinate size assuming it belongs to this layer.

Expects that handle is valid and that BaseLayerSharedFlag::Textured was enabled for the shared state the layer was created with.

void Magnum::Ui::BaseLayer::setTextureCoordinates(DataHandle handle, const Vector3& offset, const Vector2& size)

Set quad texture coordinates.

The third coordinate of offset is array layer. Expects that handle is valid and that BaseLayerSharedFlag::Textured was enabled for the shared state the layer was created with. By default the offset is {0.0f, 0.0f, 0.0f} and size is {1.0f, 1.0f}, i.e. covering the whole first slice of the texture.

Calling this function causes LayerState::NeedsDataUpdate to be set.

void Magnum::Ui::BaseLayer::setTextureCoordinates(LayerDataHandle handle, const Vector3& offset, const Vector2& size)

Set quad texture coordinates assuming it belongs to this layer.

Like setTextureCoordinates(DataHandle, const Vector3&, const Vector2&) but without checking that handle indeed belongs to this layer. See its documentation for more information.