UTKFloatStepper 추가. UTKFloatPropertyItem, UTKFloatPropertyItemView에 추가

This commit is contained in:
logonkhi
2026-02-09 20:28:09 +09:00
parent a38efd756e
commit 97bbb789ed
65 changed files with 2785 additions and 131 deletions

View File

@@ -29,6 +29,7 @@ namespace UVC.UIToolkit
private T _value;
private bool _isReadOnly;
private bool _isVisible = true;
private bool _showLabel = true;
private string? _description;
private string? _tooltip;
private string? _groupId;
@@ -103,6 +104,13 @@ namespace UVC.UIToolkit
get => _groupId;
set => _groupId = value;
}
/// <summary>라벨 표시 여부 (false면 value가 전체 너비 사용)</summary>
public bool ShowLabel
{
get => _showLabel;
set => _showLabel = value;
}
#endregion
#region Events

View File

@@ -0,0 +1,119 @@
#nullable enable
using System;
using UnityEngine;
namespace UVC.UIToolkit
{
/// <summary>
/// 버튼 속성 Item 클래스입니다.
/// UTKButton 설정을 포함하며, 클릭 시 Action 이름을 전달합니다.
/// </summary>
public class UTKButtonItem : UTKPropertyItemBase<string>
{
#region Properties
public override UTKPropertyType PropertyType => UTKPropertyType.Button;
/// <summary>버튼 텍스트</summary>
public string Text { get; set; }
/// <summary>버튼 아이콘</summary>
public string Icon { get; set; }
/// <summary>아이콘 크기</summary>
public int IconSize { get; set; }
/// <summary>버튼 스타일 변형</summary>
public UTKButton.ButtonVariant Variant { get; set; }
/// <summary>버튼 크기</summary>
public UTKButton.ButtonSize Size { get; set; }
/// <summary>커스텀 배경 색상</summary>
public Color? BackgroundColor { get; set; }
/// <summary>외곽선 굵기</summary>
public int BorderWidth { get; set; }
/// <summary>아이콘만 표시 모드</summary>
public bool IconOnly { get; set; }
/// <summary>라벨 표시 여부 (false면 버튼이 전체 너비 사용)</summary>
public bool ShowLabel { get; set; }
/// <summary>액션 이름 (버튼 클릭 시 전달되는 고유 이름)</summary>
public string ActionName { get; }
#endregion
#region Constructor
/// <summary>
/// 기본 버튼 아이템을 생성합니다.
/// </summary>
/// <param name="id">고유 ID</param>
/// <param name="actionName">액션 이름 (클릭 시 전달)</param>
/// <param name="text">버튼 텍스트</param>
/// <param name="icon">버튼 아이콘</param>
/// <param name="variant">버튼 스타일</param>
/// <param name="size">버튼 크기</param>
public UTKButtonItem(
string id,
string actionName,
string text = "",
string icon = "",
UTKButton.ButtonVariant variant = UTKButton.ButtonVariant.Normal,
UTKButton.ButtonSize size = UTKButton.ButtonSize.Medium)
: base(id, actionName, actionName)
{
ActionName = actionName;
Text = text;
Icon = icon;
IconSize = 12;
Variant = variant;
Size = size;
BackgroundColor = null;
BorderWidth = -1;
IconOnly = false;
ShowLabel = true; // 기본적으로 라벨 표시
}
/// <summary>
/// 전체 설정을 포함한 버튼 아이템을 생성합니다.
/// </summary>
/// <param name="id">고유 ID</param>
/// <param name="actionName">액션 이름</param>
/// <param name="text">버튼 텍스트</param>
/// <param name="icon">버튼 아이콘</param>
/// <param name="iconSize">아이콘 크기</param>
/// <param name="variant">버튼 스타일</param>
/// <param name="size">버튼 크기</param>
/// <param name="backgroundColor">배경 색상</param>
/// <param name="borderWidth">외곽선 굵기</param>
/// <param name="iconOnly">아이콘만 표시</param>
/// <param name="showLabel">라벨 표시 여부</param>
public UTKButtonItem(
string id,
string actionName,
string text,
string icon,
int iconSize,
UTKButton.ButtonVariant variant,
UTKButton.ButtonSize size,
Color? backgroundColor,
int borderWidth,
bool iconOnly,
bool showLabel = true)
: base(id, actionName, actionName)
{
ActionName = actionName;
Text = text;
Icon = icon;
IconSize = iconSize;
Variant = variant;
Size = size;
BackgroundColor = backgroundColor;
BorderWidth = borderWidth;
IconOnly = iconOnly;
ShowLabel = showLabel;
}
#endregion
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 180e39abb0136364c90d52fbd5b63fd6

View File

@@ -10,8 +10,10 @@ namespace UVC.UIToolkit
{
#region Fields
private bool _useSlider;
private bool _useStepper;
private float _minValue;
private float _maxValue = 1f;
private float _step = 1.0f;
#endregion
#region Properties
@@ -25,6 +27,20 @@ namespace UVC.UIToolkit
set => _useSlider = value;
}
/// <summary>스테퍼(증감 버튼) 사용 여부</summary>
public bool UseStepper
{
get => _useStepper;
set => _useStepper = value;
}
/// <summary>스테퍼 증감 단위 (기본값: 0.1)</summary>
public float Step
{
get => _step;
set => _step = value > 0 ? value : 0.1f;
}
/// <summary>최소값 (슬라이더 모드)</summary>
public float MinValue
{
@@ -63,13 +79,15 @@ namespace UVC.UIToolkit
/// <param name="minValue">최소값</param>
/// <param name="maxValue">최대값</param>
/// <param name="useSlider">슬라이더 사용 여부</param>
/// <param name="useStepper">스테퍼 사용 여부</param>
/// <param name="isReadOnly">읽기 전용 여부</param>
public UTKFloatPropertyItem(string id, string name, float initialValue, float minValue = float.MinValue, float maxValue = float.MaxValue, bool useSlider = true, bool isReadOnly = false)
public UTKFloatPropertyItem(string id, string name, float initialValue, float minValue = float.MinValue, float maxValue = float.MaxValue, bool useSlider = true, bool useStepper = false, bool isReadOnly = false)
: base(id, name, initialValue)
{
_minValue = minValue;
_maxValue = maxValue;
_useSlider = useSlider;
_useStepper = useStepper;
IsReadOnly = isReadOnly;
}
#endregion

View File

@@ -0,0 +1,162 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
namespace UVC.UIToolkit
{
/// <summary>
/// 다중 선택 드롭다운 속성 데이터 클래스입니다.
/// UI는 UTKMultiSelectDropdownPropertyItemView에서 담당합니다.
/// </summary>
public class UTKMultiSelectDropdownPropertyItem : UTKPropertyItemBase<List<string>>
{
#region Fields
private List<string> _choices;
#endregion
#region Properties
/// <summary>속성 타입</summary>
public override UTKPropertyType PropertyType => UTKPropertyType.MultiSelectDropdownList;
/// <summary>선택 가능한 항목 목록</summary>
public List<string> Choices
{
get => _choices;
set => _choices = value ?? new List<string>();
}
/// <summary>선택된 인덱스 목록</summary>
public List<int> SelectedIndices
{
get
{
if (Value == null || Value.Count == 0)
return new List<int>();
return Value
.Select(v => _choices.IndexOf(v))
.Where(i => i >= 0)
.OrderBy(i => i)
.ToList();
}
}
#endregion
#region Constructor
/// <summary>
/// 다중 선택 드롭다운 속성을 생성합니다.
/// </summary>
/// <param name="id">고유 ID</param>
/// <param name="name">표시 이름</param>
/// <param name="choices">선택 항목 목록</param>
/// <param name="initialValues">초기 선택 값 목록</param>
/// <param name="isReadOnly">읽기 전용 여부</param>
public UTKMultiSelectDropdownPropertyItem(
string id,
string name,
List<string> choices,
List<string>? initialValues = null,
bool isReadOnly = false)
: base(id, name, initialValues ?? new List<string>())
{
_choices = choices ?? new List<string>();
// initialValues가 유효한지 확인하고 필터링
if (initialValues != null && initialValues.Count > 0)
{
var validValues = initialValues.Where(v => _choices.Contains(v)).ToList();
Value = validValues;
}
IsReadOnly = isReadOnly;
}
/// <summary>
/// 다중 선택 드롭다운 속성을 생성합니다 (인덱스 기반).
/// </summary>
/// <param name="id">고유 ID</param>
/// <param name="name">표시 이름</param>
/// <param name="choices">선택 항목 목록</param>
/// <param name="selectedIndices">초기 선택 인덱스 목록</param>
/// <param name="isReadOnly">읽기 전용 여부</param>
public UTKMultiSelectDropdownPropertyItem(
string id,
string name,
IEnumerable<string> choices,
IEnumerable<int>? selectedIndices = null,
bool isReadOnly = false)
: base(id, name, new List<string>())
{
_choices = choices?.ToList() ?? new List<string>();
if (selectedIndices != null)
{
var validValues = selectedIndices
.Where(i => i >= 0 && i < _choices.Count)
.Select(i => _choices[i])
.ToList();
Value = validValues;
}
IsReadOnly = isReadOnly;
}
#endregion
#region Public Methods
/// <summary>선택 항목 추가</summary>
public void AddChoice(string choice)
{
if (!_choices.Contains(choice))
{
_choices.Add(choice);
}
}
/// <summary>선택 항목 제거</summary>
public bool RemoveChoice(string choice)
{
bool removed = _choices.Remove(choice);
if (removed && Value != null && Value.Contains(choice))
{
// 값 목록에서도 제거
var newValue = Value.Where(v => v != choice).ToList();
Value = newValue;
}
return removed;
}
/// <summary>인덱스로 선택 설정</summary>
public void SetSelectedIndices(List<int> indices)
{
var validValues = indices
.Where(i => i >= 0 && i < _choices.Count)
.Select(i => _choices[i])
.Distinct()
.ToList();
Value = validValues;
}
/// <summary>값으로 선택 설정</summary>
public void SetSelectedValues(List<string> values)
{
var validValues = values
.Where(v => _choices.Contains(v))
.Distinct()
.ToList();
Value = validValues;
}
/// <summary>모든 항목 선택</summary>
public void SelectAll()
{
Value = new List<string>(_choices);
}
/// <summary>모든 선택 해제</summary>
public void ClearSelection()
{
Value = new List<string>();
}
#endregion
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8ffce5db6e1fd4748b4e6c1d72812fb7

View File

@@ -30,6 +30,9 @@ namespace UVC.UIToolkit
get => _maxLength;
set => _maxLength = value;
}
/// <summary>액션 버튼 설정 (null이면 버튼 미표시)</summary>
public UTKButtonItem? ActionButton { get; set; }
#endregion
#region Constructor
@@ -42,12 +45,14 @@ namespace UVC.UIToolkit
/// <param name="isMultiline">멀티라인 모드</param>
/// <param name="maxLength">최대 문자 길이</param>
/// <param name="isReadOnly">읽기 전용 여부</param>
public UTKStringPropertyItem(string id, string name, string initialValue = "", bool isMultiline = false, int maxLength = -1, bool isReadOnly = false)
/// <param name="actionButton">액션 버튼</param>
public UTKStringPropertyItem(string id, string name, string initialValue = "", bool isMultiline = false, int maxLength = -1, bool isReadOnly = false, UTKButtonItem? actionButton = null)
: base(id, name, initialValue ?? string.Empty)
{
IsReadOnly = isReadOnly;
_isMultiline = isMultiline;
_maxLength = maxLength;
ActionButton = actionButton;
}
#endregion
}