UTKProperyWindow 개발 중
This commit is contained in:
@@ -114,7 +114,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnRadioValueChanged);
|
||||
RegisterCallback<ChangeEvent<bool>>(OnRadioValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -168,6 +168,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<bool>>(OnRadioValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -17,6 +17,19 @@ namespace UVC.UIToolkit
|
||||
/// toggle.label = "알림 받기";
|
||||
/// toggle.IsOn = true;
|
||||
/// toggle.OnValueChanged += (isOn) => Debug.Log($"토글: {isOn}");
|
||||
///
|
||||
/// // 상호작용 불가능 (읽기 전용, 프로그래밍 방식으로만 변경 가능)
|
||||
/// var readOnlyToggle = new UTKToggle("읽기 전용 토글");
|
||||
/// readOnlyToggle.IsOn = true;
|
||||
/// readOnlyToggle.IsInteractive = false; // 사용자 클릭/키보드 입력 차단
|
||||
/// readOnlyToggle.SetOn(false, true); // 프로그래밍 방식으로는 변경 가능
|
||||
///
|
||||
/// // IsEnabled vs IsInteractive
|
||||
/// var disabledToggle = new UTKToggle("완전 비활성화");
|
||||
/// disabledToggle.IsEnabled = false; // 시각적 비활성화 + 모든 변경 불가
|
||||
///
|
||||
/// var nonInteractiveToggle = new UTKToggle("상호작용 비활성화");
|
||||
/// nonInteractiveToggle.IsInteractive = false; // 사용자 입력만 차단, 시각적 활성화 유지
|
||||
/// </code>
|
||||
/// <para><b>UXML에서 사용:</b></para>
|
||||
/// <code>
|
||||
@@ -29,6 +42,9 @@ namespace UVC.UIToolkit
|
||||
///
|
||||
/// <!-- 비활성화 -->
|
||||
/// <utk:UTKToggle label="프리미엄 기능" is-enabled="false" />
|
||||
///
|
||||
/// <!-- 상호작용 불가능 (읽기 전용) -->
|
||||
/// <utk:UTKToggle label="시스템 상태" value="true" is-interactive="false" />
|
||||
/// </ui:UXML>
|
||||
/// </code>
|
||||
/// </example>
|
||||
@@ -42,6 +58,7 @@ namespace UVC.UIToolkit
|
||||
#region Fields
|
||||
private bool _disposed;
|
||||
private bool _isEnabled = true;
|
||||
private bool _isInteractive = true;
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
@@ -70,6 +87,22 @@ namespace UVC.UIToolkit
|
||||
EnableInClassList("utk-toggle--disabled", !value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 상호작용 가능 여부. false일 경우 마우스/키보드 입력을 무시하지만 프로그래밍 방식으로는 값 변경 가능.
|
||||
/// IsEnabled와 달리 시각적으로는 활성화 상태를 유지합니다.
|
||||
/// </summary>
|
||||
[UxmlAttribute("is-interactive")]
|
||||
public bool IsInteractive
|
||||
{
|
||||
get => _isInteractive;
|
||||
set
|
||||
{
|
||||
_isInteractive = value;
|
||||
UpdateInteractiveState();
|
||||
EnableInClassList("utk-toggle--non-interactive", !value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -102,7 +135,9 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnToggleValueChanged);
|
||||
RegisterCallback<ChangeEvent<bool>>(OnToggleValueChanged);
|
||||
RegisterCallback<MouseDownEvent>(OnMouseDown, TrickleDown.TrickleDown);
|
||||
RegisterCallback<KeyDownEvent>(OnKeyDown, TrickleDown.TrickleDown);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -126,6 +161,28 @@ namespace UVC.UIToolkit
|
||||
EnableInClassList("utk-toggle--on", evt.newValue);
|
||||
OnValueChanged?.Invoke(evt.newValue);
|
||||
}
|
||||
|
||||
private void OnMouseDown(MouseDownEvent evt)
|
||||
{
|
||||
if (!_isInteractive)
|
||||
{
|
||||
evt.StopImmediatePropagation();
|
||||
evt.PreventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDown(KeyDownEvent evt)
|
||||
{
|
||||
if (!_isInteractive)
|
||||
{
|
||||
// Space나 Enter 키로 토글 변경 방지
|
||||
if (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)
|
||||
{
|
||||
evt.StopImmediatePropagation();
|
||||
evt.PreventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
@@ -144,6 +201,15 @@ namespace UVC.UIToolkit
|
||||
OnValueChanged?.Invoke(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 상호작용 상태 업데이트
|
||||
/// </summary>
|
||||
private void UpdateInteractiveState()
|
||||
{
|
||||
// IsInteractive가 false일 때 포커스 불가능하게 설정
|
||||
focusable = _isInteractive;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
@@ -154,6 +220,9 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<bool>>(OnToggleValueChanged);
|
||||
UnregisterCallback<MouseDownEvent>(OnMouseDown, TrickleDown.TrickleDown);
|
||||
UnregisterCallback<KeyDownEvent>(OnKeyDown, TrickleDown.TrickleDown);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnValueChanged);
|
||||
RegisterCallback<ChangeEvent<ToggleButtonGroupState>>(OnValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -157,6 +157,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnSelectionChanged = null;
|
||||
UnregisterCallback<ChangeEvent<ToggleButtonGroupState>>(OnValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFoldoutValueChanged);
|
||||
RegisterCallback<ChangeEvent<bool>>(OnFoldoutValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -159,6 +159,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<bool>>(OnFoldoutValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnDropdownValueChanged);
|
||||
RegisterCallback<ChangeEvent<string>>(OnDropdownValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -240,6 +240,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnSelectionChanged = null;
|
||||
UnregisterCallback<ChangeEvent<string>>(OnDropdownValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<Enum>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -204,6 +204,7 @@ namespace UVC.UIToolkit
|
||||
_disposed = true;
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
UnregisterCallback<ChangeEvent<Enum>>(OnFieldValueChanged);
|
||||
OnValueChanged = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -46,6 +46,11 @@ namespace UVC.UIToolkit
|
||||
///
|
||||
/// // 비활성화
|
||||
/// boundsField.IsEnabled = false;
|
||||
///
|
||||
/// // 읽기 전용 (사용자가 수정할 수 없음)
|
||||
/// var readOnlyField = new UTKBoundsField("고정 경계");
|
||||
/// readOnlyField.Value = new Bounds(Vector3.zero, Vector3.one);
|
||||
/// readOnlyField.IsReadOnly = true;
|
||||
/// </code>
|
||||
/// <para><b>UXML에서 사용:</b></para>
|
||||
/// <code>
|
||||
@@ -61,7 +66,10 @@ namespace UVC.UIToolkit
|
||||
/// extents-label="크기" />
|
||||
///
|
||||
/// <!-- 비활성화 -->
|
||||
/// <utk:UTKBoundsField label="읽기전용" is-enabled="false" />
|
||||
/// <utk:UTKBoundsField label="비활성화" is-enabled="false" />
|
||||
///
|
||||
/// <!-- 읽기 전용 -->
|
||||
/// <utk:UTKBoundsField label="고정 경계" is-readonly="true" />
|
||||
/// </UXML>
|
||||
/// </code>
|
||||
/// <para><b>실제 활용 예시:</b></para>
|
||||
@@ -88,6 +96,7 @@ namespace UVC.UIToolkit
|
||||
#region Fields
|
||||
private bool _disposed;
|
||||
private bool _isEnabled = true;
|
||||
private bool _isReadOnly;
|
||||
private string _centerLabel = "Center";
|
||||
private string _extentsLabel = "Extents";
|
||||
private string _xLabel = "X";
|
||||
@@ -180,6 +189,19 @@ namespace UVC.UIToolkit
|
||||
UpdateAxisLabels();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>읽기 전용 상태</summary>
|
||||
[UxmlAttribute("is-readonly")]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
_isReadOnly = value;
|
||||
UpdateReadOnlyState();
|
||||
EnableInClassList("utk-boundsfield--readonly", value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -215,7 +237,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<Bounds>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -254,6 +276,16 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateReadOnlyState()
|
||||
{
|
||||
// 내부 Vector3Field들의 TextInput을 찾아서 읽기 전용 설정
|
||||
var textInputs = this.Query<TextInputBaseField<float>>().ToList();
|
||||
foreach (var textInput in textInputs)
|
||||
{
|
||||
textInput.isReadOnly = _isReadOnly;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
@@ -271,6 +303,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<Bounds>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<double>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -165,6 +165,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<double>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<float>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -164,6 +164,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<float>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnTextValueChanged);
|
||||
RegisterCallback<ChangeEvent<string>>(OnTextValueChanged);
|
||||
|
||||
RegisterCallback<FocusInEvent>(_ =>
|
||||
{
|
||||
@@ -304,6 +304,7 @@ namespace UVC.UIToolkit
|
||||
_disposed = true;
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
UnregisterCallback<ChangeEvent<string>>(OnTextValueChanged);
|
||||
OnValueChanged = null;
|
||||
OnFocused = null;
|
||||
OnBlurred = null;
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<int>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -163,6 +163,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<int>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<long>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -157,6 +157,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<long>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace UVC.UIToolkit
|
||||
/// stepper.Increment(); // Step만큼 증가
|
||||
/// stepper.Decrement(); // Step만큼 감소
|
||||
/// stepper.SetValue(75); // 직접 설정
|
||||
///
|
||||
/// // 읽기 전용 (사용자가 수정할 수 없음)
|
||||
/// var readOnlyStepper = new UTKNumberStepper(0, 100, 50, 1);
|
||||
/// readOnlyStepper.IsReadOnly = true;
|
||||
/// </code>
|
||||
/// <para><b>UXML에서 사용:</b></para>
|
||||
/// <code><![CDATA[
|
||||
@@ -62,6 +66,9 @@ namespace UVC.UIToolkit
|
||||
///
|
||||
/// <!-- 순환 모드 -->
|
||||
/// <utk:UTKNumberStepper value="1" min-value="1" max-value="12" wrap-around="true" />
|
||||
///
|
||||
/// <!-- 읽기 전용 -->
|
||||
/// <utk:UTKNumberStepper value="50" is-readonly="true" />
|
||||
/// ]]></code>
|
||||
/// <para><b>실제 활용 예시 (월 선택기):</b></para>
|
||||
/// <code>
|
||||
@@ -74,7 +81,7 @@ namespace UVC.UIToolkit
|
||||
/// </code>
|
||||
/// </example>
|
||||
[UxmlElement]
|
||||
public partial class UTKNumberStepper : VisualElement
|
||||
public partial class UTKNumberStepper : VisualElement, IDisposable
|
||||
{
|
||||
#region Constants
|
||||
private const string USS_PATH = "UIToolkit/Input/UTKNumberStepper";
|
||||
@@ -123,9 +130,24 @@ namespace UVC.UIToolkit
|
||||
get => _wrapAround;
|
||||
set => _wrapAround = value;
|
||||
}
|
||||
|
||||
/// <summary>읽기 전용 상태. true일 때 사용자가 값을 수정할 수 없음</summary>
|
||||
[UxmlAttribute("is-readonly")]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
_isReadOnly = value;
|
||||
UpdateReadOnlyState();
|
||||
EnableInClassList("utk-number-stepper--readonly", value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private bool _disposed;
|
||||
private bool _isReadOnly;
|
||||
private int _value;
|
||||
private int _minValue = int.MinValue;
|
||||
private int _maxValue = int.MaxValue;
|
||||
@@ -151,6 +173,7 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public UTKNumberStepper()
|
||||
{
|
||||
UTKThemeManager.Instance.ApplyThemeToElement(this);
|
||||
@@ -160,19 +183,18 @@ namespace UVC.UIToolkit
|
||||
SubscribeToThemeChanges();
|
||||
}
|
||||
|
||||
public UTKNumberStepper(int minValue, int maxValue, int initialValue = 0, int step = 1)
|
||||
public UTKNumberStepper(bool isReadOnly = false): this()
|
||||
{
|
||||
_isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKNumberStepper(int minValue, int maxValue, int initialValue = 0, int step = 1, bool isReadOnly = false): this()
|
||||
{
|
||||
_isReadOnly = isReadOnly;
|
||||
_minValue = minValue;
|
||||
_maxValue = maxValue;
|
||||
_step = Math.Max(1, step);
|
||||
_value = Mathf.Clamp(initialValue, minValue, maxValue);
|
||||
|
||||
UTKThemeManager.Instance.ApplyThemeToElement(this);
|
||||
LoadStyleSheet();
|
||||
CreateUI();
|
||||
SetupEvents();
|
||||
SubscribeToThemeChanges();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
private void LoadStyleSheet()
|
||||
@@ -269,6 +291,7 @@ namespace UVC.UIToolkit
|
||||
// Text Field
|
||||
_textField = new TextField { name = "stepper-input" };
|
||||
_textField.AddToClassList("utk-number-stepper__input");
|
||||
_textField.isReadOnly = _isReadOnly;
|
||||
|
||||
// TextField 내부 input 스타일링
|
||||
_textField.RegisterCallback<AttachToPanelEvent>(_ =>
|
||||
@@ -290,6 +313,7 @@ namespace UVC.UIToolkit
|
||||
_upButton = new Button { name = "stepper-up", text = UTKMaterialIcons.KeyboardArrowUp };
|
||||
_upButton.AddToClassList("utk-number-stepper__btn");
|
||||
_upButton.AddToClassList("utk-number-stepper__btn--up");
|
||||
_upButton.SetEnabled(!_isReadOnly);
|
||||
UTKMaterialIcons.ApplyIconStyle(_upButton, 14);
|
||||
buttonContainer.Add(_upButton);
|
||||
|
||||
@@ -297,6 +321,7 @@ namespace UVC.UIToolkit
|
||||
_downButton = new Button { name = "stepper-down", text = UTKMaterialIcons.KeyboardArrowDown };
|
||||
_downButton.AddToClassList("utk-number-stepper__btn");
|
||||
_downButton.AddToClassList("utk-number-stepper__btn--down");
|
||||
_downButton.SetEnabled(!_isReadOnly);
|
||||
UTKMaterialIcons.ApplyIconStyle(_downButton, 14);
|
||||
buttonContainer.Add(_downButton);
|
||||
|
||||
@@ -307,78 +332,85 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
_upButton?.RegisterCallback<ClickEvent>(_ => Increment());
|
||||
_downButton?.RegisterCallback<ClickEvent>(_ => Decrement());
|
||||
_upButton?.RegisterCallback<ClickEvent>(OnUpButtonClick);
|
||||
_downButton?.RegisterCallback<ClickEvent>(OnDownButtonClick);
|
||||
|
||||
_textField?.RegisterValueChangedCallback(evt =>
|
||||
_textField?.RegisterCallback<ChangeEvent<string>>(OnTextFieldChanged);
|
||||
_textField?.RegisterCallback<KeyDownEvent>(OnTextFieldKeyDown);
|
||||
_textField?.RegisterCallback<KeyDownEvent>(OnTextFieldTabKeyDown, TrickleDown.TrickleDown);
|
||||
|
||||
RegisterCallback<MouseEnterEvent>(OnMouseEnter);
|
||||
RegisterCallback<MouseLeaveEvent>(OnMouseLeave);
|
||||
RegisterCallback<WheelEvent>(OnWheelEvent);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
private void OnUpButtonClick(ClickEvent evt) => Increment();
|
||||
private void OnDownButtonClick(ClickEvent evt) => Decrement();
|
||||
|
||||
private void OnTextFieldChanged(ChangeEvent<string> evt)
|
||||
{
|
||||
if (_isUpdating) return;
|
||||
|
||||
if (int.TryParse(evt.newValue, out int parsed))
|
||||
{
|
||||
if (_isUpdating) return;
|
||||
|
||||
if (int.TryParse(evt.newValue, out int parsed))
|
||||
{
|
||||
SetValue(parsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 유효하지 않은 입력이면 이전 값으로 복원
|
||||
UpdateDisplay();
|
||||
}
|
||||
});
|
||||
|
||||
// 키보드 이벤트 (위/아래 화살표)
|
||||
_textField?.RegisterCallback<KeyDownEvent>(evt =>
|
||||
SetValue(parsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (evt.keyCode == KeyCode.UpArrow)
|
||||
{
|
||||
Increment();
|
||||
evt.StopPropagation();
|
||||
}
|
||||
else if (evt.keyCode == KeyCode.DownArrow)
|
||||
{
|
||||
Decrement();
|
||||
evt.StopPropagation();
|
||||
}
|
||||
});
|
||||
// 유효하지 않은 입력이면 이전 값으로 복원
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
// Tab 키 이벤트 - TrickleDown으로 먼저 캡처
|
||||
_textField?.RegisterCallback<KeyDownEvent>(evt =>
|
||||
private void OnTextFieldKeyDown(KeyDownEvent evt)
|
||||
{
|
||||
if (evt.keyCode == KeyCode.UpArrow)
|
||||
{
|
||||
if (evt.keyCode == KeyCode.Tab)
|
||||
{
|
||||
if (evt.shiftKey && OnShiftTabPressed != null)
|
||||
{
|
||||
// Shift+Tab: 이전 요소로 이동
|
||||
OnShiftTabPressed.Invoke();
|
||||
evt.StopImmediatePropagation();
|
||||
}
|
||||
else if (!evt.shiftKey && OnTabPressed != null)
|
||||
{
|
||||
// Tab: 다음 요소로 이동
|
||||
OnTabPressed.Invoke();
|
||||
evt.StopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
}, TrickleDown.TrickleDown);
|
||||
|
||||
// 마우스 호버 상태 추적
|
||||
RegisterCallback<MouseEnterEvent>(_ => _isHovered = true);
|
||||
RegisterCallback<MouseLeaveEvent>(_ => _isHovered = false);
|
||||
|
||||
// 마우스 휠 이벤트 (호버 상태에서만)
|
||||
RegisterCallback<WheelEvent>(evt =>
|
||||
{
|
||||
if (!_isHovered) return;
|
||||
|
||||
if (evt.delta.y < 0)
|
||||
{
|
||||
Increment();
|
||||
}
|
||||
else if (evt.delta.y > 0)
|
||||
{
|
||||
Decrement();
|
||||
}
|
||||
Increment();
|
||||
evt.StopPropagation();
|
||||
});
|
||||
}
|
||||
else if (evt.keyCode == KeyCode.DownArrow)
|
||||
{
|
||||
Decrement();
|
||||
evt.StopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTextFieldTabKeyDown(KeyDownEvent evt)
|
||||
{
|
||||
if (evt.keyCode == KeyCode.Tab)
|
||||
{
|
||||
if (evt.shiftKey && OnShiftTabPressed != null)
|
||||
{
|
||||
OnShiftTabPressed.Invoke();
|
||||
evt.StopImmediatePropagation();
|
||||
}
|
||||
else if (!evt.shiftKey && OnTabPressed != null)
|
||||
{
|
||||
OnTabPressed.Invoke();
|
||||
evt.StopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMouseEnter(MouseEnterEvent evt) => _isHovered = true;
|
||||
private void OnMouseLeave(MouseLeaveEvent evt) => _isHovered = false;
|
||||
|
||||
private void OnWheelEvent(WheelEvent evt)
|
||||
{
|
||||
if (!_isHovered) return;
|
||||
|
||||
if (evt.delta.y < 0)
|
||||
{
|
||||
Increment();
|
||||
}
|
||||
else if (evt.delta.y > 0)
|
||||
{
|
||||
Decrement();
|
||||
}
|
||||
evt.StopPropagation();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -401,6 +433,56 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
return Mathf.Clamp(value, _minValue, _maxValue);
|
||||
}
|
||||
|
||||
private void UpdateReadOnlyState()
|
||||
{
|
||||
if (_textField != null)
|
||||
{
|
||||
_textField.isReadOnly = _isReadOnly;
|
||||
}
|
||||
|
||||
if (_upButton != null)
|
||||
{
|
||||
_upButton.SetEnabled(!_isReadOnly);
|
||||
}
|
||||
|
||||
if (_downButton != null)
|
||||
{
|
||||
_downButton.SetEnabled(!_isReadOnly);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
|
||||
// 이벤트 콜백 해제
|
||||
_upButton?.UnregisterCallback<ClickEvent>(OnUpButtonClick);
|
||||
_downButton?.UnregisterCallback<ClickEvent>(OnDownButtonClick);
|
||||
|
||||
_textField?.UnregisterCallback<ChangeEvent<string>>(OnTextFieldChanged);
|
||||
_textField?.UnregisterCallback<KeyDownEvent>(OnTextFieldKeyDown);
|
||||
_textField?.UnregisterCallback<KeyDownEvent>(OnTextFieldTabKeyDown);
|
||||
|
||||
UnregisterCallback<MouseEnterEvent>(OnMouseEnter);
|
||||
UnregisterCallback<MouseLeaveEvent>(OnMouseLeave);
|
||||
UnregisterCallback<WheelEvent>(OnWheelEvent);
|
||||
|
||||
// 이벤트 null 처리
|
||||
OnValueChanged = null;
|
||||
OnTabPressed = null;
|
||||
OnShiftTabPressed = null;
|
||||
|
||||
// UI 참조 정리
|
||||
_textField = null;
|
||||
_upButton = null;
|
||||
_downButton = null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ namespace UVC.UIToolkit
|
||||
/// rectField.YLabel = "Top";
|
||||
/// rectField.WLabel = "Width";
|
||||
/// rectField.HLabel = "Height";
|
||||
///
|
||||
/// // 읽기 전용 (사용자가 수정할 수 없음)
|
||||
/// var readOnlyField = new UTKRectField("고정 영역");
|
||||
/// readOnlyField.Value = new Rect(10, 10, 200, 100);
|
||||
/// readOnlyField.IsReadOnly = true;
|
||||
/// </code>
|
||||
/// <para><b>UXML에서 사용:</b></para>
|
||||
/// <code><![CDATA[
|
||||
@@ -53,7 +58,10 @@ namespace UVC.UIToolkit
|
||||
/// w-label="W" h-label="H" />
|
||||
///
|
||||
/// <!-- 비활성화 상태 -->
|
||||
/// <utk:UTKRectField label="읽기 전용" is-enabled="false" />
|
||||
/// <utk:UTKRectField label="비활성화" is-enabled="false" />
|
||||
///
|
||||
/// <!-- 읽기 전용 -->
|
||||
/// <utk:UTKRectField label="고정 영역" is-readonly="true" />
|
||||
/// ]]></code>
|
||||
/// <para><b>실제 활용 예시 (스프라이트 영역 편집):</b></para>
|
||||
/// <code>
|
||||
@@ -76,6 +84,7 @@ namespace UVC.UIToolkit
|
||||
#region Fields
|
||||
private bool _disposed;
|
||||
private bool _isEnabled = true;
|
||||
private bool _isReadOnly;
|
||||
private string _xLabel = "X";
|
||||
private string _yLabel = "Y";
|
||||
private string _wLabel = "W";
|
||||
@@ -155,6 +164,19 @@ namespace UVC.UIToolkit
|
||||
UpdateAxisLabels();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>읽기 전용 상태</summary>
|
||||
[UxmlAttribute("is-readonly")]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
_isReadOnly = value;
|
||||
UpdateReadOnlyState();
|
||||
EnableInClassList("utk-rectfield--readonly", value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -173,9 +195,17 @@ namespace UVC.UIToolkit
|
||||
SubscribeToThemeChanges();
|
||||
}
|
||||
|
||||
public UTKRectField(string label) : this()
|
||||
public UTKRectField(bool isReadOnly) : this()
|
||||
{
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
|
||||
public UTKRectField(string label, bool isReadOnly = false) : this()
|
||||
{
|
||||
this.label = label;
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -190,7 +220,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<Rect>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -219,6 +249,16 @@ namespace UVC.UIToolkit
|
||||
floatFields[3].label = _hLabel;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateReadOnlyState()
|
||||
{
|
||||
// 내부 FloatField들의 TextInput을 찾아서 읽기 전용 설정
|
||||
var textInputs = this.Query<TextInputBaseField<float>>().ToList();
|
||||
foreach (var textInput in textInputs)
|
||||
{
|
||||
textInput.isReadOnly = _isReadOnly;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
@@ -236,6 +276,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<Rect>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace UVC.UIToolkit
|
||||
///
|
||||
/// // 비활성화
|
||||
/// vec2Field.IsEnabled = false;
|
||||
///
|
||||
/// // 읽기 전용 (사용자가 수정할 수 없음)
|
||||
/// var readOnlyField = new UTKVector2Field("고정 크기");
|
||||
/// readOnlyField.Value = new Vector2(100, 50);
|
||||
/// readOnlyField.IsReadOnly = true;
|
||||
/// </code>
|
||||
/// <para><b>UXML에서 사용:</b></para>
|
||||
/// <code>
|
||||
@@ -50,7 +55,10 @@ namespace UVC.UIToolkit
|
||||
/// <utk:UTKVector2Field label="크기" x-label="Width" y-label="Height" />
|
||||
///
|
||||
/// <!-- 비활성화 -->
|
||||
/// <utk:UTKVector2Field label="고정 크기" is-enabled="false" />
|
||||
/// <utk:UTKVector2Field label="비활성화" is-enabled="false" />
|
||||
///
|
||||
/// <!-- 읽기 전용 -->
|
||||
/// <utk:UTKVector2Field label="고정 크기" is-readonly="true" />
|
||||
/// </UXML>
|
||||
/// </code>
|
||||
/// <para><b>실제 활용 예시:</b></para>
|
||||
@@ -79,6 +87,7 @@ namespace UVC.UIToolkit
|
||||
#region Fields
|
||||
private bool _disposed;
|
||||
private bool _isEnabled = true;
|
||||
private bool _isReadOnly = false;
|
||||
private string _xLabel = "X";
|
||||
private string _yLabel = "Y";
|
||||
#endregion
|
||||
@@ -132,6 +141,19 @@ namespace UVC.UIToolkit
|
||||
UpdateAxisLabels();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>읽기 전용 상태</summary>
|
||||
[UxmlAttribute("is-readonly")]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
_isReadOnly = value;
|
||||
UpdateReadOnlyState();
|
||||
EnableInClassList("utk-vector2-field--readonly", value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -150,9 +172,17 @@ namespace UVC.UIToolkit
|
||||
SubscribeToThemeChanges();
|
||||
}
|
||||
|
||||
public UTKVector2Field(string label) : this()
|
||||
public UTKVector2Field(bool isReadOnly) : this()
|
||||
{
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
|
||||
public UTKVector2Field(string label, bool isReadOnly = false) : this()
|
||||
{
|
||||
this.label = label;
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -167,7 +197,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<Vector2>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -194,6 +224,16 @@ namespace UVC.UIToolkit
|
||||
floatFields[1].label = _yLabel;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateReadOnlyState()
|
||||
{
|
||||
// 내부 FloatField들의 TextInput을 찾아서 읽기 전용 설정
|
||||
var textInputs = this.Query<TextInputBaseField<float>>().ToList();
|
||||
foreach (var textInput in textInputs)
|
||||
{
|
||||
textInput.isReadOnly = _isReadOnly;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
@@ -211,6 +251,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<Vector2>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ namespace UVC.UIToolkit
|
||||
/// var posField = new UTKVector3Field("위치");
|
||||
/// posField.Value = transform.position;
|
||||
/// posField.OnValueChanged += (pos) => transform.position = pos;
|
||||
///
|
||||
/// // 읽기 전용 (사용자가 수정할 수 없음)
|
||||
/// var readOnlyField = new UTKVector3Field("고정 위치");
|
||||
/// readOnlyField.Value = new Vector3(1, 2, 3);
|
||||
/// readOnlyField.IsReadOnly = true;
|
||||
/// </code>
|
||||
/// <para><b>UXML에서 사용:</b></para>
|
||||
/// <code><![CDATA[
|
||||
@@ -57,7 +62,10 @@ namespace UVC.UIToolkit
|
||||
/// x-label="Width" y-label="Height" z-label="Depth" />
|
||||
///
|
||||
/// <!-- 비활성화 상태 -->
|
||||
/// <utk:UTKVector3Field label="읽기 전용" is-enabled="false" />
|
||||
/// <utk:UTKVector3Field label="비활성화" is-enabled="false" />
|
||||
///
|
||||
/// <!-- 읽기 전용 -->
|
||||
/// <utk:UTKVector3Field label="고정 위치" is-readonly="true" />
|
||||
/// ]]></code>
|
||||
/// <para><b>실제 활용 예시 (Transform 편집기):</b></para>
|
||||
/// <code>
|
||||
@@ -85,6 +93,7 @@ namespace UVC.UIToolkit
|
||||
#region Fields
|
||||
private bool _disposed;
|
||||
private bool _isEnabled = true;
|
||||
private bool _isReadOnly = false;
|
||||
private string _xLabel = "X";
|
||||
private string _yLabel = "Y";
|
||||
private string _zLabel = "Z";
|
||||
@@ -151,6 +160,19 @@ namespace UVC.UIToolkit
|
||||
UpdateAxisLabels();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>읽기 전용 상태</summary>
|
||||
[UxmlAttribute("is-readonly")]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
_isReadOnly = value;
|
||||
UpdateReadOnlyState();
|
||||
EnableInClassList("utk-vector3-field--readonly", value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -169,9 +191,17 @@ namespace UVC.UIToolkit
|
||||
SubscribeToThemeChanges();
|
||||
}
|
||||
|
||||
public UTKVector3Field(string label) : this()
|
||||
public UTKVector3Field(bool isReadOnly) : this()
|
||||
{
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
|
||||
public UTKVector3Field(string label, bool isReadOnly = false) : this()
|
||||
{
|
||||
this.label = label;
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -186,7 +216,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<Vector3>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -214,6 +244,16 @@ namespace UVC.UIToolkit
|
||||
floatFields[2].label = _zLabel;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateReadOnlyState()
|
||||
{
|
||||
// 내부 FloatField들의 TextInput을 찾아서 읽기 전용 설정
|
||||
var textInputs = this.Query<TextInputBaseField<float>>().ToList();
|
||||
foreach (var textInput in textInputs)
|
||||
{
|
||||
textInput.isReadOnly = _isReadOnly;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
@@ -231,6 +271,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<Vector3>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace UVC.UIToolkit
|
||||
///
|
||||
/// // 비활성화
|
||||
/// vec4Field.IsEnabled = false;
|
||||
///
|
||||
/// // 읽기 전용 (사용자가 수정할 수 없음)
|
||||
/// var readOnlyField = new UTKVector4Field("고정 파라미터");
|
||||
/// readOnlyField.Value = new Vector4(1, 0.5f, 0.5f, 1);
|
||||
/// readOnlyField.IsReadOnly = true;
|
||||
/// </code>
|
||||
/// <para><b>UXML에서 사용:</b></para>
|
||||
/// <code>
|
||||
@@ -55,7 +60,10 @@ namespace UVC.UIToolkit
|
||||
/// x-label="R" y-label="G" z-label="B" w-label="A" />
|
||||
///
|
||||
/// <!-- 비활성화 -->
|
||||
/// <utk:UTKVector4Field label="고정값" is-enabled="false" />
|
||||
/// <utk:UTKVector4Field label="비활성화" is-enabled="false" />
|
||||
///
|
||||
/// <!-- 읽기 전용 -->
|
||||
/// <utk:UTKVector4Field label="고정값" is-readonly="true" />
|
||||
/// </UXML>
|
||||
/// </code>
|
||||
/// <para><b>실제 활용 예시:</b></para>
|
||||
@@ -82,6 +90,7 @@ namespace UVC.UIToolkit
|
||||
#region Fields
|
||||
private bool _disposed;
|
||||
private bool _isEnabled = true;
|
||||
private bool _isReadOnly = false;
|
||||
private string _xLabel = "X";
|
||||
private string _yLabel = "Y";
|
||||
private string _zLabel = "Z";
|
||||
@@ -161,6 +170,19 @@ namespace UVC.UIToolkit
|
||||
UpdateAxisLabels();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>읽기 전용 상태</summary>
|
||||
[UxmlAttribute("is-readonly")]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
_isReadOnly = value;
|
||||
UpdateReadOnlyState();
|
||||
EnableInClassList("utk-vector4field--readonly", value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -179,9 +201,17 @@ namespace UVC.UIToolkit
|
||||
SubscribeToThemeChanges();
|
||||
}
|
||||
|
||||
public UTKVector4Field(string label) : this()
|
||||
public UTKVector4Field(bool isReadOnly) : this()
|
||||
{
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
|
||||
public UTKVector4Field(string label, bool isReadOnly = false) : this()
|
||||
{
|
||||
this.label = label;
|
||||
_isReadOnly = isReadOnly;
|
||||
UpdateReadOnlyState();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -196,7 +226,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnFieldValueChanged);
|
||||
RegisterCallback<ChangeEvent<Vector4>>(OnFieldValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -225,6 +255,16 @@ namespace UVC.UIToolkit
|
||||
floatFields[3].label = _wLabel;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateReadOnlyState()
|
||||
{
|
||||
// 내부 FloatField들의 TextInput을 찾아서 읽기 전용 설정
|
||||
var textInputs = this.Query<TextInputBaseField<float>>().ToList();
|
||||
foreach (var textInput in textInputs)
|
||||
{
|
||||
textInput.isReadOnly = _isReadOnly;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
@@ -242,6 +282,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<Vector4>>(OnFieldValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -308,6 +308,12 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// 현재 색상을 설정합니다.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
/// <param name="setAsOriginal"></param>
|
||||
public void SetColor(Color color, bool setAsOriginal = true)
|
||||
{
|
||||
_currentColor = color;
|
||||
@@ -321,8 +327,15 @@ namespace UVC.UIToolkit
|
||||
UpdateAllUI();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 선택된 색상을 반환합니다.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Color GetColor() => _currentColor;
|
||||
|
||||
/// <summary>
|
||||
/// 피커를 닫고, 정리합니다.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
OnClosed?.Invoke();
|
||||
@@ -331,6 +344,9 @@ namespace UVC.UIToolkit
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 선택을 취소하고 원래 색상으로 복원합니다.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
_currentColor = _originalColor;
|
||||
@@ -338,6 +354,9 @@ namespace UVC.UIToolkit
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 색상을 확정하고 선택 이벤트를 발생시킵니다.
|
||||
/// </summary>
|
||||
public void Confirm()
|
||||
{
|
||||
OnColorSelected?.Invoke(_currentColor);
|
||||
@@ -535,19 +554,19 @@ namespace UVC.UIToolkit
|
||||
_hueBar?.RegisterCallback<PointerUpEvent>(OnHueBarPointerUp);
|
||||
|
||||
// RGB Sliders
|
||||
_sliderR?.RegisterValueChangedCallback(evt => OnRGBSliderChanged('R', evt.newValue));
|
||||
_sliderG?.RegisterValueChangedCallback(evt => OnRGBSliderChanged('G', evt.newValue));
|
||||
_sliderB?.RegisterValueChangedCallback(evt => OnRGBSliderChanged('B', evt.newValue));
|
||||
_sliderA?.RegisterValueChangedCallback(evt => OnRGBSliderChanged('A', evt.newValue));
|
||||
_sliderR?.RegisterCallback<ChangeEvent<float>>(OnSliderRChanged);
|
||||
_sliderG?.RegisterCallback<ChangeEvent<float>>(OnSliderGChanged);
|
||||
_sliderB?.RegisterCallback<ChangeEvent<float>>(OnSliderBChanged);
|
||||
_sliderA?.RegisterCallback<ChangeEvent<float>>(OnSliderAChanged);
|
||||
|
||||
// RGB Fields
|
||||
_fieldR?.RegisterValueChangedCallback(evt => OnRGBFieldChanged('R', evt.newValue));
|
||||
_fieldG?.RegisterValueChangedCallback(evt => OnRGBFieldChanged('G', evt.newValue));
|
||||
_fieldB?.RegisterValueChangedCallback(evt => OnRGBFieldChanged('B', evt.newValue));
|
||||
_fieldA?.RegisterValueChangedCallback(evt => OnRGBFieldChanged('A', evt.newValue));
|
||||
_fieldR?.RegisterCallback<ChangeEvent<int>>(OnFieldRChanged);
|
||||
_fieldG?.RegisterCallback<ChangeEvent<int>>(OnFieldGChanged);
|
||||
_fieldB?.RegisterCallback<ChangeEvent<int>>(OnFieldBChanged);
|
||||
_fieldA?.RegisterCallback<ChangeEvent<int>>(OnFieldAChanged);
|
||||
|
||||
// Hex Field
|
||||
_hexField?.RegisterValueChangedCallback(OnHexFieldChanged);
|
||||
_hexField?.RegisterCallback<ChangeEvent<string>>(OnHexFieldChanged);
|
||||
|
||||
// Original preview click - 원래 색상으로 복원
|
||||
_previewOriginal?.RegisterCallback<ClickEvent>(_ => SetColor(_originalColor));
|
||||
@@ -685,6 +704,16 @@ namespace UVC.UIToolkit
|
||||
NotifyColorChanged();
|
||||
}
|
||||
|
||||
private void OnSliderRChanged(ChangeEvent<float> evt) => OnRGBSliderChanged('R', evt.newValue);
|
||||
private void OnSliderGChanged(ChangeEvent<float> evt) => OnRGBSliderChanged('G', evt.newValue);
|
||||
private void OnSliderBChanged(ChangeEvent<float> evt) => OnRGBSliderChanged('B', evt.newValue);
|
||||
private void OnSliderAChanged(ChangeEvent<float> evt) => OnRGBSliderChanged('A', evt.newValue);
|
||||
|
||||
private void OnFieldRChanged(ChangeEvent<int> evt) => OnRGBFieldChanged('R', evt.newValue);
|
||||
private void OnFieldGChanged(ChangeEvent<int> evt) => OnRGBFieldChanged('G', evt.newValue);
|
||||
private void OnFieldBChanged(ChangeEvent<int> evt) => OnRGBFieldChanged('B', evt.newValue);
|
||||
private void OnFieldAChanged(ChangeEvent<int> evt) => OnRGBFieldChanged('A', evt.newValue);
|
||||
|
||||
private void OnRGBSliderChanged(char channel, float value)
|
||||
{
|
||||
if (_isUpdating) return;
|
||||
@@ -1148,6 +1177,19 @@ namespace UVC.UIToolkit
|
||||
_sliderATexture = null;
|
||||
}
|
||||
|
||||
// 이벤트 콜백 해제
|
||||
_sliderR?.UnregisterCallback<ChangeEvent<float>>(OnSliderRChanged);
|
||||
_sliderG?.UnregisterCallback<ChangeEvent<float>>(OnSliderGChanged);
|
||||
_sliderB?.UnregisterCallback<ChangeEvent<float>>(OnSliderBChanged);
|
||||
_sliderA?.UnregisterCallback<ChangeEvent<float>>(OnSliderAChanged);
|
||||
|
||||
_fieldR?.UnregisterCallback<ChangeEvent<int>>(OnFieldRChanged);
|
||||
_fieldG?.UnregisterCallback<ChangeEvent<int>>(OnFieldGChanged);
|
||||
_fieldB?.UnregisterCallback<ChangeEvent<int>>(OnFieldBChanged);
|
||||
_fieldA?.UnregisterCallback<ChangeEvent<int>>(OnFieldAChanged);
|
||||
|
||||
_hexField?.UnregisterCallback<ChangeEvent<string>>(OnHexFieldChanged);
|
||||
|
||||
OnColorChanged = null;
|
||||
OnColorSelected = null;
|
||||
OnClosed = null;
|
||||
|
||||
@@ -533,6 +533,9 @@ namespace UVC.UIToolkit
|
||||
s_dayNameKeys = DEFAULT_DAY_NAME_KEYS;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 피커를 닫고, 정리합니다.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
OnClosed?.Invoke();
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
FadeOut(() =>
|
||||
{
|
||||
style.display = DisplayStyle.None;
|
||||
RemoveFromHierarchy();
|
||||
Dispose();
|
||||
});
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace UVC.UIToolkit
|
||||
|
||||
#region Fields
|
||||
private T _value;
|
||||
private bool _isReadOnly;
|
||||
private bool _isVisible = true;
|
||||
protected bool _isReadOnly;
|
||||
protected bool _isVisible = true;
|
||||
private string? _description;
|
||||
private string? _tooltip;
|
||||
private string? _groupId;
|
||||
|
||||
@@ -18,9 +18,10 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKBoolPropertyItem(string id, string name, bool initialValue = false)
|
||||
public UTKBoolPropertyItem(string id, string name, bool initialValue = false, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -37,6 +38,7 @@ namespace UVC.UIToolkit
|
||||
if (_toggle != null)
|
||||
{
|
||||
_toggle.IsOn = Value;
|
||||
_toggle.IsInteractive = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -55,6 +57,7 @@ namespace UVC.UIToolkit
|
||||
_toggle = new UTKToggle();
|
||||
_toggle.name = "value-field";
|
||||
_toggle.IsOn = Value;
|
||||
_toggle.IsInteractive = !IsReadOnly;
|
||||
|
||||
valueContainer.Add(_toggle);
|
||||
container.Add(valueContainer);
|
||||
@@ -70,7 +73,7 @@ namespace UVC.UIToolkit
|
||||
if (_toggle != null)
|
||||
{
|
||||
_toggle.IsOn = Value;
|
||||
_toggle.IsEnabled = !IsReadOnly;
|
||||
_toggle.IsInteractive = !IsReadOnly;
|
||||
_toggle.OnValueChanged += OnToggleChanged;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +103,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
if (_toggle != null)
|
||||
{
|
||||
_toggle.IsEnabled = !IsReadOnly;
|
||||
_toggle.IsInteractive = !IsReadOnly;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -30,10 +30,11 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKColorPropertyItem(string id, string name, Color initialValue = default, bool useAlpha = false)
|
||||
public UTKColorPropertyItem(string id, string name, Color initialValue = default, bool useAlpha = false, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
_useAlpha = useAlpha;
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -53,11 +54,18 @@ namespace UVC.UIToolkit
|
||||
if (_colorPreview != null)
|
||||
{
|
||||
_colorPreview.style.backgroundColor = Value;
|
||||
_colorPreview.SetEnabled(!IsReadOnly);
|
||||
}
|
||||
|
||||
if (_hexField != null)
|
||||
{
|
||||
_hexField.Value = ColorToHex(Value);
|
||||
_hexField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if(_pickerButton != null)
|
||||
{
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -78,6 +86,7 @@ namespace UVC.UIToolkit
|
||||
_colorPreview.name = "color-preview";
|
||||
_colorPreview.AddToClassList("utk-property-item__color-preview");
|
||||
_colorPreview.style.backgroundColor = Value;
|
||||
_colorPreview.SetEnabled(!IsReadOnly);
|
||||
valueContainer.Add(_colorPreview);
|
||||
|
||||
// Hex 입력
|
||||
@@ -86,11 +95,13 @@ namespace UVC.UIToolkit
|
||||
_hexField.Value = ColorToHex(Value);
|
||||
_hexField.style.width = 80;
|
||||
_hexField.style.marginLeft = 5;
|
||||
_hexField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_hexField);
|
||||
|
||||
// 피커 버튼
|
||||
_pickerButton = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_pickerButton.name = "picker-btn";
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
_pickerButton.AddToClassList("utk-property-item__picker-btn");
|
||||
valueContainer.Add(_pickerButton);
|
||||
|
||||
@@ -110,13 +121,14 @@ namespace UVC.UIToolkit
|
||||
if (_colorPreview != null)
|
||||
{
|
||||
_colorPreview.style.backgroundColor = Value;
|
||||
_colorPreview.SetEnabled(!IsReadOnly);
|
||||
_colorPreview.RegisterCallback<ClickEvent>(OnPreviewClicked);
|
||||
}
|
||||
|
||||
if (_hexField != null)
|
||||
{
|
||||
_hexField.Value = ColorToHex(Value);
|
||||
_hexField.SetEnabled(!IsReadOnly);
|
||||
_hexField.isReadOnly = IsReadOnly;
|
||||
_hexField.OnValueChanged += OnHexChanged;
|
||||
}
|
||||
|
||||
@@ -173,11 +185,10 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
|
||||
_hexField?.SetEnabled(!IsReadOnly);
|
||||
if (_pickerButton != null)
|
||||
{
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
_colorPreview?.SetEnabled(!IsReadOnly);
|
||||
|
||||
if(_hexField != null) _hexField.isReadOnly = IsReadOnly;
|
||||
if (_pickerButton != null) _pickerButton.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -217,7 +228,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_currentPicker.OnColorChanged -= OnPickerColorChanged;
|
||||
_currentPicker.OnColorSelected -= OnPickerColorSelected;
|
||||
_currentPicker.Dispose();
|
||||
_currentPicker.Close(); // Close()를 호출하여 블로커도 함께 정리
|
||||
_currentPicker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,16 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKColorStatePropertyItem(string id, string name, UTKColorState initialValue = default)
|
||||
public UTKColorStatePropertyItem(string id, string name, UTKColorState initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKColorStatePropertyItem(string id, string name, string state, Color color)
|
||||
public UTKColorStatePropertyItem(string id, string name, string state, Color color, bool isReadOnly = false)
|
||||
: base(id, name, new UTKColorState(state, color))
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -54,8 +56,8 @@ namespace UVC.UIToolkit
|
||||
if (_colorPreview != null)
|
||||
{
|
||||
_colorPreview.style.backgroundColor = Value.Color;
|
||||
_colorPreview.SetEnabled(!IsReadOnly);
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@@ -81,12 +83,14 @@ namespace UVC.UIToolkit
|
||||
_colorPreview.name = "color-preview";
|
||||
_colorPreview.AddToClassList("utk-property-item__color-preview");
|
||||
_colorPreview.style.backgroundColor = Value.Color;
|
||||
_colorPreview.SetEnabled(!IsReadOnly);
|
||||
valueContainer.Add(_colorPreview);
|
||||
|
||||
// 피커 버튼
|
||||
_pickerButton = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_pickerButton.name = "picker-btn";
|
||||
_pickerButton.AddToClassList("utk-property-item__picker-btn");
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
valueContainer.Add(_pickerButton);
|
||||
|
||||
container.Add(valueContainer);
|
||||
@@ -110,6 +114,7 @@ namespace UVC.UIToolkit
|
||||
if (_colorPreview != null)
|
||||
{
|
||||
_colorPreview.style.backgroundColor = Value.Color;
|
||||
_colorPreview.SetEnabled(!IsReadOnly);
|
||||
_colorPreview.RegisterCallback<ClickEvent>(OnPreviewClicked);
|
||||
}
|
||||
|
||||
@@ -156,6 +161,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
if (_pickerButton != null) _pickerButton.IsEnabled = !IsReadOnly;
|
||||
if (_colorPreview != null) _colorPreview.SetEnabled(!IsReadOnly);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -199,7 +205,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_currentPicker.OnColorChanged -= OnPickerColorChanged;
|
||||
_currentPicker.OnColorSelected -= OnPickerColorSelected;
|
||||
_currentPicker.Dispose();
|
||||
_currentPicker.Close();
|
||||
_currentPicker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,10 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKDatePropertyItem(string id, string name, DateTime initialValue = default)
|
||||
public UTKDatePropertyItem(string id, string name, DateTime initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue == default ? DateTime.Today : initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -54,6 +55,12 @@ namespace UVC.UIToolkit
|
||||
if (_dateField != null)
|
||||
{
|
||||
_dateField.Value = Value.ToString(_dateFormat);
|
||||
_dateField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_pickerButton != null)
|
||||
{
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -73,11 +80,13 @@ namespace UVC.UIToolkit
|
||||
_dateField.name = "date-field";
|
||||
_dateField.Value = Value.ToString(_dateFormat);
|
||||
_dateField.style.flexGrow = 1;
|
||||
_dateField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_dateField);
|
||||
|
||||
_pickerButton = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_pickerButton.name = "picker-btn";
|
||||
_pickerButton.AddToClassList("utk-property-item__picker-btn");
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
valueContainer.Add(_pickerButton);
|
||||
|
||||
container.Add(valueContainer);
|
||||
@@ -95,7 +104,7 @@ namespace UVC.UIToolkit
|
||||
if (_dateField != null)
|
||||
{
|
||||
_dateField.Value = Value.ToString(_dateFormat);
|
||||
_dateField.SetEnabled(!IsReadOnly);
|
||||
_dateField.isReadOnly = IsReadOnly;
|
||||
_dateField.OnValueChanged += OnDateTextChanged;
|
||||
}
|
||||
|
||||
@@ -141,7 +150,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
|
||||
_dateField?.SetEnabled(!IsReadOnly);
|
||||
if (_dateField != null) _dateField.isReadOnly = IsReadOnly;
|
||||
if (_pickerButton != null) _pickerButton.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
#endregion
|
||||
@@ -173,7 +182,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_currentPicker.OnDateSelected -= OnPickerDateSelected;
|
||||
_currentPicker.OnClosed -= OnPickerClosed;
|
||||
_currentPicker.Dispose();
|
||||
_currentPicker.Close();
|
||||
_currentPicker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,16 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKDateRangePropertyItem(string id, string name, UTKDateRange initialValue = default)
|
||||
public UTKDateRangePropertyItem(string id, string name, UTKDateRange initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue.Start == default ? new UTKDateRange(DateTime.Today, DateTime.Today) : initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKDateRangePropertyItem(string id, string name, DateTime start, DateTime end)
|
||||
public UTKDateRangePropertyItem(string id, string name, DateTime start, DateTime end, bool isReadOnly = false)
|
||||
: base(id, name, new UTKDateRange(start, end))
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -63,11 +65,22 @@ namespace UVC.UIToolkit
|
||||
if (_startField != null)
|
||||
{
|
||||
_startField.Value = Value.Start.ToString(_dateFormat);
|
||||
_startField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_endField != null)
|
||||
{
|
||||
_endField.Value = Value.End.ToString(_dateFormat);
|
||||
_endField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if(_startPickerBtn != null)
|
||||
{
|
||||
_startPickerBtn.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
if(_endPickerBtn != null)
|
||||
{
|
||||
_endPickerBtn.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -89,10 +102,12 @@ namespace UVC.UIToolkit
|
||||
_startField.name = "start-field";
|
||||
_startField.Value = Value.Start.ToString(_dateFormat);
|
||||
_startField.style.flexGrow = 1;
|
||||
_startField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_startField);
|
||||
|
||||
_startPickerBtn = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_startPickerBtn.name = "start-picker-btn";
|
||||
_startPickerBtn.IsEnabled = !IsReadOnly;
|
||||
_startPickerBtn.AddToClassList("utk-property-item__picker-btn");
|
||||
valueContainer.Add(_startPickerBtn);
|
||||
|
||||
@@ -105,10 +120,12 @@ namespace UVC.UIToolkit
|
||||
_endField.name = "end-field";
|
||||
_endField.Value = Value.End.ToString(_dateFormat);
|
||||
_endField.style.flexGrow = 1;
|
||||
_endField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_endField);
|
||||
|
||||
_endPickerBtn = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_endPickerBtn.name = "end-picker-btn";
|
||||
_endPickerBtn.IsEnabled = !IsReadOnly;
|
||||
_endPickerBtn.AddToClassList("utk-property-item__picker-btn");
|
||||
valueContainer.Add(_endPickerBtn);
|
||||
|
||||
@@ -129,14 +146,14 @@ namespace UVC.UIToolkit
|
||||
if (_startField != null)
|
||||
{
|
||||
_startField.Value = Value.Start.ToString(_dateFormat);
|
||||
_startField.SetEnabled(!IsReadOnly);
|
||||
_startField.isReadOnly = IsReadOnly;
|
||||
_startField.OnValueChanged += OnStartTextChanged;
|
||||
}
|
||||
|
||||
if (_endField != null)
|
||||
{
|
||||
_endField.Value = Value.End.ToString(_dateFormat);
|
||||
_endField.SetEnabled(!IsReadOnly);
|
||||
_endField.isReadOnly = IsReadOnly;
|
||||
_endField.OnValueChanged += OnEndTextChanged;
|
||||
}
|
||||
|
||||
@@ -208,8 +225,8 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
|
||||
_startField?.SetEnabled(!IsReadOnly);
|
||||
_endField?.SetEnabled(!IsReadOnly);
|
||||
if (_startField != null) _startField.isReadOnly = IsReadOnly;
|
||||
if (_endField != null) _endField.isReadOnly = IsReadOnly;
|
||||
if (_startPickerBtn != null) _startPickerBtn.IsEnabled = !IsReadOnly;
|
||||
if (_endPickerBtn != null) _endPickerBtn.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
@@ -247,7 +264,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_currentPicker.OnDateSelected -= OnPickerDateSelected;
|
||||
_currentPicker.OnClosed -= OnPickerClosed;
|
||||
_currentPicker.Dispose();
|
||||
_currentPicker.Close();
|
||||
_currentPicker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,10 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKDateTimePropertyItem(string id, string name, DateTime initialValue = default)
|
||||
public UTKDateTimePropertyItem(string id, string name, DateTime initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue == default ? DateTime.Now : initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -54,6 +55,12 @@ namespace UVC.UIToolkit
|
||||
if (_dateTimeField != null)
|
||||
{
|
||||
_dateTimeField.Value = Value.ToString(_dateTimeFormat);
|
||||
_dateTimeField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_pickerButton != null)
|
||||
{
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -73,10 +80,12 @@ namespace UVC.UIToolkit
|
||||
_dateTimeField.name = "datetime-field";
|
||||
_dateTimeField.Value = Value.ToString(_dateTimeFormat);
|
||||
_dateTimeField.style.flexGrow = 1;
|
||||
_dateTimeField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_dateTimeField);
|
||||
|
||||
_pickerButton = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_pickerButton.name = "picker-btn";
|
||||
_pickerButton.IsEnabled = !IsReadOnly;
|
||||
_pickerButton.AddToClassList("utk-property-item__picker-btn");
|
||||
valueContainer.Add(_pickerButton);
|
||||
|
||||
@@ -95,7 +104,7 @@ namespace UVC.UIToolkit
|
||||
if (_dateTimeField != null)
|
||||
{
|
||||
_dateTimeField.Value = Value.ToString(_dateTimeFormat);
|
||||
_dateTimeField.SetEnabled(!IsReadOnly);
|
||||
_dateTimeField.isReadOnly = IsReadOnly;
|
||||
_dateTimeField.OnValueChanged += OnDateTimeTextChanged;
|
||||
}
|
||||
|
||||
@@ -141,7 +150,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
|
||||
_dateTimeField?.SetEnabled(!IsReadOnly);
|
||||
if (_dateTimeField != null) _dateTimeField.isReadOnly = IsReadOnly;
|
||||
if (_pickerButton != null) _pickerButton.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
#endregion
|
||||
@@ -173,7 +182,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_currentPicker.OnDateSelected -= OnPickerDateSelected;
|
||||
_currentPicker.OnClosed -= OnPickerClosed;
|
||||
_currentPicker.Dispose();
|
||||
_currentPicker.Close();
|
||||
_currentPicker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,16 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKDateTimeRangePropertyItem(string id, string name, UTKDateTimeRange initialValue = default)
|
||||
public UTKDateTimeRangePropertyItem(string id, string name, UTKDateTimeRange initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue.Start == default ? new UTKDateTimeRange(DateTime.Now, DateTime.Now) : initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKDateTimeRangePropertyItem(string id, string name, DateTime start, DateTime end)
|
||||
public UTKDateTimeRangePropertyItem(string id, string name, DateTime start, DateTime end, bool isReadOnly = false)
|
||||
: base(id, name, new UTKDateTimeRange(start, end))
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -63,11 +65,23 @@ namespace UVC.UIToolkit
|
||||
if (_startField != null)
|
||||
{
|
||||
_startField.Value = Value.Start.ToString(_dateTimeFormat);
|
||||
_startField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_endField != null)
|
||||
{
|
||||
_endField.Value = Value.End.ToString(_dateTimeFormat);
|
||||
_endField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_startPickerBtn != null)
|
||||
{
|
||||
_startPickerBtn.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
if (_endPickerBtn != null)
|
||||
{
|
||||
_endPickerBtn.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -89,10 +103,12 @@ namespace UVC.UIToolkit
|
||||
_startField.name = "start-field";
|
||||
_startField.Value = Value.Start.ToString(_dateTimeFormat);
|
||||
_startField.style.flexGrow = 1;
|
||||
_startField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_startField);
|
||||
|
||||
_startPickerBtn = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_startPickerBtn.name = "start-picker-btn";
|
||||
_startPickerBtn.IsEnabled = !IsReadOnly;
|
||||
_startPickerBtn.AddToClassList("utk-property-item__picker-btn");
|
||||
valueContainer.Add(_startPickerBtn);
|
||||
|
||||
@@ -105,10 +121,12 @@ namespace UVC.UIToolkit
|
||||
_endField.name = "end-field";
|
||||
_endField.Value = Value.End.ToString(_dateTimeFormat);
|
||||
_endField.style.flexGrow = 1;
|
||||
_endField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_endField);
|
||||
|
||||
_endPickerBtn = new UTKButton("...", "", UTKButton.ButtonVariant.Secondary);
|
||||
_endPickerBtn.name = "end-picker-btn";
|
||||
_endPickerBtn.IsEnabled = !IsReadOnly;
|
||||
_endPickerBtn.AddToClassList("utk-property-item__picker-btn");
|
||||
valueContainer.Add(_endPickerBtn);
|
||||
|
||||
@@ -129,14 +147,14 @@ namespace UVC.UIToolkit
|
||||
if (_startField != null)
|
||||
{
|
||||
_startField.Value = Value.Start.ToString(_dateTimeFormat);
|
||||
_startField.SetEnabled(!IsReadOnly);
|
||||
_startField.isReadOnly = IsReadOnly;
|
||||
_startField.OnValueChanged += OnStartTextChanged;
|
||||
}
|
||||
|
||||
if (_endField != null)
|
||||
{
|
||||
_endField.Value = Value.End.ToString(_dateTimeFormat);
|
||||
_endField.SetEnabled(!IsReadOnly);
|
||||
_endField.isReadOnly = IsReadOnly;
|
||||
_endField.OnValueChanged += OnEndTextChanged;
|
||||
}
|
||||
|
||||
@@ -208,8 +226,8 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
|
||||
_startField?.SetEnabled(!IsReadOnly);
|
||||
_endField?.SetEnabled(!IsReadOnly);
|
||||
if (_startField != null) _startField.isReadOnly = IsReadOnly;
|
||||
if (_endField != null) _endField.isReadOnly = IsReadOnly;
|
||||
if (_startPickerBtn != null) _startPickerBtn.IsEnabled = !IsReadOnly;
|
||||
if (_endPickerBtn != null) _endPickerBtn.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
@@ -247,7 +265,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_currentPicker.OnDateSelected -= OnPickerDateSelected;
|
||||
_currentPicker.OnClosed -= OnPickerClosed;
|
||||
_currentPicker.Dispose();
|
||||
_currentPicker.Close();
|
||||
_currentPicker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKDropdownPropertyItem(string id, string name, List<string> choices, string initialValue = "")
|
||||
public UTKDropdownPropertyItem(string id, string name, List<string> choices, string initialValue = "", bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
_choices = choices ?? new List<string>();
|
||||
@@ -46,9 +46,10 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
Value = _choices[0];
|
||||
}
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKDropdownPropertyItem(string id, string name, IEnumerable<string> choices, int selectedIndex = 0)
|
||||
public UTKDropdownPropertyItem(string id, string name, IEnumerable<string> choices, int selectedIndex = 0, bool isReadOnly = false)
|
||||
: base(id, name, string.Empty)
|
||||
{
|
||||
_choices = choices?.ToList() ?? new List<string>();
|
||||
@@ -61,6 +62,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
Value = _choices[0];
|
||||
}
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -79,6 +81,7 @@ namespace UVC.UIToolkit
|
||||
_dropdown.SetOptions(_choices);
|
||||
int selectedIndex = _choices.IndexOf(Value);
|
||||
_dropdown.SelectedIndex = Math.Max(0, selectedIndex);
|
||||
_dropdown.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -99,6 +102,7 @@ namespace UVC.UIToolkit
|
||||
_dropdown.SetOptions(_choices);
|
||||
int selectedIndex = _choices.IndexOf(Value);
|
||||
_dropdown.SelectedIndex = Math.Max(0, selectedIndex);
|
||||
_dropdown.IsEnabled = !IsReadOnly;
|
||||
valueContainer.Add(_dropdown);
|
||||
|
||||
container.Add(valueContainer);
|
||||
|
||||
@@ -23,10 +23,11 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKEnumPropertyItem(string id, string name, Enum initialValue)
|
||||
public UTKEnumPropertyItem(string id, string name, Enum initialValue, bool isReadOnly = false)
|
||||
: base(id, name, initialValue ?? throw new ArgumentNullException(nameof(initialValue)))
|
||||
{
|
||||
_enumType = initialValue.GetType();
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -43,6 +44,7 @@ namespace UVC.UIToolkit
|
||||
if (_enumDropdown != null)
|
||||
{
|
||||
_enumDropdown.Init(Value);
|
||||
_enumDropdown.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -61,6 +63,7 @@ namespace UVC.UIToolkit
|
||||
_enumDropdown = new UTKEnumDropDown();
|
||||
_enumDropdown.name = "enum-dropdown";
|
||||
_enumDropdown.Init(Value);
|
||||
_enumDropdown.IsEnabled = !IsReadOnly;
|
||||
valueContainer.Add(_enumDropdown);
|
||||
|
||||
container.Add(valueContainer);
|
||||
|
||||
@@ -58,17 +58,19 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKFloatPropertyItem(string id, string name, float initialValue = 0f)
|
||||
public UTKFloatPropertyItem(string id, string name, float initialValue = 0f, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKFloatPropertyItem(string id, string name, float initialValue, float minValue, float maxValue, bool useSlider = true)
|
||||
public UTKFloatPropertyItem(string id, string name, float initialValue, float minValue, float maxValue, bool useSlider = true, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
_minValue = minValue;
|
||||
_maxValue = maxValue;
|
||||
_useSlider = useSlider;
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -88,6 +90,7 @@ namespace UVC.UIToolkit
|
||||
if (_floatField != null)
|
||||
{
|
||||
_floatField.Value = Value;
|
||||
_floatField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_slider != null)
|
||||
@@ -95,6 +98,7 @@ namespace UVC.UIToolkit
|
||||
_slider.lowValue = _minValue;
|
||||
_slider.highValue = _maxValue;
|
||||
_slider.Value = Value;
|
||||
_slider.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -119,12 +123,14 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_slider = new UTKSlider("", _minValue, _maxValue, Value);
|
||||
_slider.name = "slider-field";
|
||||
_slider.IsEnabled = !IsReadOnly;
|
||||
_slider.AddToClassList("utk-property-item__slider");
|
||||
valueContainer.Add(_slider);
|
||||
|
||||
_floatField = new UTKFloatField();
|
||||
_floatField.name = "value-field";
|
||||
_floatField.Value = Value;
|
||||
_floatField.isReadOnly = IsReadOnly;
|
||||
_floatField.AddToClassList("utk-property-item__number-field");
|
||||
valueContainer.Add(_floatField);
|
||||
}
|
||||
@@ -133,6 +139,7 @@ namespace UVC.UIToolkit
|
||||
_floatField = new UTKFloatField();
|
||||
_floatField.name = "value-field";
|
||||
_floatField.Value = Value;
|
||||
_floatField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_floatField);
|
||||
}
|
||||
|
||||
@@ -151,7 +158,7 @@ namespace UVC.UIToolkit
|
||||
if (_floatField != null)
|
||||
{
|
||||
_floatField.Value = Value;
|
||||
_floatField.IsEnabled = !IsReadOnly;
|
||||
_floatField.isReadOnly = IsReadOnly;
|
||||
_floatField.OnValueChanged += OnFloatFieldChanged;
|
||||
}
|
||||
|
||||
@@ -201,15 +208,17 @@ namespace UVC.UIToolkit
|
||||
|
||||
if (_floatField != null)
|
||||
{
|
||||
_floatField.IsEnabled = !IsReadOnly;
|
||||
_floatField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
if (_slider != null) _slider.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void OnFloatFieldChanged(float newValue)
|
||||
{
|
||||
Debug.Log($"OnFloatFieldChanged: {newValue}");
|
||||
float clampedValue = _useSlider ? Mathf.Clamp(newValue, _minValue, _maxValue) : newValue;
|
||||
|
||||
if (_slider != null && !Mathf.Approximately(_slider.Value, clampedValue))
|
||||
@@ -217,6 +226,11 @@ namespace UVC.UIToolkit
|
||||
_slider.SetValueWithoutNotify(clampedValue);
|
||||
}
|
||||
|
||||
if (_floatField != null && !Mathf.Approximately(_floatField.Value, clampedValue))
|
||||
{
|
||||
_floatField.SetValueWithoutNotify(clampedValue);
|
||||
}
|
||||
|
||||
DebounceValueChange(clampedValue, 100).Forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKFloatRangePropertyItem(string id, string name, UTKFloatRange initialValue = default)
|
||||
public UTKFloatRangePropertyItem(string id, string name, UTKFloatRange initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKFloatRangePropertyItem(string id, string name, float min, float max)
|
||||
public UTKFloatRangePropertyItem(string id, string name, float min, float max, bool isReadOnly = false)
|
||||
: base(id, name, new UTKFloatRange(min, max))
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -46,11 +48,13 @@ namespace UVC.UIToolkit
|
||||
if (_minField != null)
|
||||
{
|
||||
_minField.Value = Value.Min;
|
||||
_minField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_maxField != null)
|
||||
{
|
||||
_maxField.Value = Value.Max;
|
||||
_maxField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -71,6 +75,7 @@ namespace UVC.UIToolkit
|
||||
_minField.name = "min-field";
|
||||
_minField.Value = Value.Min;
|
||||
_minField.style.flexGrow = 1;
|
||||
_minField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_minField);
|
||||
|
||||
var separator = new UTKLabel("~", UTKLabel.LabelSize.Body2);
|
||||
@@ -81,6 +86,7 @@ namespace UVC.UIToolkit
|
||||
_maxField.name = "max-field";
|
||||
_maxField.Value = Value.Max;
|
||||
_maxField.style.flexGrow = 1;
|
||||
_maxField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_maxField);
|
||||
|
||||
container.Add(valueContainer);
|
||||
@@ -98,14 +104,14 @@ namespace UVC.UIToolkit
|
||||
if (_minField != null)
|
||||
{
|
||||
_minField.Value = Value.Min;
|
||||
_minField.IsEnabled = !IsReadOnly;
|
||||
_minField.isReadOnly = IsReadOnly;
|
||||
_minField.OnValueChanged += OnMinChanged;
|
||||
}
|
||||
|
||||
if (_maxField != null)
|
||||
{
|
||||
_maxField.Value = Value.Max;
|
||||
_maxField.IsEnabled = !IsReadOnly;
|
||||
_maxField.isReadOnly = IsReadOnly;
|
||||
_maxField.OnValueChanged += OnMaxChanged;
|
||||
}
|
||||
}
|
||||
@@ -144,8 +150,8 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
|
||||
if (_minField != null) _minField.IsEnabled = !IsReadOnly;
|
||||
if (_maxField != null) _maxField.IsEnabled = !IsReadOnly;
|
||||
if (_minField != null) _minField.isReadOnly = IsReadOnly;
|
||||
if (_maxField != null) _maxField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -63,12 +63,13 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
}
|
||||
|
||||
public UTKIntPropertyItem(string id, string name, int initialValue, int minValue, int maxValue, bool useSlider = true)
|
||||
public UTKIntPropertyItem(string id, string name, int initialValue, int minValue, int maxValue, bool useSlider = true, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
_minValue = minValue;
|
||||
_maxValue = maxValue;
|
||||
_useSlider = useSlider;
|
||||
_isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -88,6 +89,7 @@ namespace UVC.UIToolkit
|
||||
if (_intField != null)
|
||||
{
|
||||
_intField.Value = Value;
|
||||
_intField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_slider != null)
|
||||
@@ -95,6 +97,7 @@ namespace UVC.UIToolkit
|
||||
_slider.lowValue = _minValue;
|
||||
_slider.highValue = _maxValue;
|
||||
_slider.Value = Value;
|
||||
_slider.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -120,11 +123,13 @@ namespace UVC.UIToolkit
|
||||
_slider = new UTKSliderInt("", _minValue, _maxValue, Value);
|
||||
_slider.name = "slider-field";
|
||||
_slider.AddToClassList("utk-property-item__slider");
|
||||
_slider.IsEnabled = !IsReadOnly;
|
||||
valueContainer.Add(_slider);
|
||||
|
||||
_intField = new UTKIntegerField();
|
||||
_intField.name = "value-field";
|
||||
_intField.Value = Value;
|
||||
_intField.isReadOnly = IsReadOnly;
|
||||
_intField.AddToClassList("utk-property-item__number-field");
|
||||
valueContainer.Add(_intField);
|
||||
}
|
||||
@@ -133,6 +138,7 @@ namespace UVC.UIToolkit
|
||||
_intField = new UTKIntegerField();
|
||||
_intField.name = "value-field";
|
||||
_intField.Value = Value;
|
||||
_intField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_intField);
|
||||
}
|
||||
|
||||
@@ -151,7 +157,7 @@ namespace UVC.UIToolkit
|
||||
if (_intField != null)
|
||||
{
|
||||
_intField.Value = Value;
|
||||
_intField.IsEnabled = !IsReadOnly;
|
||||
_intField.isReadOnly = IsReadOnly;
|
||||
_intField.OnValueChanged += OnIntFieldChanged;
|
||||
}
|
||||
|
||||
@@ -201,7 +207,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
if (_intField != null)
|
||||
{
|
||||
_intField.IsEnabled = !IsReadOnly;
|
||||
_intField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
if (_slider != null) _slider.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,16 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKIntRangePropertyItem(string id, string name, UTKIntRange initialValue = default)
|
||||
public UTKIntRangePropertyItem(string id, string name, UTKIntRange initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
public UTKIntRangePropertyItem(string id, string name, int min, int max)
|
||||
public UTKIntRangePropertyItem(string id, string name, int min, int max, bool isReadOnly = false)
|
||||
: base(id, name, new UTKIntRange(min, max))
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -45,11 +47,13 @@ namespace UVC.UIToolkit
|
||||
if (_minField != null)
|
||||
{
|
||||
_minField.Value = Value.Min;
|
||||
_minField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
if (_maxField != null)
|
||||
{
|
||||
_maxField.Value = Value.Max;
|
||||
_maxField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
@@ -70,6 +74,7 @@ namespace UVC.UIToolkit
|
||||
_minField.name = "min-field";
|
||||
_minField.Value = Value.Min;
|
||||
_minField.style.flexGrow = 1;
|
||||
_minField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_minField);
|
||||
|
||||
var separator = new UTKLabel("~", UTKLabel.LabelSize.Body2);
|
||||
@@ -80,6 +85,7 @@ namespace UVC.UIToolkit
|
||||
_maxField.name = "max-field";
|
||||
_maxField.Value = Value.Max;
|
||||
_maxField.style.flexGrow = 1;
|
||||
_maxField.isReadOnly = IsReadOnly;
|
||||
valueContainer.Add(_maxField);
|
||||
|
||||
container.Add(valueContainer);
|
||||
@@ -97,14 +103,14 @@ namespace UVC.UIToolkit
|
||||
if (_minField != null)
|
||||
{
|
||||
_minField.Value = Value.Min;
|
||||
_minField.IsEnabled = !IsReadOnly;
|
||||
_minField.isReadOnly = IsReadOnly;
|
||||
_minField.OnValueChanged += OnMinChanged;
|
||||
}
|
||||
|
||||
if (_maxField != null)
|
||||
{
|
||||
_maxField.Value = Value.Max;
|
||||
_maxField.IsEnabled = !IsReadOnly;
|
||||
_maxField.isReadOnly = IsReadOnly;
|
||||
_maxField.OnValueChanged += OnMaxChanged;
|
||||
}
|
||||
}
|
||||
@@ -143,8 +149,8 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
base.UpdateReadOnlyState();
|
||||
|
||||
if (_minField != null) _minField.IsEnabled = !IsReadOnly;
|
||||
if (_maxField != null) _maxField.IsEnabled = !IsReadOnly;
|
||||
if (_minField != null) _minField.isReadOnly = IsReadOnly;
|
||||
if (_maxField != null) _maxField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -47,14 +47,15 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKRadioPropertyItem(string id, string name, List<string> choices, int selectedIndex = 0)
|
||||
public UTKRadioPropertyItem(string id, string name, List<string> choices, int selectedIndex = 0, bool isReadOnly = false)
|
||||
: base(id, name, Math.Max(0, Math.Min(selectedIndex, (choices?.Count ?? 1) - 1)))
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
_choices = choices ?? new List<string>();
|
||||
}
|
||||
|
||||
public UTKRadioPropertyItem(string id, string name, IEnumerable<string> choices, int selectedIndex = 0)
|
||||
: this(id, name, choices?.ToList() ?? new List<string>(), selectedIndex)
|
||||
public UTKRadioPropertyItem(string id, string name, IEnumerable<string> choices, int selectedIndex = 0, bool isReadOnly = false)
|
||||
: this(id, name, choices?.ToList() ?? new List<string>(), selectedIndex, isReadOnly)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
@@ -185,8 +186,9 @@ namespace UVC.UIToolkit
|
||||
radio.AddToClassList("utk-property-item__radio");
|
||||
|
||||
int index = i;
|
||||
radio.OnValueChanged += (isChecked) => OnRadioChanged(index, isChecked);
|
||||
|
||||
radio.OnValueChanged += (isChecked) => OnRadioChanged(index, isChecked);
|
||||
radio.IsEnabled = !IsReadOnly;
|
||||
|
||||
_radioButtons.Add(radio);
|
||||
_radioContainer.Add(radio);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,12 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKStringPropertyItem(string id, string name, string initialValue = "")
|
||||
public UTKStringPropertyItem(string id, string name, string initialValue = "", bool isReadOnly = false, bool isMultiline = false, int maxLength = 0)
|
||||
: base(id, name, initialValue ?? string.Empty)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
_isMultiline = isMultiline;
|
||||
_maxLength = maxLength;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -68,6 +71,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_inputField.Value = Value;
|
||||
_inputField.multiline = _isMultiline;
|
||||
_inputField.isReadOnly = base._isReadOnly;
|
||||
if (_maxLength > 0)
|
||||
{
|
||||
_inputField.maxLength = _maxLength;
|
||||
@@ -91,6 +95,7 @@ namespace UVC.UIToolkit
|
||||
_inputField.name = "value-field";
|
||||
_inputField.Value = Value;
|
||||
_inputField.multiline = _isMultiline;
|
||||
_inputField.isReadOnly = IsReadOnly;
|
||||
if (_maxLength > 0)
|
||||
{
|
||||
_inputField.maxLength = _maxLength;
|
||||
@@ -110,7 +115,8 @@ namespace UVC.UIToolkit
|
||||
if (_inputField != null)
|
||||
{
|
||||
_inputField.Value = Value;
|
||||
_inputField.SetEnabled(!IsReadOnly);
|
||||
_inputField.multiline = _isMultiline;
|
||||
_inputField.isReadOnly = IsReadOnly;
|
||||
_inputField.OnValueChanged += OnTextChanged;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +146,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
if (_inputField != null)
|
||||
{
|
||||
_inputField.SetEnabled(!IsReadOnly);
|
||||
_inputField.isReadOnly = IsReadOnly;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -19,9 +19,10 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public UTKVector2PropertyItem(string id, string name, Vector2 initialValue = default)
|
||||
public UTKVector2PropertyItem(string id, string name, Vector2 initialValue = default, bool isReadOnly = false)
|
||||
: base(id, name, initialValue)
|
||||
{
|
||||
base._isReadOnly = isReadOnly;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -39,6 +40,7 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
_vectorField.Value = Value;
|
||||
_vectorField.label = "";
|
||||
_vectorField.IsEnabled = !IsReadOnly;
|
||||
}
|
||||
|
||||
return container;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace UVC.UIToolkit
|
||||
private UTKLabel? _titleLabel;
|
||||
private UTKButton? _closeButton;
|
||||
private string _title = "Properties";
|
||||
private bool _showCloseButton = true;
|
||||
private bool _showCloseButton = false;
|
||||
private bool _isDragging;
|
||||
private Vector2 _dragStartPosition;
|
||||
private Vector2 _dragStartMousePosition;
|
||||
@@ -165,8 +165,7 @@ namespace UVC.UIToolkit
|
||||
if (_titleLabel != null)
|
||||
{
|
||||
_titleLabel.Text = _title;
|
||||
_titleLabel.IsBold = true;
|
||||
_titleLabel.Size = UTKLabel.LabelSize.Label1;
|
||||
_titleLabel.Size = UTKLabel.LabelSize.Label3;
|
||||
}
|
||||
|
||||
// 닫기 버튼 설정
|
||||
@@ -195,9 +194,8 @@ namespace UVC.UIToolkit
|
||||
_header.name = "header";
|
||||
_header.AddToClassList("utk-property-window__header");
|
||||
|
||||
_titleLabel = new UTKLabel(_title, UTKLabel.LabelSize.Label1);
|
||||
_titleLabel = new UTKLabel(_title, UTKLabel.LabelSize.Label3);
|
||||
_titleLabel.name = "title";
|
||||
_titleLabel.IsBold = true;
|
||||
_titleLabel.AddToClassList("utk-property-window__title");
|
||||
_header.Add(_titleLabel);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnSliderValueChanged);
|
||||
RegisterCallback<ChangeEvent<Vector2>>(OnSliderValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -195,6 +195,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<Vector2>>(OnSliderValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnSliderValueChanged);
|
||||
RegisterCallback<ChangeEvent<float>>(OnSliderValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -177,6 +177,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<float>>(OnSliderValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
private void SetupEvents()
|
||||
{
|
||||
this.RegisterValueChangedCallback(OnSliderValueChanged);
|
||||
RegisterCallback<ChangeEvent<int>>(OnSliderValueChanged);
|
||||
}
|
||||
|
||||
private void SubscribeToThemeChanges()
|
||||
@@ -186,6 +186,7 @@ namespace UVC.UIToolkit
|
||||
|
||||
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
|
||||
OnValueChanged = null;
|
||||
UnregisterCallback<ChangeEvent<int>>(OnSliderValueChanged);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user