15 #define GETTEXT_DOMAIN "wesnoth-lib"
30 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
31 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
42 , best_slider_length_(0)
44 , minimum_value_label_()
45 , maximum_value_label_()
48 connect_signal<event::SDL_KEY_DOWN>(std::bind(
50 connect_signal<event::LEFT_BUTTON_UP>(
73 <<
" result " << result <<
".\n";
131 if(value > maximum_value) {
164 return conf->minimum_positioner_length;
173 return conf->maximum_positioner_length;
182 return conf->left_offset;
191 return conf->right_offset;
200 && coordinate.
y > 0 && coordinate.
y < static_cast<int>(
get_height());
205 const unsigned x =
static_cast<size_t>(coordinate.
x);
206 const unsigned y =
static_cast<size_t>(coordinate.
y);
234 for(
auto & tmp :
canvas())
271 if(key == SDLK_DOWN || key == SDLK_LEFT) {
273 }
else if(key == SDLK_UP || key == SDLK_RIGHT) {
292 assert(
int(value_labels.size()) == max);
293 assert(item_position < max && item_position >= 0);
294 return value_labels[item_position];
308 DBG_GUI_P <<
"Parsing slider " <<
id <<
'\n';
310 load_resolutions<tresolution>(cfg);
362 , minimum_positioner_length(cfg[
"minimum_positioner_length"])
363 , maximum_positioner_length(cfg[
"maximum_positioner_length"])
364 , left_offset(cfg[
"left_offset"])
365 , right_offset(cfg[
"right_offset"])
369 "minimum_positioner_length"));
434 tbuilder_slider::tbuilder_slider(
const config& cfg)
436 , best_slider_length_(cfg[
"best_slider_length"])
437 , minimum_value_(cfg[
"minimum_value"])
438 , maximum_value_(cfg[
"maximum_value"])
439 , step_size_(cfg[
"step_size"])
440 , value_(cfg[
"value"])
441 , minimum_value_label_(cfg[
"minimum_value_label"].t_str())
442 , maximum_value_label_(cfg[
"maximum_value_label"].t_str())
470 _(
"The number of value_labels and values don't match."));
479 DBG_GUI_G <<
"Window builder: placed slider '" <<
id
480 <<
"' with definition '" <<
definition <<
"'.\n";
Define the common log macros for the gui toolkit.
int on_bar(const tpoint &coordinate) const
Inherited from tscrollbar.
void handle_key_increase(bool &handled)
unsigned best_slider_length_
child_itors child_range(const std::string &key)
t_string maximum_value_label_
When the slider shows the maximum value can show a special text.
void set_best_slider_length(const unsigned length)
int minimum_value_
The minimum value the slider holds.
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
GLuint GLuint GLsizei GLenum type
tresolution_definition_ptr config()
int get_maximum_value() const
Inherited from tinteger_selector_.
void child_callback_positioner_moved()
Inherited from tscrollbar.
void set_minimum_value(const int minimum_value)
Inherited from tinteger_selector_.
lg::log_domain log_gui_layout("gui/layout")
virtual void update_canvas() override
See tcontrol::update_canvas.
void signal_handler_left_button_up(const event::tevent event, bool &handled)
void set_maximum_value(const int maximum_value)
Inherited from tinteger_selector_.
bool on_positioner(const tpoint &coordinate) const
Inherited from tscrollbar.
GLint GLint GLint GLint GLint GLint y
void set_value(const int value)
Inherited from tinteger_selector_.
t_string get_value_label() const
Returns the label shown for the current value.
std::string sound_slider_adjust
Base class of a resolution, contains the common keys for a resolution.
tlabel_creator value_labels_
This allows the slider to show custom texts instead of the values.
std::string missing_mandatory_wml_key(const std::string §ion, const std::string &key, const std::string &primary_key, const std::string &primary_value)
Returns a standard message for a missing wml key.
void set_value_labels(const std::vector< t_string > &value_labels)
A class inherited from ttext_box that displays its input as stars.
void init_control(tcontrol *control) const
std::string definition
Parameters for the control.
void handle_key_decrease(bool &handled)
Handlers for keyboard input.
unsigned minimum_positioner_length() const
Inherited from tscrollbar.
unsigned offset_after() const
Inherited from tscrollbar.
static UNUSEDNOWARN std::string _(const char *str)
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
int get_value() const
Inherited from tinteger_selector_.
GLsizei const GLfloat * value
unsigned offset_before() const
Inherited from tscrollbar.
static t_string default_value_label_generator(const std::vector< t_string > &value_labels, int item_position, int max)
unsigned minimum_positioner_length
#define log_scope2(domain, description)
tevent
The event send to the dispatcher.
std::vector< t_string > value_labels_
Contains the state info for a resolution.
unsigned best_slider_length_
The best size for the slider part itself, if 0 ignored.
tslider_definition(const config &cfg)
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
unsigned maximum_positioner_length() const
Inherited from tscrollbar.
t_string minimum_value_label_
When the slider shows the minimum value can show a special text.
void signal_handler_sdl_key_down(const event::tevent event, bool &handled, const SDLKey key)
Signal handlers:
GLint GLint GLint GLint GLint x
std::vector< tcanvas > & canvas()
t_string maximum_value_label_
int get_minimum_value() const
Inherited from tinteger_selector_.
std::vector< tstate_definition > state
virtual tpoint calculate_best_size() const override
See twidget::calculate_best_size.
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void play_UI_sound(const std::string &files)
t_string minimum_value_label_
void keyboard_capture(twidget *widget)
A config object defines a single node in a WML file, with access to child nodes.
bool in_orthogonal_range(const tpoint &coordinate) const
Inherited from tscrollbar.
GLsizei const GLcharARB ** string
void set_maximum_value_label(const t_string &maximum_value_label)
Contains the implementation details for lexical_cast and shouldn't be used directly.
void set_minimum_value_label(const t_string &minimum_value_label)
virtual tpoint calculate_best_size() const override
See twidget::calculate_best_size.
tresolution(const config &cfg)