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 // `pending_dungeon_rooms` is optional — when supplied and > 0, the Dungeon
41 // category icon gets a warning badge even if ROM-buffer/file dirty state is
42 // still clean.
43 void Render(size_t session_id, const std::string& active_category,
44 const std::vector<std::string>& all_categories,
45 const std::unordered_set<std::string>& active_editor_categories,
46 std::function<bool()> has_rom,
47 std::function<bool()> is_rom_dirty = {},
48 std::function<int()> pending_dungeon_rooms = {});
49
50 void DrawWindowBrowser(size_t session_id, bool* p_open);
51
52 // Pure sort helper. Exposed for unit tests.
53 // - pinned set (intersected with visible) renders first, in `input` order
54 // - entries present in `order` render next, respecting `order`
55 // - remaining newcomers render alphabetically
56 // - entries in `hidden` are filtered out entirely
57 static std::vector<std::string> SortCategories(
58 const std::vector<std::string>& input,
59 const std::vector<std::string>& order,
60 const std::unordered_set<std::string>& pinned,
61 const std::unordered_set<std::string>& hidden);
62
63 private:
64 void DrawUtilityButtons(std::function<bool()> has_rom);
66 size_t session_id, const std::string& active_category,
67 const std::vector<std::string>& all_categories,
68 const std::unordered_set<std::string>& active_editor_categories,
69 std::function<bool()> has_rom, std::function<bool()> is_rom_dirty,
70 std::function<int()> pending_dungeon_rooms);
71 void DrawSidePanel(size_t session_id, const std::string& category,
72 std::function<bool()> has_rom);
73 float GetBottomReservedHeight() const;
74
75 // Right-click context menu on a sidebar icon. Mutates user_settings_ if set.
76 void DrawCategoryContextMenu(const std::string& category);
77 // Wraps an icon's ItemRect as both a drag source and drop target for the
78 // reorder payload ("YAZE_SIDEBAR_CAT"). No-op when user_settings_ is null.
79 void HandleReorderDragAndDrop(const std::string& category);
80
85 std::unique_ptr<MoreActionsRegistry> actions_registry_;
86};
87
88} // namespace editor
89} // namespace yaze
90
91#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)
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)
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.
Central registry for all editor cards with session awareness and dependency injection.