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(WorkspaceWindowManager& window_manager,
23 std::function<bool()> is_dungeon_workbench_mode = {},
24 std::function<void(bool)> set_dungeon_workflow_mode = {},
25 std::function<EditorContextSnapshot(const std::string&)>
26 context_provider = {});
28
29 // Optional: when set, the rail reads per-user pin/hide/order prefs and
30 // mutates them in response to right-click menus and drag-drop. Safe to leave
31 // null — the rail falls back to the incoming `all_categories` order.
32 void SetUserSettings(UserSettings* settings) {
33 user_settings_ = settings;
35 }
36
37 // Extensible registry powering the "More Actions" popup at the bottom of
38 // the rail. Populated by EditorManager at construction time; callers may
39 // Register/Unregister further entries at runtime.
41
42 // `is_rom_dirty` is optional — when supplied and true, the icon for the
43 // selected+open editor gets a small dot badge in the top-right corner.
44 // `pending_dungeon_rooms` is optional — when supplied and > 0, the Dungeon
45 // category icon gets a warning badge even if ROM-buffer/file dirty state is
46 // still clean.
47 void Render(size_t session_id, const std::string& active_category,
48 const std::vector<std::string>& all_categories,
49 const std::unordered_set<std::string>& active_editor_categories,
50 std::function<bool()> has_rom,
51 std::function<bool()> is_rom_dirty = {},
52 std::function<int()> pending_dungeon_rooms = {});
53
54 void DrawWindowBrowser(size_t session_id, bool* p_open);
55
56 // Pure sort helper. Exposed for unit tests.
57 // - pinned set (intersected with visible) renders first, in `input` order
58 // - entries present in `order` render next, respecting `order`
59 // - remaining newcomers render alphabetically
60 // - entries in `hidden` are filtered out entirely
61 static std::vector<std::string> SortCategories(
62 const std::vector<std::string>& input,
63 const std::vector<std::string>& order,
64 const std::unordered_set<std::string>& pinned,
65 const std::unordered_set<std::string>& hidden);
66
67 private:
68 void DrawUtilityButtons(std::function<bool()> has_rom);
70 size_t session_id, const std::string& active_category,
71 const std::vector<std::string>& all_categories,
72 const std::unordered_set<std::string>& active_editor_categories,
73 std::function<bool()> has_rom, std::function<bool()> is_rom_dirty,
74 std::function<int()> pending_dungeon_rooms);
75 void DrawSidePanel(size_t session_id, const std::string& category,
76 std::function<bool()> has_rom);
77 float GetBottomReservedHeight() const;
78
79 // Right-click context menu on a sidebar icon. Mutates user_settings_ if set.
80 void DrawCategoryContextMenu(const std::string& category);
81 // Wraps an icon's ItemRect as both a drag source and drop target for the
82 // reorder payload ("YAZE_SIDEBAR_CAT"). No-op when user_settings_ is null.
83 void HandleReorderDragAndDrop(const std::string& category);
84
89 std::unique_ptr<MoreActionsRegistry> actions_registry_;
90};
91
92} // namespace editor
93} // namespace yaze
94
95#endif // YAZE_APP_EDITOR_MENU_ACTIVITY_BAR_H_
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)
WindowBrowser window_browser_
void DrawUtilityButtons(std::function< bool()> has_rom)
UserSettings * user_settings_
std::unique_ptr< MoreActionsRegistry > actions_registry_
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={}, std::function< int()> pending_dungeon_rooms={})
WindowSidebar window_sidebar_
void DrawCategoryContextMenu(const std::string &category)
WorkspaceWindowManager & window_manager_
void SetUserSettings(UserSettings *settings)
ActivityBar(WorkspaceWindowManager &window_manager, std::function< bool()> is_dungeon_workbench_mode={}, std::function< void(bool)> set_dungeon_workflow_mode={}, std::function< EditorContextSnapshot(const std::string &)> context_provider={})
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 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, std::function< int()> pending_dungeon_rooms)
float GetBottomReservedHeight() const
Manages user preferences and settings persistence.
void SetUserSettings(UserSettings *settings)
Central registry for all editor cards with session awareness and dependency injection.