slider.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * This file is part of Soft Mood (https://notabug.org/alkeon/soft-mood).
  3. * Copyright (c) 2019 Alejandro "alkeon" Castilla
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, version 3.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __SDL_SLIDER__
  18. #define __SDL_SLIDER__
  19. #include <iostream>
  20. #include "SDL_mixer.h"
  21. #include "SDL_image.h"
  22. #include "SDL.h"
  23. #include <thread>
  24. #include <chrono>
  25. using namespace std;
  26. #define SLIDER_WIDTH 32
  27. #define SLIDER_HEIGHT 46
  28. class slider{
  29. string _image_file;
  30. bool _has_image;
  31. SDL_Renderer * _src;
  32. SDL_Rect _fillbar_dst;
  33. SDL_Rect _button_dst;
  34. SDL_Rect _button_bounds_dst;
  35. bool _mouse_follow = false;
  36. int _value;
  37. int _pos_x;
  38. int _pos_y;
  39. public:
  40. slider(SDL_Renderer * src, int pos_x, int pos_y);
  41. void set_image(const string& file);
  42. void test_mouse_follow(SDL_Point* mouse, SDL_Point* mouse_offset);
  43. void mouse_follow_off(){ _mouse_follow = false; }
  44. SDL_Rect get_button_dst() { return _button_dst; }
  45. int get_value() { return _value; }
  46. void draw_image();
  47. void draw();
  48. void update(int pos_y);
  49. };
  50. #endif