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 "absl/types/span.h"
10#include "app/editor/editor.h"
12#include "imgui/imgui.h"
13
14namespace yaze {
15
16class Rom;
17
18namespace project {
19struct YazeProject;
20}
21
22namespace core {
23class VersionManager;
24}
25
26namespace editor {
27
28// Forward declarations
29class ProposalDrawer;
30class ToastManager;
31class AgentChat;
32class SettingsPanel;
33class SelectionPropertiesPanel;
34class ProjectManagementPanel;
35class ShortcutManager;
36
57 public:
59 std::function<void(const std::string&)> on_open_reference;
60 std::function<void(uint32_t)> on_open_address;
61 std::function<void(uint32_t)> on_open_lookup;
62 };
63
64 enum class DrawerType {
65 kNone = 0,
69 kHelp,
70 kNotifications, // Full notification history panel
71 kProperties, // Full-editing properties panel
72 kProject, // Project management panel
73 kToolOutput // Tool/query results panel
74 };
76
77 RightDrawerManager() = default;
79
80 // Non-copyable
83
84 // ============================================================================
85 // Configuration
86 // ============================================================================
87
88 void SetAgentChat(AgentChat* chat) { agent_chat_ = chat; }
92 shortcut_manager_ = manager;
93 }
100 void SetToastManager(ToastManager* manager) { toast_manager_ = manager; }
101 void SetRom(Rom* rom) { rom_ = rom; }
102 void SetToolOutput(std::string title, std::string query, std::string content,
103 ToolOutputActions actions = {});
104 const std::string& tool_output_title() const { return tool_output_title_; }
105 const std::string& tool_output_query() const { return tool_output_query_; }
106 const std::string& tool_output_content() const {
108 }
109
115
116 // ============================================================================
117 // Panel Control
118 // ============================================================================
119
127 void ToggleDrawer(DrawerType type);
128 [[deprecated("Use ToggleDrawer() instead.")]]
130 ToggleDrawer(type);
131 }
132
137 void OpenDrawer(DrawerType type);
138 [[deprecated("Use OpenDrawer() instead.")]]
139 void OpenPanel(PanelType type) {
140 OpenDrawer(type);
141 }
142
146 void CloseDrawer();
147 [[deprecated("Use CloseDrawer() instead.")]]
148 void ClosePanel() {
149 CloseDrawer();
150 }
151
156 void CycleDrawer(int direction);
159 [[deprecated("Use CycleDrawer() instead.")]]
160 void CyclePanel(int direction) {
161 CycleDrawer(direction);
162 }
163 [[deprecated("Use CycleToNextDrawer() instead.")]]
166 }
167 [[deprecated("Use CycleToPreviousDrawer() instead.")]]
171
178 void OnHostVisibilityChanged(bool visible);
179
183 bool IsDrawerExpanded() const;
184 [[deprecated("Use IsDrawerExpanded() instead.")]]
185 bool IsPanelExpanded() const {
186 return IsDrawerExpanded();
187 }
188
193 [[deprecated("Use GetActiveDrawer() instead.")]]
195 return GetActiveDrawer();
196 }
197
201 bool IsDrawerActive(DrawerType type) const { return active_panel_ == type; }
202 [[deprecated("Use IsDrawerActive() instead.")]]
203 bool IsPanelActive(PanelType type) const {
204 return IsDrawerActive(type);
205 }
206
207 // ============================================================================
208 // Dimensions
209 // ============================================================================
210
214 float GetDrawerWidth() const;
215 [[deprecated("Use GetDrawerWidth() instead.")]]
216 float GetPanelWidth() const {
217 return GetDrawerWidth();
218 }
219
223 static constexpr float GetCollapsedWidth() { return 0.0f; }
224
228 void SetDrawerWidth(DrawerType type, float width);
229 [[deprecated("Use SetDrawerWidth() instead.")]]
230 void SetPanelWidth(PanelType type, float width) {
231 SetDrawerWidth(type, width);
232 }
233
237 void ResetDrawerWidths();
238 [[deprecated("Use ResetDrawerWidths() instead.")]]
241 }
242
249 static float GetDefaultDrawerWidth(DrawerType type,
251 [[deprecated("Use GetDefaultDrawerWidth() instead.")]]
254 return GetDefaultDrawerWidth(type, editor);
255 }
256
261
265 void SetPanelSizeLimits(PanelType type, const PanelSizeLimits& limits);
268 SetPanelSizeLimits(type, limits);
269 }
273
277 std::unordered_map<std::string, float> SerializeDrawerWidths() const;
279 const std::unordered_map<std::string, float>& widths);
280 [[deprecated("Use SerializeDrawerWidths() instead.")]]
281 std::unordered_map<std::string, float> SerializePanelWidths() const {
282 return SerializeDrawerWidths();
283 }
284 [[deprecated("Use RestoreDrawerWidths() instead.")]]
286 const std::unordered_map<std::string, float>& widths) {
287 RestoreDrawerWidths(widths);
288 }
289
291 std::function<void(DrawerType, float)> callback) {
292 on_panel_width_changed_ = std::move(callback);
293 }
294 [[deprecated("Use SetDrawerWidthChangedCallback() instead.")]]
296 std::function<void(PanelType, float)> callback) {
297 on_panel_width_changed_ = std::move(callback);
298 }
299
300 // ============================================================================
301 // Rendering
302 // ============================================================================
303
310 void Draw();
311
320 [[deprecated("Use DrawDrawerToggleButtons() instead.")]]
324
331 static float GetDrawerToggleClusterWidth();
332
333 // ============================================================================
334 // Panel-specific accessors
335 // ============================================================================
336
337 AgentChat* agent_chat() const { return agent_chat_; }
344
345 private:
347
348 void DrawPanelHeader(PanelType type, const char* title, const char* icon);
349 void DrawDrawerNavStrip(PanelType current_panel);
350 void DrawHeaderActions(PanelType type);
352 void DrawAgentChatPanel();
353 void DrawProposalsPanel();
354 void DrawSettingsPanel();
355 void DrawHelpPanel();
357 void DrawPropertiesPanel();
358 void DrawProjectPanel();
359 void DrawToolOutputPanel();
361
362 // Help panel helpers for context-aware content
364 void DrawGlobalShortcuts();
368 void DrawAboutSection();
369
370 // Styling helpers for consistent panel UI
371 bool BeginPanelSection(const char* label, const char* icon = nullptr,
372 bool default_open = true);
373 void EndPanelSection();
374 void DrawPanelDivider();
375 void DrawPanelLabel(const char* label);
376 void DrawPanelValue(const char* label, const char* value);
377 void DrawPanelDescription(const char* text);
378 std::string GetShortcutLabel(const std::string& action,
379 const std::string& fallback) const;
380 void DrawShortcutRow(const std::string& action, const char* description,
381 const std::string& fallback);
382 float GetConfiguredPanelWidth(PanelType type) const;
383 float GetClampedPanelWidth(PanelType type, float viewport_width) const;
384 void NotifyPanelWidthChanged(PanelType type, float width);
385 static std::string PanelTypeKey(PanelType type);
386
387 // Active panel
389
390 // Active editor for context-aware help
392
393 // Panel widths (customizable per panel type) - consistent sizing
401 float tool_output_width_ = 460.0f;
402
403 // Component references (not owned)
411 Rom* rom_ = nullptr;
416
417 // Properties panel lock state
418 bool properties_locked_ = false;
419
420 // Animation state
421 float panel_animation_ = 0.0f; // 0.0 = fully closed, 1.0 = fully open
422 float animation_target_ = 0.0f; // Target value for lerp
423 bool animating_ = false;
424 bool closing_ = false; // True during close animation
425 PanelType closing_panel_ = PanelType::kNone; // Panel being animated closed
426 std::unordered_map<std::string, PanelSizeLimits> panel_size_limits_;
427 std::function<void(PanelType, float)> on_panel_width_changed_;
428};
429
434
439
444
450 const char* name = nullptr;
451 const char* icon = nullptr;
452 const char* shortcut_action = nullptr;
453};
454
458absl::Span<const DrawerCatalogEntry> GetDrawerCatalog();
459
461 return GetPanelTypeName(type);
462}
463
465 return GetPanelTypeIcon(type);
466}
467
468inline const char* GetDrawerShortcutAction(
470 return GetPanelShortcutAction(type);
471}
472
473} // namespace editor
474} // namespace yaze
475
476#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 the single Drawers overflow control 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 DrawPanelHeader(PanelType type, const char *title, const char *icon)
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)
static float GetDrawerToggleClusterWidth()
Menu-bar width reserved for the Drawers overflow control.
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)
void DrawDrawerNavStrip(PanelType current_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)
absl::Span< const DrawerCatalogEntry > GetDrawerCatalog()
Switchable drawers in header-cycle order (excludes Tool Output).
const char * GetPanelTypeName(RightDrawerManager::PanelType type)
Get the name of a panel type.
const char * GetPanelShortcutAction(RightDrawerManager::PanelType type)
Shortcut action id used by ShortcutManager for a drawer toggle.
const char * GetDrawerShortcutAction(RightDrawerManager::DrawerType type)
const char * GetDrawerTypeIcon(RightDrawerManager::DrawerType type)
const char * GetPanelTypeIcon(RightDrawerManager::PanelType type)
Get the icon for a panel type.
One entry in the shared right-drawer catalog (header / overflow / View).
RightDrawerManager::DrawerType 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