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