yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
canvas_popup.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_CANVAS_CANVAS_POPUP_H
2#define YAZE_APP_GUI_CANVAS_CANVAS_POPUP_H
3
4#include <functional>
5#include <string>
6#include <vector>
7
8#include "imgui/imgui.h"
9
10namespace yaze {
11namespace gui {
12
19struct PopupState {
20 // Unique popup identifier (used with ImGui::OpenPopup/BeginPopup)
21 std::string popup_id;
22
23 // Whether the popup is currently open
24 bool is_open = false;
25
26 // Callback that renders the popup content
27 // Should call ImGui::BeginPopup(popup_id) / ImGui::EndPopup()
28 std::function<void()> render_callback;
29
30 // Whether the popup should persist across frames
31 bool persist = true;
32
33 // Default constructor
34 PopupState() = default;
35
36 // Constructor with id and callback
37 PopupState(const std::string& id, std::function<void()> callback)
38 : popup_id(id), is_open(false), render_callback(std::move(callback)) {}
39};
40
51 public:
52 PopupRegistry() = default;
53
63 void Open(const std::string& popup_id, std::function<void()> render_callback);
64
73 void Close(const std::string& popup_id);
74
81 bool IsOpen(const std::string& popup_id) const;
82
92 void RenderAll();
93
99 size_t GetActiveCount() const;
100
107 void Clear();
108
114 std::vector<PopupState>& GetPopups() { return popups_; }
115 const std::vector<PopupState>& GetPopups() const { return popups_; }
116
117 private:
118 // Internal storage for popup states
119 std::vector<PopupState> popups_;
120
121 // Helper to find a popup by ID
122 std::vector<PopupState>::iterator FindPopup(const std::string& popup_id);
123 std::vector<PopupState>::const_iterator FindPopup(const std::string& popup_id) const;
124};
125
126} // namespace gui
127} // namespace yaze
128
129#endif // YAZE_APP_GUI_CANVAS_CANVAS_POPUP_H
130
Registry for managing persistent popups.
void Close(const std::string &popup_id)
Close a persistent popup.
size_t GetActiveCount() const
Get the number of active popups.
void RenderAll()
Render all active popups.
void Clear()
Clear all popups from the registry.
std::vector< PopupState > popups_
std::vector< PopupState > & GetPopups()
Get direct access to the popup list (for migration/debugging)
bool IsOpen(const std::string &popup_id) const
Check if a popup is currently open.
const std::vector< PopupState > & GetPopups() const
std::vector< PopupState >::iterator FindPopup(const std::string &popup_id)
void Open(const std::string &popup_id, std::function< void()> render_callback)
Open a persistent popup.
Main namespace for the application.
Definition controller.cc:20
State for a single persistent popup.
PopupState(const std::string &id, std::function< void()> callback)
std::function< void()> render_callback