78 const std::vector<Menu>&
menus()
const {
return menus_; }
95 const std::string&
title()
const {
return title_; }
116 View* content_root_ =
nullptr;
117 std::vector<Menu> menus_;
119 std::unique_ptr<WindowHost> host_;
143 const std::string&
ok_label()
const {
return ok_label_; }
154 completion_ = std::move(handler);
171 const std::string&
title()
const {
return title_; }
178 View* content_root_ =
nullptr;
179 std::string ok_label_ =
"OK";
180 std::string cancel_label_ =
"Cancel";
182 std::unique_ptr<WindowHost> host_;
183 bool dismissed_ =
false;
215 button_handler_ = std::move(handler);
229 const std::string&
title()
const {
return title_; }
230 const std::string&
message()
const {
return message_; }
237 static std::unique_ptr<AlertWindow>
info(
const std::string&
title,
247 static std::unique_ptr<AlertWindow>
error(
const std::string&
title,
286 std::string message_;
288 std::vector<std::string> buttons_;
290 std::unique_ptr<View> root_view_;
291 std::unique_ptr<WindowHost> host_;
292 bool dismissed_ =
false;
const std::string & button_label(std::size_t i) const
Definition window_classes.hpp:227
AlertWindow(const AlertWindow &)=delete
WindowHost * host()
Definition window_classes.hpp:231
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.
void set_button_handler(ButtonHandler handler)
Install a handler invoked with the index of the chosen button.
Definition window_classes.hpp:214
AlertWindow(const std::string &title, const std::string &message, AlertIcon icon=AlertIcon::info)
static std::unique_ptr< AlertWindow > info(const std::string &title, const std::string &message, ButtonHandler handler={})
"Info" alert with a single OK button.
void click_button(std::size_t index)
Programmatic button click — fires the handler with index and tears the alert down.
std::size_t button_count() const
Definition window_classes.hpp:226
std::function< void(std::size_t)> ButtonHandler
Definition window_classes.hpp:200
StyleTokens style_tokens() const
Convenience that returns this alert's styled tokens.
Definition window_classes.hpp:282
AlertIcon icon() const
Definition window_classes.hpp:228
bool is_dismissed() const
Definition window_classes.hpp:225
static std::unique_ptr< AlertWindow > error(const std::string &title, const std::string &message, ButtonHandler handler={})
"Error" alert with a single OK button.
const std::string & message() const
Definition window_classes.hpp:230
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.
std::size_t add_button(std::string label)
Append a button. Returns the index assigned to this button (0-based).
const std::string & title() const
Definition window_classes.hpp:229
static StyleTokens style_tokens_for(AlertIcon icon)
Returns the style tokens for an icon.
bool show()
Show the alert. Returns false if no WindowHost::Factory exists.
AlertWindow & operator=(const AlertWindow &)=delete
DialogWindow(const std::string &title, View &content_root)
const std::string & title() const
Definition window_classes.hpp:171
const std::string & cancel_label() const
Definition window_classes.hpp:149
DialogWindow & operator=(const DialogWindow &)=delete
bool is_dismissed() const
Definition window_classes.hpp:168
const std::string & ok_label() const
Definition window_classes.hpp:143
DialogWindow(const DialogWindow &)=delete
std::function< void(DialogResult)> CompletionHandler
Definition window_classes.hpp:132
WindowHost * host()
Definition window_classes.hpp:174
DialogResult last_result() const
Definition window_classes.hpp:169
bool is_modal() const
Definition window_classes.hpp:170
void set_ok_label(std::string label)
Customize the OK button label (default "OK").
Definition window_classes.hpp:142
View & content()
Definition window_classes.hpp:173
bool show(bool modal=true)
Show the dialog.
void dismiss(DialogResult result)
Programmatic dismissal — call from a button handler.
void set_cancel_label(std::string label)
Customize the Cancel button label (default "Cancel").
Definition window_classes.hpp:148
void set_completion_handler(CompletionHandler handler)
Set the completion handler.
Definition window_classes.hpp:153
void hide()
Hide the window without closing it (close-confirm is NOT consulted).
const View & content() const
Definition window_classes.hpp:92
void set_menus(std::vector< Menu > menus)
Set or replace the logical menu model.
const std::vector< Menu > & menus() const
Definition window_classes.hpp:78
DocumentWindow & operator=(DocumentWindow &&)=delete
View & content()
The content View attached to this window's content area.
Definition window_classes.hpp:91
const std::string & title() const
The window's title.
Definition window_classes.hpp:95
std::function< bool()> CloseConfirmationHandler
Hook called when the user requests the window to close (clicked the close button, hit ⌘W,...
Definition window_classes.hpp:46
bool has_native_window() const
True if show() produced a live native window.
Definition window_classes.hpp:112
bool show()
Create the native window and show it.
DocumentWindow(const std::string &title, View &content_root)
CloseConfirmationHandler set_close_confirmation_handler(CloseConfirmationHandler handler)
Install a close-confirmation hook.
bool request_close()
Programmatic close request — runs the close-confirmation handler and (if it returns true) tears down ...
DocumentWindow(const DocumentWindow &)=delete
DocumentWindow(DocumentWindow &&)=delete
WindowHost * host()
Underlying WindowHost (nullptr until show() is called or until a factory becomes available).
Definition window_classes.hpp:100
DocumentWindow & operator=(const DocumentWindow &)=delete
Definition window_host.hpp:113
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ none
Definition appearance_defects.hpp:53
@ modal
A ModalOverlay in the tree consumed Escape through its own handler.
Definition overlay_dismissal.hpp:259
@ ok
bound; the widget exists and accepts this target
Definition binding_diagnostics.hpp:27
@ i
Definition input_events.hpp:40
AlertIcon
Definition window_classes.hpp:190
@ question
Definition window_classes.hpp:195
@ info
Definition window_classes.hpp:192
DialogResult
Definition window_classes.hpp:124
@ cancel
Definition window_classes.hpp:126
@ closed
User dismissed the dialog without explicitly choosing.
Definition window_classes.hpp:127
@ warning
Definition design_ir.hpp:696
@ info
Definition design_ir.hpp:695
@ error
Definition design_ir.hpp:697
Theme color-token names the host should look up when painting each AlertIcon.
Definition window_classes.hpp:264
const char * icon_color
Token for the icon glyph color.
Definition window_classes.hpp:265
const char * accent_color
Token for the chrome accent (border / title).
Definition window_classes.hpp:266
const char * glyph
Glyph hint (e.g. "i", "!", "x", "?").
Definition window_classes.hpp:267