yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
activity_bar.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MENU_ACTIVITY_BAR_H_
2#define YAZE_APP_EDITOR_MENU_ACTIVITY_BAR_H_
3
4#include <functional>
5#include <memory>
6#include <string>
7#include <unordered_set>
8#include <vector>
9
13
14namespace yaze {
15namespace editor {
16
17class WorkspaceWindowManager;
18class UserSettings;
19
21 public:
22 explicit ActivityBar(
23 WorkspaceWindowManager& window_manager,
24 std::function<bool()> is_dungeon_workbench_mode = {},
25 std::function<void(bool)> set_dungeon_workflow_mode = {});
27
28 // Optional: when set, the rail reads per-user pin/hide/order prefs and
29 // mutates them in response to right-click menus and drag-drop. Safe to leave
30 // null — the rail falls back to the incoming `all_categories` order.
31 void SetUserSettings(UserSettings* settings) { user_settings_ = settings; }
32
33 // Extensible registry powering the "More Actions" popup at the bottom of
34 // the rail. Populated by EditorManager at construction time; callers may
35 // Register/Unregister further entries at runtime.
37
38 // `is_rom_dirty` is optional — when supplied and true, the icon for the
39 // selected+open editor gets a small dot badge in the top-right corner.
40 void Render(size_t session_id, const std::string& active_category,
41 const std::vector<std::string>& all_categories,
42 const std::unordered_set<std::string>& active_editor_categories,
43 std::function<bool()> has_rom,
44 std::function<bool()> is_rom_dirty = {});
45
46 void DrawWindowBrowser(size_t session_id, bool* p_open);
47
48 // Pure sort helper. Exposed for unit tests.
49 // - pinned set (intersected with visible) renders first, in `input` order
50 // - entries present in `order` render next, respecting `order`
51 // - remaining newcomers render alphabetically
52 // - entries in `hidden` are filtered out entirely
53 static std::vector<std::string> SortCategories(
54 const std::vector<std::string>& input,
55 const std::vector<std::string>& order,
56 const std::unordered_set<std::string>& pinned,
57 const std::unordered_set<std::string>& hidden);
58
59 private:
60 void DrawUtilityButtons(std::function<bool()> has_rom);
62 size_t session_id, const std::string& active_category,
63 const std::vector<std::string>& all_categories,
64 const std::unordered_set<std::string>& active_editor_categories,
65 std::function<bool()> has_rom,
66 std::function<bool()> is_rom_dirty);
67 void DrawSidePanel(size_t session_id, const std::string& category,
68 std::function<bool()> has_rom);
69
70 // Right-click context menu on a sidebar icon. Mutates user_settings_ if set.
71 void DrawCategoryContextMenu(const std::string& category);
72 // Wraps an icon's ItemRect as both a drag source and drop target for the
73 // reorder payload ("YAZE_SIDEBAR_CAT"). No-op when user_settings_ is null.
74 void HandleReorderDragAndDrop(const std::string& category);
75
80 std::unique_ptr<MoreActionsRegistry> actions_registry_;
81};
82
83} // namespace editor
84} // namespace yaze
85
86#endif // YAZE_APP_EDITOR_MENU_ACTIVITY_BAR_H_
ActivityBar(WorkspaceWindowManager &window_manager, std::function< bool()> is_dungeon_workbench_mode={}, std::function< void(bool)> set_dungeon_workflow_mode={})
void DrawSidePanel(size_t session_id, const std::string &category, std::function< bool()> has_rom)
MoreActionsRegistry & actions_registry()
void DrawWindowBrowser(size_t session_id, bool *p_open)
void DrawActivityBarStrip(size_t session_id, const std::string &active_category, const std::vector< std::string > &all_categories, const std::unordered_set< std::string > &active_editor_categories, std::function< bool()> has_rom, std::function< bool()> is_rom_dirty)
WindowBrowser window_browser_
void DrawUtilityButtons(std::function< bool()> has_rom)
UserSettings * user_settings_
std::unique_ptr< MoreActionsRegistry > actions_registry_
WindowSidebar window_sidebar_
void DrawCategoryContextMenu(const std::string &category)
WorkspaceWindowManager & window_manager_
void SetUserSettings(UserSettings *settings)
static std::vector< std::string > SortCategories(const std::vector< std::string > &input, const std::vector< std::string > &order, const std::unordered_set< std::string > &pinned, const std::unordered_set< std::string > &hidden)
void HandleReorderDragAndDrop(const std::string &category)
void Render(size_t session_id, const std::string &active_category, const std::vector< std::string > &all_categories, const std::unordered_set< std::string > &active_editor_categories, std::function< bool()> has_rom, std::function< bool()> is_rom_dirty={})
Manages user preferences and settings persistence.
Central registry for all editor cards with session awareness and dependency injection.