16 #define GETTEXT_DOMAIN "wesnoth-lib" 31 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__ 32 #define LOG_HEADER LOG_SCOPE_HEADER + ':' 47 set_wants_mouse_left_double_click();
49 connect_signal<event::MOUSE_ENTER>(std::bind(
51 connect_signal<event::MOUSE_LEAVE>(std::bind(
54 connect_signal<event::LEFT_BUTTON_CLICK>(
57 std::placeholders::_2),
60 connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
62 connect_signal<event::LEFT_BUTTON_CLICK>(
65 std::placeholders::_2,
66 std::placeholders::_3),
68 connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(
71 std::placeholders::_2,
72 std::placeholders::_3));
73 connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(
76 std::placeholders::_2,
77 std::placeholders::_3),
91 for(
const auto &
item : data)
100 const bool must_be_active)
115 const bool must_be_active)
const 142 const auto conf = cast_config_to<toggle_panel_definition>();
146 result.x += conf->left_border;
147 result.y += conf->top_border;
148 result.w -= conf->left_border + conf->right_border;
149 result.h -= conf->top_border + conf->bottom_border;
156 const auto conf = cast_config_to<toggle_panel_definition>();
159 return point(conf->left_border + conf->right_border, conf->top_border + conf->bottom_border);
192 const auto conf = cast_config_to<toggle_panel_definition>();
289 load_resolutions<resolution>(cfg);
294 , top_border(cfg[
"top_border"])
295 , bottom_border(cfg[
"bottom_border"])
296 , left_border(cfg[
"left_border"])
297 , right_border(cfg[
"right_border"])
302 state.emplace_back(
c.child(
"enabled"));
303 state.emplace_back(
c.child(
"disabled"));
304 state.emplace_back(
c.child(
"focused"));
313 builder_toggle_panel::builder_toggle_panel(
const config& cfg)
316 , retval_id_(cfg[
"return_value_id"])
317 , retval_(cfg[
"return_value"])
323 grid = std::make_shared<builder_grid>(
c);
328 auto widget = std::make_unique<toggle_panel>(*this);
332 DBG_GUI_G <<
"Window builder: placed toggle panel '" <<
id 333 <<
"' with definition '" <<
definition <<
"'.";
Define the common log macros for the gui toolkit.
Base class of a resolution, contains the common keys for a resolution.
Class for a toggle button.
virtual unsigned get_state() const override
See styled_widget::get_state.
virtual void set_value(unsigned selected, bool fire_event=false) override
Inherited from selectable_item.
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void set_child_members(const widget_data &data)
Sets the members of the child controls.
std::vector< state_definition > state
unsigned state_num_
Usually 1 for selected and 0 for not selected, can also have higher values in tristate buttons...
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
ui_event
The event sent to the dispatcher.
virtual bool get_active() const override
See styled_widget::get_active.
A panel is a visible container to hold multiple widgets.
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
virtual point border_space() const override
See container_base::border_space.
child_itors child_range(config_key_type key)
int get_retval(const std::string &retval_id, const int retval, const std::string &id)
Returns the return value for a widget.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
static std::string _(const char *str)
toggle_panel_definition(const config &cfg)
bool fire_event(const ui_event event, const std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&... params)
Helper function for fire_event.
void signal_handler_pre_left_button_click(const event::ui_event event)
virtual void impl_draw_foreground() override
See widget::impl_draw_foreground.
void signal_handler_mouse_leave(const event::ui_event event, bool &handled)
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
This file contains the settings handling of the widget library.
void set_state(const state_t state)
void signal_handler_left_button_click(const event::ui_event event, bool &handled)
virtual unsigned num_states() const override
Inherited from selectable_item.
state_t state_
Current state of the widget.
int retval_
The return value of the button.
state_t
Possible states of the widget.
virtual void set_active(const bool active) override
See styled_widget::set_active.
void set_retval(const int retval)
Default, unset return value.
resolution(const config &cfg)
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
std::string sound_toggle_panel_click
virtual void impl_draw_background() override
See widget::impl_draw_background.
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
virtual std::unique_ptr< widget > build() const override
void play_UI_sound(const std::string &files)
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
void point(int x, int y)
Draw a single point.
std::map< std::string, widget_item > widget_data
retval
Default window/dialog return values.
void signal_handler_left_button_double_click(const event::ui_event event, bool &handled)
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
A config object defines a single node in a WML file, with access to child nodes.
virtual unsigned get_value() const override
Inherited from selectable_item.
virtual SDL_Rect get_client_rect() const override
See container_base::get_client_rect.
base class of top level items, the only item which needs to store the final canvases to draw on...
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::pair< std::string, unsigned > item
void signal_handler_mouse_enter(const event::ui_event event, bool &handled)