UTKProperyWindow 개발 중

This commit is contained in:
logonkhi
2026-02-03 20:43:36 +09:00
parent 297ca29082
commit 8181eae4c6
74 changed files with 1268 additions and 385 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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);