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

Base for UserInterface styles.

Subclassing

A subclass implements at least doFeatures() and doApply(), and then a subset of the other virtual functions based on what features are actually supplied by the style. See their documentation for more information.

Derived classes

class McssDarkStyle new in Git master
Style for builtin widgets based on the m.css dark theme.

Public functions

auto features() const -> StyleFeatures
Features supplied by a style.
auto baseLayerStyleUniformCount() const -> UnsignedInt
Style uniform count for the base layer.
auto baseLayerStyleCount() const -> UnsignedInt
Style count for the base layer.
auto baseLayerDynamicStyleCount() const -> UnsignedInt
Dynamic style count for the base layer.
auto setBaseLayerDynamicStyleCount(UnsignedInt count) -> AbstractStyle&
Request more base layer dynamic styles.
auto baseLayerFlags() const -> BaseLayerSharedFlags
Additional flags for the base layer.
auto setBaseLayerFlags(BaseLayerSharedFlags add, BaseLayerSharedFlags clear) -> AbstractStyle&
Set additional base layer flags.
auto textLayerStyleUniformCount() const -> UnsignedInt
Style uniform count for the text layer.
auto textLayerStyleCount() const -> UnsignedInt
Style count for the text layer.
auto textLayerEditingStyleUniformCount() const -> UnsignedInt
Editing style uniform count for the text layer.
auto textLayerEditingStyleCount() const -> UnsignedInt
Editing style count for the text layer.
auto textLayerDynamicStyleCount() const -> UnsignedInt
Dynamic style count for the text layer.
auto setTextLayerDynamicStyleCount(UnsignedInt count) -> AbstractStyle&
Request more text layer dynamic styles.
auto textLayerGlyphCacheFormat() const -> PixelFormat
Text layer glyph cache format.
auto textLayerGlyphCacheSize(StyleFeatures features) const -> Vector3i
Text layer glyph cache size.
auto textLayerGlyphCachePadding() const -> Vector2i
Text layer glyph cache padding.
auto setTextLayerGlyphCacheSize(const Vector3i& size, const Vector2i& padding = {}) -> AbstractStyle&
Request a larger glyph cache size.
auto apply(UserInterface& ui, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager, PluginManager::Manager<Text::AbstractFont>* fontManager) const -> bool
Apply the style.

Private functions

auto doFeatures() const -> StyleFeatures pure virtual
Implementation for features()
auto doBaseLayerStyleUniformCount() const -> UnsignedInt virtual
Implementation for baseLayerStyleUniformCount()
auto doBaseLayerStyleCount() const -> UnsignedInt virtual
Implementation for baseLayerStyleCount()
auto doBaseLayerDynamicStyleCount() const -> UnsignedInt virtual
Implementation for baseLayerDynamicStyleCount()
auto doBaseLayerFlags() const -> BaseLayerSharedFlags virtual
Implementation for baseLayerFlags()
auto doTextLayerStyleUniformCount() const -> UnsignedInt virtual
Implementation for textLayerStyleUniformCount()
auto doTextLayerStyleCount() const -> UnsignedInt virtual
Implementation for textLayerStyleCount()
auto doTextLayerEditingStyleUniformCount() const -> UnsignedInt virtual
Implementation for textLayerEditingStyleUniformCount()
auto doTextLayerEditingStyleCount() const -> UnsignedInt virtual
Implementation for textLayerEditingStyleCount()
auto doTextLayerDynamicStyleCount() const -> UnsignedInt virtual
Implementation for textLayerDynamicStyleCount()
auto doTextLayerGlyphCacheFormat() const -> PixelFormat virtual
Implementation for textLayerGlyphCacheFormat()
auto doTextLayerGlyphCacheSize(StyleFeatures features) const -> Vector3i virtual
Implementation for textLayerGlyphCacheSize()
auto doTextLayerGlyphCachePadding() const -> Vector2i virtual
Implementation for textLayerGlyphCacheFormat()
auto doApply(UserInterface& ui, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager, PluginManager::Manager<Text::AbstractFont>* fontManager) const -> bool pure virtual
Implementation for apply()

Function documentation

StyleFeatures Magnum::Ui::AbstractStyle::features() const

Features supplied by a style.

Guaranteed to return at least one StyleFeature.

UnsignedInt Magnum::Ui::AbstractStyle::baseLayerStyleUniformCount() const

Style uniform count for the base layer.

Expects that StyleFeature::BaseLayer is supported. The returned value is passed to the BaseLayer::Shared::Configuration::Configuration(UnsignedInt, UnsignedInt) constructor by UserInterfaceGL::setStyle().

UnsignedInt Magnum::Ui::AbstractStyle::baseLayerStyleCount() const

Style count for the base layer.

Expects that StyleFeature::BaseLayer is supported. The returned value is passed to the BaseLayer::Shared::Configuration::Configuration(UnsignedInt, UnsignedInt) constructor by UserInterfaceGL::setStyle().

UnsignedInt Magnum::Ui::AbstractStyle::baseLayerDynamicStyleCount() const

Dynamic style count for the base layer.

Expects that StyleFeature::BaseLayer is supported. The returned value is passed to BaseLayer::Shared::Configuration::setDynamicStyleCount() by UserInterfaceGL::setStyle(). Call setBaseLayerDynamicStyleCount() to increase the count if needed.

AbstractStyle& Magnum::Ui::AbstractStyle::setBaseLayerDynamicStyleCount(UnsignedInt count)

Request more base layer dynamic styles.

Returns Reference to self (for method chaining)

Expects that StyleFeature::BaseLayer is supported. Call this function if the dynamic style count requested by the style isn't enough for extra animations and other dynamic style features used by the application. The used count will be a maximum of what the style itself returned and what was requested with this function.

BaseLayerSharedFlags Magnum::Ui::AbstractStyle::baseLayerFlags() const

Additional flags for the base layer.

Expects that StyleFeature::BaseLayer is supported. The returned value is passed to BaseLayer::Shared::Configuration::setFlags() by UserInterfaceGL::setStyle(). Call setBaseLayerFlags() to supply additional flags to add or clear from the set if needed.

AbstractStyle& Magnum::Ui::AbstractStyle::setBaseLayerFlags(BaseLayerSharedFlags add, BaseLayerSharedFlags clear)

Set additional base layer flags.

Returns Reference to self (for method chaining)

Expects that StyleFeature::BaseLayer is supported, add is a subset of BaseLayerSharedFlag::SubdividedQuads, and clear is a subset of BaseLayerSharedFlag::NoRoundedCorners and NoOutline. Flags used are a union of what the style itself returned and what was requested in add, with everything in clear cleared from the set.

AbstractStyle& Magnum::Ui::AbstractStyle::setTextLayerDynamicStyleCount(UnsignedInt count)

Request more text layer dynamic styles.

Returns Reference to self (for method chaining)

Expects that StyleFeature::TextLayer is supported. Call this function if the dynamic style count requested by the style isn't enough for extra animations and other dynamic style features used by the application. The used count will be a maximum of what the style itself returned and what was requested with this function.

Vector3i Magnum::Ui::AbstractStyle::textLayerGlyphCacheSize(StyleFeatures features) const

Text layer glyph cache size.

Expects that StyleFeature::TextLayer is supported and that features are a subset of features() and contain at least StyleFeature::TextLayer. The implementation may choose to return a different value based on whether StyleFeature::TextLayerImages is present in features or not. The returned value is passed to the Text::GlyphCache constructor by UserInterfaceGL::setStyle(). Call setTextLayerGlyphCacheSize() to enlarge the glyph cache if the application needs to store more glyphs.

Vector2i Magnum::Ui::AbstractStyle::textLayerGlyphCachePadding() const

Text layer glyph cache padding.

Expects that StyleFeature::TextLayer is supported. The returned value is passed to the Text::GlyphCache constructor by UserInterfaceGL::setStyle(). Call setTextLayerGlyphCacheSize() to enlarge the glyph cache size or padding if needed.

AbstractStyle& Magnum::Ui::AbstractStyle::setTextLayerGlyphCacheSize(const Vector3i& size, const Vector2i& padding = {})

Request a larger glyph cache size.

Returns Reference to self (for method chaining)

Expects that StyleFeature::TextLayer is supported. Call this function if the glyph cache size requested by the style isn't enough for extra glyphs used by the application, if the application adds additional fonts or other image data to it or if additional padding is needed. The used size and padding will be a maximum of what the style itself returned and what was requested with this function.

bool Magnum::Ui::AbstractStyle::apply(UserInterface& ui, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager, PluginManager::Manager<Text::AbstractFont>* fontManager) const

Apply the style.

Used internally from UserInterfaceGL::setStyle() / trySetStyle(), you'll likely want to call that function instead if setting up a style on a new UserInterface instance. Direct use of this function is mainly for applying another compatible style to a user interface that already has a style set.

Expects that ui has user interface size already set, either using the constructor or by calling UserInterface::setSize(). Expects that features are a subset of features() and contain at least one feature, that ui already contains all layers corresponding to features, that their shared state style uniform and style count matches the subset of baseLayerStyleUniformCount(), baseLayerStyleCount(), textLayerStyleUniformCount(), textLayerStyleCount(), textLayerEditingStyleUniformCount(), textLayerEditingStyleCount() matching features and their shared state dynamic style count is at least the subset of baseLayerDynamicStyleCount(), textLayerDynamicStyleCount() matching features. Additionally, if StyleFeature::TextLayer is present in features, expects that the TextLayer::Shared instance has a glyph cache set that matches textLayerGlyphCacheFormat(), has size at least textLayerGlyphCacheSize() for features and padding at least textLayerGlyphCachePadding() and that fontManager is not nullptr; and if StyleFeature::TextLayerImages is present in features, expects that either the TextLayer is already present in the user interface or that StyleFeature::TextLayer is included in features as well, and that importerManager is not nullptr. Returns true on success, prints a message to Error and returns false if some run-time error happened during style preparation, such as a plugin not being found or external data failing to load.

StyleFeatures Magnum::Ui::AbstractStyle::doFeatures() const pure virtual private

Implementation for features()

Is expected to return at least one StyleFeature.

UnsignedInt Magnum::Ui::AbstractStyle::doBaseLayerStyleUniformCount() const virtual private

Implementation for baseLayerStyleUniformCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::BaseLayer. Default implementation delegates to doBaseLayerStyleCount().

UnsignedInt Magnum::Ui::AbstractStyle::doBaseLayerStyleCount() const virtual private

Implementation for baseLayerStyleCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::BaseLayer. Has to be implemented if doFeatures() contains StyleFeature::BaseLayer.

UnsignedInt Magnum::Ui::AbstractStyle::doBaseLayerDynamicStyleCount() const virtual private

Implementation for baseLayerDynamicStyleCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::BaseLayer. Default implementation returns 0.

BaseLayerSharedFlags Magnum::Ui::AbstractStyle::doBaseLayerFlags() const virtual private

Implementation for baseLayerFlags()

Guaranteed to be called only if doFeatures() contains StyleFeature::BaseLayer. Expects that the implementation returns a subset of BaseLayerSharedFlag::NoRoundedCorners and NoOutline. Default implementation returns an empty set.

UnsignedInt Magnum::Ui::AbstractStyle::doTextLayerStyleUniformCount() const virtual private

Implementation for textLayerStyleUniformCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. Default implementation delegates to doTextLayerStyleCount().

UnsignedInt Magnum::Ui::AbstractStyle::doTextLayerStyleCount() const virtual private

Implementation for textLayerStyleCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. Has to be implemented if doFeatures() contains StyleFeature::TextLayer.

UnsignedInt Magnum::Ui::AbstractStyle::doTextLayerEditingStyleUniformCount() const virtual private

Implementation for textLayerEditingStyleUniformCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. Default implementation delegates to doTextLayerEditingStyleCount().

UnsignedInt Magnum::Ui::AbstractStyle::doTextLayerEditingStyleCount() const virtual private

Implementation for textLayerEditingStyleCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. Default implementation returns 0.

UnsignedInt Magnum::Ui::AbstractStyle::doTextLayerDynamicStyleCount() const virtual private

Implementation for textLayerDynamicStyleCount()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. Default implementation returns 0.

PixelFormat Magnum::Ui::AbstractStyle::doTextLayerGlyphCacheFormat() const virtual private

Implementation for textLayerGlyphCacheFormat()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. Default implementation returns PixelFormat::R8Unorm.

Vector3i Magnum::Ui::AbstractStyle::doTextLayerGlyphCacheSize(StyleFeatures features) const virtual private

Implementation for textLayerGlyphCacheSize()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. The features are guaranteed to be a subset of features() and contain at least StyleFeature::TextLayer. Has to be implemented if doFeatures() contains StyleFeature::TextLayer.

Vector2i Magnum::Ui::AbstractStyle::doTextLayerGlyphCachePadding() const virtual private

Implementation for textLayerGlyphCacheFormat()

Guaranteed to be called only if doFeatures() contains StyleFeature::TextLayer. Default implementation returns {1, 1}, consistently with default padding in Text::AbstractGlyphCache, to prevent artifacts. See Glyph padding for more information.

bool Magnum::Ui::AbstractStyle::doApply(UserInterface& ui, StyleFeatures features, PluginManager::Manager<Trade::AbstractImporter>* importerManager, PluginManager::Manager<Text::AbstractFont>* fontManager) const pure virtual private

Implementation for apply()

Should call BaseLayer::Shared::setStyle(), BaseLayer::Shared::setStyleTransition(), TextLayer::Shared::addFont(), TextLayer::Shared::setStyle() and TextLayer::Shared::setStyleTransition() with style contents based on what features are passed and return true. If some runtime error happens, should print a message to Error and return false.

The ui is guaranteed to have user interface set for the style to use to calculate font rasterization and icon sizes, for example. The features are guaranteed to be a subset of features() and contain at least one feature, that ui already contains all layers corresponding to features, that their shared state style uniform and style count matches the subset of baseLayerStyleUniformCount(), baseLayerStyleCount(), textLayerStyleUniformCount(), textLayerStyleCount() matching features and their shared state dynamic style count is at least the subset of baseLayerDynamicStyleCount(), textLayerDynamicStyleCount() matching features. Additionally, if StyleFeature::TextLayer is present in features, the TextLayer::Shared instance is guaranteed to have a glyph cache set that matches textLayerGlyphCacheFormat(), with a size at least textLayerGlyphCacheSize() for features and padding at least textLayerGlyphCachePadding(), and fontManager is guaranteed to not be nullptr; and if StyleFeature::TextLayerImages is present in features, the importerManager is guaranteed to not be nullptr.