Window Framework for UI Toolkit v2.0.x
GWG.WindowFramework.Theming.DeveloperThemeSelector Class Reference

Supported selector matching for application-owned prepared developer mappings. More...

Data Structures

class  Compiled
 A lease-owned parsed selector. No global cache or player-controlled selector input.

Static Public Member Functions

static bool Matches (string selector, VisualElement element, VisualElement scope, ISet< VisualElement > hovered=null, ISet< VisualElement > active=null, bool ignoreStates=false)
 Matches within an explicit scope. Repeated runtime callers should retain a compiled selector.
static int Specificity (string selector)
 Validates a single selector and computes USS specificity.

Static Private Member Functions

static string[] Tokens (string selector)

Static Private Attributes

static readonly Regex Part = new Regex(@"\G(?:(?<prefix>[.#:])?(?<name>[A-Za-z_][A-Za-z0-9_-]*)|(?<star>\*))")

Detailed Description

Supported selector matching for application-owned prepared developer mappings.

Supports type/class/ID/universal selectors, descendant/child relations and hover/active/focus/disabled/enabled/checked/root states. This is a mapping vocabulary, NOT a validator for the developer's stylesheet. The compiler reports unsupported selector consumers and leaves them unmapped without discarding the annotated exported setting; Unity still owns ordinary USS.

REQUIRED MAINTENANCE BOUNDARY: preserve the accepted selector/cache behavior unless a change is explicitly authorized. Do not expand this into a second CSS engine, introduce private Unity stylesheet access, or repeatedly tokenize/regex-parse selectors on pointer or focus events.

HOW IT WORKS: Specificity() checks one proposed mapping selector and computes its ordering weight. Each DeveloperThemeBinding creates one Compiled instance per distinct prepared selector in that lease. The constructor converts text to terms and child/descendant relationships once. Matches() then checks existing element names, classes, type ancestry and relevant states using those retained terms; it does not discover all controls or read player files.

ignoreStates is used for initial/owner target discovery so hover, disabled and checked consumers remain discoverable even while their state is inactive. Normal matching evaluates those states when choosing an applied rule. Ancestor matching is bounded by the explicit scope. Hover/active sets belong to the binding lease; focus/enabled/checked come from the actual controls.

There is no global retained selector cache, reflected property setter or reflection-created control. Cache lifetime follows the selected theme's binding lease. The public string Matches() convenience method constructs a selector for that call; repeated runtime work must use the binding's retained Compiled instances instead.

Member Function Documentation

◆ Matches()

bool GWG.WindowFramework.Theming.DeveloperThemeSelector.Matches ( string selector,
VisualElement element,
VisualElement scope,
ISet< VisualElement > hovered = null,
ISet< VisualElement > active = null,
bool ignoreStates = false )
inlinestatic

Matches within an explicit scope. Repeated runtime callers should retain a compiled selector.

◆ Specificity()

int GWG.WindowFramework.Theming.DeveloperThemeSelector.Specificity ( string selector)
inlinestatic

Validates a single selector and computes USS specificity.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Tokens()

string[] GWG.WindowFramework.Theming.DeveloperThemeSelector.Tokens ( string selector)
inlinestaticprivate
Here is the caller graph for this function:

Field Documentation

◆ Part

readonly Regex GWG.WindowFramework.Theming.DeveloperThemeSelector.Part = new Regex(@"\G(?:(?<prefix>[.#:])?(?<name>[A-Za-z_][A-Za-z0-9_-]*)|(?<star>\*))")
staticprivate