15 #define GETTEXT_DOMAIN "wesnoth-lib"
19 #include "widgets/slider.hpp"
28 #include <boost/math/special_functions/sign.hpp>
42 pressedImage_(image::
get_image(image + pressed_image)),
43 activeImage_(image::
get_image(image + active_image)),
44 disabledImage_(image::
get_image(image + disabled_image)),
46 min_(-100000), max_(100000), value_(0),
47 increment_(1), value_change_(false), state_(
NORMAL)
133 static const SDL_Rect default_value = {0,0,0,0};
136 return default_value;
158 assert(image !=
nullptr);
167 if (image->w >= loc.w)
178 line_color.r, line_color.g, line_color.b));
187 int tmp = x - loc.x -
image_->w / 2;
190 if (tmp > loc.w -
image_->w)
222 if (event.button != SDL_BUTTON_LEFT)
243 SDL_GetMouseState(&x, &y);
248 if (event.y > 0 || event.x > 0) {
258 if (event.y < 0 || event.x < 0) {
275 if(event ==
nullptr) {
280 if(event->type == SDL_KEYDOWN) {
281 SDLKey key =
event->key.keysym.sym;
304 case SDL_MOUSEBUTTONUP:
310 case SDL_MOUSEBUTTONDOWN:
314 case SDL_MOUSEMOTION:
320 const SDL_keysym& key =
reinterpret_cast<const SDL_KeyboardEvent&
>(
event).keysym;
321 const int c = key.sym;
325 }
else if(c == SDLK_RIGHT) {
338 if (start_state !=
state_)
374 for(
unsigned i = 0, nb =
items_.size();
i < nb; ++
i)
391 set_max(items.size() - 1);
408 :
slider(video, image, black)
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
void fill_rect(surface &dst, SDL_Rect *dst_rect, const Uint32 color)
Fill a rectangle on a given surface.
void mouse_down(const SDL_MouseButtonEvent &event)
const SDL_Color BLACK_COLOR
void set_value(int value)
slider(CVideo &video, const std::string &image="buttons/sliders/slider", bool black=false)
surface image_
The image is cached in this surface.
const std::string slider_adjust
GLenum GLsizei GLenum GLenum const GLvoid * image
void set_increment(int increment)
GLint GLint GLint GLint GLint GLint y
const std::vector< std::string > items
void blit_surface(int x, int y, surface surf, SDL_Rect *srcrect=nullptr, SDL_Rect *clip_rect=nullptr)
bool requires_event_focus(const SDL_Event *event=nullptr) const
const SDL_Color NORMAL_COLOR
void set_location(int x, int y)
const SDL_Color DISABLED_COLOR
virtual bool allow_key_events()
const std::string sign
sign "-" - hyphen-minus used to set sign of signed integer
void mouse_wheel(const SDL_MouseWheelEvent &event)
GLsizei const GLfloat * value
list_slider(CVideo &video)
void set_items(const std::vector< T > &items)
virtual void enable(bool new_val=true)
bool select_item(const T &item)
virtual void handle_event(const SDL_Event &event)
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
Encapsulates the map of the game.
zoom_slider(CVideo &video, const std::string &image="buttons/sliders/slider", bool black=false)
const T & item_selected() const
void mouse_motion(const SDL_MouseMotionEvent &event)
virtual void draw_contents()
GLint GLint GLint GLint GLint x
GLdouble GLdouble GLdouble r
const std::string button_press
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
Contains the SDL_Rect helper code.
this module manages the cache of images.
void play_UI_sound(const std::string &files)
void assign(const surface &o)
void set_slider_position(int x)
GLsizei const GLcharARB ** string
SDL_Rect slider_area() const