The Battle for Wesnoth  1.19.0-dev
select_orb_colors.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2024
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 #pragma once
16 
18 #include "gui/widgets/group.hpp"
19 
20 #include <map>
21 
22 namespace gui2::dialogs
23 {
25 {
26 public:
28 
29  /**
30  * The display function.
31  *
32  * See @ref modal_dialog for more information.
33  */
35 
36 private:
37  /**
38  * Sets up the checkbox that's common to the no-color, one-color and two-color settings.
39  * Sets its ticked/unticked state and connects the callback for user interaction.
40  */
41  void setup_orb_toggle(const std::string& base_id, bool& shown);
42  /**
43  * Sets up the checkbox and row of color buttons for the one-color options, including
44  * connecting the callbacks for user interaction.
45  *
46  * @param base_id which group of checkboxes and buttons to affect
47  * @param shown the checkbox's ticked state (input and asynchronous output)
48  * @param initial which color to select (input only)
49  */
50  void setup_orb_group(const std::string& base_id, bool& shown, const std::string& initial);
51  /**
52  * Sets up two checkboxes and a row of color buttons.
53  */
54  void setup_orb_group_two_color(const std::string& base_id, bool& shown, bool& two_color, const std::string& initial);
55 
56  /**
57  * Change the UI's ticked/unticked state. Neither sets up nor triggers callbacks.
58  */
59  void reset_orb_toggle(const std::string& base_id, bool shown);
60  void reset_orb_group(const std::string& base_id, bool shown, const std::string& initial);
61  void reset_orb_group_two_color(const std::string& base_id, bool shown, bool two_color, const std::string& initial);
62 
63  void toggle_orb_callback(bool& storage);
64  void reset_orb_callback();
65 
70  bool show_ally_;
73 
74  std::map<std::string, group<std::string>> groups_;
75 
76  virtual const std::string& window_id() const override;
77 
78  virtual void pre_show(window& window) override;
79 
80  virtual void post_show(window& window) override;
81 };
82 
83 } // namespace dialogs
Abstract base class for all modal dialogs.
void setup_orb_toggle(const std::string &base_id, bool &shown)
The display function.
void reset_orb_group(const std::string &base_id, bool shown, const std::string &initial)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
void setup_orb_group(const std::string &base_id, bool &shown, const std::string &initial)
Sets up the checkbox and row of color buttons for the one-color options, including connecting the cal...
void setup_orb_group_two_color(const std::string &base_id, bool &shown, bool &two_color, const std::string &initial)
Sets up two checkboxes and a row of color buttons.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
void reset_orb_group_two_color(const std::string &base_id, bool shown, bool two_color, const std::string &initial)
std::map< std::string, group< std::string > > groups_
virtual const std::string & window_id() const override
The ID of the window to build.
void reset_orb_toggle(const std::string &base_id, bool shown)
Change the UI's ticked/unticked state.
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:61
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's mo...