Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ImageSlider.hpp 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * DISTRHO Plugin Toolkit (DPT)
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * For a full copy of the license see the LGPL.txt file
  15. */
  16. #ifndef __DGL_IMAGE_SLIDER_HPP__
  17. #define __DGL_IMAGE_SLIDER_HPP__
  18. #include "Image.hpp"
  19. #include "Widget.hpp"
  20. START_NAMESPACE_DGL
  21. // -------------------------------------------------
  22. class ImageSlider : public Widget
  23. {
  24. public:
  25. class Callback
  26. {
  27. public:
  28. virtual ~Callback() {}
  29. virtual void imageSliderDragStarted(ImageSlider* imageSlider) = 0;
  30. virtual void imageSliderDragFinished(ImageSlider* imageSlider) = 0;
  31. virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0;
  32. };
  33. ImageSlider(Window* parent, const Image& image);
  34. ImageSlider(const ImageSlider& imageSlider);
  35. float getValue() const;
  36. void setStartPos(const Point<int>& startPos);
  37. void setEndPos(const Point<int>& endPos);
  38. void setRange(float min, float max);
  39. void setValue(float value, bool sendCallback = false);
  40. void setCallback(Callback* callback);
  41. protected:
  42. void onDisplay();
  43. bool onMouse(int button, bool press, int x, int y);
  44. bool onMotion(int x, int y);
  45. private:
  46. Image fImage;
  47. float fMinimum;
  48. float fMaximum;
  49. float fValue;
  50. bool fDragging;
  51. int fStartedX;
  52. int fStartedY;
  53. Callback* fCallback;
  54. Point<int> fStartPos;
  55. Point<int> fEndPos;
  56. Rectangle<int> fSliderArea;
  57. void _recheckArea();
  58. };
  59. // -------------------------------------------------
  60. END_NAMESPACE_DGL
  61. #endif // __DGL_IMAGE_SLIDER_HPP__