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

A custom image control that extends Unity's Image 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.UsoImage:

Public Member Functions

 UsoImage ()
 Initializes a new instance of the UsoImage class with default settings. Creates an empty image with USO framework integration enabled.
 UsoImage (string fieldName, string bindingPath, BindingMode bindingMode, out UsoImage newField)
 Initializes a new instance of the UsoImage class with field name, data binding, and returns a reference. Creates an image with custom identification, automatic data binding, and provides an out parameter for immediate access.
 UsoImage (string fieldName, string bindingPath, BindingMode bindingMode=BindingMode.ToTarget)
 Initializes a new instance of the UsoImage class with field name and data binding configuration. Creates an image with custom identification and automatic data binding, without initial texture content.
 UsoImage (string fieldName, Texture2D viewImage)
 Initializes a new instance of the UsoImage class with field name and texture. Creates an image with custom identification and pre-loaded texture content.
 UsoImage (string fieldName, Texture2D viewImage, out UsoImage newField)
 Initializes a new instance of the UsoImage class with field name, texture, and returns a reference. Creates an image with custom identification, texture content, and provides an out parameter for immediate access.
 UsoImage (string fieldName, Texture2D viewImage, string bindingPath, BindingMode bindingMode, out UsoImage newField)
 Initializes a new instance of the UsoImage class with complete configuration including texture, binding, and reference output. Creates a fully configured image with custom identification, initial texture, automatic data binding, and immediate access to the created instance.
 UsoImage (string fieldName, Texture2D viewImage, string bindingPath, BindingMode bindingMode=BindingMode.ToTarget)
 Initializes a new instance of the UsoImage class with field name, texture, and data binding configuration. Creates a fully configured image with custom identification, initial texture, and automatic data binding.
 UsoImage (Texture2D viewImage)
 Initializes a new instance of the UsoImage class with the specified texture. Creates an image pre-loaded with the provided texture content.
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.
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.
Texture Image [get, set]
 Gets or sets the texture displayed in the image control. This property provides a convenient wrapper around the base image property for UXML attribute binding.

Private Attributes

FieldStatusTypes _fieldStatus
bool _fieldStatusEnabled = true

Static Private Attributes

const string DefaultBindProp = "image"
 Default binding property used when applying data bindings to this field. Binds to the 'image' property which controls the displayed texture content.
const string ElementClass = "uso-image"
 CSS class name applied to all UsoImage 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 image control that extends Unity's Image 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 for texture content, and custom styling through CSS classes. The control includes a convenient Image property wrapper for UXML attribute binding and supports various constructor overloads for different initialization scenarios including texture assignment and data binding configuration.

Constructor & Destructor Documentation

◆ UsoImage() [1/8]

GWG.UsoUIElements.UsoImage.UsoImage ( )

Initializes a new instance of the UsoImage class with default settings. Creates an empty image with USO framework integration enabled.

◆ UsoImage() [2/8]

GWG.UsoUIElements.UsoImage.UsoImage ( Texture2D viewImage)

Initializes a new instance of the UsoImage class with the specified texture. Creates an image pre-loaded with the provided texture content.

Parameters
viewImageThe Texture2D to display in the image control.

◆ UsoImage() [3/8]

GWG.UsoUIElements.UsoImage.UsoImage ( string fieldName,
Texture2D viewImage )

Initializes a new instance of the UsoImage class with field name and texture. Creates an image with custom identification and pre-loaded texture content.

Parameters
fieldNameThe name to assign to this image element.
viewImageThe Texture2D to display in the image control.

◆ UsoImage() [4/8]

GWG.UsoUIElements.UsoImage.UsoImage ( string fieldName,
Texture2D viewImage,
out UsoImage newField )

Initializes a new instance of the UsoImage class with field name, texture, and returns a reference. Creates an image with custom identification, texture content, and provides an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this image element.
viewImageThe Texture2D to display in the image control.
newFieldOutput parameter that receives a reference to the newly created image.

◆ UsoImage() [5/8]

GWG.UsoUIElements.UsoImage.UsoImage ( string fieldName,
Texture2D viewImage,
string bindingPath,
BindingMode bindingMode = BindingMode::ToTarget )

Initializes a new instance of the UsoImage class with field name, texture, and data binding configuration. Creates a fully configured image with custom identification, initial texture, and automatic data binding.

Parameters
fieldNameThe name to assign to this image element.
viewImageThe Texture2D to display initially in the image control.
bindingPathThe path to the data source property for automatic binding.
bindingModeThe binding mode that controls data flow between source and target. Default is ToTarget.

◆ UsoImage() [6/8]

GWG.UsoUIElements.UsoImage.UsoImage ( string fieldName,
string bindingPath,
BindingMode bindingMode = BindingMode::ToTarget )

Initializes a new instance of the UsoImage class with field name and data binding configuration. Creates an image with custom identification and automatic data binding, without initial texture content.

Parameters
fieldNameThe name to assign to this image element.
bindingPathThe path to the data source property for automatic binding.
bindingModeThe binding mode that controls data flow between source and target. Default is ToTarget.

◆ UsoImage() [7/8]

GWG.UsoUIElements.UsoImage.UsoImage ( string fieldName,
string bindingPath,
BindingMode bindingMode,
out UsoImage newField )

Initializes a new instance of the UsoImage class with field name, data binding, and returns a reference. Creates an image with custom identification, automatic data binding, and provides an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this image element.
bindingPathThe path to the data source property for automatic binding.
bindingModeThe binding mode that controls data flow between source and target.
newFieldOutput parameter that receives a reference to the newly created image.

◆ UsoImage() [8/8]

GWG.UsoUIElements.UsoImage.UsoImage ( string fieldName,
Texture2D viewImage,
string bindingPath,
BindingMode bindingMode,
out UsoImage newField )

Initializes a new instance of the UsoImage class with complete configuration including texture, binding, and reference output. Creates a fully configured image with custom identification, initial texture, automatic data binding, and immediate access to the created instance.

Parameters
fieldNameThe name to assign to this image element.
viewImageThe Texture2D to display initially in the image control.
bindingPathThe path to the data source property for automatic binding.
bindingModeThe binding mode that controls data flow between source and target.
newFieldOutput parameter that receives a reference to the newly created image.

Member Function Documentation

◆ ApplyBinding()

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

◆ _fieldStatusEnabled

bool GWG.UsoUIElements.UsoImage._fieldStatusEnabled = true
private

◆ DefaultBindProp

const string GWG.UsoUIElements.UsoImage.DefaultBindProp = "image"
staticprivate

Default binding property used when applying data bindings to this field. Binds to the 'image' property which controls the displayed texture content.

◆ ElementClass

const string GWG.UsoUIElements.UsoImage.ElementClass = "uso-image"
staticprivate

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

◆ ElementValidationClass

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

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

Property Documentation

◆ FieldStatus

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

◆ Image

Texture GWG.UsoUIElements.UsoImage.Image
getset

Gets or sets the texture displayed in the image control. This property provides a convenient wrapper around the base image property for UXML attribute binding.

The Texture to display in the image control. Can be null to display no image.