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