yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
command_palette_providers.cc
Go to the documentation of this file.
2
3#include <utility>
4
5#include "absl/strings/str_format.h"
8
9namespace yaze {
10namespace editor {
11
13 WorkspaceWindowManager* window_manager, size_t session_id)
14 : window_manager_(window_manager), session_id_(session_id) {}
15
19
21 std::function<void(const std::string&)> switch_callback)
22 : switch_callback_(std::move(switch_callback)) {}
23
27
29 std::function<void(const std::string&)> open_callback)
30 : open_callback_(std::move(open_callback)) {}
31
35
37 : session_id_(session_id) {}
38
42
44 WorkspaceWindowManager* window_manager, size_t session_id)
45 : window_manager_(window_manager), session_id_(session_id) {}
46
50
52 WorkspaceWindowManager* window_manager, UserSettings* user_settings,
53 size_t session_id)
54 : window_manager_(window_manager),
55 user_settings_(user_settings),
56 session_id_(session_id) {}
57
59 if (!palette || !user_settings_ || !window_manager_) return;
60
62
63 // Global helpers first — they're callable any time.
64 palette->AddCommand(
65 "Sidebar: Reset Order", CommandCategory::kView,
66 "Clear the custom sidebar order and revert to defaults",
67 /*shortcut=*/"", [this]() {
68 if (!user_settings_) return;
69 user_settings_->prefs().sidebar_order.clear();
70 (void)user_settings_->Save();
71 });
72
73 palette->AddCommand(
74 "Sidebar: Show All Categories", CommandCategory::kView,
75 "Un-hide every sidebar category",
76 /*shortcut=*/"", [this]() {
77 if (!user_settings_) return;
79 (void)user_settings_->Save();
80 });
81
82 // Per-category toggles. Using static "Toggle" labels avoids the need to
83 // refresh the provider every time state flips.
84 for (const auto& cat : categories) {
86
87 std::string pin_name =
88 absl::StrFormat("Sidebar: Toggle Pin: %s", cat);
89 std::string pin_desc =
90 absl::StrFormat("Pin or unpin %s at the top of the sidebar", cat);
91 std::string captured_cat_pin = cat;
92 palette->AddCommand(pin_name, CommandCategory::kView, pin_desc,
93 /*shortcut=*/"",
94 [this, captured_cat_pin]() {
95 if (!user_settings_) return;
96 auto& pinned =
97 user_settings_->prefs().sidebar_pinned;
98 if (pinned.count(captured_cat_pin)) {
99 pinned.erase(captured_cat_pin);
100 } else {
101 pinned.insert(captured_cat_pin);
102 }
103 (void)user_settings_->Save();
104 });
105
106 std::string hide_name =
107 absl::StrFormat("Sidebar: Toggle Visibility: %s", cat);
108 std::string hide_desc =
109 absl::StrFormat("Show or hide %s in the sidebar", cat);
110 std::string captured_cat_hide = cat;
111 palette->AddCommand(hide_name, CommandCategory::kView, hide_desc,
112 /*shortcut=*/"",
113 [this, captured_cat_hide]() {
114 if (!user_settings_) return;
115 auto& hidden =
116 user_settings_->prefs().sidebar_hidden;
117 if (hidden.count(captured_cat_hide)) {
118 hidden.erase(captured_cat_hide);
119 } else {
120 hidden.insert(captured_cat_hide);
121 }
122 (void)user_settings_->Save();
123 });
124 }
125}
126
128 : callbacks_(std::move(callbacks)) {}
129
137
138} // namespace editor
139} // namespace yaze
void RegisterDungeonRoomCommands(size_t session_id)
Register dungeon room navigation commands.
void RegisterWelcomeCommands(const RecentProjectsModel *model, const std::vector< std::string > &template_names, std::function< void(const std::string &)> remove_callback, std::function< void(const std::string &)> toggle_pin_callback, std::function< void()> undo_remove_callback, std::function< void()> clear_recents_callback, std::function< void(const std::string &)> create_from_template_callback, std::function< void()> dismiss_welcome_callback, std::function< void()> show_welcome_callback)
Expose welcome-screen actions through the command palette.
void AddCommand(const std::string &name, const std::string &category, const std::string &description, const std::string &shortcut, std::function< void()> callback)
void RegisterPanelCommands(WorkspaceWindowManager *window_manager, size_t session_id)
Register all window toggle commands from WorkspaceWindowManager.
void RegisterWorkflowCommands(WorkspaceWindowManager *window_manager, size_t session_id)
Register hack workflow commands from workflow-aware panels/actions.
void RegisterEditorCommands(std::function< void(const std::string &)> switch_callback)
Register all editor switch commands.
void RegisterRecentFilesCommands(std::function< void(const std::string &)> open_callback)
Register commands to open recent files.
void Provide(CommandPalette *palette) override
Populate palette with this source's commands.
void Provide(CommandPalette *palette) override
Populate palette with this source's commands.
EditorCommandsProvider(std::function< void(const std::string &)> switch_callback)
std::function< void(const std::string &) switch_callback_)
void Provide(CommandPalette *palette) override
Populate palette with this source's commands.
PanelCommandsProvider(WorkspaceWindowManager *window_manager, size_t session_id)
void Provide(CommandPalette *palette) override
Populate palette with this source's commands.
std::function< void(const std::string &) open_callback_)
RecentFilesCommandsProvider(std::function< void(const std::string &)> open_callback)
void Provide(CommandPalette *palette) override
Populate palette with this source's commands.
SidebarCommandsProvider(WorkspaceWindowManager *window_manager, UserSettings *user_settings, size_t session_id)
Manages user preferences and settings persistence.
void Provide(CommandPalette *palette) override
Populate palette with this source's commands.
void Provide(CommandPalette *palette) override
Populate palette with this source's commands.
WorkflowCommandsProvider(WorkspaceWindowManager *window_manager, size_t session_id)
Central registry for all editor cards with session awareness and dependency injection.
static constexpr const char * kDashboardCategory
std::vector< std::string > GetAllCategories(size_t session_id) const
static constexpr const char * kView
std::unordered_set< std::string > sidebar_hidden
std::function< void(const std::string &) toggle_pin)
std::function< void(const std::string &) remove)
std::function< void(const std::string &) create_from_template)