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#include <utility>
9
10#include "absl/types/span.h"
11#include "app/editor/editor.h"
13#include "imgui/imgui.h"
14
15namespace yaze {
16
17class Rom;
18
19namespace project {
20struct YazeProject;
21}
22
23namespace core {
24class VersionManager;
25}
26
27namespace editor {
28
29// Forward declarations
30class ProposalDrawer;
31class ToastManager;
32class AgentChat;
33class SettingsPanel;
34class SelectionPropertiesPanel;
35class ProjectManagementPanel;
36class ShortcutManager;
37
58 public:
60 std::function<void(const std::string&)> on_open_reference;
61 std::function<void(uint32_t)> on_open_address;
62 std::function<void(uint32_t)> on_open_lookup;
63 };
64
65 enum class DrawerType {
66 kNone = 0,
70 kHelp,
71 kNotifications, // Full notification history panel
72 kProperties, // Full-editing properties panel
73 kProject, // Project management panel
74 kToolOutput // Tool/query results panel
75 };
77
78 RightDrawerManager() = default;
80
81 // Non-copyable
84
85 // ============================================================================
86 // Configuration
87 // ============================================================================
88
89 void SetAgentChat(AgentChat* chat) { agent_chat_ = chat; }
92 // Supplies a SettingsPanel when the drawer opens with none bound, which
93 // happens on the Welcome screen before any session exists. EditorManager
94 // creates an empty session, like SwitchToEditor(EditorType::kSettings).
95 void SetSettingsPanelProvider(std::function<SettingsPanel*()> provider) {
96 settings_panel_provider_ = std::move(provider);
97 }
99 shortcut_manager_ = manager;
100 }
107 void SetToastManager(ToastManager* manager) { toast_manager_ = manager; }
108 void SetRom(Rom* rom) { rom_ = rom; }
109 void SetToolOutput(std::string title, std::string query, std::string content,
110 ToolOutputActions actions = {});
111 const std::string& tool_output_title() const { return tool_output_title_; }
112 const std::string& tool_output_query() const { return tool_output_query_; }
113 const std::string& tool_output_content() const {
115 }
116
122
123 // ============================================================================
124 // Panel Control
125 // ============================================================================
126
134 void ToggleDrawer(DrawerType type);
135 [[deprecated("Use ToggleDrawer() instead.")]]
137 ToggleDrawer(type);
138 }
139
144 void OpenDrawer(DrawerType type);
145 [[deprecated("Use OpenDrawer() instead.")]]
146 void OpenPanel(PanelType type) {
147 OpenDrawer(type);
148 }
149
156 void ToggleLastDrawer();
158
162 void CloseDrawer();
163 [[deprecated("Use CloseDrawer() instead.")]]
164 void ClosePanel() {
165 CloseDrawer();
166 }
167
172 void CycleDrawer(int direction);
175 [[deprecated("Use CycleDrawer() instead.")]]
176 void CyclePanel(int direction) {
177 CycleDrawer(direction);
178 }
179
186 void OnHostVisibilityChanged(bool visible);
187
191 bool IsDrawerExpanded() const;
192 [[deprecated("Use IsDrawerExpanded() instead.")]]
193 bool IsPanelExpanded() const {
194 return IsDrawerExpanded();
195 }
196
201 [[deprecated("Use GetActiveDrawer() instead.")]]
203 return GetActiveDrawer();
204 }
205
209 bool IsDrawerActive(DrawerType type) const { return active_panel_ == type; }
210 [[deprecated("Use IsDrawerActive() instead.")]]
211 bool IsPanelActive(PanelType type) const {
212 return IsDrawerActive(type);
213 }
214
215 // ============================================================================
216 // Dimensions
217 // ============================================================================
218
220 float GetDrawerWidth() const;
222 float GetExpandedDrawerWidth() const;
223 [[deprecated("Use GetDrawerWidth() instead.")]]
224 float GetPanelWidth() const {
225 return GetDrawerWidth();
226 }
227
231 static constexpr float GetCollapsedWidth() { return 0.0f; }
232
236 void SetDrawerWidth(DrawerType type, float width);
237 [[deprecated("Use SetDrawerWidth() instead.")]]
238 void SetPanelWidth(PanelType type, float width) {
239 SetDrawerWidth(type, width);
240 }
241
245 void ResetDrawerWidths();
246
253 static float GetDefaultDrawerWidth(DrawerType type,
255
260
264 void SetPanelSizeLimits(PanelType type, const PanelSizeLimits& limits);
267 SetPanelSizeLimits(type, limits);
268 }
272
274 std::unordered_map<std::string, float> SerializeDrawerWidths() const;
276 const std::unordered_map<std::string, float>& widths);
277
279 std::function<void(DrawerType, float)> callback) {
280 on_panel_width_changed_ = std::move(callback);
281 }
282
283 // ============================================================================
284 // Rendering
285 // ============================================================================
286
293 void Draw();
294
297 [[deprecated("Use DrawSidebarToggleButton() instead.")]]
301
303 static float GetSidebarToggleWidth();
304 [[deprecated("Use GetSidebarToggleWidth() instead.")]]
306 return GetSidebarToggleWidth();
307 }
308
309 // ============================================================================
310 // Panel-specific accessors
311 // ============================================================================
312
313 AgentChat* agent_chat() const { return agent_chat_; }
320
321 private:
323
324 void DrawPanelHeader(PanelType type, const char* title, const char* icon);
325 void DrawDrawerNavStrip(PanelType current_panel);
326 void DrawHeaderActions(PanelType type);
327 void DrawHeaderContextBadge(PanelType type, float available_width);
328 void DrawAgentChatPanel();
329 void DrawProposalsPanel();
330 void DrawSettingsPanel();
331 void DrawHelpPanel();
333 void DrawPropertiesPanel();
334 void DrawProjectPanel();
335 void DrawToolOutputPanel();
337
338 // Help panel helpers for context-aware content
340 void DrawGlobalShortcuts();
344 void DrawAboutSection();
345
346 // Styling helpers for consistent panel UI
347 bool BeginPanelSection(const char* label, const char* icon = nullptr,
348 bool default_open = true);
349 void EndPanelSection();
350 void DrawPanelDivider();
351 void DrawPanelLabel(const char* label);
352 void DrawPanelValue(const char* label, const char* value);
353 void DrawPanelDescription(const char* text);
354 std::string GetShortcutLabel(const std::string& action,
355 const std::string& fallback) const;
356 void DrawShortcutRow(const std::string& action, const char* description,
357 const std::string& fallback);
358 float GetConfiguredPanelWidth(PanelType type) const;
359 float GetClampedPanelWidth(PanelType type, float viewport_width) const;
361 void NotifyPanelWidthChanged(PanelType type, float width);
362 static std::string PanelTypeKey(PanelType type);
363
364 // Active and last-selected persistent tab.
367
368 // Active editor for context-aware help
370
371 // Every drawer uses the same user-resizable width so switching tabs does not
372 // move the workspace edge.
373 float shared_width_ = 480.0f;
374
375 // Component references (not owned)
384 Rom* rom_ = nullptr;
389
390 // Properties panel lock state
391 bool properties_locked_ = false;
392
393 // Animation state
394 float panel_animation_ = 0.0f; // 0.0 = fully closed, 1.0 = fully open
395 float animation_target_ = 0.0f; // Target value for lerp
396 bool animating_ = false;
397 bool closing_ = false; // True during close animation
398 PanelType closing_panel_ = PanelType::kNone; // Panel being animated closed
399 std::unordered_map<std::string, PanelSizeLimits> panel_size_limits_;
400 std::function<void(PanelType, float)> on_panel_width_changed_;
401};
402
407
412
417
423 const char* name = nullptr;
424 const char* icon = nullptr;
425 const char* shortcut_action = nullptr;
426};
427
431absl::Span<const DrawerCatalogEntry> GetDrawerCatalog();
432
434 return GetPanelTypeName(type);
435}
436
438 return GetPanelTypeIcon(type);
439}
440
441inline const char* GetDrawerShortcutAction(
443 return GetPanelShortcutAction(type);
444}
445
446} // namespace editor
447} // namespace yaze
448
449#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:49
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)
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 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={})
void ToggleLastDrawer()
Toggle the right sidebar using its last selected persistent tab.
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 SetSettingsPanelProvider(std::function< SettingsPanel *()> provider)
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
const std::string & tool_output_title() const
float GetConfiguredPanelWidth(PanelType type) const
PanelSizeLimits GetSharedPanelSizeLimits() const
ProposalDrawer * proposal_drawer() const
std::unordered_map< std::string, PanelSizeLimits > panel_size_limits_
void SetProposalDrawer(ProposalDrawer *drawer)
void DrawHeaderContextBadge(PanelType type, float available_width)
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)
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
ProjectManagementPanel * project_panel_
void SetPropertiesPanel(SelectionPropertiesPanel *panel)
void DrawDrawerNavStrip(PanelType current_panel)
PanelSizeLimits GetPanelSizeLimits(PanelType type) const
std::function< SettingsPanel *()> settings_panel_provider_
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 kMaxPanelWidthRatio
Definition ui_config.h:39