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

OpenGL implementation of the main user interface.

Owns the whole user interface, providing everything from input event handling to animation and drawing. Compared to AbstractUserInterface includes everything that's needed by builtin widgets, while the UserInterface base class is a common interface not tied to OpenGL.

Setting up a user interface instance

The simplest variant of the constructor takes a UI size, in respect to which all contents as well as input events get positioned, and a theme instance describing how the widgets all look like. At the moment, DarkTheme is the only theme provided by the library itself.

Ui::UserInterfaceGL ui{{800, 600}, Ui::DarkTheme{}};

The rest of the setup — drawing and event handling — is the same for all AbstractUserInterface subclasses, see its documentation for details.

Additional setup options

The above by default populates the user interface with everything a theme provides for use by builtin widgets — in particular, making most of dataLayer(), backgroundLayer(), baseLayer(), textLayer(), eventLayer(), layoutLayer(), snapLayouter(), genericLayouter(), nodeAnimator(), backgroundLayerStyleAnimator(), baseLayerStyleAnimator() and textLayerStyleAnimator() available. In case you for example use just a subset of the builtin widgets that only need a part of the above, you can specify a ThemeFeatures subset. This can be further combined with setTheme(), where, as long as you specify non-overlapping sets of ThemeFeatures, you can combine multiple themes together:

/* Pick everything except icons from the builtin theme */
Ui::UserInterfaceGL ui{{800, 600}, Ui::DarkTheme{},
    ~Ui::ThemeFeature::TextLayerImages};



/* Use icons from a custom theme instead */
ui.setTheme(myCustomStyle, Ui::ThemeFeature::TextLayerImages);

The constructors also provide a way to supply external plugin managers for fonts and images, for example if you want to configure the plugins before they're used or if you're going to use the same plugin managers elsewhere and want to reduce duplication. The passed instances are expected to stay alive for the whole user interface lifetime.

PluginManager::Manager<Trade::AbstractImporter> importerManager;
PluginManager::Manager<Text::AbstractFont> fontManager;


Ui::UserInterfaceGL ui{, &importerManager, &fontManager};

Delayed user interface creation

By default, the class expects that a Magnum OpenGL context is available at the point of construction. If you're using delayed Application context creation or if you just need additional logic before creating the UI, you can employ a similar approach as with the application itself — construct with UserInterfaceGL(NoCreateT) and then call create() once you're ready:

class MyApplication: public Platform::Application {
    

    private:
        Ui::UserInterfaceGL _ui{NoCreate};
};

MyApplication::MyApplication(const Arguments& arguments):
    Platform::Application{arguments, NoCreate}
{
    

    create();
    _ui.create(, Ui::DarkTheme{});
}

The create() as well as the main constructor both exit the application if something goes wrong such as if a font plugin cannot be loaded. If you want to deal with potential errors more gracefully or try out several options, tryCreate() returns false instead of exiting, and there's a trySetTheme() counterpart as well.

Supplying a custom renderer instance

Setting a theme either in the constructor or in create() / tryCreate() implicitly sets up a RendererGL instance. If you want to supply a custom one — for example to set up a compositing framebuffer for a custom layer — pass it to setRendererInstance() and then call setSize() and setTheme() / trySetTheme() instead of create() / tryCreate():

Ui::UserInterfaceGL ui{NoCreate};

ui
    .setRendererInstance(Containers::pointer<Ui::RendererGL>())
    .setSize()
    .setTheme(Ui::DarkTheme{});

Supplying custom layer and layouter instances

If a constructor or create() taking a theme isn't used at all, or if a theme is applied excluding a particular layer, layouter or animator, you can supply a custom instance using setDataLayerInstance(), setBackgroundLayerInstance(), setBaseLayerInstance(), setTextLayerInstance(), setEventLayerInstance(), setLayoutLayerInstance(), setSnapLayouterInstance(), setGenericLayouterInstance(), setNodeAnimatorInstance(), setBackgroundLayerStyleAnimatorInstance(), setBaseLayerStyleAnimatorInstance() or setTextLayerStyleAnimatorInstance(). Note that however, at this point, you're on your own when you attempt to use any builtin widgets that rely on given instance being set up in a particular way.

Ui::UserInterfaceGL ui{, Ui::DarkTheme{},
    ~Ui::ThemeFeature::BaseLayer};



ui.setBaseLayerInstance(Containers::pointer<Ui::BaseLayerGL>());

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 AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct.
template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
UserInterfaceGL(const Application& application, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with properties taken from an application instance.
UserInterfaceGL(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with a subset of the theme.
template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
UserInterfaceGL(const Application& application, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with a subset of the theme with properties taken from an application instance.
UserInterfaceGL(const Vector2i& size, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with an unscaled size.
UserInterfaceGL(const Vector2i& size, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit
Construct with an unscaled size and a subset of the theme.

Public functions

auto create(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface.
template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
auto create(const Application& application, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface with properties taken from an application instance.
auto create(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface with a subset of the theme.
template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
auto create(const Application& application, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Create the user interface with a subset of the theme with properties taken from an application instance.
auto create(const Vector2i& size, const AbstractTheme& theme, 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 AbstractTheme& theme, ThemeFeatures themeFeatures, 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 theme.
auto tryCreate(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface.
template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
auto tryCreate(const Application& application, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface with properties taken from an application instance.
auto tryCreate(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface with a subset of the theme.
template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
auto tryCreate(const Application& application, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to create the user interface with a subset of the theme with properties taken from an application instance.
auto tryCreate(const Vector2i& size, const AbstractTheme& theme, 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 AbstractTheme& theme, ThemeFeatures themeFeatures, 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 theme.
auto setRendererInstance(Containers::Pointer<RendererGL>&& instance) -> UserInterfaceGL&
Set renderer instance.
auto renderer() -> RendererGL&
Renderer instance.
auto renderer() const -> const RendererGL&
auto setTheme(const AbstractTheme& theme, ThemeFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Set features from a theme.
auto setTheme(const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> UserInterfaceGL&
Set all features from a theme.
auto trySetTheme(const AbstractTheme& theme, ThemeFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to set features from a theme.
auto trySetTheme(const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) -> bool
Try to set all features from a theme.
auto setBackgroundLayerInstance(Containers::Pointer<BaseLayerGL>&& instance) -> UserInterfaceGL&
Set a background layer instance.
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 theme.

Magnum::Ui::UserInterfaceGL::UserInterfaceGL(const Vector2& size, const Vector2& windowSize, const Vector2i& framebufferSize, const AbstractTheme& theme, 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.
theme Theme 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 AbstractTheme&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information. In particular, if theme application fails, the program exits. Use the UserInterfaceGL(NoCreateT) constructor in combination with tryCreate() for a more graceful failure handling.

template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
Magnum::Ui::UserInterfaceGL::UserInterfaceGL(const Application& application, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

Construct with properties taken from an application instance.

Parameters
application Application instance to query properties from
theme Theme 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 Application&, const AbstractTheme&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information. In particular, if theme 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 AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

Construct with a subset of the theme.

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.
theme Theme instance to use
themeFeatures Theme 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 AbstractTheme&, ThemeFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information. In particular, if theme application fails, the program exits. Use the UserInterfaceGL(NoCreateT) constructor in combination with tryCreate() for a more graceful failure handling.

template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
Magnum::Ui::UserInterfaceGL::UserInterfaceGL(const Application& application, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

Construct with a subset of the theme with properties taken from an application instance.

Parameters
application Application instance to query properties from
theme Theme instance to use
themeFeatures Theme 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 Application&, const AbstractTheme&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*). See documentation of these functions for more information. In particular, if theme 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 AbstractTheme& theme, 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 AbstractTheme&, 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 AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr) explicit

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

Delegates to UserInterfaceGL(const Vector2&, const Vector2&, const Vector2i&, const AbstractTheme&, ThemeFeatures 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 AbstractTheme& theme, 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.
theme Theme 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(), setDataLayerInstance(), setBackgroundLayerInstance(), setBaseLayerInstance(), setTextLayerInstance(), setEventLayerInstance(), setLayoutLayerInstance(), setSnapLayouterInstance(), setGenericLayouterInstance(), setNodeAnimatorInstance(), setBackgroundLayerStyleAnimatorInstance(), setBaseLayerStyleAnimatorInstance(), setTextLayerStyleAnimatorInstance() or setRendererInstance() was called yet. Equivalent to calling setSize(const Vector2&, const Vector2&, const Vector2i&) followed by setTheme(const AbstractTheme&, 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 theme application fails during the creation process, the program exits. Use tryCreate() for a more graceful failure handling.

template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
UserInterfaceGL& Magnum::Ui::UserInterfaceGL::create(const Application& application, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Create the user interface with properties taken from an application instance.

Parameters
application Application instance to query properties from
theme Theme 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(), setDataLayerInstance(), setBackgroundLayerInstance(), setBaseLayerInstance(), setTextLayerInstance(), setEventLayerInstance(), setLayoutLayerInstance(), setSnapLayouterInstance(), setGenericLayouterInstance(), setNodeAnimatorInstance(), setBackgroundLayerStyleAnimatorInstance(), setBaseLayerStyleAnimatorInstance(), setTextLayerStyleAnimatorInstance() or setRendererInstance() was called yet. Equivalent to calling setSize(const ApplicationOrViewportEvent&) followed by setTheme(const AbstractTheme&, 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 theme 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 AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Create the user interface with a subset of the theme.

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.
theme Theme instance to use
themeFeatures Theme 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(), setDataLayerInstance(), setBackgroundLayerInstance(), setBaseLayerInstance(), setTextLayerInstance(), setEventLayerInstance(), setLayoutLayerInstance(), setSnapLayouterInstance(), setGenericLayouterInstance(), setNodeAnimatorInstance(), setBackgroundLayerStyleAnimatorInstance(), setBaseLayerStyleAnimatorInstance(), setTextLayerStyleAnimatorInstance() or setRendererInstance() was called yet. Equivalent to calling setSize(const Vector2&, const Vector2&, const Vector2i&) followed by setTheme(const AbstractTheme&, ThemeFeatures, 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 theme application fails during the creation process, the program exits. Use tryCreate() for a more graceful failure handling.

template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
UserInterfaceGL& Magnum::Ui::UserInterfaceGL::create(const Application& application, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Create the user interface with a subset of the theme with properties taken from an application instance.

Parameters
application Application instance to query properties from
theme Theme instance to use
themeFeatures Theme 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(), setDataLayerInstance(), setBackgroundLayerInstance(), setBaseLayerInstance(), setTextLayerInstance(), setEventLayerInstance(), setLayoutLayerInstance(), setSnapLayouterInstance(), setGenericLayouterInstance(), setNodeAnimatorInstance(), setBackgroundLayerStyleAnimatorInstance(), setBaseLayerStyleAnimatorInstance(), setTextLayerStyleAnimatorInstance() or setRendererInstance() was called yet. Equivalent to calling setSize(const ApplicationOrViewportEvent&) followed by setTheme(const AbstractTheme&, 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 theme 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 AbstractTheme& theme, 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 AbstractTheme&, 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 AbstractTheme& theme, ThemeFeatures themeFeatures, 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 theme.

Delegates to create(const Vector2&, const Vector2&, const Vector2i&, const AbstractTheme&, ThemeFeatures, 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 AbstractTheme& theme, 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 AbstractTheme&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractTheme::apply() failed instead of exiting, true otherwise. Equivalent to calling setSize(const Vector2&, const Vector2&, const Vector2i&) followed by trySetTheme(const AbstractTheme&, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*).

template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
bool Magnum::Ui::UserInterfaceGL::tryCreate(const Application& application, const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to create the user interface with properties taken from an application instance.

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

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

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

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

template<class Application, class = decltype(Implementation::ApplicationSizeConverter<Application>::set(std::declval<AbstractUserInterface&>(), std::declval<const Application&>()))>
bool Magnum::Ui::UserInterfaceGL::tryCreate(const Application& application, const AbstractTheme& theme, ThemeFeatures themeFeatures, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to create the user interface with a subset of the theme with properties taken from an application instance.

Unlike create(const Application&, const AbstractTheme&, ThemeFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractTheme::apply() failed instead of exiting, true otherwise. Equivalent to calling setSize(const ApplicationOrViewportEvent&) followed by trySetTheme(const AbstractTheme&, ThemeFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*).

bool Magnum::Ui::UserInterfaceGL::tryCreate(const Vector2i& size, const AbstractTheme& theme, ThemeFeatures themeFeatures, 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 theme.

Unlike create(const Vector2i&, const AbstractTheme&, ThemeFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) returns false if AbstractTheme::apply() failed instead of exiting, true otherwise. Equivalent to calling setSize(const Vector2i&) followed by trySetTheme(const AbstractTheme&, ThemeFeatures, 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::setTheme() or a UserInterfaceGL constructor taking a theme 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::setTheme() or a UserInterfaceGL constructor taking a theme 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::setTheme(const AbstractTheme& theme, ThemeFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Set features from a theme.

Parameters
theme Theme instance to use
features Theme 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 and layouter instances corresponding to all features with style uniform count, style count and other parameters coming from theme. If features contain ThemeFeature::TextLayer and fontManager is nullptr, an internal font plugin manager instance is created; if features contain ThemeFeature::TextLayerImages and importerManager is nullptr, an internal importer plugin manager instance is created. The function then calls AbstractTheme::apply() to apply the theme to those layers, layouters and animators. If it fails, the program exits, see trySetTheme() 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 AbstractTheme::features() of theme, contain at least one feature and that the user interface doesn't yet contain any layers or layouters corresponding to features as documented in the ThemeFeature enum values.

While it's not allowed to set theme 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 theme with another compatible theme, call AbstractTheme::apply() directly. See its documentation for more information about theme compatibility restrictions.

UserInterfaceGL& Magnum::Ui::UserInterfaceGL::setTheme(const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Set all features from a theme.

Returns Reference to self (for method chaining)

Equivalent to calling setTheme(const AbstractTheme&, ThemeFeatures, PluginManager::Manager<Trade::AbstractImporter>*, PluginManager::Manager<Text::AbstractFont>*) with features set to AbstractTheme::features() of theme.

bool Magnum::Ui::UserInterfaceGL::trySetTheme(const AbstractTheme& theme, ThemeFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to set features from a theme.

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

bool Magnum::Ui::UserInterfaceGL::trySetTheme(const AbstractTheme& theme, PluginManager::Manager<Trade::AbstractImporter>* importerManager = nullptr, PluginManager::Manager<Text::AbstractFont>* fontManager = nullptr)

Try to set all features from a theme.

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

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

Set a background 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 setTheme(), create() or a constructor taking a theme instance. The instance is subsequently available through backgroundLayer().

Note that because backgroundLayer() may alias baseLayer() if a background layer instance isn't present, it's not recommended to call this function after any widgets have been already created, as it could lead to internal state inconsistencies.

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 setTheme(), create() or a constructor taking a theme 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 setTheme(), create() or a constructor taking a theme instance. The instance is subsequently available through textLayer().