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

A custom line item container element that extends Unity's VisualElement with USO UI framework functionality and hierarchical organization capabilities. Provides enhanced styling, field validation, data binding capabilities, validation state management, and integration with the USO UI system for structured content organization. More...

Inheritance diagram for GWG.UsoUIElements.UsoLineItem:

Public Member Functions

 UsoLineItem ()
 Initializes a new instance of the UsoLineItem class with default settings. Creates a line item container with USO framework integration and validation functionality enabled.
 UsoLineItem (string fieldName)
 Initializes a new instance of the UsoLineItem class with the specified field name. Creates a line item container with custom identification for binding and reference purposes.
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.
List< UsoLineItemGetChildLineItems ()
 Retrieves a list of direct child UsoLineItem elements within this line item's hierarchy. This method provides access to nested line item structures for validation coordination and hierarchical management.
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 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.
bool IsValidated [get, set]
 Gets or sets a value indicating whether this line item has passed validation checks. This property is used for tracking validation state within forms and structured layouts.

Private Attributes

FieldStatusTypes _fieldStatus
bool _fieldStatusEnabled = true

Static Private Attributes

const string DefaultBindProp = ""
 Default binding property used when applying data bindings to this field. Currently set to empty string as line items typically manage child element bindings rather than direct values.
const string ElementClass = "uso-line-item"
 CSS class name applied to all UsoLineItem 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 line item container element that extends Unity's VisualElement with USO UI framework functionality and hierarchical organization capabilities. Provides enhanced styling, field validation, data binding capabilities, validation state management, and integration with the USO UI system for structured content organization.

This control implements the IUsoUiElement interface to provide consistent behavior across the USO UI framework. It supports field status indicators, automatic data binding capabilities, and custom styling through CSS classes. The control serves as a fundamental organizational unit within the USO framework, designed for creating structured layouts with hierarchical relationships between form elements and content sections. It includes validation state tracking through the IsValidated property and provides methods for querying child line item relationships within the UI hierarchy. Line items are commonly used as containers for form rows, content sections, and organizational groupings that require consistent styling and validation management throughout the application. The control enables nested line item structures for complex UI organizations while maintaining framework consistency and parent-child relationship management.

Constructor & Destructor Documentation

◆ UsoLineItem() [1/2]

GWG.UsoUIElements.UsoLineItem.UsoLineItem ( )

Initializes a new instance of the UsoLineItem class with default settings. Creates a line item container with USO framework integration and validation functionality enabled.

◆ UsoLineItem() [2/2]

GWG.UsoUIElements.UsoLineItem.UsoLineItem ( string fieldName)

Initializes a new instance of the UsoLineItem class with the specified field name. Creates a line item container with custom identification for binding and reference purposes.

Parameters
fieldNameThe name to assign to this line item element.

Member Function Documentation

◆ ApplyBinding()

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

While line items typically manage child element bindings, this method enables binding to container-level properties such as visibility, validation states, or other organizational characteristics.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ GetChildLineItems()

List< UsoLineItem > GWG.UsoUIElements.UsoLineItem.GetChildLineItems ( )

Retrieves a list of direct child UsoLineItem elements within this line item's hierarchy. This method provides access to nested line item structures for validation coordination and hierarchical management.

Returns
A List<UsoLineItem> containing all direct child line items, excluding this line item itself.

This method performs a query to find all child UsoLineItem elements and filters out the current instance to prevent self-inclusion in the results. It's useful for implementing hierarchical validation systems, cascading style applications, and organizational operations that need to work with nested line item structures. The method only returns direct children and does not perform recursive searches through deeper nested levels.

◆ GetParentLineItem()

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

Returns
The parent UsoLineItem if found; otherwise, null.

This method enables hierarchical line item relationships, allowing child line items to access their parent containers for validation coordination, styling inheritance, and organizational purposes.

◆ InitElement()

void GWG.UsoUIElements.UsoLineItem.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.UsoLineItem.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.UsoLineItem.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.UsoLineItem._fieldStatus
private

◆ _fieldStatusEnabled

bool GWG.UsoUIElements.UsoLineItem._fieldStatusEnabled = true
private

◆ DefaultBindProp

const string GWG.UsoUIElements.UsoLineItem.DefaultBindProp = ""
staticprivate

Default binding property used when applying data bindings to this field. Currently set to empty string as line items typically manage child element bindings rather than direct values.

◆ ElementClass

const string GWG.UsoUIElements.UsoLineItem.ElementClass = "uso-line-item"
staticprivate

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

◆ ElementValidationClass

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

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

Property Documentation

◆ FieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoLineItem.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.UsoLineItem.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 for line items.

Unlike some other USO container elements, line items have field status functionality enabled by default since they commonly participate in validation scenarios and form organization.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ IsValidated

bool GWG.UsoUIElements.UsoLineItem.IsValidated
getset

Gets or sets a value indicating whether this line item has passed validation checks. This property is used for tracking validation state within forms and structured layouts.

True if the line item and its contents have been validated successfully; otherwise, false.

This property provides a way to track validation state at the line item level, enabling form validation systems to coordinate validation results across hierarchical content structures. It can be used in conjunction with field status indicators to provide comprehensive validation feedback.