The Battle for Wesnoth  1.19.5+dev
modeless_dialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
19 
20 #include "gui/core/gui_definition.hpp" // get_window_builder
21 #include "video.hpp"
22 
23 namespace gui2::dialogs
24 {
25 
26 modeless_dialog::modeless_dialog(const std::string& window_id)
27  : window(get_window_builder(window_id))
28 {
30 }
31 
33 {
34 }
35 
36 void modeless_dialog::show(const bool allow_interaction, const unsigned /*auto_close_time*/)
37 {
38  if(video::headless()) {
39  return;
40  }
41 
42  if(allow_interaction) {
43  open_window_stack.push_back(this);
46  } else {
47  window::show_tooltip(/*auto_close_time*/);
48  }
49 }
50 
51 } // namespace dialogs
modeless_dialog(const std::string &window_id)
void show(const bool allow_interaction=false, const unsigned auto_close_time=0)
Shows the window.
virtual const std::string & window_id() const
The ID of the window to build.
void set_id(const std::string &id)
Definition: widget.cpp:98
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:61
void show_tooltip()
Shows the window as a tooltip.
Definition: window.cpp:432
void show_non_modal()
Shows the window non modal.
Definition: window.cpp:464
void remove_from_window_stack(window *window)
Removes a entry from the open_window_stack list.
Definition: handler.cpp:1074
const builder_window::window_resolution & get_window_builder(const std::string &type)
Returns an reference to the requested builder.
std::vector< window * > open_window_stack
Keeps track of any open windows of any type (modal, non-modal, or tooltip) in the order in which they...
Definition: handler.cpp:1072
bool headless()
The game is running headless.
Definition: video.cpp:139