UsoUIElements 0.1.0
Data Centric implimentation of Unity's UI Elements (UI Toolkit)
Loading...
Searching...
No Matches
GWG.UsoUIElements.UsoFoldout Class Reference

A custom foldout control that extends Unity's Foldout with USO UI framework functionality. Provides enhanced styling, field validation, data binding capabilities, and integration with the USO UI system. More...

Inheritance diagram for GWG.UsoUIElements.UsoFoldout:

Public Member Functions

 UsoFoldout ()
 Initializes a new instance of the UsoFoldout class with default settings. Creates a basic foldout with USO framework integration enabled.
 UsoFoldout (string fieldName, bool state)
 Initializes a new instance of the UsoFoldout class with the specified field name and initial state. Creates a foldout with custom identification and sets its expanded/collapsed state.
 UsoFoldout (string fieldName, bool state, out UsoFoldout newField)
 Initializes a new instance of the UsoFoldout class with field name, initial state, and returns a reference. Provides custom identification and state configuration with an out parameter for immediate access.
 UsoFoldout (string fieldName, string headerText)
 Initializes a new instance of the UsoFoldout class with field name and header text. Combines custom identification with display text configuration for the header.
 UsoFoldout (string fieldName, string headerText, bool state)
 Initializes a new instance of the UsoFoldout class with field name, header text, and initial state. Creates a fully configured foldout with custom identification, display text, and expansion state.
 UsoFoldout (string fieldName, string headerText, bool state, out UsoFoldout newField)
 Initializes a new instance of the UsoFoldout class with full configuration and returns a reference. Provides complete foldout setup with custom identification, header text, state, and immediate access to the created instance.
 UsoFoldout (string fieldName, string headerText, out UsoFoldout newField)
 Initializes a new instance of the UsoFoldout class with field name, header text, and returns a reference. Provides custom identification and header configuration with an out parameter for immediate access.
 UsoFoldout (string headerText)
 Initializes a new instance of the UsoFoldout class with the specified header text. Creates a foldout with a custom display text for the header toggle.
void ApplyBinding (string fieldBindingProp, string fieldBindingPath, BindingMode fieldBindingMode)
 Applies data binding to the specified property of this control using Unity's data binding system. Configures the binding with the provided path and mode for automatic data synchronization.
UsoLineItem GetParentLineItem ()
 Retrieves the first ancestor UsoLineItem control in the visual tree hierarchy. This is useful for accessing parent container functionality and maintaining proper UI structure.
void InitElement (string fieldName=null)
 Initializes the USO UI element with the specified field name and applies necessary styling classes. This method sets up the basic USO framework integration for the control and configures the header toggle.
void SetFieldStatus (FieldStatusTypes fieldStatus)
 Updates the field's status type, which affects its visual appearance and validation state. The status change is automatically reflected in the UI through the FieldStatus property.
void ShowFieldStatus (bool status)
 Controls the visibility and functionality of the field status/validation system. When disabled, removes validation-related styling from the control.
Public Member Functions inherited from GWG.UsoUIElements.IUsoUiElement
void AddToClassList (string className)
 Adds the specified CSS class name to this element's class list. This method is inherited from Unity's VisualElement and enables dynamic styling modifications.
void ClearBindings ()
 Removes all data binding configurations from this element. This method is inherited from Unity's VisualElement and provides cleanup functionality for data bindings.
void RemoveFromClassList (string className)
 Removes the specified CSS class name from this element's class list. This method is inherited from Unity's VisualElement and provides dynamic styling capabilities.

Public Attributes

Toggle Header
 Reference to the toggle element that serves as the foldout header. This toggle controls the expanded/collapsed state and can be styled independently.

Properties

FieldStatusTypes FieldStatus [get, private set]
 Gets the current field status type, which determines the visual state and validation feedback. This property is automatically reflected in the UI through CSS class modifications.
bool FieldStatusEnabled [get, private set]
 Gets or sets whether field status/validation functionality is enabled for this control. When enabled, adds validation CSS class for styling. When disabled, removes validation styling.

Private Member Functions

 ~UsoFoldout ()
 Finalizer for the UsoFoldout class. Currently empty but reserved for future cleanup operations if needed.

Private Attributes

string _elementHeaderStylesheet
 Private field for storing custom header stylesheet information. Used for applying specific styling to the foldout header element.
FieldStatusTypes _fieldStatus
bool _fieldStatusEnabled = true

Static Private Attributes

const string DefaultBindProp = "value"
 Default binding property used when applying data bindings to this field. Binds to the 'value' property which controls the expanded/collapsed state.
const string ElementClass = "uso-foldout"
 CSS class name applied to all UsoFoldout instances for styling purposes.
const string ElementHeaderStylesheet = "uso-foldout-header"
 CSS class name applied to the foldout header for independent styling of the toggle element.
const string ElementValidationClass = "uso-field-validation"
 CSS class name applied when field validation/status functionality is enabled.

Detailed Description

A custom foldout control that extends Unity's Foldout with USO UI framework functionality. Provides enhanced styling, field validation, data binding capabilities, and integration with the USO UI system.

This control implements the IUsoUiElement interface to provide consistent behavior across the USO UI framework. It supports field status indicators, automatic data binding, and custom styling through CSS classes. The control includes a header toggle element that can be styled independently and supports various constructor overloads for different initialization scenarios. The foldout is configured with flex-shrink: 0 by default to maintain its size.

Constructor & Destructor Documentation

◆ UsoFoldout() [1/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( )

Initializes a new instance of the UsoFoldout class with default settings. Creates a basic foldout with USO framework integration enabled.

◆ UsoFoldout() [2/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( string headerText)

Initializes a new instance of the UsoFoldout class with the specified header text. Creates a foldout with a custom display text for the header toggle.

Parameters
headerTextThe text to display in the foldout header.

◆ UsoFoldout() [3/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( string fieldName,
bool state )

Initializes a new instance of the UsoFoldout class with the specified field name and initial state. Creates a foldout with custom identification and sets its expanded/collapsed state.

Parameters
fieldNameThe name to assign to this field element.
stateTrue to initialize the foldout as expanded; false for collapsed.

◆ UsoFoldout() [4/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( string fieldName,
bool state,
out UsoFoldout newField )

Initializes a new instance of the UsoFoldout class with field name, initial state, and returns a reference. Provides custom identification and state configuration with an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this field element.
stateTrue to initialize the foldout as expanded; false for collapsed.
newFieldOutput parameter that receives a reference to the newly created field.

◆ UsoFoldout() [5/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( string fieldName,
string headerText )

Initializes a new instance of the UsoFoldout class with field name and header text. Combines custom identification with display text configuration for the header.

Parameters
fieldNameThe name to assign to this field element.
headerTextThe text to display in the foldout header.

◆ UsoFoldout() [6/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( string fieldName,
string headerText,
out UsoFoldout newField )

Initializes a new instance of the UsoFoldout class with field name, header text, and returns a reference. Provides custom identification and header configuration with an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this field element.
headerTextThe text to display in the foldout header.
newFieldOutput parameter that receives a reference to the newly created field.

◆ UsoFoldout() [7/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( string fieldName,
string headerText,
bool state )

Initializes a new instance of the UsoFoldout class with field name, header text, and initial state. Creates a fully configured foldout with custom identification, display text, and expansion state.

Parameters
fieldNameThe name to assign to this field element.
headerTextThe text to display in the foldout header.
stateTrue to initialize the foldout as expanded; false for collapsed.

◆ UsoFoldout() [8/8]

GWG.UsoUIElements.UsoFoldout.UsoFoldout ( string fieldName,
string headerText,
bool state,
out UsoFoldout newField )

Initializes a new instance of the UsoFoldout class with full configuration and returns a reference. Provides complete foldout setup with custom identification, header text, state, and immediate access to the created instance.

Parameters
fieldNameThe name to assign to this field element.
headerTextThe text to display in the foldout header.
stateTrue to initialize the foldout as expanded; false for collapsed.
newFieldOutput parameter that receives a reference to the newly created field.

◆ ~UsoFoldout()

GWG.UsoUIElements.UsoFoldout.~UsoFoldout ( )
private

Finalizer for the UsoFoldout class. Currently empty but reserved for future cleanup operations if needed.

Member Function Documentation

◆ ApplyBinding()

void GWG.UsoUIElements.UsoFoldout.ApplyBinding ( string fieldBindingProp,
string fieldBindingPath,
BindingMode fieldBindingMode )

Applies data binding to the specified property of this control using Unity's data binding system. Configures the binding with the provided path and mode for automatic data synchronization.

Parameters
fieldBindingPropThe property name on this control to bind to.
fieldBindingPathThe path to the data source property to bind from.
fieldBindingModeThe binding mode that determines how data flows between source and target.
Exceptions
ExceptionThrown when binding setup fails. Original exception is preserved and re-thrown.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ GetParentLineItem()

UsoLineItem GWG.UsoUIElements.UsoFoldout.GetParentLineItem ( )

Retrieves the first ancestor UsoLineItem control in the visual tree hierarchy. This is useful for accessing parent container functionality and maintaining proper UI structure.

Returns
The parent UsoLineItem if found; otherwise, null.

◆ InitElement()

void GWG.UsoUIElements.UsoFoldout.InitElement ( string fieldName = null)

Initializes the USO UI element with the specified field name and applies necessary styling classes. This method sets up the basic USO framework integration for the control and configures the header toggle.

Parameters
fieldNameOptional name to assign to the element. If null, no name is set.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ SetFieldStatus()

void GWG.UsoUIElements.UsoFoldout.SetFieldStatus ( FieldStatusTypes fieldStatus)

Updates the field's status type, which affects its visual appearance and validation state. The status change is automatically reflected in the UI through the FieldStatus property.

Parameters
fieldStatusThe new field status type to apply.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ ShowFieldStatus()

void GWG.UsoUIElements.UsoFoldout.ShowFieldStatus ( bool status)

Controls the visibility and functionality of the field status/validation system. When disabled, removes validation-related styling from the control.

Parameters
statusTrue to enable field status functionality; false to disable it.

Implements GWG.UsoUIElements.IUsoUiElement.

Member Data Documentation

◆ _elementHeaderStylesheet

string GWG.UsoUIElements.UsoFoldout._elementHeaderStylesheet
private

Private field for storing custom header stylesheet information. Used for applying specific styling to the foldout header element.

◆ _fieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoFoldout._fieldStatus
private

◆ _fieldStatusEnabled

bool GWG.UsoUIElements.UsoFoldout._fieldStatusEnabled = true
private

◆ DefaultBindProp

const string GWG.UsoUIElements.UsoFoldout.DefaultBindProp = "value"
staticprivate

Default binding property used when applying data bindings to this field. Binds to the 'value' property which controls the expanded/collapsed state.

◆ ElementClass

const string GWG.UsoUIElements.UsoFoldout.ElementClass = "uso-foldout"
staticprivate

CSS class name applied to all UsoFoldout instances for styling purposes.

◆ ElementHeaderStylesheet

const string GWG.UsoUIElements.UsoFoldout.ElementHeaderStylesheet = "uso-foldout-header"
staticprivate

CSS class name applied to the foldout header for independent styling of the toggle element.

◆ ElementValidationClass

const string GWG.UsoUIElements.UsoFoldout.ElementValidationClass = "uso-field-validation"
staticprivate

CSS class name applied when field validation/status functionality is enabled.

◆ Header

Toggle GWG.UsoUIElements.UsoFoldout.Header

Reference to the toggle element that serves as the foldout header. This toggle controls the expanded/collapsed state and can be styled independently.

Property Documentation

◆ FieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoFoldout.FieldStatus
getprivate set

Gets the current field status type, which determines the visual state and validation feedback. This property is automatically reflected in the UI through CSS class modifications.

The current FieldStatusTypes value indicating the field's validation state.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ FieldStatusEnabled

bool GWG.UsoUIElements.UsoFoldout.FieldStatusEnabled
getprivate set

Gets or sets whether field status/validation functionality is enabled for this control. When enabled, adds validation CSS class for styling. When disabled, removes validation styling.

True if field status functionality is enabled; otherwise, false. Default is true.

Implements GWG.UsoUIElements.IUsoUiElement.