The Battle for Wesnoth  1.19.2+dev
preferences_dialog.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2024
3  by Charles Dang <exodia339gmail.com>
4  Copyright (C) 2011, 2015 by Iris Morelle <shadowm2006@gmail.com>
5  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY.
13 
14  See the COPYING file for more details.
15 */
16 #pragma once
17 
19 #include "gui/widgets/group.hpp"
22 #include "theme.hpp"
23 
24 // This file is not named preferences.hpp in order -I conflicts with src/preferences.hpp.
25 
26 namespace {
27  /**
28  * Map containing page mappings that can be used to set the initially displayed page
29  * of the dialog. The pair is in an 0-indexed toplevel stack/substack format, where
30  * the first is the list of main Preference categories (such as General and Display)
31  * and the second is any sub-stack found on that page.
32  *
33  * TODO: this isn't the most optimal solution, since if the order or number of pages
34  * in either stack changes, this map needs to be updated. Optimally the stacked_widget
35  * widget would allow specifying page by string id, but that would require changes to
36  * generator. It's something to look into, however.
37  */
38  static std::map<pref_constants::PREFERENCE_VIEW, std::pair<int,int>> pef_view_map {
41  };
42 }
43 
44 namespace gui2
45 {
46 
47 class listbox;
48 class menu_button;
49 class text_box;
50 
51 namespace dialogs
52 {
53 
55 {
56 public:
58 
59  /** The display function -- see @ref modal_dialog for more information. */
61 
62 private:
63  virtual const std::string& window_id() const override;
64 
65  virtual void pre_show(window& window) override;
66  virtual void post_show(window& /*window*/) override;
67 
68  /** Initializers */
69  void initialize_callbacks();
70  void initialize_tabs(listbox& selector);
71  void set_resolution_list(menu_button& res_list);
75 
76  template<bool(*toggle_getter)(), bool(*toggle_setter)(bool), int(*vol_getter)(), void(*vol_setter)(int)>
77  void initialize_sound_option_group(const std::string& id_suffix);
78 
79  void apply_pixel_scale();
80 
82 
83  void add_friend_list_entry(const bool is_friend, text_box& textbox);
84  void remove_friend_list_entry(listbox& friends_list, text_box& textbox);
85 
86  void on_friends_list_select(listbox& list, text_box& textbox);
88 
89  void set_visible_page(unsigned int page, const std::string& pager_id);
90 
91  /** Callback for selection changes */
92  void on_page_select();
93  void on_tab_select();
95 
96  /** Special callback functions */
97  void handle_res_select();
98  void handle_theme_select();
101  void add_hotkey_callback(listbox& hotkeys);
102  void remove_hotkey_callback(listbox& hotkeys);
104  void hotkey_filter_callback();
105 
107 
108  std::vector<point> resolutions_;
109  std::vector<theme_info> themes_;
110  std::vector<std::string> gui2_themes_;
111 
113 
114  std::vector<double> accl_speeds_;
115 
116  std::vector<const hotkey::hotkey_command*> visible_hotkeys_;
117 
118  std::set<hotkey::HOTKEY_CATEGORY> visible_categories_;
119 
120  // The page/tab index pairs for setting visible pages
121  const std::pair<int, int>& initial_index_;
122 };
123 
124 } // namespace dialogs
125 } // namespace gui2
Abstract base class for all modal dialogs.
void set_visible_page(unsigned int page, const std::string &pager_id)
void set_theme_list(menu_button &theme_list)
void remove_hotkey_callback(listbox &hotkeys)
const std::pair< int, int > & initial_index_
virtual void post_show(window &) override
Actions to be taken after the window has been shown.
void set_resolution_list(menu_button &res_list)
void on_advanced_prefs_list_select(listbox &tree)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
preferences_dialog(const pref_constants::PREFERENCE_VIEW initial_view=pref_constants::VIEW_DEFAULT)
void on_page_select()
Callback for selection changes.
void on_friends_list_select(listbox &list, text_box &textbox)
void add_friend_list_entry(const bool is_friend, text_box &textbox)
std::vector< const hotkey::hotkey_command * > visible_hotkeys_
virtual const std::string & window_id() const override
The display function – see modal_dialog for more information.
widget_data get_friends_list_row_data(const preferences::acquaintance &entry)
std::set< hotkey::HOTKEY_CATEGORY > visible_categories_
void update_friends_list_controls(listbox &list)
void handle_res_select()
Special callback functions.
std::vector< std::string > gui2_themes_
void remove_friend_list_entry(listbox &friends_list, text_box &textbox)
void initialize_sound_option_group(const std::string &id_suffix)
void add_hotkey_callback(listbox &hotkeys)
group< pref_constants::lobby_joins > lobby_joins_group
void set_gui2_theme_list(menu_button &theme_list)
The listbox class.
Definition: listbox.hpp:43
A widget that allows the user to input text in single line.
Definition: text_box.hpp:125
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...
Various uncategorised dialogs.
Generic file dialog.
std::map< std::string, widget_item > widget_data
Definition: widget.hpp:34
Definitions related to theme-support.