Class Slider<TValue, TScalar, TInputField>
Base class for Sliders (SliderFloat, SliderInt).
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public abstract class Slider<TValue, TScalar, TInputField> : BaseSlider<TValue, TScalar>, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder, IInputElement<TValue>, IValidatableElement<TValue>, INotifyValueChanging<TValue>, INotifyValueChanged<TValue>, IFormattable<TScalar> where TScalar : unmanaged where TInputField : VisualElement, IValidatableElement<TValue>, IFormattable<TScalar>, new()
Type Parameters
Name | Description |
---|---|
TValue | The final value type. |
TScalar | The thumb single value type. |
TInputField | The input field type. |
Constructors
Slider()
Default constructor.
Declaration
protected Slider()
Fields
inputFieldUssClassName
The USS class name for the input field.
Declaration
public const string inputFieldUssClassName = "appui-slider__input-field"
Field Value
Type | Description |
---|---|
string |
m_InputField
The Input field element of the slider.
Declaration
protected readonly TInputField m_InputField
Field Value
Type | Description |
---|---|
TInputField |
m_MarkContainer
The Mark container element of the slider. This is populated with marks elements based on the step value or the custom marks.
Declaration
protected readonly VisualElement m_MarkContainer
Field Value
Type | Description |
---|---|
VisualElement |
m_ProgressContainer
The Progress container element of the slider. This is populated with 3 progress elements to support the track display mode.
Declaration
protected readonly VisualElement m_ProgressContainer
Field Value
Type | Description |
---|---|
VisualElement |
m_SliderControl
The Slider control element.
Declaration
protected readonly VisualElement m_SliderControl
Field Value
Type | Description |
---|---|
VisualElement |
m_ThumbsContainer
The Thumbs container element of the slider. This is populated with thumb elements based on the thumb count.
Declaration
protected readonly VisualElement m_ThumbsContainer
Field Value
Type | Description |
---|---|
VisualElement |
m_TrackElement
The Track element of the slider. By default, this element is empty.
Declaration
protected readonly VisualElement m_TrackElement
Field Value
Type | Description |
---|---|
VisualElement |
markContainerUssClassName
The USS class name for the mark container.
Declaration
public const string markContainerUssClassName = "appui-slider__mark-container"
Field Value
Type | Description |
---|---|
string |
markLabelUssClassName
The USS class name for the mark label.
Declaration
public const string markLabelUssClassName = "appui-slider__mark-label"
Field Value
Type | Description |
---|---|
string |
markUssClassName
The USS class name for the mark.
Declaration
public const string markUssClassName = "appui-slider__mark"
Field Value
Type | Description |
---|---|
string |
progressContainerUssClassName
The USS class name for the progress container.
Declaration
public const string progressContainerUssClassName = "appui-slider__progress-container"
Field Value
Type | Description |
---|---|
string |
progressUssClassName
The USS class name for the progress element.
Declaration
public const string progressUssClassName = "appui-slider__progress"
Field Value
Type | Description |
---|---|
string |
showMarksUssClassName
The show marks variant USS class name.
Declaration
public const string showMarksUssClassName = "appui-slider--show-marks"
Field Value
Type | Description |
---|---|
string |
sliderControlUssClassName
The USS class name for the slider control.
Declaration
public const string sliderControlUssClassName = "appui-slider__slider-control"
Field Value
Type | Description |
---|---|
string |
thumbUssClassName
The USS class name for the thumb.
Declaration
public const string thumbUssClassName = "appui-slider__thumb"
Field Value
Type | Description |
---|---|
string |
thumbsContainerUssClassName
The USS class name for the thumbs container.
Declaration
public const string thumbsContainerUssClassName = "appui-slider__thumbs-container"
Field Value
Type | Description |
---|---|
string |
trackDisplayVariantUssClassName
The track display type variant USS class name.
Declaration
public const string trackDisplayVariantUssClassName = "appui-slider--track-"
Field Value
Type | Description |
---|---|
string |
trackUssClassName
The USS class name for the track.
Declaration
public const string trackUssClassName = "appui-slider__track"
Field Value
Type | Description |
---|---|
string |
ussClassName
The USS class name for the slider.
Declaration
public const string ussClassName = "appui-slider"
Field Value
Type | Description |
---|---|
string |
valueDisplayVariantUssClassName
The show marks label variant USS class name.
Declaration
public const string valueDisplayVariantUssClassName = "appui-slider--value-display-"
Field Value
Type | Description |
---|---|
string |
variantUssClassName
The orientation variant USS class name.
Declaration
public const string variantUssClassName = "appui-slider--"
Field Value
Type | Description |
---|---|
string |
Properties
contentContainer
The content container of this element.
Declaration
public override VisualElement contentContainer { get; }
Property Value
Type | Description |
---|---|
VisualElement |
Overrides
customMarks
The custom marks to display on the slider.
Declaration
public IList<SliderMark<TScalar>> customMarks { get; set; }
Property Value
Type | Description |
---|---|
IList<SliderMark<TScalar>> |
displayValueLabel
The mode to display the value of the slider.
Declaration
public ValueDisplayMode displayValueLabel { get; set; }
Property Value
Type | Description |
---|---|
ValueDisplayMode |
restrictedValues
The policy to restrict the values of the slider.
Declaration
public RestrictedValuesPolicy restrictedValues { get; set; }
Property Value
Type | Description |
---|---|
RestrictedValuesPolicy |
scale
Handler to scale the value of the slider thumbs and marks.
Declaration
public Slider<TValue, TScalar, TInputField>.ScaleHandler scale { get; set; }
Property Value
Type | Description |
---|---|
Slider<TValue, TScalar, TInputField>.ScaleHandler |
showInputField
Whether to show the input field.
Declaration
public bool showInputField { get; set; }
Property Value
Type | Description |
---|---|
bool |
showMarks
Whether to show the marks on the slider. If no custom marks are set, the marks are generated based on the step value.
Declaration
public bool showMarks { get; set; }
Property Value
Type | Description |
---|---|
bool |
showMarksLabel
Whether to show the marks labels on the slider.
Declaration
public bool showMarksLabel { get; set; }
Property Value
Type | Description |
---|---|
bool |
track
The mode to display the track of the slider.
Declaration
public TrackDisplayType track { get; set; }
Property Value
Type | Description |
---|---|
TrackDisplayType |
Methods
ComputeValueFromDrag(Draggable)
Returns the value to set as slider value based on a given dragger position.
Declaration
protected override TValue ComputeValueFromDrag(Draggable dragger)
Parameters
Type | Name | Description |
---|---|---|
Draggable | dragger | The dragger manipulator. |
Returns
Type | Description |
---|---|
TValue | The value to set as slider value based on a given dragger position. |
Overrides
GetClampedValue(TValue)
Declaration
protected override TValue GetClampedValue(TValue newValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | newValue | The value to clamp. |
Returns
Type | Description |
---|---|
TValue | The clamped value. |
Overrides
Remarks
The method also checks if low and high values are inverted.
GetOrientationClassName(Direction)
Declaration
public static string GetOrientationClassName(Direction enumValue)
Parameters
Type | Name | Description |
---|---|---|
Direction | enumValue |
Returns
Type | Description |
---|---|
string |
GetTrackDisplayTypeUssClassName(TrackDisplayType)
Declaration
public static string GetTrackDisplayTypeUssClassName(TrackDisplayType enumValue)
Parameters
Type | Name | Description |
---|---|---|
TrackDisplayType | enumValue |
Returns
Type | Description |
---|---|
string |
GetTrackElement()
Get the element that represent the entire track of the slider.
Declaration
protected override VisualElement GetTrackElement()
Returns
Type | Description |
---|---|
VisualElement | The element that represent the entire track of the slider. |
Overrides
GetValueDisplayModeUssClassName(ValueDisplayMode)
Declaration
public static string GetValueDisplayModeUssClassName(ValueDisplayMode enumValue)
Parameters
Type | Name | Description |
---|---|---|
ValueDisplayMode | enumValue |
Returns
Type | Description |
---|---|
string |
KeyDecrement(TScalar, TScalar, KeyDownEvent)
Decrement the value of the slider on a specific thumb.
Declaration
protected override TScalar KeyDecrement(TScalar baseValue, TScalar stepValue, KeyDownEvent evt)
Parameters
Type | Name | Description |
---|---|---|
TScalar | baseValue | The base value to decrement. |
TScalar | stepValue | The decrement step value. |
KeyDownEvent | evt | The key down event. |
Returns
Type | Description |
---|---|
TScalar | The decremented value. |
Overrides
KeyIncrement(TScalar, TScalar, KeyDownEvent)
Increment the value of the slider on a specific thumb.
Declaration
protected override TScalar KeyIncrement(TScalar baseValue, TScalar stepValue, KeyDownEvent evt)
Parameters
Type | Name | Description |
---|---|---|
TScalar | baseValue | The base value to increment. |
TScalar | stepValue | The increment step value. |
KeyDownEvent | evt | The key down event. |
Returns
Type | Description |
---|---|
TScalar | The incremented value. |
Overrides
OnTrackDown(Draggable)
Event callback called when a pointer down event is received.
Declaration
protected override void OnTrackDown(Draggable dragger)
Parameters
Type | Name | Description |
---|---|---|
Draggable | dragger | The dragger manipulator. |
Overrides
OnTrackUp(Draggable)
Event callback called when a pointer up event is received.
Declaration
protected override void OnTrackUp(Draggable dragger)
Parameters
Type | Name | Description |
---|---|---|
Draggable | dragger | The dragger manipulator. |
Overrides
RefreshUI()
Refresh the UI of the slider. This is usually called during SetValueWithoutNotify(TValue) or directly in a setter of a bound property.
Declaration
protected virtual void RefreshUI()
SetOrientation(Direction)
Called when the orientation of the slider has changed.
Declaration
protected override void SetOrientation(Direction newValue)
Parameters
Type | Name | Description |
---|---|---|
Direction | newValue | The new orientation value. |
Overrides
SetStep(TScalar)
Set the step value of the slider.
Declaration
protected override void SetStep(TScalar newStep)
Parameters
Type | Name | Description |
---|---|---|
TScalar | newStep | The new step value. |
Overrides
SetValueWithoutNotify(TValue)
Set the value of the slider without sending any event.
Declaration
public override void SetValueWithoutNotify(TValue newValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | newValue | The new value of the slider. |