yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
activity_bar_actions_registry.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MENU_ACTIVITY_BAR_ACTIONS_REGISTRY_H_
2#define YAZE_APP_EDITOR_MENU_ACTIVITY_BAR_ACTIONS_REGISTRY_H_
3
4#include <functional>
5#include <string>
6#include <vector>
7
8namespace yaze {
9namespace editor {
10
11// A single action surfaced by the ActivityBar's "More Actions" popup.
12// `icon` may be null (menus render label only).
13// `enabled_fn` may be null (action is always enabled).
14struct MoreAction {
15 std::string id;
16 std::string label;
17 const char* icon = nullptr;
18 std::function<void()> on_invoke;
19 std::function<bool()> enabled_fn;
20};
21
22// Extensible registry for "More Actions" entries in the activity bar.
23// Preserves insertion order so downstream ordering is predictable for users
24// and for test assertions. Registering an action whose id already exists
25// replaces the prior entry in-place (keeps the one-id invariant without
26// reshuffling the tail).
28 public:
29 void Register(MoreAction action);
30 void Unregister(const std::string& id);
31 void Clear();
32 void ForEach(const std::function<void(const MoreAction&)>& fn) const;
33 size_t size() const { return actions_.size(); }
34 bool empty() const { return actions_.empty(); }
35
36 private:
37 std::vector<MoreAction> actions_;
38};
39
40} // namespace editor
41} // namespace yaze
42
43#endif // YAZE_APP_EDITOR_MENU_ACTIVITY_BAR_ACTIONS_REGISTRY_H_
void ForEach(const std::function< void(const MoreAction &)> &fn) const