The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
edit_label.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2010 - 2025
3 by Fabian Müller <fabianmueller5@gmx.de>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16#define GETTEXT_DOMAIN "wesnoth-lib"
17
19
22
23#include <functional>
24
25namespace gui2::dialogs
26{
27
28REGISTER_DIALOG(editor_edit_label)
29
31 bool& immutable,
32 bool& visible_fog,
33 bool& visible_shroud,
34 color_t& color,
35 std::string& category)
36 : modal_dialog(window_id())
37 , color_store(color)
38{
39 register_text("label", true, text, true);
40 register_text("category", true, category, false);
41 register_bool("immutable_toggle", true, immutable);
42 register_bool("visible_fog_toggle", true, visible_fog);
43 register_bool("visible_shroud_toggle", true, visible_shroud);
44 register_color_component("slider_red", &color_t::r);
45 register_color_component("slider_green", &color_t::g);
46 register_color_component("slider_blue", &color_t::b);
47}
48
50{
51 add_to_tab_order(find_widget<text_box>("label", false, true));
52 add_to_tab_order(find_widget<text_box>("category", false, true));
53}
54
55void editor_edit_label::register_color_component(const std::string& widget_id, uint8_t color_t::* component) {
56 register_integer(widget_id, true,
57 std::bind(&editor_edit_label::load_color_component, this, component),
58 std::bind(&editor_edit_label::save_color_component, this, component, std::placeholders::_1));
59}
60
62 return color_store.*component;
63}
64
65void editor_edit_label::save_color_component(uint8_t color_t::* component, const int value) {
66 color_store.*component = value;
67}
68} // namespace dialogs
virtual void pre_show() override
Actions to be taken before showing the window.
int load_color_component(uint8_t color_t::*component)
color_t & color_store
The execute function.
void register_color_component(const std::string &widget_id, uint8_t color_t::*component)
void save_color_component(uint8_t color_t::*component, const int value)
Abstract base class for all modal dialogs.
field_integer * register_integer(const std::string &id, const bool mandatory, const std::function< int()> &callback_load_value=nullptr, const std::function< void(int)> &callback_save_value=nullptr)
Creates a new integer field.
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
Definition window.cpp:1223
This file contains the window object, this object is a top level container which has the event manage...
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
STL namespace.
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
Definition sound.cpp:139
The basic class for representing 8-bit RGB or RGBA colour values.
Definition color.hpp:51