Registry for managing persistent popups. More...
#include <canvas_popup.h>
Public Member Functions | |
PopupRegistry ()=default | |
void | Open (const std::string &popup_id, std::function< void()> render_callback) |
Open a persistent popup. | |
void | Close (const std::string &popup_id) |
Close a persistent popup. | |
bool | IsOpen (const std::string &popup_id) const |
Check if a popup is currently open. | |
void | RenderAll () |
Render all active popups. | |
size_t | GetActiveCount () const |
Get the number of active popups. | |
void | Clear () |
Clear all popups from the registry. | |
std::vector< PopupState > & | GetPopups () |
Get direct access to the popup list (for migration/debugging) | |
const std::vector< PopupState > & | GetPopups () const |
Private Member Functions | |
std::vector< PopupState >::iterator | FindPopup (const std::string &popup_id) |
std::vector< PopupState >::const_iterator | FindPopup (const std::string &popup_id) const |
Private Attributes | |
std::vector< PopupState > | popups_ |
Registry for managing persistent popups.
Maintains a collection of popups and their lifecycle. Handles opening, closing, and rendering popups across frames.
This class is designed to be embedded in Canvas or used standalone for testing and custom UI components.
Definition at line 50 of file canvas_popup.h.
|
default |
void yaze::gui::PopupRegistry::Open | ( | const std::string & | popup_id, |
std::function< void()> | render_callback | ||
) |
Open a persistent popup.
If the popup already exists, updates its callback and reopens it. If the popup is new, adds it to the registry and opens it.
popup_id | Unique identifier for the popup |
render_callback | Function that renders the popup content |
Definition at line 8 of file canvas_popup.cc.
References FindPopup(), yaze::gui::PopupState::is_open, yaze::gui::PopupState::persist, yaze::gui::PopupState::popup_id, popups_, and yaze::gui::PopupState::render_callback.
Referenced by yaze::gui::Canvas::DrawContextMenuItem(), yaze::gui::Canvas::OpenPersistentPopup(), and yaze::gui::CanvasContextMenu::Render().
void yaze::gui::PopupRegistry::Close | ( | const std::string & | popup_id | ) |
Close a persistent popup.
Marks the popup as closed. It will be removed from the registry on the next render pass.
popup_id | Identifier of the popup to close |
Definition at line 34 of file canvas_popup.cc.
References FindPopup(), and popups_.
Referenced by yaze::gui::Canvas::ClosePersistentPopup().
bool yaze::gui::PopupRegistry::IsOpen | ( | const std::string & | popup_id | ) | const |
Check if a popup is currently open.
popup_id | Identifier of the popup to check |
Definition at line 49 of file canvas_popup.cc.
References FindPopup(), and popups_.
void yaze::gui::PopupRegistry::RenderAll | ( | ) |
Render all active popups.
Iterates through all open popups and calls their render callbacks. Automatically removes popups that have been closed by the user.
This should be called once per frame, typically at the end of the frame after all other rendering is complete.
Definition at line 54 of file canvas_popup.cc.
References popups_.
Referenced by yaze::gui::Canvas::RenderPersistentPopups().
size_t yaze::gui::PopupRegistry::GetActiveCount | ( | ) | const |
Get the number of active popups.
Definition at line 77 of file canvas_popup.cc.
References popups_.
void yaze::gui::PopupRegistry::Clear | ( | ) |
Clear all popups from the registry.
Closes all popups and removes them from the registry. Useful for cleanup or resetting state.
Definition at line 82 of file canvas_popup.cc.
References popups_.
|
inline |
Get direct access to the popup list (for migration/debugging)
Definition at line 114 of file canvas_popup.h.
References popups_.
|
inline |
Definition at line 115 of file canvas_popup.h.
References popups_.
|
private |
|
private |
Definition at line 103 of file canvas_popup.cc.
References popups_.
|
private |
Definition at line 119 of file canvas_popup.h.
Referenced by Clear(), Close(), FindPopup(), FindPopup(), GetActiveCount(), GetPopups(), GetPopups(), IsOpen(), Open(), and RenderAll().