16 #define GETTEXT_DOMAIN "wesnoth-lib"
40 , icon(cfg["icon"].str())
47 if(cfg.has_attribute(
"checkbox")) {
48 checkbox = cfg[
"checkbox"].to_bool(
false);
51 if(cfg.has_attribute(
"radio")) {
52 radio = cfg[
"radio"].to_bool(
false);
56 if(cfg.has_attribute(
"image")) {
57 image = cfg[
"image"].str();
60 if(cfg.has_attribute(
"details")) {
61 details = cfg[
"details"].t_str();
77 checkbox->set_value_bool(!checkbox->get_value_bool(),
true);
90 , items_(items.begin(), items.end())
92 , button_pos_(parent->get_rectangle())
93 , selected_item_(selected_item)
94 , selected_item_pos_(-1, -1)
95 , use_markup_(parent->get_use_markup())
96 , keep_open_(keep_open)
97 , mouse_down_happened_(false)
104 , items_(items.begin(), items.end())
106 , button_pos_(button_pos)
107 , selected_item_(selected_item)
108 , use_markup_(use_markup)
109 , keep_open_(keep_open)
110 , mouse_down_happened_(false)
120 listbox& list = find_widget<listbox>(
"list",
true);
171 listbox& list = find_widget<listbox>(
"list",
true);
173 for(
const auto& entry :
items_) {
181 if(!entry.checkbox) {
182 item[
"label"] = entry.icon;
183 data.emplace(
"icon", item);
187 item[
"label"] = entry.label;
188 data.emplace(
"label", item);
192 item[
"label"] = *entry.details;
193 data.emplace(
"details", item);
203 auto checkbox = build_single_widget_instance<toggle_button>(
config{
"definition",
"no_label"});
204 checkbox->set_id(
"checkbox");
205 checkbox->set_value_bool(*entry.checkbox);
206 checkbox->set_linked_group(
"icons");
219 checkbox->set_active(
false);
225 if(theme_transition_toggle_callback_) {
226 theme_transition_toggle_callback_(index);
232 mi_grid.
swap_child(
"icon", std::move(checkbox),
false);
241 auto radio = build_single_widget_instance<toggle_button>(
config{
"definition",
"radio_no_label"});
242 radio->set_id(
"checkbox");
243 radio->set_value_bool(*entry.radio);
244 radio->set_linked_group(
"icons");
249 radio->set_active(
false);
256 mi_grid.swap_child(
"icon", std::move(radio),
false);
260 auto img = build_single_widget_instance<image>();
261 img->set_label(*entry.image);
263 mi_grid.swap_child(
"label", std::move(
img),
false);
268 radio_manager_->on_modified([
this](
widget&,
int index) {
276 else if(legacy_menu_mode_ && keep_open_ && theme_transition_toggle_callback_) {
277 theme_transition_toggle_callback_(
index);
282 if(selected_item_ >= 0 &&
static_cast<unsigned>(selected_item_) < list.
get_item_count()) {
286 keyboard_capture(&list);
289 connect_signal<event::SDL_LEFT_BUTTON_UP>(
292 connect_signal<event::SDL_RIGHT_BUTTON_UP>(
295 connect_signal<event::SDL_LEFT_BUTTON_DOWN>(
299 connect_signal<event::SDL_VIDEO_RESIZE>(
304 [
this](
auto&&...) { callback_flip_embedded_toggle(*
this); });
309 const listbox& list = find_widget<listbox>(
"list",
true);
324 const listbox& list = find_widget<const listbox>(
"list",
true);
325 boost::dynamic_bitset<> states;
331 states.push_back(checkbox->get_value_bool());
333 states.push_back(
false);
A config object defines a single node in a WML file, with access to child nodes.
Abstract base class for all modal dialogs.
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
std::unique_ptr< widget > swap_child(const std::string &id, std::unique_ptr< widget > w, const bool recurse, widget *new_parent=nullptr)
Exchanges a child in the grid.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
const grid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
bool select_row(const unsigned row, const bool select=true)
Selects a row.
int get_selected_row() const
Returns the first selected row.
unsigned get_item_count() const
Returns the number of items in the listbox.
base class of top level items, the only item which needs to store the final canvases to draw on.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
void set_variable(const std::string &key, const wfl::variant &value)
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
@ OK
Dialog was closed with the OK button.
@ CANCEL
Dialog was closed with the CANCEL button.
Functions to load and save images from/to disk.
std::string img(const std::string &src, const std::string &align, bool floating)
Generates a Help markup tag corresponding to an image.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::string bool_string(const bool value)
Converts a bool value to 'true' or 'false'.
Contains the SDL_Rect helper code.
An abstract description of a rectangle with integer coordinates.