The Battle for Wesnoth  1.17.0-dev
modeless_dialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2021
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/widgets/window.hpp"
21 #include "video.hpp"
22 
23 namespace gui2::dialogs
24 {
25 
27 {
28 }
29 
31 {
32  hide();
33 }
34 
35 void modeless_dialog::show(const bool allow_interaction, const unsigned /*auto_close_time*/)
36 {
37  if(CVideo::get_singleton().faked()) {
38  return;
39  }
40 
41  hide();
42 
44 
46 
47  pre_show(*window_);
48 
49  if(allow_interaction) {
50  open_window_stack.push_back(window_.get());
51  window_->show_non_modal();
52  } else {
53  window_->show_tooltip(/*auto_close_time*/);
54  }
55 }
56 
58 {
59  if(window_) {
60  // Don't bother if show_mode_ == tooltip, because in that case we didn't add it anyway.
61  if(window_->mode() == window::show_mode::modeless) {
63  }
64 
65  window_->undraw();
66  window_.reset(nullptr); }
67 }
68 
69 std::unique_ptr<window> modeless_dialog::build_window() const
70 {
71  return build(window_id());
72 }
73 
75 {
76  /* DO NOTHING */
77 }
78 
80 {
81  /* DO NOTHING */
82 }
83 
84 } // namespace dialogs
This file contains the window object, this object is a top level container which has the event manage...
virtual void post_build(window &window)
Actions to be taken directly after the window is build.
static CVideo & get_singleton()
Definition: video.hpp:49
virtual const std::string & window_id() const =0
The id of the window to build.
std::unique_ptr< window > build_window() const
Builds the window.
void remove_from_window_stack(window *window)
Removes a entry from the open_window_stack list.
Definition: handler.cpp:1106
void hide()
Hides the window.
virtual void pre_show(window &window)
Actions to be taken before showing the window.
std::unique_ptr< window > window_
The window, used in show.
void show(const bool allow_interaction=false, const unsigned auto_close_time=0)
Shows the window.
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
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:1104