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
10
namespace
yaze
{
11
namespace
gui {
12
19
struct
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
50
class
PopupRegistry
{
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
yaze::gui::PopupRegistry
Registry for managing persistent popups.
Definition
canvas_popup.h:50
yaze::gui::PopupRegistry::PopupRegistry
PopupRegistry()=default
yaze::gui::PopupRegistry::Close
void Close(const std::string &popup_id)
Close a persistent popup.
Definition
canvas_popup.cc:34
yaze::gui::PopupRegistry::GetActiveCount
size_t GetActiveCount() const
Get the number of active popups.
Definition
canvas_popup.cc:77
yaze::gui::PopupRegistry::RenderAll
void RenderAll()
Render all active popups.
Definition
canvas_popup.cc:54
yaze::gui::PopupRegistry::Clear
void Clear()
Clear all popups from the registry.
Definition
canvas_popup.cc:82
yaze::gui::PopupRegistry::popups_
std::vector< PopupState > popups_
Definition
canvas_popup.h:119
yaze::gui::PopupRegistry::GetPopups
std::vector< PopupState > & GetPopups()
Get direct access to the popup list (for migration/debugging)
Definition
canvas_popup.h:114
yaze::gui::PopupRegistry::IsOpen
bool IsOpen(const std::string &popup_id) const
Check if a popup is currently open.
Definition
canvas_popup.cc:49
yaze::gui::PopupRegistry::GetPopups
const std::vector< PopupState > & GetPopups() const
Definition
canvas_popup.h:115
yaze::gui::PopupRegistry::FindPopup
std::vector< PopupState >::iterator FindPopup(const std::string &popup_id)
Definition
canvas_popup.cc:95
yaze::gui::PopupRegistry::Open
void Open(const std::string &popup_id, std::function< void()> render_callback)
Open a persistent popup.
Definition
canvas_popup.cc:8
yaze
Main namespace for the application.
Definition
controller.cc:20
yaze::gui::PopupState
State for a single persistent popup.
Definition
canvas_popup.h:19
yaze::gui::PopupState::is_open
bool is_open
Definition
canvas_popup.h:24
yaze::gui::PopupState::PopupState
PopupState(const std::string &id, std::function< void()> callback)
Definition
canvas_popup.h:37
yaze::gui::PopupState::persist
bool persist
Definition
canvas_popup.h:31
yaze::gui::PopupState::popup_id
std::string popup_id
Definition
canvas_popup.h:21
yaze::gui::PopupState::PopupState
PopupState()=default
yaze::gui::PopupState::render_callback
std::function< void()> render_callback
Definition
canvas_popup.h:28
src
app
gui
canvas
canvas_popup.h
Generated by
1.9.8