yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gui::PopupRegistry Class Reference

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< PopupStatepopups_
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PopupRegistry()

yaze::gui::PopupRegistry::PopupRegistry ( )
default

Member Function Documentation

◆ Open()

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.

Parameters
popup_idUnique identifier for the popup
render_callbackFunction 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().

Here is the call graph for this function:

◆ Close()

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.

Parameters
popup_idIdentifier of the popup to close

Definition at line 34 of file canvas_popup.cc.

References FindPopup(), and popups_.

Referenced by yaze::gui::Canvas::ClosePersistentPopup().

Here is the call graph for this function:

◆ IsOpen()

bool yaze::gui::PopupRegistry::IsOpen ( const std::string &  popup_id) const

Check if a popup is currently open.

Parameters
popup_idIdentifier of the popup to check
Returns
true if popup is open, false otherwise

Definition at line 49 of file canvas_popup.cc.

References FindPopup(), and popups_.

Here is the call graph for this function:

◆ RenderAll()

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().

◆ GetActiveCount()

size_t yaze::gui::PopupRegistry::GetActiveCount ( ) const

Get the number of active popups.

Returns
Number of open popups in the registry

Definition at line 77 of file canvas_popup.cc.

References popups_.

◆ Clear()

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_.

◆ GetPopups() [1/2]

std::vector< PopupState > & yaze::gui::PopupRegistry::GetPopups ( )
inline

Get direct access to the popup list (for migration/debugging)

Returns
Reference to the internal popup vector

Definition at line 114 of file canvas_popup.h.

References popups_.

◆ GetPopups() [2/2]

const std::vector< PopupState > & yaze::gui::PopupRegistry::GetPopups ( ) const
inline

Definition at line 115 of file canvas_popup.h.

References popups_.

◆ FindPopup() [1/2]

std::vector< PopupState >::iterator yaze::gui::PopupRegistry::FindPopup ( const std::string &  popup_id)
private

Definition at line 95 of file canvas_popup.cc.

References popups_.

Referenced by Close(), IsOpen(), and Open().

◆ FindPopup() [2/2]

std::vector< PopupState >::const_iterator yaze::gui::PopupRegistry::FindPopup ( const std::string &  popup_id) const
private

Definition at line 103 of file canvas_popup.cc.

References popups_.

Member Data Documentation

◆ popups_

std::vector<PopupState> yaze::gui::PopupRegistry::popups_
private

The documentation for this class was generated from the following files: