16 #define GETTEXT_DOMAIN "wesnoth-lib"
26 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
27 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
48 , drag_initial_mouse_(0, 0)
49 , drag_initial_offset_(0)
50 , positioner_offset_(0)
51 , positioner_length_(0)
54 connect_signal<event::MOUSE_ENTER>(
56 connect_signal<event::MOUSE_MOTION>(
58 connect_signal<event::MOUSE_LEAVE>(
60 connect_signal<event::LEFT_BUTTON_DOWN>(
62 connect_signal<event::LEFT_BUTTON_UP>(
180 new_offset = std::clamp(new_offset, 0,
max_offset);
286 const int bar =
on_bar(mouse);
290 }
else if(bar == 1) {
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
int item_position_
The item the positioner is at, starts at 0.
point drag_initial_mouse_
The position the mouse was when draggin the slider was started.
void set_state(const state_t state)
virtual unsigned offset_after() const =0
The number of pixels we can't use since they're used for borders.
void signal_handler_mouse_enter(const event::ui_event event, bool &handled, bool &halt)
state_t
Possible states of the widget.
void recalculate_positioner()
virtual int get_length_difference(const point &original, const point ¤t) const =0
Gets the relevant difference in between the two positions.
int drag_initial_offset_
The offset in pixels the slider was when dragging the positioner was started.
virtual void update_canvas() override
See styled_widget::update_canvas.
void signal_handler_left_button_up(const event::ui_event event, bool &handled)
virtual void set_active(const bool active) override
See styled_widget::set_active.
int positioner_offset_
The start offset of the positioner.
void recalculate()
Updates the slider.
virtual bool on_positioner(const point &coordinate) const =0
Is the coordinate on the positioner?
bool snap_
Whether the slider should 'snap' into its supported values or not.
void signal_handler_mouse_motion(const event::ui_event event, bool &handled, bool &halt, const point &coordinate)
scroll_mode
scroll 'step size'.
@ ITEM_FORWARD
Go one item towards the end.
@ HALF_JUMP_BACKWARDS
Go half the visible items towards the begin.
@ ITEM_BACKWARDS
Go one item towards the begin.
@ JUMP_BACKWARDS
Go the visible items towards the begin.
@ JUMP_FORWARD
Go the visible items towards the end.
@ BEGIN
Go to begin position.
@ HALF_JUMP_FORWARD
Go half the visible items towards the end.
@ END
Go to the end position.
virtual unsigned get_state() const override
See styled_widget::get_state.
slider_base(const implementation::builder_styled_widget &builder, const std::string &control_type)
int item_last_
one less than the number items the slider 'holds'.
void move_positioner(int offset)
Moves the positioner.
virtual bool get_active() const override
See styled_widget::get_active.
void signal_handler_mouse_leave(const event::ui_event event, bool &handled)
state_t state_
Current state of the widget.
virtual unsigned offset_before() const =0
The number of pixels we can't use since they're used for borders.
void signal_handler_left_button_down(const event::ui_event event, bool &handled)
int positioner_length_
The current length of the positioner.
virtual void child_callback_positioner_moved()
Callback for subclasses to get notified about positioner movement.
void update_slider_position(slider_position_t &pos)
void set_slider_position(int item_position)
Note the position isn't guaranteed to be the wanted position the step size is honored.
void scroll(const scroll_mode scroll)
Sets the item position.
int available_length() const
virtual unsigned get_length() const =0
Get the length of the slider.
virtual int on_bar(const point &coordinate) const =0
Is the coordinate on the bar?
virtual int jump_size() const
virtual void place(const point &origin, const point &size) override
See widget::place.
void mouse_capture(const bool capture=true)
Define the common log macros for the gui toolkit.
General math utility functions.
int rounded_division(int a, int b)
ui_event
The event sent to the dispatcher.
point get_mouse_position()
Returns the current mouse position.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
Helper container for the slider's current position.