namespace UVC.UI.Toolbar { /// /// 한 번 클릭으로 특정 동작을 수행하는 표준적인 버튼입니다. /// ToolbarButtonBase를 상속받아 텍스트, 아이콘, 툴팁, 활성화 상태 및 클릭 커맨드 기능을 가집니다. /// /// /// 이 클래스는 ToolbarButtonBase의 기능을 그대로 사용하며, 특별히 추가된 로직은 없습니다. /// 복잡한 상태 관리 없이 단순 클릭 동작만을 필요로 하는 경우에 사용됩니다. /// View 레이어(예: ToolbarView)에서는 이 모델에 해당하는 UI 요소(예: UnityEngine.UI.Button)를 생성하고, /// 사용자가 UI 버튼을 클릭하면 이 모델의 ExecuteClick 메서드가 호출되도록 연결합니다. /// /// /// /// // ToolbarController 또는 ToolbarModel 등에서 ToolbarStandardButton 생성 및 사용 예시 /// /// // 1. 버튼 클릭 시 실행될 커맨드 정의 (예: 간단한 로그 출력) /// ICommand saveCommand = new ActionCommand(() => /// { /// UnityEngine.Debug.Log("저장 버튼 클릭됨. 저장 로직 실행..."); /// // 여기에 실제 저장 로직 구현 /// }); /// /// // 2. ToolbarStandardButton 인스턴스 생성 및 속성 설정 /// ToolbarStandardButton saveButton = new ToolbarStandardButton /// { /// Text = "button_save", // 버튼 텍스트 (다국어 키 또는 실제 텍스트) /// IconSpritePath = "icons/toolbar/save_icon", // Resources 폴더 내 아이콘 경로 /// TooltipKey = "tooltip_save_button_description", // 툴팁 (다국어 키 또는 실제 텍스트) /// ClickCommand = saveCommand, // 위에서 정의한 커맨드 할당 /// IsEnabled = true // 버튼 활성화 상태 /// }; /// /// // 3. 생성된 버튼 모델을 ToolbarModel에 추가 (ToolbarModel의 AddItem 또는 AddStandardButton 메서드 사용) /// // toolbarModel.AddItem(saveButton); /// // 또는 /// // toolbarModel.AddStandardButton("button_save", "icons/toolbar/save_icon", saveCommand, "tooltip_save_button_description"); /// /// // 4. 버튼 상태 변경 예시 /// // saveButton.IsEnabled = false; // 버튼 비활성화 (UI에 반영됨) /// // saveButton.Text = "button_saved"; // 버튼 텍스트 변경 (UI에 반영됨) /// /// public class ToolbarStandardButton : ToolbarButtonBase { // ToolbarStandardButton은 ToolbarButtonBase의 모든 기능을 상속받습니다. // 특별히 ToolbarStandardButton만을 위한 추가적인 속성이나 메서드가 필요하다면 여기에 정의할 수 있습니다. // 예시: 생성자를 통해 주요 속성을 설정하도록 할 수도 있습니다. // /// // /// 지정된 속성으로 ToolbarStandardButton의 새 인스턴스를 초기화합니다. // /// // /// 버튼 텍스트 또는 다국어 키입니다. // /// 아이콘의 Resources 경로입니다. // /// 클릭 시 실행될 커맨드입니다. // /// 툴팁 텍스트 또는 다국어 키입니다. // public ToolbarStandardButton(string text, string iconSpritePath = null, ICommand command = null, string tooltipKey = null) // { // this.Text = text; // this.IconSpritePath = iconSpritePath; // this.ClickCommand = command; // this.TooltipKey = tooltipKey; // } // ToolbarButtonBase의 ExecuteClick 메서드를 그대로 사용합니다. // 만약 StandardButton만의 특별한 클릭 전/후 처리가 필요하다면 ExecuteClick 메서드를 override 할 수 있습니다. // /// // /// 버튼 클릭 로직을 실행합니다. // /// // /// 커맨드에 전달할 파라미터입니다. // public override void ExecuteClick(object parameter = null) // { // if (!IsEnabled) return; // // // UnityEngine.Debug.Log($"ToolbarStandardButton '{Text}' ExecuteClick 호출됨."); // // // 부모 클래스의 ExecuteClick (ClickCommand 실행 등) // base.ExecuteClick(parameter); // // // 여기에 ToolbarStandardButton만의 추가적인 로직이 있다면 작성 // // 예를 들어, 클릭 후 특정 사운드 재생 등 // } } }