class GUIStyleSheet

Inherits: Resource, std::enable_shared_from_this<GUIStyleSheet>

Contains rulesets that determine how are GUI elements displayed.

GUI elements will perform lookup into the style sheet based on the element type, element ID, current element state and other properties.

Public

Constructors

GUIStyleSheet

GUIStyleSheet(TArray<GUIStyleSheetRuleset> rulesets = {})

Methods

~GUIStyleSheet

~GUIStyleSheet() noexcept override = default

BuildRules

GUIStyleSheetRules BuildRules(const GUIRenderable &guiElement, StringView pseudoElement = "", StringView pseudoClass = "", const GUIStyleSheetRules *inheritedRules = nullptr) const

Builds the appropriate ruleset to use for a particular GUI element.

This looks up relevant rulesets based on GUI elements type and optionally its class, id, parent elements and provided pseudo-element name.

BuildRules

GUIStyleSheetRules BuildRules(StringView elementType, StringView elementClass = "", StringView elementId = "", StringView pseudoElement = "", StringView pseudoClass = "", const GUIStyleSheetRules *inheritedRules = nullptr) const

Builds the appropriate rules that matches a GUI element with the provided type/class/id/pseud-class/pseudo-element.

Any of the provided selectors may be empty, in which case they will be ignored in the lookup.

GetRulesets

const TArray<GUIStyleSheetRuleset> &GetRulesets() const

Returns all rulesets stored in the stylesheet.

GetMatchingRulesetIndices

void GetMatchingRulesetIndices(const GUIRenderable &guiElement, TArray<u32> &outOrderedRulesetIndices, StringView pseudoElement = "", StringView pseudoClass = "", bool ignorePseudoClass = false) const

Populates the provided array with a list of ruleset indices matching the provided GUI element.

The ruleset indices can be used for accessing the array returned from GetRulesets().

HasRulesetForClass

bool HasRulesetForClass(StringView elementClass, StringView elementType = "") const

Checks if the style sheet has a ruleset for this particular class.

elementClass
Class name to check.
elementType
Optional name of the GUI element type. If not empty, only classes matching this element will be considered.

Returns: True if there is at least one ruleset for the class.

staticParse

static HGUIStyleSheet Parse(const Path &file)

Attempts to parse the provided style sheet file and outputs the parsed style sheet, if successful.

staticCreate

static HGUIStyleSheet Create(TArray<GUIStyleSheetRuleset> rulesets = {})

Creates a new style sheet.

staticCreateShared

static SPtr<GUIStyleSheet> CreateShared(TArray<GUIStyleSheetRuleset> rulesets = {})

Creates a new style sheet.

staticCreateUninitialized

static SPtr<GUIStyleSheet> CreateUninitialized(TArray<GUIStyleSheetRuleset> rulesets = {})

Creates a new style sheet without calling Initialize().

Caller must manually call Initialize().

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Private

Methods

Initialize

void Initialize() override

Initializes all the internal data of this object.

Must be called right after construction for new objects, or after deserialization for deserialized objects. If requested, render proxy is created and queued for initialization on the render thread.

PopulatePotentialRulesetIndices

void PopulatePotentialRulesetIndices(const GUIRenderable &guiElement, FrameSet<u32> &outOrderedRulesetIndices) const

Builds a list of all potential ruleset indices for the specified GUI element, using the ruleset lookup map.

Note it's guaranteed that rulesets not in the set will not be a match for the provided GUI element, but rulesets in the set don't necessarily need to match - the caller needs to check for a match explicitly.

PopulatePotentialRulesetIndices

void PopulatePotentialRulesetIndices(const StringView &elementSelector, const StringView &classSelector, const StringView &idSelector, FrameSet<u32> &outOrderedRulesetIndices) const

Builds a list of all potential ruleset indices for a GUI element with specified type, class and/or id selectors, using the ruleset lookup map.* Note it's guaranteed that rulesets not in the set will not be a match for the provided type/class/id, but rulesets in the set don't necessarily need to match - the caller needs to check for a match explicitly.

staticBuildCacheLookupName

static String BuildCacheLookupName(StringView idSelector, StringView classSelector, StringView elementSelector)

Builds a string that can be used for looking up narrowed list of rulesets matching every one of the provided selectors.

Fields

mRulesets

mRulesetLookupMap

UnorderedMap<String, GUIStyleSheetRulesetList> mRulesetLookupMap

Map to avoid iterating over entire mRuleset array.