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

A custom toolbar button control that extends Unity's ToolbarButton with USO UI framework functionality. Provides enhanced styling, field validation, and integration with the USO UI system. More...

Inheritance diagram for GWG.UsoUIElements.UsoToolbarButton:

Public Member Functions

 UsoToolbarButton ()
 Initializes a new instance of the UsoToolbarButton class with default settings. Creates a toolbar button with USO framework integration enabled.
 UsoToolbarButton (Action btnAction)
 Initializes a new instance of the UsoToolbarButton class with a click action callback. Creates a toolbar button with predefined click behavior and USO framework integration.
 UsoToolbarButton (string fieldName)
 Initializes a new instance of the UsoToolbarButton class with the specified field name. Creates a toolbar button with custom identification for binding and reference purposes.
 UsoToolbarButton (string fieldName, Action btnAction)
 Initializes a new instance of the UsoToolbarButton class with field name and a click action callback. Creates a toolbar button with custom identification, predefined click behavior, and USO framework integration.
 UsoToolbarButton (string fieldName, Action btnAction, out UsoToolbarButton newField)
 Initializes a new instance of the UsoToolbarButton class with field name, click action, and returns a reference. Creates a toolbar button with custom identification, predefined click behavior, and provides an out parameter for immediate access.
 UsoToolbarButton (string fieldName, out UsoToolbarButton newField)
 Initializes a new instance of the UsoToolbarButton class with field name and returns a reference. Creates a toolbar button with custom identification and provides an out parameter for immediate access.
 UsoToolbarButton (string fieldName, string fieldText)
 Initializes a new instance of the UsoToolbarButton class with field name and display text. Creates a toolbar button with custom identification and text content for user interface clarity.
 UsoToolbarButton (string fieldName, string fieldText, out UsoToolbarButton newField)
 Initializes a new instance of the UsoToolbarButton class with field name, display text, and returns a reference. Creates a toolbar button with custom identification, text content, and provides an out parameter for immediate access.
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.
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 ApplyBinding (string fieldBindingProp, string fieldBindingPath, BindingMode fieldBindingMode)
 Applies data binding configuration to the specified property of this element using Unity's data binding system. Enables automatic synchronization between the UI element and data source properties.
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.

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 Attributes

FieldStatusTypes _fieldStatus
 Private backing field for the FieldStatus property.
bool _fieldStatusEnabled
 Private backing field for the FieldStatusEnabled property.

Static Private Attributes

const string DefaultBindProp = "value"
 Default binding property used when applying data bindings to this field. Currently set to "value" for potential future binding scenarios.
const string ElementStylesheet = "uso-toolbar-button"
 CSS class name applied to all UsoToolbarButton instances for styling purposes.
const string ElementValidationClass = "uso-field-validation"
 CSS class name applied when field validation/status functionality is enabled.

Detailed Description

A custom toolbar button control that extends Unity's ToolbarButton with USO UI framework functionality. Provides enhanced styling, field validation, 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, custom styling through CSS classes, and various initialization options. The control is specifically designed for use within toolbar contexts and provides enhanced functionality beyond the standard Unity ToolbarButton, including action-based initialization and field status management. This control is commonly used for toolbar actions, commands, and interactive elements within the USO framework.

Constructor & Destructor Documentation

◆ UsoToolbarButton() [1/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( )

Initializes a new instance of the UsoToolbarButton class with default settings. Creates a toolbar button with USO framework integration enabled.

◆ UsoToolbarButton() [2/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( string fieldName)

Initializes a new instance of the UsoToolbarButton class with the specified field name. Creates a toolbar button with custom identification for binding and reference purposes.

Parameters
fieldNameThe name to assign to this toolbar button element.

◆ UsoToolbarButton() [3/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( string fieldName,
out UsoToolbarButton newField )

Initializes a new instance of the UsoToolbarButton class with field name and returns a reference. Creates a toolbar button with custom identification and provides an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this toolbar button element.
newFieldOutput parameter that receives a reference to the newly created toolbar button.

◆ UsoToolbarButton() [4/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( string fieldName,
string fieldText )

Initializes a new instance of the UsoToolbarButton class with field name and display text. Creates a toolbar button with custom identification and text content for user interface clarity.

Parameters
fieldNameThe name to assign to this toolbar button element.
fieldTextThe text to display on the toolbar button.

◆ UsoToolbarButton() [5/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( string fieldName,
string fieldText,
out UsoToolbarButton newField )

Initializes a new instance of the UsoToolbarButton class with field name, display text, and returns a reference. Creates a toolbar button with custom identification, text content, and provides an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this toolbar button element.
fieldTextThe text to display on the toolbar button.
newFieldOutput parameter that receives a reference to the newly created toolbar button.

◆ UsoToolbarButton() [6/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( Action btnAction)

Initializes a new instance of the UsoToolbarButton class with a click action callback. Creates a toolbar button with predefined click behavior and USO framework integration.

Parameters
btnActionThe action to execute when the toolbar button is clicked.

◆ UsoToolbarButton() [7/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( string fieldName,
Action btnAction )

Initializes a new instance of the UsoToolbarButton class with field name and a click action callback. Creates a toolbar button with custom identification, predefined click behavior, and USO framework integration.

Parameters
fieldNameThe name to assign to this toolbar button element.
btnActionThe action to execute when the toolbar button is clicked.

◆ UsoToolbarButton() [8/8]

GWG.UsoUIElements.UsoToolbarButton.UsoToolbarButton ( string fieldName,
Action btnAction,
out UsoToolbarButton newField )

Initializes a new instance of the UsoToolbarButton class with field name, click action, and returns a reference. Creates a toolbar button with custom identification, predefined click behavior, and provides an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this toolbar button element.
btnActionThe action to execute when the toolbar button is clicked.
newFieldOutput parameter that receives a reference to the newly created toolbar button.

Member Function Documentation

◆ GetParentLineItem()

UsoLineItem GWG.UsoUIElements.UsoToolbarButton.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.UsoToolbarButton.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.

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

Implements GWG.UsoUIElements.IUsoUiElement.

◆ SetFieldStatus()

void GWG.UsoUIElements.UsoToolbarButton.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.UsoToolbarButton.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

◆ _fieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoToolbarButton._fieldStatus
private

Private backing field for the FieldStatus property.

◆ _fieldStatusEnabled

bool GWG.UsoUIElements.UsoToolbarButton._fieldStatusEnabled
private

Private backing field for the FieldStatusEnabled property.

◆ DefaultBindProp

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

Default binding property used when applying data bindings to this field. Currently set to "value" for potential future binding scenarios.

◆ ElementStylesheet

const string GWG.UsoUIElements.UsoToolbarButton.ElementStylesheet = "uso-toolbar-button"
staticprivate

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

◆ ElementValidationClass

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

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

Property Documentation

◆ FieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoToolbarButton.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.UsoToolbarButton.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 false.

Implements GWG.UsoUIElements.IUsoUiElement.