The Battle for Wesnoth  1.17.0-dev
modeless_dialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "gui/widgets/window.hpp"
20 #include "video.hpp"
21 
22 namespace gui2::dialogs
23 {
24 
26 {
27 }
28 
30 {
31  hide();
32 }
33 
34 void modeless_dialog::show(const bool allow_interaction, const unsigned /*auto_close_time*/)
35 {
36  if(CVideo::get_singleton().faked()) {
37  return;
38  }
39 
40  hide();
41 
43 
45 
46  pre_show(*window_);
47 
48  if(allow_interaction) {
49  open_window_stack.push_back(window_.get());
50  window_->show_non_modal();
51  } else {
52  window_->show_tooltip(/*auto_close_time*/);
53  }
54 }
55 
57 {
58  if(window_) {
59  // Don't bother if show_mode_ == tooltip, because in that case we didn't add it anyway.
60  if(window_->mode() == window::show_mode::modeless) {
62  }
63 
64  window_->undraw();
65  window_.reset(nullptr); }
66 }
67 
68 std::unique_ptr<window> modeless_dialog::build_window() const
69 {
70  return build(window_id());
71 }
72 
74 {
75  /* DO NOTHING */
76 }
77 
79 {
80  /* DO NOTHING */
81 }
82 
83 } // 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:48
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:1105
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:64
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:1103