The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
edit_label.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Fabian Müller <[email protected]>
3  Part of the Battle for Wesnoth Project http://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/settings.hpp"
20 
21 #include <SDL_video.h>
22 #include "utils/functional.hpp"
23 
24 namespace gui2
25 {
26 
27 /*WIKI
28  * @page = GUIWindowDefinitionWML
29  * @order = 2_edit_label
30  *
31  * == Edit label ==
32  *
33  * Dialog for editing gamemap labels.
34  *
35  * @begin{table}{dialog_widgets}
36  *
37  * title & & label & m &
38  * Dialog title label. $
39  *
40  * label & & text_box & m &
41  * Input field for the map label. $
42  *
43  * team_only_toggle & & toggle_button & m &
44  * Checkbox for whether to make the label visible to the player's team
45  * only or not. $
46  *
47  * @end{table}
48  */
49 
50 REGISTER_DIALOG(editor_edit_label)
51 
53  bool& immutable,
54  bool& visible_fog,
55  bool& visible_shroud,
56  SDL_Color& color,
57  std::string& category)
58  : color_store(color)
59 {
60  // std::string text = label.text();
61  // bool immutable = label.immutable();
62 
63 
64  // std::string label = old_label ? old_label->text() : "";
65  // std::string team_name = old_label ? old_label->team_name() : "";
66  // bool visible_shroud = old_label ? old_label->visible_in_shroud() :
67  // false;
68  // bool visible_fog = old_label ? old_label->visible_in_fog() :
69  // true;
70  // bool immutable = old_label ? old_label->immutable() :
71  // true;
72 
73  register_text("label", true, text, true);
74  register_text("category", true, category, false);
75  register_bool("immutable_toggle", true, immutable);
76  register_bool("visible_fog_toggle", true, visible_fog);
77  register_bool("visible_shroud_toggle", true, visible_shroud);
78  register_color_component("slider_red", &SDL_Color::r);
79  register_color_component("slider_green", &SDL_Color::g);
80  register_color_component("slider_blue", &SDL_Color::b);
81 }
82 
83 void teditor_edit_label::register_color_component(std::string widget_id, Uint8 SDL_Color::* component) {
84  register_integer(widget_id, true,
85  std::bind(&teditor_edit_label::load_color_component, this, component),
86  std::bind(&teditor_edit_label::save_color_component, this, component, _1));
87 }
88 
89 int teditor_edit_label::load_color_component(Uint8 SDL_Color::* component) {
90  return color_store.*component;
91 }
92 
93 void teditor_edit_label::save_color_component(Uint8 SDL_Color::* component, const int value) {
94  color_store.*component = value;
95 }
96 }
void register_color_component(std::string widget_id, Uint8 SDL_Color::*component)
Definition: edit_label.cpp:83
REGISTER_DIALOG(label_settings)
STL namespace.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
GLdouble GLdouble GLdouble b
Definition: glew.h:6966
This file contains the settings handling of the widget library.
tfield_integer * register_integer(const std::string &id, const bool mandatory, const std::function< int()> &callback_load_value=std::function< int()>(), const std::function< void(const int)> &callback_save_value=std::function< void(const int)>())
Creates a new integer field.
Definition: dialog.cpp:104
GLsizei const GLfloat * value
Definition: glew.h:1817
void save_color_component(Uint8 SDL_Color::*component, const int value)
Definition: edit_label.cpp:93
GLuint color
Definition: glew.h:5801
GLdouble GLdouble GLdouble r
Definition: glew.h:1374
#define g
Definition: glew.h:12730
int load_color_component(Uint8 SDL_Color::*component)
Definition: edit_label.cpp:89
GLsizei const GLcharARB ** string
Definition: glew.h:4503