Magnum::Ui::UserInterface class

Default user interface.

All positioning and sizing inside the interface is done in regard to the size parameter passed to the constructor, without taking actual screen size into account. This allows to have DPI-independent sizes.

Font plugins

Unless you pass your own font instance via UserInterface(const Vector2&, const Vector2i&, Text::AbstractFont&, Text::GlyphCache&, const StyleConfiguration&), the constructor expects that it can load some "TrueTypeFont" plugin. The plugin should be either in a system directory or be linked and correctly imported statically. If the plugin cannot be loaded, the application exits. See Loading and using plugins for more information.

Base classes

template<class ... Layers>
class BasicUserInterface
Base for user interfaces.

Constructors, destructors, conversion operators

UserInterface(const Vector2& size, const Vector2i& screenSize, const std::string& extraGlyphs = {}) explicit
Constructor.
UserInterface(const Vector2& size, const Vector2i& screenSize, const StyleConfiguration& styleConfiguration, const std::string& extraGlyphs = {}) explicit
Construct the user interface with a custom style.
UserInterface(const Vector2& size, const Vector2i& screenSize, Text::AbstractFont& font, Text::GlyphCache& glyphCache, const StyleConfiguration& styleConfiguration) explicit
Construct the user interface with custom style and font.
UserInterface(const Vector2& size, const Vector2i& screenSize, Text::AbstractFont& font, const StyleConfiguration& styleConfiguration) deprecated explicit
Construct the user interface with custom style and font.
UserInterface(const Vector2& size, const Vector2i& screenSize, Text::AbstractFont& font) deprecated explicit
Construct the user interface with a custom font.

Public functions

auto activePlane() -> Plane*
Active plane.
auto activePlane() const -> const Plane*
auto styleConfiguration() const -> const StyleConfiguration&
Used style configuration.
void setStyleConfiguration(const StyleConfiguration& configuration)
Set style configuration.
auto font() const -> const Text::AbstractFont&
Font used for the interface.
auto focusedInputWidget() -> Input*
Currently focused input widget.
void draw()
Draw the user interface.
auto inputWidgetFocused() -> Signal
Input widget was focused.
auto inputWidgetBlurred() -> Signal
Input widget was blurred.

Function documentation

Magnum::Ui::UserInterface::UserInterface(const Vector2& size, const Vector2i& screenSize, const std::string& extraGlyphs = {}) explicit

Constructor.

Parameters
size User interface size
screenSize Actual screen size
extraGlyphs Extra characters to add to glyph cache

Uses defaultStyleConfiguration() and a builtin font with pre-populated glyph cache.

Magnum::Ui::UserInterface::UserInterface(const Vector2& size, const Vector2i& screenSize, const StyleConfiguration& styleConfiguration, const std::string& extraGlyphs = {}) explicit

Construct the user interface with a custom style.

Parameters
size User interface size
screenSize Actual screen size
styleConfiguration Style configuration to use
extraGlyphs Extra characters to add to glyph cache

Uses a builtin font with pre-populated glyph cache.

Magnum::Ui::UserInterface::UserInterface(const Vector2& size, const Vector2i& screenSize, Text::AbstractFont& font, Text::GlyphCache& glyphCache, const StyleConfiguration& styleConfiguration) explicit

Construct the user interface with custom style and font.

Parameters
size User interface size
screenSize Actual screen size
font Font to use
glyphCache Populated glyph cache to use
styleConfiguration Style configuration to use

The font and glyphCache is expected to be kept in scope for the whole user interface lifetime.

Magnum::Ui::UserInterface::UserInterface(const Vector2& size, const Vector2i& screenSize, Text::AbstractFont& font, const StyleConfiguration& styleConfiguration) explicit

Construct the user interface with custom style and font.

const Plane* Magnum::Ui::UserInterface::activePlane() const

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

void Magnum::Ui::UserInterface::setStyleConfiguration(const StyleConfiguration& configuration)

Set style configuration.

Note that everything set prior to this call will have undefined contents after calling this function. Reset the contents and fill the interface again.

Input* Magnum::Ui::UserInterface::focusedInputWidget()

Currently focused input widget.

Input widget that should receive text input from the application. Returns nullptr if there is no active text input widget.

Signal Magnum::Ui::UserInterface::inputWidgetFocused()

Input widget was focused.

Text input from the application should be started upon signaling this. Currently active input widget is available in focusedInputWidget().

Signal Magnum::Ui::UserInterface::inputWidgetBlurred()

Input widget was blurred.

Text input from the application should be started upon signaling this. Currently active input widget is available in focusedInputWidget().