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

OpenGL implementation of the main user interface.

Provides an interface for setting up RendererGL, BaseLayerGL and TextLayerGL instances, either directly or via an AbstractStyle instance.

Base classes

class UserInterface new in Git master
Main user interface.

Constructors, destructors, conversion operators

UserInterfaceGL(NoCreateT) explicit
Construct without creating the user interface.
UserInterfaceGL(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct.
UserInterfaceGL(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with a subset of the style.
UserInterfaceGL(const Vector2i& size, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with an unscaled size.
UserInterfaceGL(const Vector2i& size, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with an unscaled size and a subset of the style.

Public functions

auto create(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface.
auto create(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface with a subset of the style.
auto create(const Vector2i& size, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface with an unscaled size.
auto create(const Vector2i& size, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface with an unscaled size and a subset of the style.
auto tryCreate(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface.
auto tryCreate(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface with a subset of the style.
auto tryCreate(const Vector2i& size, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface with an unscaled size.
auto tryCreate(const Vector2i& size, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface with an unscaled size and a subset of the style.
auto setRendererInstance(Containers::Pointer<RendererGL>&& instance) -> UserInterfaceGL&
Set renderer instance.
auto renderer() -> RendererGL&
Renderer instance.
auto renderer() const -> const RendererGL&
auto setStyle(const AbstractStyle& style, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Set features from a style.
auto setStyle(const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Set all features from a style.
auto trySetStyle(const AbstractStyle& style, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to set features from a style.
auto trySetStyle(const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to set all features from a style.
auto setBaseLayerInstance(Containers::Pointer<BaseLayerGL>&& instance) -> UserInterfaceGL&
Set a base layer instance.
auto setTextLayerInstance(Containers::Pointer<TextLayerGL>&& instance) -> UserInterfaceGL&
Set a text layer instance.

Function documentation

Magnum::Ui::UserInterfaceGL::UserInterfaceGL(NoCreateT) explicit

Construct without creating the user interface.

You're expected to call create() or tryCreate() afterwards in order to define the UI size and coordinate scaling and set up a style.

Magnum::Ui::UserInterfaceGL::UserInterfaceGL(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

Construct.

Parameters
size Size of the user interface to which everything is positioned
windowSize Size of the window to which all input events are related
framebufferSize Size of the window framebuffer. On some platforms with HiDPI screens may be different from window size.
style Style instance to use
importerManager Optional plugin manager instance for image loading
fontManager Optional plugin manager instance for font loading

Equivalent to constructing with UserInterfaceGL(NoCreateT) and then calling create(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information. In particular, if style application fails, the program exits. Use the UserInterfaceGL(NoCreateT) constructor in combination with tryCreate() for a more graceful failure handling.

Magnum::Ui::UserInterfaceGL::UserInterfaceGL(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

Construct with a subset of the style.

Parameters
size Size of the user interface to which everything is positioned
windowSize Size of the window to which all input events are related
framebufferSize Size of the window framebuffer. On some platforms with HiDPI screens may be different from window size.
style Style instance to use
styleFeatures Style features to apply
importerManager Optional plugin manager instance for image loading
fontManager Optional plugin manager instance for font loading

Equivalent to constructing with UserInterfaceGL(NoCreateT) and then calling create(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information. In particular, if style application fails, the program exits. Use the UserInterfaceGL(NoCreateT) constructor in combination with tryCreate() for a more graceful failure handling.

Magnum::Ui::UserInterfaceGL::UserInterfaceGL(const Vector2i& size, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

Construct with an unscaled size.

Delegates to UserInterfaceGL(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) with all sizes set to size. Doing so assumes that the coordinate system in which events are passed matches framebuffer size.

Magnum::Ui::UserInterfaceGL::UserInterfaceGL(const Vector2i& size, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

Construct with an unscaled size and a subset of the style.

Delegates to UserInterfaceGL(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) with all sizes set to size. Doing so assumes that the coordinate system in which events are passed matches framebuffer size.

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::create(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Create the user interface.

Parameters
size Size of the user interface to which everything is positioned
windowSize Size of the window to which all input events are related
framebufferSize Size of the window framebuffer. On some platforms with HiDPI screens may be different from window size.
style Style instance to use
importerManager Optional plugin manager instance for image loading
fontManager Optional plugin manager instance for font loading
Returns Reference to self (for method chaining)

Expects that none of create(), tryCreate(), setBaseLayerInstance(), setTextLayerInstance(), setEventLayerInstance() or setRendererInstance() was called yet. Equivalent to calling setSize(const Vector2&, const Vector2&, const Vector2i&) followed by setStyle(const AbstractStyle&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information and alternative ways to create the user interface. If style application fails during the creation process, the program exits. Use tryCreate() for a more graceful failure handling.

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::create(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Create the user interface with a subset of the style.

Parameters
size Size of the user interface to which everything is positioned
windowSize Size of the window to which all input events are related
framebufferSize Size of the window framebuffer. On some platforms with HiDPI screens may be different from window size.
style Style instance to use
styleFeatures Style features to apply
importerManager Optional plugin manager instance for image loading
fontManager Optional plugin manager instance for font loading
Returns Reference to self (for method chaining)

Expects that none of create(), tryCreate(), setBaseLayerInstance(), setTextLayerInstance(), setEventLayerInstance() or setRendererInstance() was called yet. Equivalent to calling setSize(const Vector2&, const Vector2&, const Vector2i&) followed by setStyle(const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information and alternative ways to create the user interface. If style application fails during the creation process, the program exits. Use tryCreate() for a more graceful failure handling.

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::create(const Vector2i& size, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Create the user interface with an unscaled size.

Delegates to create(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) with all sizes set to size. Doing so assumes that the coordinate system in which events are passed matches framebuffer size.

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::create(const Vector2i& size, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Create the user interface with an unscaled size and a subset of the style.

Delegates to create(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) with all sizes set to size. Doing so assumes that the coordinate system in which events are passed matches framebuffer size.

bool Magnum::Ui::UserInterfaceGL::tryCreate(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to create the user interface.

Unlike create(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractStyle::apply() failed instead of exiting, true otherwise. Equivalent to calling setSize(const Vector2&, const Vector2&, const Vector2i&) followed by trySetStyle(const AbstractStyle&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*).

bool Magnum::Ui::UserInterfaceGL::tryCreate(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to create the user interface with a subset of the style.

Unlike create(const Vector2&, const Vector2&, const Vector2i&, const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractStyle::apply() failed instead of exiting, true otherwise. Equivalent to calling setSize(const Vector2&, const Vector2&, const Vector2i&) followed by trySetStyle(const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*).

bool Magnum::Ui::UserInterfaceGL::tryCreate(const Vector2i& size, const AbstractStyle& style, StyleFeatures styleFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to create the user interface with an unscaled size and a subset of the style.

Unlike create(const Vector2i&, const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractStyle::apply() failed instead of exiting, true otherwise. Equivalent to calling setSize(const Vector2i&) followed by trySetStyle(const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*).

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::setRendererInstance(Containers::Pointer<RendererGL>&& instance)

Set renderer instance.

Returns Reference to self (for method chaining)

Expects that the instance hasn't been set yet, either by this function or transitively either by UserInterfaceGL::setStyle() or a UserInterfaceGL constructor taking a style instance. The instance is subsequently available through renderer().

RendererGL& Magnum::Ui::UserInterfaceGL::renderer()

Renderer instance.

Expects that an instance has been set, either by setRendererInstance() or transitively by UserInterfaceGL::setStyle() or a UserInterfaceGL constructor taking a style instance.

const RendererGL& Magnum::Ui::UserInterfaceGL::renderer() const

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

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::setStyle(const AbstractStyle& style, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Set features from a style.

Parameters
style Style instance
features Style features to apply
importerManager Optional plugin manager instance for image loading
fontManager Optional plugin manager instance for font loading
Returns Reference to self (for method chaining)

If a renderer isn't present yet, sets its instance. Then creates layer instances corresponding to all features with style uniform count, style count and other parameters coming from style. If features contain StyleFeature::TextLayer and fontManager is nullptr, an internal font plugin manager instance is created. The function then calls AbstractStyle::apply() to apply the style to those layers. If it fails, the program exits, see trySetStyle() for an alternative.

Expects that user interface size is already set, either using the constructor or by calling setSize(). Expects that features are a subset of AbstractStyle::features() of style, contain at least one feature and that the user interface doesn't yet contain any layers corresponding to features as documented in the StyleFeature enum values.

While it's not allowed to set style features more than once for one particular layer, it's possible to call this function multiple times with mutually disjoint features. To replace a layer style with another compatible style, call AbstractStyle::apply() directly. See its documentation for more information about style compatibility restrictions.

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::setStyle(const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Set all features from a style.

Returns Reference to self (for method chaining)

Equivalent to calling setStyle(const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) with features set to AbstractStyle::features() of style.

bool Magnum::Ui::UserInterfaceGL::trySetStyle(const AbstractStyle& style, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to set features from a style.

Unlike setStyle(const AbstractStyle&, StyleFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractStyle::apply() failed instead of exiting, true otherwise.

bool Magnum::Ui::UserInterfaceGL::trySetStyle(const AbstractStyle& style, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to set all features from a style.

Unlike setStyle(const AbstractStyle&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractStyle::apply() failed instead of exiting, true otherwise.

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::setBaseLayerInstance(Containers::Pointer<BaseLayerGL>&& instance)

Set a base layer instance.

Returns Reference to self (for method chaining)

Expects that the instance hasn't been set yet, either by this function or transitively either by setStyle() or a constructor taking a style instance. The instance is subsequently available through baseLayer().

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::setTextLayerInstance(Containers::Pointer<TextLayerGL>&& instance)

Set a text layer instance.

Returns Reference to self (for method chaining)

Expects that the instance hasn't been set yet, either by this function or transitively either by UserInterfaceGL::setStyle() or a UserInterfaceGL constructor taking a style instance. The instance is subsequently available through textLayer().