UTKProperyWindow 개발 중
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user