UTKIntPropertyItemView, UTKIntRangePropertyItemView UTKNumberStepper 적용
This commit is contained in:
@@ -4,8 +4,10 @@
|
|||||||
<utk:UTKLabel name="label" text="Label" class="utk-property-item-view__label" />
|
<utk:UTKLabel name="label" text="Label" class="utk-property-item-view__label" />
|
||||||
<ui:VisualElement name="value-container" class="utk-property-item-view__value">
|
<ui:VisualElement name="value-container" class="utk-property-item-view__value">
|
||||||
<utk:UTKIntegerField name="min-field" class="utk-property-item-view__field" />
|
<utk:UTKIntegerField name="min-field" class="utk-property-item-view__field" />
|
||||||
|
<utk:UTKNumberStepper name="min-stepper" class="utk-property-item-view__stepper" />
|
||||||
<utk:UTKLabel text="~" class="utk-property-item-view__range-separator" />
|
<utk:UTKLabel text="~" class="utk-property-item-view__range-separator" />
|
||||||
<utk:UTKIntegerField name="max-field" class="utk-property-item-view__field" />
|
<utk:UTKIntegerField name="max-field" class="utk-property-item-view__field" />
|
||||||
|
<utk:UTKNumberStepper name="max-stepper" class="utk-property-item-view__stepper" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -9,6 +9,14 @@
|
|||||||
|
|
||||||
.utk-property-item-view--int-range .utk-property-item-view__field {
|
.utk-property-item-view--int-range .utk-property-item-view__field {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.utk-property-item-view--int-range .utk-property-item-view__stepper {
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
flex-basis: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.utk-property-item-view--int-range .utk-property-item-view__range-separator {
|
.utk-property-item-view--int-range .utk-property-item-view__range-separator {
|
||||||
|
|||||||
@@ -180,17 +180,13 @@ namespace UVC.Sample.UIToolkit
|
|||||||
entries.Add(new UTKDatePropertyItem("date", "Date", DateTime.Today));
|
entries.Add(new UTKDatePropertyItem("date", "Date", DateTime.Today));
|
||||||
|
|
||||||
// Date (읽기 전용)
|
// Date (읽기 전용)
|
||||||
var roDate = new UTKDatePropertyItem("date_ro", "Date (RO)", DateTime.Today.AddDays(7));
|
entries.Add(new UTKDatePropertyItem("date_ro", "Date (RO)", DateTime.Today.AddDays(7), true));
|
||||||
roDate.IsReadOnly = true;
|
|
||||||
entries.Add(roDate);
|
|
||||||
|
|
||||||
// DateTime (편집 가능)
|
// DateTime (편집 가능)
|
||||||
entries.Add(new UTKDateTimePropertyItem("datetime", "DateTime", DateTime.Now));
|
entries.Add(new UTKDateTimePropertyItem("datetime", "DateTime", DateTime.Now));
|
||||||
|
|
||||||
// DateTime (읽기 전용)
|
// DateTime (읽기 전용)
|
||||||
var roDateTime = new UTKDateTimePropertyItem("datetime_ro", "DateTime (RO)", DateTime.Now.AddHours(1));
|
entries.Add(new UTKDateTimePropertyItem("datetime_ro", "DateTime (RO)", DateTime.Now.AddHours(1), true));
|
||||||
roDateTime.IsReadOnly = true;
|
|
||||||
entries.Add(roDateTime);
|
|
||||||
|
|
||||||
// DateRange (편집 가능)
|
// DateRange (편집 가능)
|
||||||
entries.Add(new UTKDateRangePropertyItem("daterange", "DateRange",
|
entries.Add(new UTKDateRangePropertyItem("daterange", "DateRange",
|
||||||
@@ -244,9 +240,13 @@ namespace UVC.Sample.UIToolkit
|
|||||||
entries.Add(new UTKIntRangePropertyItem("intrange", "IntRange", 10, 90));
|
entries.Add(new UTKIntRangePropertyItem("intrange", "IntRange", 10, 90));
|
||||||
|
|
||||||
// IntRange (읽기 전용)
|
// IntRange (읽기 전용)
|
||||||
var roIntRange = new UTKIntRangePropertyItem("intrange_ro", "IntRange (RO)", 20, 80);
|
entries.Add(new UTKIntRangePropertyItem("intrange_ro", "IntRange (RO)", 20, 80, isReadOnly: true));
|
||||||
roIntRange.IsReadOnly = true;
|
|
||||||
entries.Add(roIntRange);
|
// IntRange (편집 가능)
|
||||||
|
entries.Add(new UTKIntRangePropertyItem("intrange2", "IntRange2", 10, 90, useStepper: true));
|
||||||
|
|
||||||
|
// IntRange (읽기 전용)
|
||||||
|
entries.Add(new UTKIntRangePropertyItem("intrange2_ro", "IntRange2 (RO)", 20, 80, useStepper: true, isReadOnly: true));
|
||||||
|
|
||||||
// FloatRange (편집 가능)
|
// FloatRange (편집 가능)
|
||||||
entries.Add(new UTKFloatRangePropertyItem("floatrange", "FloatRange", 1.5f, 8.5f));
|
entries.Add(new UTKFloatRangePropertyItem("floatrange", "FloatRange", 1.5f, 8.5f));
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ namespace UVC.UIToolkit
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
private string _dateFormat = "yyyy-MM-dd";
|
private string _dateFormat = "yyyy-MM-dd";
|
||||||
|
private DateTime _minDay = DateTime.MinValue;
|
||||||
|
private DateTime _maxDay = DateTime.MaxValue;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
@@ -23,6 +25,20 @@ namespace UVC.UIToolkit
|
|||||||
get => _dateFormat;
|
get => _dateFormat;
|
||||||
set => _dateFormat = value ?? "yyyy-MM-dd";
|
set => _dateFormat = value ?? "yyyy-MM-dd";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>최소 날짜</summary>
|
||||||
|
public DateTime MinDay
|
||||||
|
{
|
||||||
|
get => _minDay;
|
||||||
|
set => _minDay = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>최대 날짜</summary>
|
||||||
|
public DateTime MaxDay
|
||||||
|
{
|
||||||
|
get => _maxDay;
|
||||||
|
set => _maxDay = value;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
@@ -36,6 +52,25 @@ namespace UVC.UIToolkit
|
|||||||
public UTKDatePropertyItem(string id, string name, DateTime initialValue = default, bool isReadOnly = false)
|
public UTKDatePropertyItem(string id, string name, DateTime initialValue = default, bool isReadOnly = false)
|
||||||
: base(id, name, initialValue == default ? DateTime.Today : initialValue)
|
: base(id, name, initialValue == default ? DateTime.Today : initialValue)
|
||||||
{
|
{
|
||||||
|
_minDay = DateTime.MinValue;
|
||||||
|
_maxDay = DateTime.MaxValue;
|
||||||
|
IsReadOnly = isReadOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 날짜 속성을 생성합니다 (날짜 제한 포함).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">고유 ID</param>
|
||||||
|
/// <param name="name">표시 이름</param>
|
||||||
|
/// <param name="initialValue">초기 값</param>
|
||||||
|
/// <param name="minDay">최소 날짜 (null이면 제한 없음)</param>
|
||||||
|
/// <param name="maxDay">최대 날짜 (null이면 제한 없음)</param>
|
||||||
|
/// <param name="isReadOnly">읽기 전용 여부</param>
|
||||||
|
public UTKDatePropertyItem(string id, string name, DateTime initialValue, DateTime? minDay, DateTime? maxDay, bool isReadOnly = false)
|
||||||
|
: base(id, name, initialValue == default ? DateTime.Today : initialValue)
|
||||||
|
{
|
||||||
|
_minDay = minDay ?? DateTime.MinValue;
|
||||||
|
_maxDay = maxDay ?? DateTime.MaxValue;
|
||||||
IsReadOnly = isReadOnly;
|
IsReadOnly = isReadOnly;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace UVC.UIToolkit
|
|||||||
/// <param name="maxValue">최대값</param>
|
/// <param name="maxValue">최대값</param>
|
||||||
/// <param name="useSlider">슬라이더 사용 여부</param>
|
/// <param name="useSlider">슬라이더 사용 여부</param>
|
||||||
/// <param name="isReadOnly">읽기 전용 여부</param>
|
/// <param name="isReadOnly">읽기 전용 여부</param>
|
||||||
public UTKFloatPropertyItem(string id, string name, float initialValue, float minValue, float maxValue, bool useSlider = true, bool isReadOnly = false)
|
public UTKFloatPropertyItem(string id, string name, float initialValue, float minValue = float.MinValue, float maxValue = float.MaxValue, bool useSlider = true, bool isReadOnly = false)
|
||||||
: base(id, name, initialValue)
|
: base(id, name, initialValue)
|
||||||
{
|
{
|
||||||
_minValue = minValue;
|
_minValue = minValue;
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ namespace UVC.UIToolkit
|
|||||||
#region Fields
|
#region Fields
|
||||||
private bool _useSlider;
|
private bool _useSlider;
|
||||||
private bool _useStepper;
|
private bool _useStepper;
|
||||||
private int _minValue;
|
private int _minValue = int.MinValue;
|
||||||
private int _maxValue = 100;
|
private int _maxValue = int.MaxValue;
|
||||||
private int _step = 1;
|
private int _step = 1;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -28,8 +28,6 @@ namespace UVC.UIToolkit
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_useSlider = value;
|
_useSlider = value;
|
||||||
// UseSlider가 true이면 UseStepper는 false로
|
|
||||||
if (value) _useStepper = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,8 +38,6 @@ namespace UVC.UIToolkit
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_useStepper = value;
|
_useStepper = value;
|
||||||
// UseStepper가 true이면 UseSlider는 false로
|
|
||||||
if (value) _useSlider = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace UVC.UIToolkit
|
namespace UVC.UIToolkit
|
||||||
{
|
{
|
||||||
@@ -8,14 +9,52 @@ namespace UVC.UIToolkit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class UTKIntRangePropertyItem : UTKPropertyItemBase<UTKIntRange>
|
public class UTKIntRangePropertyItem : UTKPropertyItemBase<UTKIntRange>
|
||||||
{
|
{
|
||||||
|
#region Fields
|
||||||
|
private bool _useStepper;
|
||||||
|
private int _stepperMinValue = int.MinValue;
|
||||||
|
private int _stepperMaxValue = int.MaxValue;
|
||||||
|
private int _stepperStep = 1;
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
/// <summary>속성 타입</summary>
|
/// <summary>속성 타입</summary>
|
||||||
public override UTKPropertyType PropertyType => UTKPropertyType.IntRange;
|
public override UTKPropertyType PropertyType => UTKPropertyType.IntRange;
|
||||||
|
|
||||||
|
/// <summary>스테퍼(증감 버튼) 사용 여부</summary>
|
||||||
|
public bool UseStepper
|
||||||
|
{
|
||||||
|
get => _useStepper;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_useStepper = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>스테퍼 증감 단위 (기본값: 1)</summary>
|
||||||
|
public int StepperStep
|
||||||
|
{
|
||||||
|
get => _stepperStep;
|
||||||
|
set => _stepperStep = Math.Max(1, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>스테퍼 최소값</summary>
|
||||||
|
public int StepperMinValue
|
||||||
|
{
|
||||||
|
get => _stepperMinValue;
|
||||||
|
set => _stepperMinValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>스테퍼 최대값</summary>
|
||||||
|
public int StepperMaxValue
|
||||||
|
{
|
||||||
|
get => _stepperMaxValue;
|
||||||
|
set => _stepperMaxValue = value;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 정수 범위 속성을 생성합니다.
|
/// 정수 범위 속성을 생성합니다 (필드 모드).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">고유 ID</param>
|
/// <param name="id">고유 ID</param>
|
||||||
/// <param name="name">표시 이름</param>
|
/// <param name="name">표시 이름</param>
|
||||||
@@ -34,10 +73,39 @@ namespace UVC.UIToolkit
|
|||||||
/// <param name="name">표시 이름</param>
|
/// <param name="name">표시 이름</param>
|
||||||
/// <param name="min">최소값</param>
|
/// <param name="min">최소값</param>
|
||||||
/// <param name="max">최대값</param>
|
/// <param name="max">최대값</param>
|
||||||
|
/// <param name="stepperStep">스테퍼 증감 단위</param>
|
||||||
|
/// <param name="stepperMinValue">스테퍼 최소값</param>
|
||||||
|
/// <param name="stepperMaxValue">스테퍼 최대값</param>
|
||||||
|
/// <param name="useStepper">스테퍼 사용 여부</param>
|
||||||
/// <param name="isReadOnly">읽기 전용 여부</param>
|
/// <param name="isReadOnly">읽기 전용 여부</param>
|
||||||
public UTKIntRangePropertyItem(string id, string name, int min, int max, bool isReadOnly = false)
|
public UTKIntRangePropertyItem(string id, string name, int min, int max, int stepperStep = 1, int stepperMinValue = int.MinValue, int stepperMaxValue = int.MaxValue, bool useStepper = false, bool isReadOnly = false)
|
||||||
: base(id, name, new UTKIntRange(min, max))
|
: base(id, name, new UTKIntRange(min, max))
|
||||||
{
|
{
|
||||||
|
_stepperMinValue = stepperMinValue;
|
||||||
|
_stepperMaxValue = stepperMaxValue;
|
||||||
|
_useStepper = useStepper;
|
||||||
|
_stepperStep = stepperStep;
|
||||||
|
IsReadOnly = isReadOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 정수 범위 속성을 생성합니다 (슬라이더/스테퍼 모드).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">고유 ID</param>
|
||||||
|
/// <param name="name">표시 이름</param>
|
||||||
|
/// <param name="initialValue">초기 범위 값</param>
|
||||||
|
/// <param name="stepperStep">스테퍼 증감 단위</param>
|
||||||
|
/// <param name="stepperMinValue">스테퍼 최소값</param>
|
||||||
|
/// <param name="stepperMaxValue">스테퍼 최대값</param>
|
||||||
|
/// <param name="useStepper">스테퍼 사용 여부</param>
|
||||||
|
/// <param name="isReadOnly">읽기 전용 여부</param>
|
||||||
|
public UTKIntRangePropertyItem(string id, string name, UTKIntRange initialValue, int stepperStep = 1, int stepperMinValue = int.MinValue, int stepperMaxValue = int.MaxValue, bool useStepper = false, bool isReadOnly = false)
|
||||||
|
: base(id, name, initialValue)
|
||||||
|
{
|
||||||
|
_stepperMinValue = stepperMinValue;
|
||||||
|
_stepperMaxValue = stepperMaxValue;
|
||||||
|
_useStepper = useStepper;
|
||||||
|
_stepperStep = stepperStep;
|
||||||
IsReadOnly = isReadOnly;
|
IsReadOnly = isReadOnly;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -15,14 +15,70 @@ namespace UVC.UIToolkit
|
|||||||
#region Fields
|
#region Fields
|
||||||
private UTKIntegerField? _minField;
|
private UTKIntegerField? _minField;
|
||||||
private UTKIntegerField? _maxField;
|
private UTKIntegerField? _maxField;
|
||||||
|
private UTKNumberStepper? _minStepper;
|
||||||
|
private UTKNumberStepper? _maxStepper;
|
||||||
|
|
||||||
private UTKIntRange _value;
|
private UTKIntRange _value;
|
||||||
|
private bool _useStepper;
|
||||||
|
private int _stepperMinValue = int.MinValue;
|
||||||
|
private int _stepperMaxValue = int.MaxValue;
|
||||||
|
private int _stepperStep = 1;
|
||||||
private IUTKPropertyItem<UTKIntRange>? _boundData;
|
private IUTKPropertyItem<UTKIntRange>? _boundData;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
protected override string ViewTypeName => "UTKIntRangePropertyItemView";
|
protected override string ViewTypeName => "UTKIntRangePropertyItemView";
|
||||||
|
|
||||||
|
/// <summary>스테퍼(증감 버튼) 사용 여부</summary>
|
||||||
|
public bool UseStepper
|
||||||
|
{
|
||||||
|
get => _useStepper;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_useStepper != value)
|
||||||
|
{
|
||||||
|
_useStepper = value;
|
||||||
|
UpdateModeClass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>스테퍼 최소값</summary>
|
||||||
|
public int StepperMinValue
|
||||||
|
{
|
||||||
|
get => _stepperMinValue;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_stepperMinValue = value;
|
||||||
|
if (_minStepper != null) _minStepper.MinValue = value;
|
||||||
|
if (_maxStepper != null) _maxStepper.MinValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>스테퍼 최대값</summary>
|
||||||
|
public int StepperMaxValue
|
||||||
|
{
|
||||||
|
get => _stepperMaxValue;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_stepperMaxValue = value;
|
||||||
|
if (_minStepper != null) _minStepper.MaxValue = value;
|
||||||
|
if (_maxStepper != null) _maxStepper.MaxValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>스테퍼 증감 단위</summary>
|
||||||
|
public int StepperStep
|
||||||
|
{
|
||||||
|
get => _stepperStep;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_stepperStep = Math.Max(1, value);
|
||||||
|
if (_minStepper != null) _minStepper.Step = _stepperStep;
|
||||||
|
if (_maxStepper != null) _maxStepper.Step = _stepperStep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>현재 값</summary>
|
/// <summary>현재 값</summary>
|
||||||
public UTKIntRange Value
|
public UTKIntRange Value
|
||||||
{
|
{
|
||||||
@@ -94,31 +150,57 @@ namespace UVC.UIToolkit
|
|||||||
{
|
{
|
||||||
_minField = this.Q<UTKIntegerField>("min-field");
|
_minField = this.Q<UTKIntegerField>("min-field");
|
||||||
_maxField = this.Q<UTKIntegerField>("max-field");
|
_maxField = this.Q<UTKIntegerField>("max-field");
|
||||||
|
_minStepper = this.Q<UTKNumberStepper>("min-stepper");
|
||||||
|
_maxStepper = this.Q<UTKNumberStepper>("max-stepper");
|
||||||
|
|
||||||
// Fallback: UXML에서 못 찾으면 생성
|
// Fallback: UXML에서 못 찾으면 생성
|
||||||
if (_valueContainer != null)
|
if (_valueContainer != null)
|
||||||
{
|
{
|
||||||
_valueContainer.style.flexDirection = FlexDirection.Row;
|
_valueContainer.style.flexDirection = FlexDirection.Row;
|
||||||
|
|
||||||
|
// IntegerField 생성
|
||||||
if (_minField == null)
|
if (_minField == null)
|
||||||
{
|
{
|
||||||
_minField = new UTKIntegerField { name = "min-field" };
|
_minField = new UTKIntegerField { name = "min-field" };
|
||||||
_minField.style.flexGrow = 1;
|
_minField.style.flexGrow = 1;
|
||||||
_minField.AddToClassList("utk-property-item-view__field");
|
_minField.AddToClassList("utk-property-item-view__field");
|
||||||
_valueContainer.Add(_minField);
|
_valueContainer.Add(_minField);
|
||||||
|
|
||||||
var separator = new UTKLabel("~", UTKLabel.LabelSize.Body2);
|
|
||||||
separator.AddToClassList("utk-property-item-view__range-separator");
|
|
||||||
_valueContainer.Add(separator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_maxField == null)
|
if (_maxField == null)
|
||||||
{
|
{
|
||||||
|
var separator = new UTKLabel("~", UTKLabel.LabelSize.Body2);
|
||||||
|
separator.AddToClassList("utk-property-item-view__range-separator");
|
||||||
|
_valueContainer.Add(separator);
|
||||||
|
|
||||||
_maxField = new UTKIntegerField { name = "max-field" };
|
_maxField = new UTKIntegerField { name = "max-field" };
|
||||||
_maxField.style.flexGrow = 1;
|
_maxField.style.flexGrow = 1;
|
||||||
_maxField.AddToClassList("utk-property-item-view__field");
|
_maxField.AddToClassList("utk-property-item-view__field");
|
||||||
_valueContainer.Add(_maxField);
|
_valueContainer.Add(_maxField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NumberStepper 생성
|
||||||
|
if (_minStepper == null)
|
||||||
|
{
|
||||||
|
_minStepper = new UTKNumberStepper(_stepperMinValue, _stepperMaxValue, _value.Min, _stepperStep, IsReadOnly)
|
||||||
|
{
|
||||||
|
name = "min-stepper"
|
||||||
|
};
|
||||||
|
_minStepper.style.flexGrow = 1;
|
||||||
|
_minStepper.AddToClassList("utk-property-item-view__stepper");
|
||||||
|
_valueContainer.Add(_minStepper);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_maxStepper == null)
|
||||||
|
{
|
||||||
|
_maxStepper = new UTKNumberStepper(_stepperMinValue, _stepperMaxValue, _value.Max, _stepperStep, IsReadOnly)
|
||||||
|
{
|
||||||
|
name = "max-stepper"
|
||||||
|
};
|
||||||
|
_maxStepper.style.flexGrow = 1;
|
||||||
|
_maxStepper.AddToClassList("utk-property-item-view__stepper");
|
||||||
|
_valueContainer.Add(_maxStepper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 초기 값 설정
|
// 초기 값 설정
|
||||||
@@ -132,6 +214,25 @@ namespace UVC.UIToolkit
|
|||||||
_maxField.SetValueWithoutNotify(_value.Max);
|
_maxField.SetValueWithoutNotify(_value.Max);
|
||||||
_maxField.isReadOnly = IsReadOnly;
|
_maxField.isReadOnly = IsReadOnly;
|
||||||
}
|
}
|
||||||
|
if (_minStepper != null)
|
||||||
|
{
|
||||||
|
_minStepper.MinValue = _stepperMinValue;
|
||||||
|
_minStepper.MaxValue = _stepperMaxValue;
|
||||||
|
_minStepper.Step = _stepperStep;
|
||||||
|
_minStepper.SetValue(_value.Min, false);
|
||||||
|
_minStepper.IsReadOnly = IsReadOnly;
|
||||||
|
}
|
||||||
|
if (_maxStepper != null)
|
||||||
|
{
|
||||||
|
_maxStepper.MinValue = _stepperMinValue;
|
||||||
|
_maxStepper.MaxValue = _stepperMaxValue;
|
||||||
|
_maxStepper.Step = _stepperStep;
|
||||||
|
_maxStepper.SetValue(_value.Max, false);
|
||||||
|
_maxStepper.IsReadOnly = IsReadOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 컨트롤 가시성 업데이트
|
||||||
|
UpdateControlVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterEvents()
|
private void RegisterEvents()
|
||||||
@@ -144,6 +245,14 @@ namespace UVC.UIToolkit
|
|||||||
{
|
{
|
||||||
_maxField.OnValueChanged += OnMaxChanged;
|
_maxField.OnValueChanged += OnMaxChanged;
|
||||||
}
|
}
|
||||||
|
if (_minStepper != null)
|
||||||
|
{
|
||||||
|
_minStepper.OnValueChanged += OnMinStepperChanged;
|
||||||
|
}
|
||||||
|
if (_maxStepper != null)
|
||||||
|
{
|
||||||
|
_maxStepper.OnValueChanged += OnMaxStepperChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnregisterEvents()
|
private void UnregisterEvents()
|
||||||
@@ -156,6 +265,65 @@ namespace UVC.UIToolkit
|
|||||||
{
|
{
|
||||||
_maxField.OnValueChanged -= OnMaxChanged;
|
_maxField.OnValueChanged -= OnMaxChanged;
|
||||||
}
|
}
|
||||||
|
if (_minStepper != null)
|
||||||
|
{
|
||||||
|
_minStepper.OnValueChanged -= OnMinStepperChanged;
|
||||||
|
}
|
||||||
|
if (_maxStepper != null)
|
||||||
|
{
|
||||||
|
_maxStepper.OnValueChanged -= OnMaxStepperChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateModeClass()
|
||||||
|
{
|
||||||
|
// ReadOnly 상태에서는 무조건 IntegerField만 표시
|
||||||
|
if (IsReadOnly)
|
||||||
|
{
|
||||||
|
RemoveFromClassList("utk-property-item-view--stepper");
|
||||||
|
UpdateControlVisibility();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 스테퍼 클래스
|
||||||
|
if (_useStepper)
|
||||||
|
{
|
||||||
|
AddToClassList("utk-property-item-view--stepper");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemoveFromClassList("utk-property-item-view--stepper");
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateControlVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>컨트롤 가시성을 업데이트합니다.</summary>
|
||||||
|
private void UpdateControlVisibility()
|
||||||
|
{
|
||||||
|
bool isReadOnlyMode = IsReadOnly;
|
||||||
|
bool showStepper = !isReadOnlyMode && _useStepper;
|
||||||
|
bool showIntField = isReadOnlyMode || !_useStepper;
|
||||||
|
|
||||||
|
if (_minField != null)
|
||||||
|
{
|
||||||
|
_minField.style.display = showIntField ? DisplayStyle.Flex : DisplayStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_maxField != null)
|
||||||
|
{
|
||||||
|
_maxField.style.display = showIntField ? DisplayStyle.Flex : DisplayStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_minStepper != null)
|
||||||
|
{
|
||||||
|
_minStepper.style.display = showStepper ? DisplayStyle.Flex : DisplayStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_maxStepper != null)
|
||||||
|
{
|
||||||
|
_maxStepper.style.display = showStepper ? DisplayStyle.Flex : DisplayStyle.None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -174,6 +342,11 @@ namespace UVC.UIToolkit
|
|||||||
{
|
{
|
||||||
if (_minField != null) _minField.isReadOnly = isReadOnly;
|
if (_minField != null) _minField.isReadOnly = isReadOnly;
|
||||||
if (_maxField != null) _maxField.isReadOnly = isReadOnly;
|
if (_maxField != null) _maxField.isReadOnly = isReadOnly;
|
||||||
|
if (_minStepper != null) _minStepper.IsReadOnly = isReadOnly;
|
||||||
|
if (_maxStepper != null) _maxStepper.IsReadOnly = isReadOnly;
|
||||||
|
|
||||||
|
// ReadOnly 상태 변경 시 모드 클래스 업데이트
|
||||||
|
UpdateModeClass();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -207,6 +380,36 @@ namespace UVC.UIToolkit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMinStepperChanged(int newMin)
|
||||||
|
{
|
||||||
|
var newValue = new UTKIntRange(newMin, _value.Max);
|
||||||
|
if (!_value.Equals(newValue))
|
||||||
|
{
|
||||||
|
_value = newValue;
|
||||||
|
OnValueChanged?.Invoke(newValue);
|
||||||
|
|
||||||
|
if (_boundData != null && !_boundData.Value.Equals(newValue))
|
||||||
|
{
|
||||||
|
_boundData.Value = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMaxStepperChanged(int newMax)
|
||||||
|
{
|
||||||
|
var newValue = new UTKIntRange(_value.Min, newMax);
|
||||||
|
if (!_value.Equals(newValue))
|
||||||
|
{
|
||||||
|
_value = newValue;
|
||||||
|
OnValueChanged?.Invoke(newValue);
|
||||||
|
|
||||||
|
if (_boundData != null && !_boundData.Value.Equals(newValue))
|
||||||
|
{
|
||||||
|
_boundData.Value = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Value Update
|
#region Value Update
|
||||||
@@ -221,6 +424,16 @@ namespace UVC.UIToolkit
|
|||||||
{
|
{
|
||||||
_maxField.SetValueWithoutNotify(_value.Max);
|
_maxField.SetValueWithoutNotify(_value.Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_minStepper != null && _minStepper.Value != _value.Min)
|
||||||
|
{
|
||||||
|
_minStepper.SetValue(_value.Min, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_maxStepper != null && _maxStepper.Value != _value.Max)
|
||||||
|
{
|
||||||
|
_maxStepper.SetValue(_value.Max, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -249,6 +462,31 @@ namespace UVC.UIToolkit
|
|||||||
IsVisible = data.IsVisible;
|
IsVisible = data.IsVisible;
|
||||||
TooltipText = data.Tooltip;
|
TooltipText = data.Tooltip;
|
||||||
|
|
||||||
|
// UTKIntRangePropertyItem의 스테퍼 설정 적용
|
||||||
|
if (data is UTKIntRangePropertyItem rangeItem)
|
||||||
|
{
|
||||||
|
_useStepper = rangeItem.UseStepper;
|
||||||
|
_stepperMinValue = rangeItem.StepperMinValue;
|
||||||
|
_stepperMaxValue = rangeItem.StepperMaxValue;
|
||||||
|
_stepperStep = rangeItem.StepperStep;
|
||||||
|
|
||||||
|
// 스테퍼에 값 적용
|
||||||
|
if (_minStepper != null)
|
||||||
|
{
|
||||||
|
_minStepper.MinValue = _stepperMinValue;
|
||||||
|
_minStepper.MaxValue = _stepperMaxValue;
|
||||||
|
_minStepper.Step = _stepperStep;
|
||||||
|
}
|
||||||
|
if (_maxStepper != null)
|
||||||
|
{
|
||||||
|
_maxStepper.MinValue = _stepperMinValue;
|
||||||
|
_maxStepper.MaxValue = _stepperMaxValue;
|
||||||
|
_maxStepper.Step = _stepperStep;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateModeClass();
|
||||||
|
}
|
||||||
|
|
||||||
data.OnTypedValueChanged += OnDataValueChanged;
|
data.OnTypedValueChanged += OnDataValueChanged;
|
||||||
|
|
||||||
UpdateValueUI();
|
UpdateValueUI();
|
||||||
@@ -287,6 +525,8 @@ namespace UVC.UIToolkit
|
|||||||
OnValueChanged = null;
|
OnValueChanged = null;
|
||||||
_minField = null;
|
_minField = null;
|
||||||
_maxField = null;
|
_maxField = null;
|
||||||
|
_minStepper = null;
|
||||||
|
_maxStepper = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
|
|||||||
Reference in New Issue
Block a user