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