Modal 개발 완료. Toolbar 개발 중
This commit is contained in:
60
Assets/Scripts/UVC/UI/ToolBar/ToolbarExpandableButton.cs
Normal file
60
Assets/Scripts/UVC/UI/ToolBar/ToolbarExpandableButton.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UVC.UI.ToolBar
|
||||
{
|
||||
/// <summary>
|
||||
/// 클릭 시 하위 버튼 그룹을 확장하여 보여주는 버튼입니다.
|
||||
/// 하위 버튼 선택 시, 주 버튼의 내용이 업데이트될 수 있습니다.
|
||||
/// </summary>
|
||||
public class ToolbarExpandableButton : ToolbarButtonBase
|
||||
{
|
||||
public enum ExpansionDirection { Horizontal, Vertical }
|
||||
|
||||
public List<ToolbarButtonBase> SubButtons { get; private set; }
|
||||
public ExpansionDirection Direction { get; set; } = ExpansionDirection.Vertical;
|
||||
public Action<ToolbarButtonBase> OnSubButtonSelected { get; set; }
|
||||
|
||||
public ToolbarExpandableButton()
|
||||
{
|
||||
SubButtons = new List<ToolbarButtonBase>();
|
||||
}
|
||||
|
||||
public override void ExecuteClick()
|
||||
{
|
||||
if (IsEnabled)
|
||||
{
|
||||
OnClick?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectSubButton(ToolbarButtonBase selectedSubButton)
|
||||
{
|
||||
if (selectedSubButton != null && selectedSubButton.IsEnabled)
|
||||
{
|
||||
bool changed = false;
|
||||
if (this.Text != selectedSubButton.Text)
|
||||
{
|
||||
this.Text = selectedSubButton.Text; // Setter가 OnStateChanged 호출 (단, Text가 실제로 변경되어야 함)
|
||||
changed = true;
|
||||
}
|
||||
if (this.Icon != selectedSubButton.Icon)
|
||||
{
|
||||
this.Icon = selectedSubButton.Icon; // Setter가 OnStateChanged 호출
|
||||
changed = true;
|
||||
}
|
||||
|
||||
OnSubButtonSelected?.Invoke(selectedSubButton);
|
||||
// selectedSubButton.ExecuteClick(); // 하위 버튼의 클릭 로직 실행은 선택 사항
|
||||
|
||||
if (changed) // Text나 Icon이 실제로 변경된 경우에만 명시적으로 호출하거나, 각 setter에 맡김
|
||||
{
|
||||
// NotifyStateChanged(); // Text, Icon setter가 이미 호출하므로 중복될 수 있음.
|
||||
// 만약 Text, Icon 외 다른 상태도 변경된다면 필요.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user