UTKNotification 수정 중

This commit is contained in:
logonkhi
2026-02-23 19:38:27 +09:00
parent 106e7f51be
commit b9b394935e
31 changed files with 961 additions and 422 deletions

View File

@@ -195,6 +195,10 @@ namespace UVC.UIToolkit
{
UTKThemeManager.Instance.OnThemeChanged -= OnThemeChanged;
UTKThemeManager.Instance.OnThemeChanged += OnThemeChanged;
// Property View에서 사용하는 Picker들의 Root를 자동 설정
UTKColorPicker.SetRoot(this);
UTKDatePicker.SetRoot(this);
}
private void OnDetachFromPanel(DetachFromPanelEvent evt)

View File

@@ -287,7 +287,7 @@ namespace UVC.UIToolkit
}
/// <summary>
/// List&lt;Dictionary&gt;로부터 데이터를 변환하여 설정합니다.
/// List<Dictionary>로부터 데이터를 변환하여 설정합니다.
/// Dictionary 키: "order" (순서), "active" (사용 유무), "text" (표시 내용)
/// </summary>
/// <param name="listDict">변환할 Dictionary 목록.</param>
@@ -332,7 +332,7 @@ namespace UVC.UIToolkit
}
/// <summary>
/// 전체 아이템을 List&lt;Dictionary&lt;string, string&gt;&gt;로 변환하여 반환합니다.
/// 전체 아이템을 List<Dictionary<string, string>>로 변환하여 반환합니다.
/// Dictionary 키: "order" (순서), "active" (사용 유무), "text" (표시 내용)
/// </summary>
/// <returns>각 아이템을 Dictionary로 변환한 목록.</returns>

View File

@@ -122,7 +122,7 @@ namespace UVC.UIToolkit
}
/// <summary>
/// List&lt;Dictionary&gt;로부터 데이터를 변환하여 설정합니다.
/// List<Dictionary>로부터 데이터를 변환하여 설정합니다.
/// Dictionary 키: "order" (순서), "active" (사용 유무), "text" (표시 내용)
/// </summary>
/// <param name="listDict">변환할 Dictionary 목록.</param>
@@ -141,7 +141,7 @@ namespace UVC.UIToolkit
}
/// <summary>
/// 전체 아이템을 List&lt;Dictionary&lt;string, string&gt;&gt;로 변환하여 반환합니다.
/// 전체 아이템을 List<Dictionary<string, string>>로 변환하여 반환합니다.
/// Dictionary 키: "order" (순서), "active" (사용 유무), "text" (표시 내용)
/// </summary>
/// <returns>각 아이템을 Dictionary로 변환한 목록.</returns>

View File

@@ -36,7 +36,6 @@ namespace UVC.UIToolkit
/// <para><b>사용 전 초기화:</b></para>
/// <para>
/// Alert를 표시하기 전에 <c>UTKAlert.SetRoot(rootVisualElement)</c>로 루트를 설정해야 합니다.
/// 또는 <c>Show(parent, ...)</c>로 부모 요소를 직접 전달할 수 있습니다.
/// </para>
///
/// <para><b>동기 vs 비동기 호출:</b></para>
@@ -57,21 +56,21 @@ namespace UVC.UIToolkit
/// <para><b>C# 코드에서 사용:</b></para>
/// <code>
/// // 초기화 (root 설정 필요)
/// UTKAlert.Initialize(rootVisualElement);
///
/// UTKAlert.SetRoot(rootVisualElement);
///
/// // 기본 알림
/// await UTKAlert.Show("알림", "작업이 완료되었습니다.");
///
/// await UTKAlert.ShowInfoAsync("알림", "작업이 완료되었습니다.");
///
/// // 확인 대화상자
/// bool confirmed = await UTKAlert.ShowConfirm("삭제 확인", "정말 삭제하시겠습니까?");
/// bool confirmed = await UTKAlert.ShowConfirmAsync("삭제 확인", "정말 삭제하시겠습니까?");
/// if (confirmed) {
/// // 삭제 실행
/// }
///
///
/// // 타입별 알림
/// await UTKAlert.ShowSuccess("성공", "저장되었습니다.");
/// await UTKAlert.ShowError("오류", "파일을 찾을 수 없습니다.");
/// await UTKAlert.ShowWarning("경고", "변경사항이 저장되지 않았습니다.");
/// await UTKAlert.ShowSuccessAsync("성공", "저장되었습니다.");
/// await UTKAlert.ShowErrorAsync("오류", "파일을 찾을 수 없습니다.");
/// await UTKAlert.ShowWarningAsync("경고", "변경사항이 저장되지 않았습니다.");
/// </code>
/// <para><b>UXML에서 사용:</b></para>
/// <code>
@@ -194,7 +193,8 @@ namespace UVC.UIToolkit
#region Static Methods
/// <summary>
/// 기본 루트 요소 설정
/// 기본 루트 요소 설정.
/// 모든 Alert는 이 루트의 panel.visualTree에 표시됩니다.
/// </summary>
/// <param name="root">Alert를 표시할 기본 루트 요소</param>
public static void SetRoot(VisualElement root)
@@ -206,65 +206,6 @@ namespace UVC.UIToolkit
/// 기본 루트 요소 반환
/// </summary>
public static VisualElement? GetRoot() => _root;
#endregion
#region Static Factory (without parent)
/// <summary>
/// Info 알림 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKAlert ShowInfo(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return Show(_root!, title, message, AlertType.Info, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Success 알림 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKAlert ShowSuccess(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return Show(_root!, title, message, AlertType.Success, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Warning 알림 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKAlert ShowWarning(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return Show(_root!, title, message, AlertType.Warning, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Error 알림 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKAlert ShowError(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return Show(_root!, title, message, AlertType.Error, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Confirm 대화상자 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKAlert ShowConfirm(string title, string message, Action? onConfirm, Action? onCancel = null, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
ValidateRoot();
var alert = Show(_root!, title, message, AlertType.Confirm, null, closeOnBlockerClick, confirmLabel, cancelLabel);
alert.OnConfirm = onConfirm;
alert.OnCancel = onCancel;
return alert;
}
/// <summary>
/// 알림 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKAlert Show(string title, string message, AlertType type = AlertType.Info, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
ValidateRoot();
return Show(_root!, title, message, type, onClose, closeOnBlockerClick, confirmLabel, cancelLabel);
}
private static void ValidateRoot()
{
@@ -275,151 +216,45 @@ namespace UVC.UIToolkit
}
#endregion
#region Static Factory Async (without parent)
/// <summary>
/// Info 알림 표시 (비동기, SetRoot로 설정된 루트 사용)
/// </summary>
public static UniTask ShowInfoAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return ShowAsync(_root!, title, message, AlertType.Info, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Success 알림 표시 (비동기, SetRoot로 설정된 루트 사용)
/// </summary>
public static UniTask ShowSuccessAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return ShowAsync(_root!, title, message, AlertType.Success, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Warning 알림 표시 (비동기, SetRoot로 설정된 루트 사용)
/// </summary>
public static UniTask ShowWarningAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return ShowAsync(_root!, title, message, AlertType.Warning, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Error 알림 표시 (비동기, SetRoot로 설정된 루트 사용)
/// </summary>
public static UniTask ShowErrorAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
ValidateRoot();
return ShowAsync(_root!, title, message, AlertType.Error, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Confirm 대화상자 표시 (비동기, SetRoot로 설정된 루트 사용)
/// </summary>
/// <returns>확인 버튼 클릭 시 true, 취소 버튼 클릭 시 false</returns>
public static UniTask<bool> ShowConfirmAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
ValidateRoot();
return ShowConfirmAsync(_root!, title, message, closeOnBlockerClick, confirmLabel, cancelLabel);
}
#endregion
#region Static Factory Async (with parent)
/// <summary>
/// Info 알림 표시 (비동기)
/// </summary>
public static UniTask ShowInfoAsync(VisualElement parent, string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(parent, title, message, AlertType.Info, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Success 알림 표시 (비동기)
/// </summary>
public static UniTask ShowSuccessAsync(VisualElement parent, string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(parent, title, message, AlertType.Success, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Warning 알림 표시 (비동기)
/// </summary>
public static UniTask ShowWarningAsync(VisualElement parent, string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(parent, title, message, AlertType.Warning, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Error 알림 표시 (비동기)
/// </summary>
public static UniTask ShowErrorAsync(VisualElement parent, string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(parent, title, message, AlertType.Error, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Confirm 대화상자 표시 (비동기)
/// </summary>
/// <returns>확인 버튼 클릭 시 true, 취소 버튼 클릭 시 false</returns>
public static UniTask<bool> ShowConfirmAsync(VisualElement parent, string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
var tcs = new UniTaskCompletionSource<bool>();
var alert = Show(parent, title, message, AlertType.Confirm, null, closeOnBlockerClick, confirmLabel, cancelLabel);
alert.OnConfirm = () => tcs.TrySetResult(true);
alert.OnCancel = () => tcs.TrySetResult(false);
alert.OnClosed = () => tcs.TrySetResult(false);
return tcs.Task;
}
/// <summary>
/// 알림 표시 (비동기)
/// </summary>
public static UniTask ShowAsync(VisualElement parent, string title, string message, AlertType type, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
var tcs = new UniTaskCompletionSource();
var alert = Show(parent, title, message, type, () => tcs.TrySetResult(), closeOnBlockerClick, confirmLabel, cancelLabel);
return tcs.Task;
}
#endregion
#region Static Factory (with parent)
#region Static Factory
/// <summary>
/// Info 알림 표시
/// </summary>
public static UTKAlert ShowInfo(VisualElement parent, string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
public static UTKAlert ShowInfo(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return Show(parent, title, message, AlertType.Info, onClose, closeOnBlockerClick, confirmLabel);
return Show(title, message, AlertType.Info, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Success 알림 표시
/// </summary>
public static UTKAlert ShowSuccess(VisualElement parent, string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
public static UTKAlert ShowSuccess(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return Show(parent, title, message, AlertType.Success, onClose, closeOnBlockerClick, confirmLabel);
return Show(title, message, AlertType.Success, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Warning 알림 표시
/// </summary>
public static UTKAlert ShowWarning(VisualElement parent, string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
public static UTKAlert ShowWarning(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return Show(parent, title, message, AlertType.Warning, onClose, closeOnBlockerClick, confirmLabel);
return Show(title, message, AlertType.Warning, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Error 알림 표시
/// </summary>
public static UTKAlert ShowError(VisualElement parent, string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
public static UTKAlert ShowError(string title, string message, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return Show(parent, title, message, AlertType.Error, onClose, closeOnBlockerClick, confirmLabel);
return Show(title, message, AlertType.Error, onClose, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Confirm 대화상자 표시
/// </summary>
public static UTKAlert ShowConfirm(VisualElement parent, string title, string message, Action? onConfirm, Action? onCancel = null, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
public static UTKAlert ShowConfirm(string title, string message, Action? onConfirm, Action? onCancel = null, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
var alert = Show(parent, title, message, AlertType.Confirm, null, closeOnBlockerClick, confirmLabel, cancelLabel);
var alert = Show(title, message, AlertType.Confirm, null, closeOnBlockerClick, confirmLabel, cancelLabel);
alert.OnConfirm = onConfirm;
alert.OnCancel = onCancel;
return alert;
@@ -428,7 +263,6 @@ namespace UVC.UIToolkit
/// <summary>
/// 알림 표시
/// </summary>
/// <param name="parent">부모 요소</param>
/// <param name="title">제목</param>
/// <param name="message">메시지</param>
/// <param name="type">알림 유형</param>
@@ -436,15 +270,17 @@ namespace UVC.UIToolkit
/// <param name="closeOnBlockerClick">배경 클릭 시 닫힘 여부</param>
/// <param name="confirmLabel">확인 버튼 레이블</param>
/// <param name="cancelLabel">취소 버튼 레이블 (Confirm 타입에서만 사용)</param>
public static UTKAlert Show(VisualElement parent, string title, string message, AlertType type, Action? onClose, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
public static UTKAlert Show(string title, string message, AlertType type = AlertType.Info, Action? onClose = null, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
ValidateRoot();
var alert = new UTKAlert(title, message, type);
alert.OnClosed = onClose;
alert._confirmLabel = confirmLabel;
alert._cancelLabel = cancelLabel;
alert.UpdateButtons();
alert._blocker = UTKModalBlocker.Show(parent, 0.5f, closeOnBlockerClick);
alert._blocker = UTKModalBlocker.Show(_root!, 0.5f, closeOnBlockerClick);
if (closeOnBlockerClick)
{
alert._blocker.OnBlockerClicked += alert.Close;
@@ -454,7 +290,10 @@ namespace UVC.UIToolkit
// closeOnBlockerClick이 false일 때 blocker 클릭 시 Alert로 포커스 유지
alert._blocker.OnBlockerClicked += () => alert.Focus();
}
alert._blocker.Add(alert);
// panel.visualTree에 직접 추가
var root = _root!.panel?.visualTree ?? _root!;
root.Add(alert);
// 중앙 정렬
alert.style.position = Position.Absolute;
@@ -463,7 +302,7 @@ namespace UVC.UIToolkit
alert.style.translate = new Translate(Length.Percent(-50), Length.Percent(-50));
// ESC 키 이벤트 등록
alert.RegisterEscapeKey(parent);
alert.RegisterEscapeKey(_root!);
// Alert에 포커스 설정 (키보드 이벤트 수신을 위해)
alert.focusable = true;
@@ -473,6 +312,64 @@ namespace UVC.UIToolkit
}
#endregion
#region Static Factory Async
/// <summary>
/// Info 알림 표시 (비동기)
/// </summary>
public static UniTask ShowInfoAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(title, message, AlertType.Info, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Success 알림 표시 (비동기)
/// </summary>
public static UniTask ShowSuccessAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(title, message, AlertType.Success, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Warning 알림 표시 (비동기)
/// </summary>
public static UniTask ShowWarningAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(title, message, AlertType.Warning, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Error 알림 표시 (비동기)
/// </summary>
public static UniTask ShowErrorAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK")
{
return ShowAsync(title, message, AlertType.Error, closeOnBlockerClick, confirmLabel);
}
/// <summary>
/// Confirm 대화상자 표시 (비동기)
/// </summary>
/// <returns>확인 버튼 클릭 시 true, 취소 버튼 클릭 시 false</returns>
public static UniTask<bool> ShowConfirmAsync(string title, string message, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
var tcs = new UniTaskCompletionSource<bool>();
var alert = Show(title, message, AlertType.Confirm, null, closeOnBlockerClick, confirmLabel, cancelLabel);
alert.OnConfirm = () => tcs.TrySetResult(true);
alert.OnCancel = () => tcs.TrySetResult(false);
alert.OnClosed = () => tcs.TrySetResult(false);
return tcs.Task;
}
/// <summary>
/// 알림 표시 (비동기)
/// </summary>
public static UniTask ShowAsync(string title, string message, AlertType type, bool closeOnBlockerClick = false, string confirmLabel = "OK", string cancelLabel = "Cancel")
{
var tcs = new UniTaskCompletionSource();
var alert = Show(title, message, type, () => tcs.TrySetResult(), closeOnBlockerClick, confirmLabel, cancelLabel);
return tcs.Task;
}
#endregion
#region UI Creation
private void CreateUI()
{
@@ -586,9 +483,9 @@ namespace UVC.UIToolkit
/// <summary>
/// ESC 키 이벤트 등록
/// </summary>
private void RegisterEscapeKey(VisualElement parent)
private void RegisterEscapeKey(VisualElement target)
{
_keyEventTarget = parent;
_keyEventTarget = target;
_keyDownCallback = evt =>
{
if (evt.keyCode == KeyCode.Escape)
@@ -635,6 +532,7 @@ namespace UVC.UIToolkit
{
UnregisterEscapeKey();
OnClosed?.Invoke();
RemoveFromHierarchy();
if (_blocker != null)
{
_blocker.OnBlockerClicked -= Close;

View File

@@ -49,11 +49,19 @@ namespace UVC.UIToolkit
/// <item><description>UI 테마 - 앱 테마 색상 커스터마이징</description></item>
/// <item><description>3D 에디터 - 머티리얼 색상 설정</description></item>
/// </list>
///
/// <para><b>사용 전 초기화:</b></para>
/// <para>
/// ColorPicker를 표시하기 전에 <c>UTKColorPicker.SetRoot(rootVisualElement)</c>로 루트를 설정해야 합니다.
/// </para>
/// </remarks>
/// <example>
/// <code>
/// // 초기화 (root 설정 필요)
/// UTKColorPicker.SetRoot(rootVisualElement);
///
/// // 기본 사용법 (Alpha 포함)
/// var picker = UTKColorPicker.Show(rootVisualElement, Color.red, "Select Color");
/// var picker = UTKColorPicker.Show(Color.red, "Select Color");
/// picker.OnColorChanged += (color) =>
/// {
/// // 실시간 색상 변경 시 호출
@@ -66,10 +74,10 @@ namespace UVC.UIToolkit
/// };
///
/// // Alpha 없이 사용
/// var pickerNoAlpha = UTKColorPicker.Show(rootVisualElement, Color.blue, "Select Color", useAlpha: false);
/// var pickerNoAlpha = UTKColorPicker.Show(Color.blue, "Select Color", useAlpha: false);
///
/// // async/await 사용법 (UniTask)
/// Color selectedColor = await UTKColorPicker.ShowAsync(rootVisualElement, Color.red, "Select Color");
/// Color selectedColor = await UTKColorPicker.ShowAsync(Color.red, "Select Color");
/// // OK 클릭 시 선택된 색상 반환, 취소/닫기 시 initialColor(Color.red) 반환
/// Debug.Log($"Result: #{ColorUtility.ToHtmlStringRGBA(selectedColor)}");
///
@@ -90,6 +98,8 @@ namespace UVC.UIToolkit
#endregion
#region Fields
private static VisualElement? _root;
private bool _disposed;
private bool _useAlpha = true;
private bool _isUpdating; // 재귀 업데이트 방지
@@ -244,31 +254,58 @@ namespace UVC.UIToolkit
}
#endregion
#region Static Methods
/// <summary>
/// 기본 루트 요소 설정.
/// 모든 ColorPicker는 이 루트의 panel.visualTree에 표시됩니다.
/// </summary>
/// <param name="root">ColorPicker를 표시할 기본 루트 요소</param>
public static void SetRoot(VisualElement root)
{
_root = root;
}
/// <summary>
/// 기본 루트 요소 반환
/// </summary>
public static VisualElement? GetRoot() => _root;
private static void ValidateRoot()
{
if (_root == null)
{
throw new InvalidOperationException("UTKColorPicker.SetRoot()를 먼저 호출하여 기본 루트 요소를 설정해야 합니다.");
}
}
#endregion
#region Static Factory
/// <summary>
/// 컬러 피커를 표시합니다.
/// </summary>
public static UTKColorPicker Show(
VisualElement parent,
Color initialColor,
string title = "Color Picker",
bool useAlpha = true)
{
ValidateRoot();
var picker = new UTKColorPicker();
picker._useAlpha = useAlpha;
picker._originalColor = initialColor;
picker._currentColor = initialColor;
picker._currentHSV = new HSV(initialColor);
// 블로커 추가
picker._blocker = UTKModalBlocker.Show(parent, 0.5f, false);
// 블로커 추가 (panel.visualTree에 추가됨)
picker._blocker = UTKModalBlocker.Show(_root!, 0.5f, false);
picker._blocker.OnBlockerClicked += picker.Cancel;
// 위치 계산 전까지 숨김 (깜빡임 방지)
picker.style.visibility = Visibility.Hidden;
// 피커 추가
parent.Add(picker);
// panel.visualTree에 직접 추가
var root = _root!.panel?.visualTree ?? _root!;
root.Add(picker);
// UI 초기화
picker.SetTitle(title);
@@ -283,13 +320,11 @@ namespace UVC.UIToolkit
/// 컬러 피커를 표시하고 색상 선택을 기다립니다.
/// OK 버튼 클릭 시 선택된 색상을 반환하고, 취소/닫기 시 initialColor를 반환합니다.
/// </summary>
/// <param name="parent">부모 VisualElement</param>
/// <param name="initialColor">초기 색상</param>
/// <param name="title">피커 제목</param>
/// <param name="useAlpha">알파 채널 사용 여부</param>
/// <returns>선택된 색상 또는 초기 색상</returns>
public static async UniTask<Color> ShowAsync(
VisualElement parent,
Color initialColor,
string title = "Color Picker",
bool useAlpha = true)
@@ -297,7 +332,7 @@ namespace UVC.UIToolkit
var tcs = new UniTaskCompletionSource<Color>();
Color resultColor = initialColor;
var picker = Show(parent, initialColor, title, useAlpha);
var picker = Show(initialColor, title, useAlpha);
picker.OnColorSelected += (color) =>
{

View File

@@ -65,25 +65,33 @@ namespace UVC.UIToolkit
/// <item><description>검색 필터 - 기간별 데이터 조회</description></item>
/// <item><description>생년월일 입력 - 회원 가입, 프로필 설정</description></item>
/// </list>
///
/// <para><b>사용 전 초기화:</b></para>
/// <para>
/// DatePicker를 표시하기 전에 <c>UTKDatePicker.SetRoot(rootVisualElement)</c>로 루트를 설정해야 합니다.
/// </para>
/// </remarks>
/// <example>
/// <code>
/// // 초기화 (root 설정 필요)
/// UTKDatePicker.SetRoot(rootVisualElement);
///
/// // 기본 사용법 (날짜만)
/// var picker = UTKDatePicker.Show(rootVisualElement, DateTime.Today, UTKDatePicker.PickerMode.DateOnly, "Select Date");
/// var picker = UTKDatePicker.Show(DateTime.Today, UTKDatePicker.PickerMode.DateOnly, "Select Date");
/// picker.OnDateSelected += (date) =>
/// {
/// Debug.Log($"Date selected: {date:yyyy-MM-dd}");
/// };
///
/// // 날짜 + 시간 선택
/// var dateTimePicker = UTKDatePicker.Show(rootVisualElement, DateTime.Now, UTKDatePicker.PickerMode.DateAndTime, "Select Date &amp; Time");
/// var dateTimePicker = UTKDatePicker.Show(DateTime.Now, UTKDatePicker.PickerMode.DateAndTime, "Select Date &amp; Time");
/// dateTimePicker.OnDateSelected += (date) =>
/// {
/// Debug.Log($"DateTime selected: {date:yyyy-MM-dd HH:mm}");
/// };
///
/// // async/await 사용법 (UniTask)
/// DateTime? selectedDate = await UTKDatePicker.ShowAsync(rootVisualElement, DateTime.Today);
/// DateTime? selectedDate = await UTKDatePicker.ShowAsync(DateTime.Today);
/// if (selectedDate.HasValue)
/// {
/// Debug.Log($"Selected: {selectedDate.Value:yyyy-MM-dd}");
@@ -94,14 +102,14 @@ namespace UVC.UIToolkit
/// }
///
/// // 날짜 범위 선택
/// var rangePicker = UTKDatePicker.ShowRange(rootVisualElement, DateTime.Today, DateTime.Today.AddDays(7));
/// var rangePicker = UTKDatePicker.ShowRange(DateTime.Today, DateTime.Today.AddDays(7));
/// rangePicker.OnDateRangeSelected += (start, end) =>
/// {
/// Debug.Log($"Range selected: {start:yyyy-MM-dd} ~ {end:yyyy-MM-dd}");
/// };
///
/// // 날짜 범위 async/await 사용법
/// var result = await UTKDatePicker.ShowRangeAsync(rootVisualElement, DateTime.Today, DateTime.Today.AddDays(7));
/// var result = await UTKDatePicker.ShowRangeAsync(DateTime.Today, DateTime.Today.AddDays(7));
/// if (result.HasValue)
/// {
/// Debug.Log($"Range: {result.Value.Start:yyyy-MM-dd} ~ {result.Value.End:yyyy-MM-dd}");
@@ -157,6 +165,7 @@ namespace UVC.UIToolkit
#endregion
#region Static Fields
private static VisualElement? _root;
private static string[] s_dayNameKeys = DEFAULT_DAY_NAME_KEYS;
private static string[]? s_customDayNames;
#endregion
@@ -267,30 +276,57 @@ namespace UVC.UIToolkit
}
#endregion
#region Static Methods
/// <summary>
/// 기본 루트 요소 설정.
/// 모든 DatePicker는 이 루트의 panel.visualTree에 표시됩니다.
/// </summary>
/// <param name="root">DatePicker를 표시할 기본 루트 요소</param>
public static void SetRoot(VisualElement root)
{
_root = root;
}
/// <summary>
/// 기본 루트 요소 반환
/// </summary>
public static VisualElement? GetRoot() => _root;
private static void ValidateRoot()
{
if (_root == null)
{
throw new InvalidOperationException("UTKDatePicker.SetRoot()를 먼저 호출하여 기본 루트 요소를 설정해야 합니다.");
}
}
#endregion
#region Static Factory
/// <summary>
/// 날짜 피커를 표시합니다.
/// </summary>
public static UTKDatePicker Show(
VisualElement parent,
DateTime initialDate,
PickerMode mode = PickerMode.DateOnly,
string title = "Select Date")
{
ValidateRoot();
var picker = new UTKDatePicker();
picker._mode = mode;
picker._selectedDate = initialDate;
picker._displayMonth = new DateTime(initialDate.Year, initialDate.Month, 1);
// 블로커 추가
picker._blocker = UTKModalBlocker.Show(parent, 0.5f, false);
// 블로커 추가 (panel.visualTree에 추가됨)
picker._blocker = UTKModalBlocker.Show(_root!, 0.5f, false);
picker._blocker.OnBlockerClicked += picker.Close;
// 위치 계산 전까지 숨김 (깜빡임 방지)
picker.style.visibility = Visibility.Hidden;
// 피커 추가
parent.Add(picker);
// panel.visualTree에 직접 추가
var root = _root!.panel?.visualTree ?? _root!;
root.Add(picker);
// UI 초기화
picker.SetTitle(title);
@@ -306,7 +342,6 @@ namespace UVC.UIToolkit
/// 날짜 피커를 표시하고 날짜 선택을 기다립니다.
/// OK 버튼 클릭 시 선택된 날짜를 반환하고, 취소/닫기 시 null을 반환합니다.
/// </summary>
/// <param name="parent">부모 VisualElement</param>
/// <param name="initialDate">초기 날짜</param>
/// <param name="mode">피커 모드 (날짜만 또는 날짜+시간)</param>
/// <param name="title">피커 제목</param>
@@ -314,7 +349,7 @@ namespace UVC.UIToolkit
/// <example>
/// <code>
/// // async/await 사용법
/// DateTime? selectedDate = await UTKDatePicker.ShowAsync(rootVisualElement, DateTime.Today);
/// DateTime? selectedDate = await UTKDatePicker.ShowAsync(DateTime.Today);
/// if (selectedDate.HasValue)
/// {
/// Debug.Log($"Selected: {selectedDate.Value:yyyy-MM-dd}");
@@ -326,7 +361,6 @@ namespace UVC.UIToolkit
/// </code>
/// </example>
public static async UniTask<DateTime?> ShowAsync(
VisualElement parent,
DateTime initialDate,
PickerMode mode = PickerMode.DateOnly,
string title = "Select Date")
@@ -334,7 +368,7 @@ namespace UVC.UIToolkit
var tcs = new UniTaskCompletionSource<DateTime?>();
DateTime? resultDate = null;
var picker = Show(parent, initialDate, mode, title);
var picker = Show(initialDate, mode, title);
picker.OnDateSelected += (date) =>
{
@@ -354,18 +388,18 @@ namespace UVC.UIToolkit
/// <summary>
/// 날짜 범위 피커를 표시합니다.
/// </summary>
/// <param name="parent">부모 VisualElement</param>
/// <param name="initialStartDate">초기 시작 날짜 (null이면 오늘)</param>
/// <param name="initialEndDate">초기 종료 날짜 (null이면 시작 날짜와 동일)</param>
/// <param name="includeTime">시간 선택 포함 여부</param>
/// <param name="title">피커 제목</param>
public static UTKDatePicker ShowRange(
VisualElement parent,
DateTime? initialStartDate = null,
DateTime? initialEndDate = null,
bool includeTime = false,
string title = "Select Date Range")
{
ValidateRoot();
var picker = new UTKDatePicker();
picker._mode = includeTime ? PickerMode.DateTimeRange : PickerMode.DateRange;
@@ -383,15 +417,16 @@ namespace UVC.UIToolkit
picker._rangeState = RangeSelectionState.SelectingStart;
picker._displayMonth = new DateTime(startDate.Year, startDate.Month, 1);
// 블로커 추가
picker._blocker = UTKModalBlocker.Show(parent, 0.5f, false);
// 블로커 추가 (panel.visualTree에 추가됨)
picker._blocker = UTKModalBlocker.Show(_root!, 0.5f, false);
picker._blocker.OnBlockerClicked += picker.Close;
// 위치 계산 전까지 숨김 (깜빡임 방지)
picker.style.visibility = Visibility.Hidden;
// 피커 추가
parent.Add(picker);
// panel.visualTree에 직접 추가
var root = _root!.panel?.visualTree ?? _root!;
root.Add(picker);
// UI 초기화
picker.SetTitle(title);
@@ -408,7 +443,6 @@ namespace UVC.UIToolkit
/// 날짜 범위 피커를 표시하고 범위 선택을 기다립니다.
/// OK 버튼 클릭 시 선택된 범위를 반환하고, 취소/닫기 시 null을 반환합니다.
/// </summary>
/// <param name="parent">부모 VisualElement</param>
/// <param name="initialStartDate">초기 시작 날짜</param>
/// <param name="initialEndDate">초기 종료 날짜</param>
/// <param name="includeTime">시간 선택 포함 여부</param>
@@ -417,7 +451,7 @@ namespace UVC.UIToolkit
/// <example>
/// <code>
/// // async/await 사용법
/// var result = await UTKDatePicker.ShowRangeAsync(rootVisualElement);
/// var result = await UTKDatePicker.ShowRangeAsync();
/// if (result.HasValue)
/// {
/// Debug.Log($"Range: {result.Value.Start:yyyy-MM-dd} ~ {result.Value.End:yyyy-MM-dd}");
@@ -429,7 +463,6 @@ namespace UVC.UIToolkit
/// </code>
/// </example>
public static async UniTask<(DateTime Start, DateTime End)?> ShowRangeAsync(
VisualElement parent,
DateTime? initialStartDate = null,
DateTime? initialEndDate = null,
bool includeTime = false,
@@ -438,7 +471,7 @@ namespace UVC.UIToolkit
var tcs = new UniTaskCompletionSource<(DateTime, DateTime)?>();
(DateTime, DateTime)? result = null;
var picker = ShowRange(parent, initialStartDate, initialEndDate, includeTime, title);
var picker = ShowRange(initialStartDate, initialEndDate, includeTime, title);
picker.OnDateRangeSelected += (start, end) =>
{

View File

@@ -9,25 +9,29 @@ namespace UVC.UIToolkit
/// 모달 창 컴포넌트.
/// 사용자 정의 콘텐츠를 포함할 수 있는 모달 대화상자입니다.
/// </summary>
/// <remarks>
/// <para><b>사용 전 초기화:</b></para>
/// <para>
/// Modal을 표시하기 전에 <c>UTKModal.SetRoot(rootVisualElement)</c>로 루트를 설정해야 합니다.
/// </para>
/// </remarks>
/// <example>
/// <para><b>C# 코드에서 사용:</b></para>
/// <code>
/// // 모달 생성 및 표시
/// var modal = new UTKModal();
/// modal.Title = "설정";
/// modal.Size = UTKModal.ModalSize.Medium;
/// // 초기화 (root 설정 필요)
/// UTKModal.SetRoot(rootVisualElement);
///
/// // Static Factory로 표시
/// var modal = UTKModal.Show("설정", UTKModal.ModalSize.Medium);
/// modal.OnClosed += () => Debug.Log("모달 닫힘");
///
///
/// // 콘텐츠 추가
/// var content = new Label("모달 내용");
/// modal.AddContent(content);
///
/// // 푸터 버튼 추가
/// modal.AddFooterButton("확인", UTKButton.ButtonVariant.Primary, () => modal.Close());
/// modal.AddFooterButton("취소", UTKButton.ButtonVariant.Normal, () => modal.Close());
///
/// // 표시
/// modal.Show(rootElement);
/// modal.Add(content);
///
/// // 푸터 버튼 추가
/// modal.AddToFooter(new UTKButton("확인", "", UTKButton.ButtonVariant.Primary));
/// modal.AddToFooter(new UTKButton("취소", "", UTKButton.ButtonVariant.Normal));
/// </code>
/// <para><b>UXML에서 사용:</b></para>
/// <code>
@@ -46,17 +50,19 @@ namespace UVC.UIToolkit
#endregion
#region Fields
private static VisualElement? _root;
private bool _disposed;
private UTKModalBlocker? _blocker;
private VisualElement? _header;
private Label? _titleLabel;
private Button? _closeButton;
private UTKButton? _closeButton;
private VisualElement? _content;
private VisualElement? _footer;
private string _title = "Modal";
private bool _showCloseButton = true;
private bool _closeOnBackdropClick = true;
private bool _closeOnBackdropClick = false;
private ModalSize _size = ModalSize.Medium;
#endregion
@@ -153,20 +159,50 @@ namespace UVC.UIToolkit
}
#endregion
#region Static Methods
/// <summary>
/// 기본 루트 요소 설정.
/// 모든 Modal은 이 루트의 panel.visualTree에 표시됩니다.
/// </summary>
/// <param name="root">Modal을 표시할 기본 루트 요소</param>
public static void SetRoot(VisualElement root)
{
_root = root;
}
/// <summary>
/// 기본 루트 요소 반환
/// </summary>
public static VisualElement? GetRoot() => _root;
private static void ValidateRoot()
{
if (_root == null)
{
throw new InvalidOperationException("UTKModal.SetRoot()를 먼저 호출하여 기본 루트 요소를 설정해야 합니다.");
}
}
#endregion
#region Static Factory
/// <summary>
/// 모달 표시
/// </summary>
public static UTKModal Show(VisualElement parent, string title, ModalSize size = ModalSize.Medium)
public static UTKModal Show(string title, ModalSize size = ModalSize.Medium)
{
ValidateRoot();
var modal = new UTKModal(title, size);
modal._blocker = UTKModalBlocker.Show(parent, 0.5f, false);
modal._blocker = UTKModalBlocker.Show(_root!, 0.5f, false);
if (modal._closeOnBackdropClick)
{
modal._blocker.OnBlockerClicked += modal.Close;
}
modal._blocker.Add(modal);
// panel.visualTree에 직접 추가
var root = _root!.panel?.visualTree ?? _root!;
root.Add(modal);
// 중앙 정렬
modal.style.position = Position.Absolute;
@@ -192,7 +228,10 @@ namespace UVC.UIToolkit
_titleLabel.AddToClassList("utk-modal__title");
_header.Add(_titleLabel);
_closeButton = new Button { name = "close-btn", text = "✕" };
_closeButton = new UTKButton("close-btn", UTKMaterialIcons.Close);
_closeButton.Variant = UTKButton.ButtonVariant.Text;
_closeButton.IconOnly = true;
_closeButton.IconSize = 16;
_closeButton.AddToClassList("utk-modal__close-btn");
_header.Add(_closeButton);
@@ -299,6 +338,7 @@ namespace UVC.UIToolkit
public void Close()
{
OnClosed?.Invoke();
RemoveFromHierarchy();
if (_blocker != null)
{
_blocker.OnBlockerClicked -= Close;

View File

@@ -55,12 +55,13 @@ namespace UVC.UIToolkit
#region Static Factory
/// <summary>
/// 모달 블로커를 생성하고 표시합니다.
/// parent의 panel.visualTree에 블로커를 추가합니다.
/// </summary>
/// <param name="root">블로커를 추가할 루트 요소</param>
/// <param name="parent">panel 접근용 부모 요소</param>
/// <param name="opacity">배경 투명도 (0~1)</param>
/// <param name="closeOnClick">클릭 시 자동 닫힘 여부</param>
/// <returns>생성된 UTKModalBlocker 인스턴스</returns>
public static UTKModalBlocker Show(VisualElement root, float opacity = DEFAULT_OPACITY, bool closeOnClick = false)
public static UTKModalBlocker Show(VisualElement parent, float opacity = DEFAULT_OPACITY, bool closeOnClick = false)
{
var blocker = new UTKModalBlocker
{
@@ -68,6 +69,7 @@ namespace UVC.UIToolkit
_targetOpacity = Mathf.Clamp01(opacity)
};
var root = parent.panel?.visualTree ?? parent;
root.Add(blocker);
blocker.FadeIn();

View File

@@ -10,28 +10,26 @@ namespace UVC.UIToolkit
/// 알림 창 컴포넌트.
/// 화면 모서리에 표시되는 알림 메시지입니다.
/// </summary>
/// <remarks>
/// <para><b>사용 전 초기화:</b></para>
/// <para>
/// Notification을 표시하기 전에 <c>UTKNotification.SetRoot(rootVisualElement)</c>로 루트를 설정해야 합니다.
/// </para>
/// </remarks>
/// <example>
/// <para><b>C# 코드에서 사용:</b></para>
/// <code>
/// // 초기화 (root 설정 필요)
/// UTKNotification.Initialize(rootVisualElement);
///
/// UTKNotification.SetRoot(rootVisualElement);
///
/// // 기본 알림
/// UTKNotification.Show("알림", "새로운 메시지가 있습니다.");
///
/// UTKNotification.Show("알림", "새로운 메시지가 있습니다.",
/// NotificationType.Info, NotificationPosition.TopRight);
///
/// // 타입별 알림
/// UTKNotification.ShowSuccess("성공", "저장되었습니다.");
/// UTKNotification.ShowError("오류", "실패했습니다.");
/// UTKNotification.ShowWarning("경고", "주의가 필요합니다.");
///
/// // 위치 설정
/// UTKNotification.Show("알림", "메시지", position: NotificationPosition.BottomRight);
///
/// // 액션 버튼 있는 알림
/// UTKNotification.Show("알림", "메시지", actions: new[] {
/// ("확인", () => Debug.Log("확인")),
/// ("취소", () => Debug.Log("취소"))
/// });
/// </code>
/// <para><b>UXML에서 사용:</b></para>
/// <code>
@@ -50,11 +48,13 @@ namespace UVC.UIToolkit
#endregion
#region Fields
private static VisualElement? _root;
private bool _disposed;
private VisualElement? _header;
private Label? _iconLabel;
private UTKLabel? _iconLabel;
private Label? _titleLabel;
private Button? _closeButton;
private UTKButton? _closeButton;
private Label? _messageLabel;
private VisualElement? _actions;
@@ -175,50 +175,79 @@ namespace UVC.UIToolkit
}
#endregion
#region Static Methods
/// <summary>
/// 기본 루트 요소 설정.
/// 모든 Notification은 이 루트의 panel.visualTree에 표시됩니다.
/// </summary>
/// <param name="root">Notification을 표시할 기본 루트 요소</param>
public static void SetRoot(VisualElement root)
{
_root = root;
}
/// <summary>
/// 기본 루트 요소 반환
/// </summary>
public static VisualElement? GetRoot() => _root;
private static void ValidateRoot()
{
if (_root == null)
{
throw new InvalidOperationException("UTKNotification.SetRoot()를 먼저 호출하여 기본 루트 요소를 설정해야 합니다.");
}
}
#endregion
#region Static Factory
/// <summary>
/// Info 알림 표시
/// </summary>
public static UTKNotification ShowInfo(VisualElement parent, string title, string message, int duration = DEFAULT_DURATION_MS)
public static UTKNotification ShowInfo(string title, string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, title, message, NotificationType.Info, NotificationPosition.TopRight, duration);
return Show(title, message, NotificationType.Info, NotificationPosition.TopRight, duration);
}
/// <summary>
/// Success 알림 표시
/// </summary>
public static UTKNotification ShowSuccess(VisualElement parent, string title, string message, int duration = DEFAULT_DURATION_MS)
public static UTKNotification ShowSuccess(string title, string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, title, message, NotificationType.Success, NotificationPosition.TopRight, duration);
return Show(title, message, NotificationType.Success, NotificationPosition.TopRight, duration);
}
/// <summary>
/// Warning 알림 표시
/// </summary>
public static UTKNotification ShowWarning(VisualElement parent, string title, string message, int duration = DEFAULT_DURATION_MS)
public static UTKNotification ShowWarning(string title, string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, title, message, NotificationType.Warning, NotificationPosition.TopRight, duration);
return Show(title, message, NotificationType.Warning, NotificationPosition.TopRight, duration);
}
/// <summary>
/// Error 알림 표시
/// </summary>
public static UTKNotification ShowError(VisualElement parent, string title, string message, int duration = DEFAULT_DURATION_MS)
public static UTKNotification ShowError(string title, string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, title, message, NotificationType.Error, NotificationPosition.TopRight, duration);
return Show(title, message, NotificationType.Error, NotificationPosition.TopRight, duration);
}
/// <summary>
/// 알림 표시
/// </summary>
public static UTKNotification Show(VisualElement parent, string title, string message,
public static UTKNotification Show(string title, string message,
NotificationType type, NotificationPosition position, int duration = DEFAULT_DURATION_MS)
{
ValidateRoot();
var notification = new UTKNotification(title, message, type);
notification._duration = duration;
notification._position = position;
parent.Add(notification);
// panel.visualTree에 직접 추가
var root = _root!.panel?.visualTree ?? _root!;
root.Add(notification);
// 위치 설정
notification.style.position = UnityEngine.UIElements.Position.Absolute;
@@ -244,18 +273,20 @@ namespace UVC.UIToolkit
_header.AddToClassList("utk-notification__header");
Add(_header);
_iconLabel = new Label { name = "icon" };
_iconLabel = new UTKLabel();
_iconLabel.IconSize = 16;
_iconLabel.AddToClassList("utk-notification__icon");
UTKMaterialIcons.ApplyIconStyle(_iconLabel, 20);
_header.Add(_iconLabel);
_titleLabel = new Label { name = "title" };
_titleLabel.AddToClassList("utk-notification__title");
_header.Add(_titleLabel);
_closeButton = new Button { name = "close-btn", text = UTKMaterialIcons.Close };
_closeButton = new UTKButton("close-btn", UTKMaterialIcons.Close);
_closeButton.Variant = UTKButton.ButtonVariant.Text;
_closeButton.IconOnly = true;
_closeButton.IconSize = 16;
_closeButton.AddToClassList("utk-notification__close-btn");
UTKMaterialIcons.ApplyIconStyle(_closeButton, 16);
_closeButton.RegisterCallback<ClickEvent>(_ => Close());
_header.Add(_closeButton);
@@ -325,13 +356,13 @@ namespace UVC.UIToolkit
if (_iconLabel != null)
{
_iconLabel.text = _type switch
_iconLabel.SetMaterialIcon(_type switch
{
NotificationType.Success => UTKMaterialIcons.CheckCircle,
NotificationType.Warning => UTKMaterialIcons.Warning,
NotificationType.Error => UTKMaterialIcons.Error,
_ => UTKMaterialIcons.Info
};
});
}
}

View File

@@ -42,7 +42,6 @@ namespace UVC.UIToolkit
/// <para><b>사용 전 초기화:</b></para>
/// <para>
/// Toast를 표시하기 전에 <c>UTKToast.SetRoot(rootVisualElement)</c>로 루트를 설정해야 합니다.
/// 또는 <c>Show(parent, ...)</c>로 부모 요소를 직접 전달할 수 있습니다.
/// </para>
///
/// <para><b>실제 활용 예시:</b></para>
@@ -57,7 +56,7 @@ namespace UVC.UIToolkit
/// <para><b>C# 코드에서 사용:</b></para>
/// <code>
/// // 초기화 (root 설정 필요)
/// UTKToast.Initialize(rootVisualElement);
/// UTKToast.SetRoot(rootVisualElement);
///
/// // 기본 토스트
/// UTKToast.Show("저장되었습니다.");
@@ -213,95 +212,52 @@ namespace UVC.UIToolkit
}
#endregion
#region Static Factory (without parent)
/// <summary>
/// Info 토스트 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKToast ShowInfo(string message, int duration = DEFAULT_DURATION_MS)
{
ValidateRoot();
return Show(_root!, message, ToastType.Info, duration);
}
/// <summary>
/// Success 토스트 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKToast ShowSuccess(string message, int duration = DEFAULT_DURATION_MS)
{
ValidateRoot();
return Show(_root!, message, ToastType.Success, duration);
}
/// <summary>
/// Warning 토스트 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKToast ShowWarning(string message, int duration = DEFAULT_DURATION_MS)
{
ValidateRoot();
return Show(_root!, message, ToastType.Warning, duration);
}
/// <summary>
/// Error 토스트 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKToast ShowError(string message, int duration = DEFAULT_DURATION_MS)
{
ValidateRoot();
return Show(_root!, message, ToastType.Error, duration);
}
/// <summary>
/// 토스트 표시 (SetRoot로 설정된 루트 사용)
/// </summary>
public static UTKToast Show(string message, ToastType type = ToastType.Info, int duration = DEFAULT_DURATION_MS)
{
ValidateRoot();
return Show(_root!, message, type, duration);
}
#endregion
#region Static Factory (with parent)
#region Static Factory
/// <summary>
/// Info 토스트 표시
/// </summary>
public static UTKToast ShowInfo(VisualElement parent, string message, int duration = DEFAULT_DURATION_MS)
public static UTKToast ShowInfo(string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, message, ToastType.Info, duration);
return Show(message, ToastType.Info, duration);
}
/// <summary>
/// Success 토스트 표시
/// </summary>
public static UTKToast ShowSuccess(VisualElement parent, string message, int duration = DEFAULT_DURATION_MS)
public static UTKToast ShowSuccess(string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, message, ToastType.Success, duration);
return Show(message, ToastType.Success, duration);
}
/// <summary>
/// Warning 토스트 표시
/// </summary>
public static UTKToast ShowWarning(VisualElement parent, string message, int duration = DEFAULT_DURATION_MS)
public static UTKToast ShowWarning(string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, message, ToastType.Warning, duration);
return Show(message, ToastType.Warning, duration);
}
/// <summary>
/// Error 토스트 표시
/// </summary>
public static UTKToast ShowError(VisualElement parent, string message, int duration = DEFAULT_DURATION_MS)
public static UTKToast ShowError(string message, int duration = DEFAULT_DURATION_MS)
{
return Show(parent, message, ToastType.Error, duration);
return Show(message, ToastType.Error, duration);
}
/// <summary>
/// 토스트 표시
/// </summary>
public static UTKToast Show(VisualElement parent, string message, ToastType type, int duration = DEFAULT_DURATION_MS)
public static UTKToast Show(string message, ToastType type = ToastType.Info, int duration = DEFAULT_DURATION_MS)
{
ValidateRoot();
var toast = new UTKToast(message, type);
toast._duration = duration;
parent.Add(toast);
// panel.visualTree에 직접 추가
var root = _root!.panel?.visualTree ?? _root!;
root.Add(toast);
// 하단 중앙 정렬
toast.style.position = Position.Absolute;

View File

@@ -238,13 +238,7 @@ namespace UVC.UIToolkit
{
if (_currentPicker != null) return;
var root = this as VisualElement;
while (root.parent != null)
{
root = root.parent;
}
_currentPicker = UTKColorPicker.Show(root, _value, Label, _useAlpha);
_currentPicker = UTKColorPicker.Show(_value, Label, _useAlpha);
_currentPicker.OnColorChanged += OnPickerColorChanged;
_currentPicker.OnColorSelected += OnPickerColorSelected;
}

View File

@@ -202,10 +202,7 @@ namespace UVC.UIToolkit
{
if (_currentPicker != null) return;
var root = this as VisualElement;
while (root.parent != null) root = root.parent;
_currentPicker = UTKColorPicker.Show(root, _value.Color, $"{Label} - {_value.State}", false);
_currentPicker = UTKColorPicker.Show(_value.Color, $"{Label} - {_value.State}", false);
_currentPicker.OnColorChanged += OnPickerColorChanged;
_currentPicker.OnColorSelected += OnPickerColorSelected;
}

View File

@@ -207,13 +207,7 @@ namespace UVC.UIToolkit
{
if (_currentPicker != null) return;
var root = this as VisualElement;
while (root.parent != null)
{
root = root.parent;
}
_currentPicker = UTKDatePicker.Show(root, _value, UTKDatePicker.PickerMode.DateOnly, Label);
_currentPicker = UTKDatePicker.Show(_value, UTKDatePicker.PickerMode.DateOnly, Label);
_currentPicker.OnDateSelected += OnPickerDateSelected;
_currentPicker.OnClosed += OnPickerClosed;
}

View File

@@ -299,11 +299,8 @@ namespace UVC.UIToolkit
{
if (_currentPicker != null) return;
var root = this as VisualElement;
while (root.parent != null) root = root.parent;
string title = _isEditingStart ? $"{Label} - 시작일" : $"{Label} - 종료일";
_currentPicker = UTKDatePicker.Show(root, initialDate, UTKDatePicker.PickerMode.DateOnly, title);
_currentPicker = UTKDatePicker.Show(initialDate, UTKDatePicker.PickerMode.DateOnly, title);
_currentPicker.OnDateSelected += OnPickerDateSelected;
_currentPicker.OnClosed += OnPickerClosed;
}

View File

@@ -207,13 +207,7 @@ namespace UVC.UIToolkit
{
if (_currentPicker != null) return;
var root = this as VisualElement;
while (root.parent != null)
{
root = root.parent;
}
_currentPicker = UTKDatePicker.Show(root, _value, UTKDatePicker.PickerMode.DateAndTime, Label);
_currentPicker = UTKDatePicker.Show(_value, UTKDatePicker.PickerMode.DateAndTime, Label);
_currentPicker.OnDateSelected += OnPickerDateSelected;
_currentPicker.OnClosed += OnPickerClosed;
}

View File

@@ -299,11 +299,8 @@ namespace UVC.UIToolkit
{
if (_currentPicker != null) return;
var root = this as VisualElement;
while (root.parent != null) root = root.parent;
string title = _isEditingStart ? $"{Label} - 시작" : $"{Label} - 종료";
_currentPicker = UTKDatePicker.Show(root, initialDateTime, UTKDatePicker.PickerMode.DateAndTime, title);
_currentPicker = UTKDatePicker.Show(initialDateTime, UTKDatePicker.PickerMode.DateAndTime, title);
_currentPicker.OnDateSelected += OnPickerDateSelected;
_currentPicker.OnClosed += OnPickerClosed;
}

View File

@@ -29,15 +29,15 @@ namespace UVC.UIToolkit
/// window.ShowAllTab = false;
///
/// var generalTab = new TabPropertyData("일반");
/// generalTab.SetGroupedData(new List&lt;IUTKPropertyGroup&gt; { transformGroup, renderGroup });
/// generalTab.SetGroupedData(new List<IUTKPropertyGroup> { transformGroup, renderGroup });
///
/// var advancedTab = new TabPropertyData("고급");
/// advancedTab.SetFlatData(new List&lt;IUTKPropertyItem&gt; { debugItem, logItem });
/// advancedTab.SetFlatData(new List<IUTKPropertyItem> { debugItem, logItem });
///
/// window.SetTabData(new List&lt;TabPropertyData&gt; { generalTab, advancedTab });
/// window.SetTabData(new List<TabPropertyData> { generalTab, advancedTab });
///
/// window.OnTabChanged += (index, data) =&gt; Debug.Log($"탭 변경: {data?.Name}");
/// window.OnPropertyValueChanged += args =&gt; Debug.Log($"{args.PropertyId} = {args.NewValue}");
/// window.OnTabChanged += (index, data) => Debug.Log($"탭 변경: {data?.Name}");
/// window.OnPropertyValueChanged += args => Debug.Log($"{args.PropertyId} = {args.NewValue}");
///
/// root.Add(window);
/// </code>