Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::AlertWindow Class Reference

#include <window_classes.hpp>

Classes

struct  StyleTokens
 Theme color-token names the host should look up when painting each AlertIcon. More...

Public Types

using ButtonHandler = std::function<void(std::size_t )>

Public Member Functions

 AlertWindow (const std::string &title, const std::string &message, AlertIcon icon=AlertIcon::info)
 ~AlertWindow ()
 AlertWindow (const AlertWindow &)=delete
AlertWindow & operator= (const AlertWindow &)=delete
std::size_t add_button (std::string label)
 Append a button. Returns the index assigned to this button (0-based).
void set_button_handler (ButtonHandler handler)
 Install a handler invoked with the index of the chosen button.
bool show ()
 Show the alert. Returns false if no WindowHost::Factory exists.
void click_button (std::size_t index)
 Programmatic button click — fires the handler with index and tears the alert down.
bool is_dismissed () const
std::size_t button_count () const
const std::string & button_label (std::size_t i) const
AlertIcon icon () const
const std::string & title () const
const std::string & message () const
WindowHost * host ()
StyleTokens style_tokens () const
 Convenience that returns this alert's styled tokens.

Static Public Member Functions

static std::unique_ptr< AlertWindow > info (const std::string &title, const std::string &message, ButtonHandler handler={})
 "Info" alert with a single OK button.
static std::unique_ptr< AlertWindow > confirm (const std::string &title, const std::string &message, ButtonHandler handler={})
 "Question" alert with Cancel (0) and OK (1) buttons.
static std::unique_ptr< AlertWindow > error (const std::string &title, const std::string &message, ButtonHandler handler={})
 "Error" alert with a single OK button.
static std::unique_ptr< AlertWindow > warning (const std::string &title, const std::string &message, ButtonHandler handler={})
 "Warning" alert with a single OK button — sibling of info / error.
static StyleTokens style_tokens_for (AlertIcon icon)
 Returns the style tokens for an icon.

Member Typedef Documentation

◆ ButtonHandler

using pulp::view::AlertWindow::ButtonHandler = std::function<void(std::size_t )>

Constructor & Destructor Documentation

◆ AlertWindow() [1/2]

pulp::view::AlertWindow::AlertWindow ( const std::string & title,
const std::string & message,
AlertIcon icon = AlertIcon::info )

◆ ~AlertWindow()

pulp::view::AlertWindow::~AlertWindow ( )

◆ AlertWindow() [2/2]

pulp::view::AlertWindow::AlertWindow ( const AlertWindow & )
delete

Member Function Documentation

◆ add_button()

std::size_t pulp::view::AlertWindow::add_button ( std::string label)

Append a button. Returns the index assigned to this button (0-based).

◆ button_count()

std::size_t pulp::view::AlertWindow::button_count ( ) const
inline

◆ button_label()

const std::string & pulp::view::AlertWindow::button_label ( std::size_t i) const
inline

◆ click_button()

void pulp::view::AlertWindow::click_button ( std::size_t index)

Programmatic button click — fires the handler with index and tears the alert down.

◆ confirm()

std::unique_ptr< AlertWindow > pulp::view::AlertWindow::confirm ( const std::string & title,
const std::string & message,
ButtonHandler handler = {} )
static

"Question" alert with Cancel (0) and OK (1) buttons.

◆ error()

std::unique_ptr< AlertWindow > pulp::view::AlertWindow::error ( const std::string & title,
const std::string & message,
ButtonHandler handler = {} )
static

"Error" alert with a single OK button.

◆ host()

WindowHost * pulp::view::AlertWindow::host ( )
inline

◆ icon()

AlertIcon pulp::view::AlertWindow::icon ( ) const
inline

◆ info()

std::unique_ptr< AlertWindow > pulp::view::AlertWindow::info ( const std::string & title,
const std::string & message,
ButtonHandler handler = {} )
static

"Info" alert with a single OK button.

The handler fires with index = 0 when the user dismisses it.

◆ is_dismissed()

bool pulp::view::AlertWindow::is_dismissed ( ) const
inline

◆ message()

const std::string & pulp::view::AlertWindow::message ( ) const
inline

◆ operator=()

AlertWindow & pulp::view::AlertWindow::operator= ( const AlertWindow & )
delete

◆ set_button_handler()

void pulp::view::AlertWindow::set_button_handler ( ButtonHandler handler)
inline

Install a handler invoked with the index of the chosen button.

Fires at most once.

◆ show()

bool pulp::view::AlertWindow::show ( )

Show the alert. Returns false if no WindowHost::Factory exists.

◆ style_tokens()

StyleTokens pulp::view::AlertWindow::style_tokens ( ) const
inline

Convenience that returns this alert's styled tokens.

◆ style_tokens_for()

StyleTokens pulp::view::AlertWindow::style_tokens_for ( AlertIcon icon)
static

Returns the style tokens for an icon.

The host can use these to paint the alert chrome in a theme-driven color without baking a specific palette into the alert window itself.

info → "alert.info.icon" + "alert.info.accent" + glyph "i" warning → "alert.warning.icon" + "alert.warning.accent" + glyph "!" error → "alert.error.icon" + "alert.error.accent" + glyph "x" question → "alert.question.icon" + "alert.question.accent" + "?" none → empty tokens.

◆ title()

const std::string & pulp::view::AlertWindow::title ( ) const
inline

◆ warning()

std::unique_ptr< AlertWindow > pulp::view::AlertWindow::warning ( const std::string & title,
const std::string & message,
ButtonHandler handler = {} )
static

"Warning" alert with a single OK button — sibling of info / error.


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