Window Framework for UI Toolkit v2.0.x
GWG.WindowFramework.Theming.PlayerThemeRuntime Class Referencesealed

Owns a runtime player catalog and selection leases for explicit UI scopes. More...

Inheritance diagram for GWG.WindowFramework.Theming.PlayerThemeRuntime:
Collaboration diagram for GWG.WindowFramework.Theming.PlayerThemeRuntime:

Public Member Functions

 PlayerThemeRuntime (IReadOnlyList< WindowFrameTheme > builtIns, Func< IEnumerable< VisualElement > > scopes, Action< int > applyBuiltIn, Action< string > persist, PlayerThemeExtensionRegistry extensions=null)
 Creates an application-owned runtime selection manager.
async System.Threading.Tasks.Task<(bool Success, string FolderName, string Error)> CreateEditableCopyAsync (string root, string name, VisualElement scope, System.Threading.CancellationToken cancellation=default)
 Creates a copy, rasterizing a trusted configured vector preview when needed.
void Dispose ()
 Releases scope leases before catalog textures.
bool Refresh (string root, string savedId, int legacyIndex, out string error)
void RefreshControls ()
 Reconciles dynamic controls after explicit application attachment notifications.
bool Select (string id, out string error)
 Selects by identity from the live catalog or built-ins and persists after success.
bool TryCreateEditableCopy (string root, string name, VisualElement scope, out string folderName, out string error)
 Creates an independent portable copy of the committed effective theme.

Properties

string ActiveId [get, private set]
 Gets current successfully applied stable selection.
PlayerThemeCatalog Catalog [get]
 Gets current imported catalog, or null before initialization.
string Status [get, private set]
 Gets the safe last migration, fallback or selection explanation.

Events

Action Changed
 Raised after a committed catalog/selection change, never during baseline application.

Private Member Functions

bool Apply (string id, PlayerThemeCatalog catalog, out string error)
PlayerThemeValues FrameworkValues (WindowFrameTheme baseline, PlayerThemeFolder player)
PlayerThemeExtensionRegistry ImportExtensions (string root=null)
void Notify ()
void Release ()
bool TryCreateEditableCopyCore (string root, string name, VisualElement scope, UnityEngine.Texture2D renderedPreview, out string folderName, out string error, IReadOnlyDictionary< string, UnityEngine.Texture2D > renderedImages=null)

Private Attributes

readonly Action< int > _applyBuiltIn
readonly HashSet< VisualElement > _boundScopes = new HashSet<VisualElement>()
readonly IReadOnlyList< WindowFrameTheme > _builtIns
bool _busy
PlayerThemeCatalog _catalog
System.Threading.CancellationTokenSource _copyCancellation
bool _disposed
readonly PlayerThemeExtensionRegistry _extensions
readonly List< IDisposable > _leases = new List<IDisposable>()
readonly Action< string > _persist
bool _refreshingControls
readonly Func< IEnumerable< VisualElement > > _scopes

Detailed Description

Owns a runtime player catalog and selection leases for explicit UI scopes.

Application must supply its existing built-in selection and persistence authority. Release bindings before disposing imported textures. Refresh is transactional: discovery or validation failure retains the previous catalog. Defaults are never inferred from list order. This owner does not scan folders each frame or write an independent preference file.

Constructor & Destructor Documentation

◆ PlayerThemeRuntime()

GWG.WindowFramework.Theming.PlayerThemeRuntime.PlayerThemeRuntime ( IReadOnlyList< WindowFrameTheme > builtIns,
Func< IEnumerable< VisualElement > > scopes,
Action< int > applyBuiltIn,
Action< string > persist,
PlayerThemeExtensionRegistry extensions = null )
inline

Creates an application-owned runtime selection manager.

Parameters
builtInsShipped configuration with stable IDs.
scopesCurrent explicit independent theme scopes.
applyBuiltInExisting stylesheet-selection path, invoked with shipped index.
persistExisting persistence callback, invoked after successful application.
extensionsOptional compiled handler registry.
Here is the caller graph for this function:

Member Function Documentation

◆ Apply()

bool GWG.WindowFramework.Theming.PlayerThemeRuntime.Apply ( string id,
PlayerThemeCatalog catalog,
out string error )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateEditableCopyAsync()

async System.Threading.Tasks.Task<(bool Success, string FolderName, string Error)> GWG.WindowFramework.Theming.PlayerThemeRuntime.CreateEditableCopyAsync ( string root,
string name,
VisualElement scope,
System.Threading.CancellationToken cancellation = default )
inline

Creates a copy, rasterizing a trusted configured vector preview when needed.

Main-thread runtime call. Preserves the synchronous raster API. Cancellation applies before commit; once committed the independent copy is never deleted. Source identity and scope attachment are checked again after rendering. No player SVG is read.

Parameters
rootConfigured local root.
nameSafe copy name.
scopeAttached application scope.
cancellationCancels pre-commit rendering.
Returns
Success, committed folder if any, and bounded failure explanation.
Here is the call graph for this function:

◆ Dispose()

void GWG.WindowFramework.Theming.PlayerThemeRuntime.Dispose ( )
inline

Releases scope leases before catalog textures.

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

◆ FrameworkValues()

PlayerThemeValues GWG.WindowFramework.Theming.PlayerThemeRuntime.FrameworkValues ( WindowFrameTheme baseline,
PlayerThemeFolder player )
inlineprivate
Here is the caller graph for this function:

◆ ImportExtensions()

PlayerThemeExtensionRegistry GWG.WindowFramework.Theming.PlayerThemeRuntime.ImportExtensions ( string root = null)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Notify()

void GWG.WindowFramework.Theming.PlayerThemeRuntime.Notify ( )
inlineprivate
Here is the caller graph for this function:

◆ Refresh()

bool GWG.WindowFramework.Theming.PlayerThemeRuntime.Refresh ( string root,
string savedId,
int legacyIndex,
out string error )
inline
Parameters
rootConfigured theme root.
savedIdExisting saved identity on first initialization.
legacyIndexShipped index for one-time migration.
errorFailure diagnostic.
Returns
True after replacement selection and persistence succeed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RefreshControls()

void GWG.WindowFramework.Theming.PlayerThemeRuntime.RefreshControls ( )
inline

Reconciles dynamic controls after explicit application attachment notifications.

Attachment notifications refresh framework mappings and reapply extension leases even when their root scope is unchanged, so newly constructed window controls are discovered. Existing extension targets handle detach/reattach locally. No catalog reload or persistence write.

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

◆ Release()

void GWG.WindowFramework.Theming.PlayerThemeRuntime.Release ( )
inlineprivate
Here is the caller graph for this function:

◆ Select()

bool GWG.WindowFramework.Theming.PlayerThemeRuntime.Select ( string id,
out string error )
inline

Selects by identity from the live catalog or built-ins and persists after success.

Parameters
idExact stable ID; unavailable IDs are rejected.
errorFailure diagnostic.
Returns
True if selection applied.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryCreateEditableCopy()

bool GWG.WindowFramework.Theming.PlayerThemeRuntime.TryCreateEditableCopy ( string root,
string name,
VisualElement scope,
out string folderName,
out string error )
inline

Creates an independent portable copy of the committed effective theme.

Parameters
rootConfigured local portable-theme root.
nameBounded user-facing copy name, not a path.
scopeAttached baseline-resolved scope for complete tokens and extension snapshots.
folderNameNew independent folder on export success, including when subsequent selection fails.
errorSafe actionable failure explanation.
Returns
True after export, catalog refresh and copy selection succeed.

Never rewrites or deletes the source. A committed copy remains available if refresh or persistence fails. Unsupported/incomplete snapshots are refused before filesystem writes. Caller must wait for resolved custom styles after stylesheet changes. Main thread only.

Here is the call graph for this function:

◆ TryCreateEditableCopyCore()

bool GWG.WindowFramework.Theming.PlayerThemeRuntime.TryCreateEditableCopyCore ( string root,
string name,
VisualElement scope,
UnityEngine.Texture2D renderedPreview,
out string folderName,
out string error,
IReadOnlyDictionary< string, UnityEngine.Texture2D > renderedImages = null )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ _applyBuiltIn

readonly Action<int> GWG.WindowFramework.Theming.PlayerThemeRuntime._applyBuiltIn
private

◆ _boundScopes

readonly HashSet<VisualElement> GWG.WindowFramework.Theming.PlayerThemeRuntime._boundScopes = new HashSet<VisualElement>()
private

◆ _builtIns

readonly IReadOnlyList<WindowFrameTheme> GWG.WindowFramework.Theming.PlayerThemeRuntime._builtIns
private

◆ _busy

bool GWG.WindowFramework.Theming.PlayerThemeRuntime._busy
private

◆ _catalog

PlayerThemeCatalog GWG.WindowFramework.Theming.PlayerThemeRuntime._catalog
private

◆ _copyCancellation

System.Threading.CancellationTokenSource GWG.WindowFramework.Theming.PlayerThemeRuntime._copyCancellation
private

◆ _disposed

bool GWG.WindowFramework.Theming.PlayerThemeRuntime._disposed
private

◆ _extensions

readonly PlayerThemeExtensionRegistry GWG.WindowFramework.Theming.PlayerThemeRuntime._extensions
private

◆ _leases

readonly List<IDisposable> GWG.WindowFramework.Theming.PlayerThemeRuntime._leases = new List<IDisposable>()
private

◆ _persist

readonly Action<string> GWG.WindowFramework.Theming.PlayerThemeRuntime._persist
private

◆ _refreshingControls

bool GWG.WindowFramework.Theming.PlayerThemeRuntime._refreshingControls
private

◆ _scopes

readonly Func<IEnumerable<VisualElement> > GWG.WindowFramework.Theming.PlayerThemeRuntime._scopes
private

Property Documentation

◆ ActiveId

string GWG.WindowFramework.Theming.PlayerThemeRuntime.ActiveId
getprivate set

Gets current successfully applied stable selection.

◆ Catalog

PlayerThemeCatalog GWG.WindowFramework.Theming.PlayerThemeRuntime.Catalog
get

Gets current imported catalog, or null before initialization.

◆ Status

string GWG.WindowFramework.Theming.PlayerThemeRuntime.Status
getprivate set

Gets the safe last migration, fallback or selection explanation.

Event Documentation

◆ Changed

Action GWG.WindowFramework.Theming.PlayerThemeRuntime.Changed

Raised after a committed catalog/selection change, never during baseline application.