toolbar 개발 중
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
namespace UVC.UI.ToolBar
|
||||
{
|
||||
/// <summary>
|
||||
/// 툴바의 전체적인 컨테이너 및 관리 클래스입니다.
|
||||
/// IToolbarItem 객체들을 동적으로 추가하고 관리합니다.
|
||||
/// </summary>
|
||||
public class Toolbar
|
||||
{
|
||||
public System.Collections.Generic.List<IToolbarItem> Items { get; private set; }
|
||||
private System.Collections.Generic.Dictionary<string, ToolbarRadioButtonGroup> _radioGroups;
|
||||
|
||||
public Toolbar()
|
||||
{
|
||||
Items = new System.Collections.Generic.List<IToolbarItem>();
|
||||
_radioGroups = new System.Collections.Generic.Dictionary<string, ToolbarRadioButtonGroup>();
|
||||
}
|
||||
|
||||
public void AddItem(IToolbarItem item)
|
||||
{
|
||||
Items.Add(item);
|
||||
|
||||
if (item is ToolbarRadioButton radioButton)
|
||||
{
|
||||
if (!_radioGroups.TryGetValue(radioButton.GroupName, out var group))
|
||||
{
|
||||
group = new ToolbarRadioButtonGroup();
|
||||
_radioGroups.Add(radioButton.GroupName, group);
|
||||
}
|
||||
group.RegisterButton(radioButton);
|
||||
}
|
||||
// UI 갱신 로직 호출
|
||||
}
|
||||
|
||||
public ToolbarStandardButton AddStandardButton(string text, UnityEngine.Sprite icon = null, System.Action onClick = null, string tooltipKey = null)
|
||||
{
|
||||
var button = new ToolbarStandardButton { Text = text, Icon = icon, OnClick = onClick, TooltipKey = tooltipKey };
|
||||
AddItem(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
public ToolbarToggleButton AddToggleButton(string text, bool initialState = false, UnityEngine.Sprite icon = null, System.Action<bool> onToggle = null, string tooltipKey = null)
|
||||
{
|
||||
var button = new ToolbarToggleButton { Text = text, IsSelected = initialState, Icon = icon, OnToggle = onToggle, TooltipKey = tooltipKey };
|
||||
AddItem(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
public ToolbarRadioButton AddRadioButton(string groupName, string text, bool initialState = false, UnityEngine.Sprite icon = null, System.Action<bool> onToggle = null, string tooltipKey = null)
|
||||
{
|
||||
var button = new ToolbarRadioButton(groupName) { Text = text, IsSelected = initialState, Icon = icon, OnToggle = onToggle, TooltipKey = tooltipKey };
|
||||
// AddItem 내에서 그룹 처리가 되므로, 여기서는 IsSelected 초기값만 주의 (그룹 내 하나만 true여야 함)
|
||||
AddItem(button);
|
||||
// 그룹의 초기 선택 상태를 설정하는 로직이 추가로 필요할 수 있습니다.
|
||||
// 예를 들어, 첫 번째로 추가된 라디오 버튼을 기본 선택으로 하거나, 명시적으로 설정.
|
||||
if (initialState && _radioGroups.TryGetValue(groupName, out var group))
|
||||
{
|
||||
group.SetSelected(button);
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
public ToolbarExpandableButton AddExpandableButton(string text, UnityEngine.Sprite icon = null, System.Action onClick = null, string tooltipKey = null)
|
||||
{
|
||||
var button = new ToolbarExpandableButton { Text = text, Icon = icon, OnClick = onClick, TooltipKey = tooltipKey };
|
||||
AddItem(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
public void AddSeparator()
|
||||
{
|
||||
AddItem(new ToolbarSeparator());
|
||||
}
|
||||
|
||||
// 실제 UI 렌더링 및 상호작용 로직은 이 클래스 또는 별도의 UI View 클래스에서 처리됩니다.
|
||||
// (예: Unity UI GameObject 생성, 이벤트 연결 등)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user