yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
right_drawer_manager.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MENU_RIGHT_DRAWER_MANAGER_H_
2#define YAZE_APP_EDITOR_MENU_RIGHT_DRAWER_MANAGER_H_
3
4#include <cstdint>
5#include <functional>
6#include <string>
7#include <unordered_map>
8
9#include "app/editor/editor.h"
11#include "imgui/imgui.h"
12
13namespace yaze {
14
15class Rom;
16
17namespace project {
18struct YazeProject;
19}
20
21namespace core {
22class VersionManager;
23}
24
25namespace editor {
26
27// Forward declarations
28class ProposalDrawer;
29class ToastManager;
30class AgentChat;
31class SettingsPanel;
32class SelectionPropertiesPanel;
33class ProjectManagementPanel;
34class ShortcutManager;
35
56 public:
58 std::function<void(const std::string&)> on_open_reference;
59 std::function<void(uint32_t)> on_open_address;
60 std::function<void(uint32_t)> on_open_lookup;
61 };
62
63 enum class DrawerType {
64 kNone = 0,
68 kHelp,
69 kNotifications, // Full notification history panel
70 kProperties, // Full-editing properties panel
71 kProject, // Project management panel
72 kToolOutput // Tool/query results panel
73 };
75
76 RightDrawerManager() = default;
78
79 // Non-copyable
82
83 // ============================================================================
84 // Configuration
85 // ============================================================================
86
87 void SetAgentChat(AgentChat* chat) { agent_chat_ = chat; }
91 shortcut_manager_ = manager;
92 }
99 void SetToastManager(ToastManager* manager) { toast_manager_ = manager; }
100 void SetRom(Rom* rom) { rom_ = rom; }
101 void SetToolOutput(std::string title, std::string query, std::string content,
102 ToolOutputActions actions = {});
103 const std::string& tool_output_title() const { return tool_output_title_; }
104 const std::string& tool_output_query() const { return tool_output_query_; }
105 const std::string& tool_output_content() const {
107 }
108
114
115 // ============================================================================
116 // Panel Control
117 // ============================================================================
118
126 void ToggleDrawer(DrawerType type);
127 [[deprecated("Use ToggleDrawer() instead.")]]
129 ToggleDrawer(type);
130 }
131
136 void OpenDrawer(DrawerType type);
137 [[deprecated("Use OpenDrawer() instead.")]]
138 void OpenPanel(PanelType type) {
139 OpenDrawer(type);
140 }
141
145 void CloseDrawer();
146 [[deprecated("Use CloseDrawer() instead.")]]
147 void ClosePanel() {
148 CloseDrawer();
149 }
150
155 void CycleDrawer(int direction);
158 [[deprecated("Use CycleDrawer() instead.")]]
159 void CyclePanel(int direction) {
160 CycleDrawer(direction);
161 }
162 [[deprecated("Use CycleToNextDrawer() instead.")]]
165 }
166 [[deprecated("Use CycleToPreviousDrawer() instead.")]]
170
177 void OnHostVisibilityChanged(bool visible);
178
182 bool IsDrawerExpanded() const;
183 [[deprecated("Use IsDrawerExpanded() instead.")]]
184 bool IsPanelExpanded() const {
185 return IsDrawerExpanded();
186 }
187
192 [[deprecated("Use GetActiveDrawer() instead.")]]
194 return GetActiveDrawer();
195 }
196
200 bool IsDrawerActive(DrawerType type) const { return active_panel_ == type; }
201 [[deprecated("Use IsDrawerActive() instead.")]]
202 bool IsPanelActive(PanelType type) const {
203 return IsDrawerActive(type);
204 }
205
206 // ============================================================================
207 // Dimensions
208 // ============================================================================
209
213 float GetDrawerWidth() const;
214 [[deprecated("Use GetDrawerWidth() instead.")]]
215 float GetPanelWidth() const {
216 return GetDrawerWidth();
217 }
218
222 static constexpr float GetCollapsedWidth() { return 0.0f; }
223
227 void SetDrawerWidth(DrawerType type, float width);
228 [[deprecated("Use SetDrawerWidth() instead.")]]
229 void SetPanelWidth(PanelType type, float width) {
230 SetDrawerWidth(type, width);
231 }
232
236 void ResetDrawerWidths();
237 [[deprecated("Use ResetDrawerWidths() instead.")]]
240 }
241
248 static float GetDefaultDrawerWidth(DrawerType type,
250 [[deprecated("Use GetDefaultDrawerWidth() instead.")]]
253 return GetDefaultDrawerWidth(type, editor);
254 }
255
260
264 void SetPanelSizeLimits(PanelType type, const PanelSizeLimits& limits);
267 SetPanelSizeLimits(type, limits);
268 }
272
276 std::unordered_map<std::string, float> SerializeDrawerWidths() const;
278 const std::unordered_map<std::string, float>& widths);
279 [[deprecated("Use SerializeDrawerWidths() instead.")]]
280 std::unordered_map<std::string, float> SerializePanelWidths() const {
281 return SerializeDrawerWidths();
282 }
283 [[deprecated("Use RestoreDrawerWidths() instead.")]]
285 const std::unordered_map<std::string, float>& widths) {
286 RestoreDrawerWidths(widths);
287 }
288
290 std::function<void(DrawerType, float)> callback) {
291 on_panel_width_changed_ = std::move(callback);
292 }
293 [[deprecated("Use SetDrawerWidthChangedCallback() instead.")]]
295 std::function<void(PanelType, float)> callback) {
296 on_panel_width_changed_ = std::move(callback);
297 }
298
299 // ============================================================================
300 // Rendering
301 // ============================================================================
302
309 void Draw();
310
317 [[deprecated("Use DrawDrawerToggleButtons() instead.")]]
321
322 // ============================================================================
323 // Panel-specific accessors
324 // ============================================================================
325
326 AgentChat* agent_chat() const { return agent_chat_; }
333
334 private:
335 void DrawPanelHeader(const char* title, const char* icon);
336 void DrawAgentChatPanel();
337 void DrawProposalsPanel();
338 void DrawSettingsPanel();
339 void DrawHelpPanel();
341 void DrawPropertiesPanel();
342 void DrawProjectPanel();
343 void DrawToolOutputPanel();
345
346 // Help panel helpers for context-aware content
348 void DrawGlobalShortcuts();
352 void DrawAboutSection();
353
354 // Styling helpers for consistent panel UI
355 bool BeginPanelSection(const char* label, const char* icon = nullptr,
356 bool default_open = true);
357 void EndPanelSection();
358 void DrawPanelDivider();
359 void DrawPanelLabel(const char* label);
360 void DrawPanelValue(const char* label, const char* value);
361 void DrawPanelDescription(const char* text);
362 std::string GetShortcutLabel(const std::string& action,
363 const std::string& fallback) const;
364 void DrawShortcutRow(const std::string& action, const char* description,
365 const std::string& fallback);
366 float GetConfiguredPanelWidth(PanelType type) const;
367 float GetClampedPanelWidth(PanelType type, float viewport_width) const;
368 void NotifyPanelWidthChanged(PanelType type, float width);
369 static std::string PanelTypeKey(PanelType type);
370
371 // Active panel
373
374 // Active editor for context-aware help
376
377 // Panel widths (customizable per panel type) - consistent sizing
385 float tool_output_width_ = 460.0f;
386
387 // Component references (not owned)
395 Rom* rom_ = nullptr;
400
401 // Properties panel lock state
402 bool properties_locked_ = false;
403
404 // Animation state
405 float panel_animation_ = 0.0f; // 0.0 = fully closed, 1.0 = fully open
406 float animation_target_ = 0.0f; // Target value for lerp
407 bool animating_ = false;
408 bool closing_ = false; // True during close animation
409 PanelType closing_panel_ = PanelType::kNone; // Panel being animated closed
410 std::unordered_map<std::string, PanelSizeLimits> panel_size_limits_;
411 std::function<void(PanelType, float)> on_panel_width_changed_;
412};
413
418
423
425 return GetPanelTypeName(type);
426}
427
429 return GetPanelTypeIcon(type);
430}
431
432} // namespace editor
433} // namespace yaze
434
435#endif // YAZE_APP_EDITOR_MENU_RIGHT_DRAWER_MANAGER_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Unified Agent Chat Component.
Definition agent_chat.h:32
Panel for managing project settings, ROM versions, and snapshots.
ImGui drawer for displaying and managing agent proposals.
Manages right-side sliding drawers for agent chat, proposals, settings.
RightDrawerManager & operator=(const RightDrawerManager &)=delete
void CycleDrawer(int direction)
Cycle to the next/previous right drawer in header order.
void SetToastManager(ToastManager *manager)
bool DrawDrawerToggleButtons()
Draw drawer toggle buttons for the status cluster.
static std::string PanelTypeKey(PanelType type)
const std::string & tool_output_query() const
void NotifyPanelWidthChanged(PanelType type, float width)
void SetDrawerWidthChangedCallback(std::function< void(DrawerType, float)> callback)
void RestorePanelWidths(const std::unordered_map< std::string, float > &widths)
void SetActiveEditor(EditorType type)
Set the active editor for context-aware help content.
void DrawShortcutRow(const std::string &action, const char *description, const std::string &fallback)
std::string GetShortcutLabel(const std::string &action, const std::string &fallback) const
float GetClampedPanelWidth(PanelType type, float viewport_width) const
void OpenDrawer(DrawerType type)
Open a specific drawer.
void SetDrawerWidth(DrawerType type, float width)
Set drawer width for a specific drawer type.
void SetPanelWidth(PanelType type, float width)
RightDrawerManager(const RightDrawerManager &)=delete
void SetToolOutput(std::string title, std::string query, std::string content, ToolOutputActions actions={})
static float GetDefaultPanelWidth(PanelType type, EditorType editor=EditorType::kUnknown)
void DrawPanelValue(const char *label, const char *value)
void Draw()
Draw the drawer and its contents.
static constexpr float GetCollapsedWidth()
Get the width of the collapsed panel strip (toggle buttons)
std::function< void(PanelType, float)> on_panel_width_changed_
ProjectManagementPanel * project_panel() const
void ResetDrawerWidths()
Reset all drawer widths to their defaults.
void SetProjectManagementPanel(ProjectManagementPanel *panel)
void DrawPanelHeader(const char *title, const char *icon)
SelectionPropertiesPanel * properties_panel_
bool BeginPanelSection(const char *label, const char *icon=nullptr, bool default_open=true)
void ToggleDrawer(DrawerType type)
Toggle a specific drawer on/off.
SelectionPropertiesPanel * properties_panel() const
void SetSettingsPanel(SettingsPanel *panel)
void SetDrawerSizeLimits(DrawerType type, const PanelSizeLimits &limits)
static float GetDefaultDrawerWidth(DrawerType type, EditorType editor=EditorType::kUnknown)
Get the default width for a specific drawer type.
const std::string & tool_output_content() const
void SetPanelWidthChangedCallback(std::function< void(PanelType, float)> callback)
const std::string & tool_output_title() const
float GetConfiguredPanelWidth(PanelType type) const
ProposalDrawer * proposal_drawer() const
std::unordered_map< std::string, PanelSizeLimits > panel_size_limits_
void SetProposalDrawer(ProposalDrawer *drawer)
bool IsPanelActive(PanelType type) const
DrawerType GetActiveDrawer() const
Get the currently active drawer type.
PanelSizeLimits GetDrawerSizeLimits(DrawerType type) const
bool IsDrawerActive(DrawerType type) const
Check if a specific drawer is active.
bool IsDrawerExpanded() const
Check if any drawer is currently expanded (or animating closed)
float GetDrawerWidth() const
Get the width of the drawer when expanded.
void OnHostVisibilityChanged(bool visible)
Snap transient animations when host visibility changes.
void CloseDrawer()
Close the currently active drawer.
void RestoreDrawerWidths(const std::unordered_map< std::string, float > &widths)
std::unordered_map< std::string, float > SerializeDrawerWidths() const
Persist/restore per-drawer widths for user settings.
std::unordered_map< std::string, float > SerializePanelWidths() const
ProjectManagementPanel * project_panel_
void SetPropertiesPanel(SelectionPropertiesPanel *panel)
PanelSizeLimits GetPanelSizeLimits(PanelType type) const
void SetShortcutManager(ShortcutManager *manager)
void SetPanelSizeLimits(PanelType type, const PanelSizeLimits &limits)
Set sizing constraints for an individual right panel.
Full-editing properties panel for selected entities.
Manages the settings UI displayed in the right sidebar.
const char * GetDrawerTypeName(RightDrawerManager::DrawerType type)
const char * GetPanelTypeName(RightDrawerManager::PanelType type)
Get the name of a panel type.
const char * GetDrawerTypeIcon(RightDrawerManager::DrawerType type)
const char * GetPanelTypeIcon(RightDrawerManager::PanelType type)
Get the icon for a panel type.
std::function< void(const std::string &) on_open_reference)
static constexpr float kPanelWidthSettings
Definition ui_config.h:31
static constexpr float kPanelWidthHelp
Definition ui_config.h:32
static constexpr float kPanelWidthNotifications
Definition ui_config.h:33
static constexpr float kMaxPanelWidthRatio
Definition ui_config.h:39
static constexpr float kPanelWidthProject
Definition ui_config.h:35
static constexpr float kPanelWidthProposals
Definition ui_config.h:30
static constexpr float kPanelWidthProperties
Definition ui_config.h:34
static constexpr float kPanelWidthAgentChat
Definition ui_config.h:29