탐색기, 라이브러리, 화면 객체 배치

This commit is contained in:
logonkhi
2025-12-18 20:38:38 +09:00
parent beca5f0da5
commit deeaa9a7ad
102 changed files with 4956 additions and 387 deletions

View File

@@ -71,6 +71,42 @@ namespace UVC.UI.Toolbar.Model
/// </remarks>
public Action<ToolbarButtonBase> OnSubButtonSelected { get; set; }
/// <summary>
/// 하위 버튼 선택 변경 시 발생하는 이벤트입니다.
/// 확장 버튼의 텍스트와 선택된 하위 버튼의 텍스트가 파라미터로 전달됩니다.
/// Toolbar/Toolbox에서 OnAction 이벤트를 발생시키기 위해 구독합니다.
/// </summary>
public event Action<string, string> OnSubButtonSelectionChanged;
/// <summary>
/// 현재 선택된 하위 버튼을 저장합니다.
/// 동일한 버튼이 다시 선택될 때 이벤트 중복 발생을 방지합니다.
/// </summary>
private ToolbarButtonBase _selectedSubButton;
/// <summary>
/// 현재 선택된 하위 버튼을 가져옵니다.
/// </summary>
public ToolbarButtonBase SelectedSubButton => _selectedSubButton;
/// <summary>
/// AddExpandableButton에서 설정한 원본 텍스트를 저장합니다.
/// OnSubButtonSelectionChanged 이벤트 발생 시 이 값이 Text로 전달됩니다.
/// </summary>
private string _originalText;
/// <summary>
/// AddExpandableButton에서 설정한 원본 텍스트를 가져옵니다.
/// </summary>
public string OriginalText => _originalText;
/// <summary>
/// 서브 버튼 선택 시 주 버튼의 아이콘을 선택된 서브 버튼의 아이콘으로 변경할지 여부입니다.
/// true이면 아이콘이 변경되고, false이면 원래 아이콘을 유지합니다.
/// 기본값은 true입니다.
/// </summary>
public bool UpdateIconOnSelection { get; set; } = false;
/// <summary>
/// ToolbarExpandableButton의 새 인스턴스를 초기화합니다.
/// SubButtons 리스트를 빈 리스트로 생성합니다.
@@ -80,6 +116,15 @@ namespace UVC.UI.Toolbar.Model
SubButtons = new List<ToolbarButtonBase>();
}
/// <summary>
/// 원본 텍스트를 설정합니다. AddExpandableButton에서 호출됩니다.
/// </summary>
/// <param name="text">원본 텍스트</param>
public void SetOriginalText(string text)
{
_originalText = text;
}
/// <summary>
/// 주 확장 버튼이 클릭되었을 때의 로직을 실행합니다.
/// 기본적으로 부모 클래스(ToolbarButtonBase)의 ExecuteClick을 호출하여
@@ -118,23 +163,40 @@ namespace UVC.UI.Toolbar.Model
{
if (selectedSubButton != null && selectedSubButton.IsEnabled)
{
// 주 버튼의 텍스트를 선택된 하위 버튼의 텍스트로 변경
// Text 속성의 setter는 내부적으로 OnStateChanged를 호출하여 View 업데이트를 트리거합니다.
if (this.Text != selectedSubButton.Text)
// 동일한 버튼이 다시 선택된 경우 이벤트를 발생시키지 않음
if (_selectedSubButton == selectedSubButton)
{
this.Text = selectedSubButton.Text;
return;
}
// 주 버튼의 아이콘 경로를 선택된 하위 버튼의 아이콘 경로로 변경
// IconSpritePath 속성의 setter는 내부적으로 OnStateChanged를 호출합니다.
if (this.IconSpritePath != selectedSubButton.IconSpritePath)
// 현재 선택된 하위 버튼 업데이트
_selectedSubButton = selectedSubButton;
// UpdateIconOnSelection이 true일 때만 주 버튼의 텍스트와 아이콘을 변경
if (UpdateIconOnSelection)
{
this.IconSpritePath = selectedSubButton.IconSpritePath;
// 주 버튼의 텍스트를 선택된 하위 버튼의 텍스트로 변경
// Text 속성의 setter는 내부적으로 OnStateChanged를 호출하여 View 업데이트를 트리거합니다.
if (Text != selectedSubButton.Text)
{
Text = selectedSubButton.Text;
}
// 주 버튼의 아이콘 경로를 선택된 하위 버튼의 아이콘 경로로 변경
// IconSpritePath 속성의 setter는 내부적으로 OnStateChanged를 호출합니다.
if (IconSpritePath != selectedSubButton.IconSpritePath)
{
IconSpritePath = selectedSubButton.IconSpritePath;
}
}
// 하위 버튼 선택 콜백 호출
OnSubButtonSelected?.Invoke(selectedSubButton);
// 하위 버튼 선택 변경 이벤트 발생 (Toolbar/Toolbox에서 OnAction 이벤트 발생용)
// _originalText는 AddExpandableButton에서 설정한 원본 텍스트
OnSubButtonSelectionChanged?.Invoke(_originalText, selectedSubButton.Text);
// 선택된 하위 버튼 자체의 ClickCommand 실행은 여기서 하지 않습니다.
// View에서 하위 버튼 UI 클릭 시 해당 하위 버튼의 ExecuteClick()이 직접 호출되는 것이 일반적입니다.
// 만약 여기서 실행해야 한다면: selectedSubButton.ExecuteClick();
@@ -148,6 +210,7 @@ namespace UVC.UI.Toolbar.Model
{
base.ClearEventHandlers(); // 부모 클래스의 이벤트 정리 (OnStateChanged)
OnSubButtonSelected = null;
OnSubButtonSelectionChanged = null;
if (SubButtons != null)
{