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.

85 lines
2.1KB

  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_KNOB_HPP__
  17. #define __DGL_IMAGE_KNOB_HPP__
  18. #include "Image.hpp"
  19. #include "Widget.hpp"
  20. START_NAMESPACE_DGL
  21. // -------------------------------------------------
  22. class ImageKnob : public Widget
  23. {
  24. public:
  25. enum Orientation {
  26. Horizontal,
  27. Vertical
  28. };
  29. class Callback
  30. {
  31. public:
  32. virtual ~Callback() {}
  33. virtual void imageKnobDragStarted(ImageKnob* imageKnob) = 0;
  34. virtual void imageKnobDragFinished(ImageKnob* imageKnob) = 0;
  35. virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0;
  36. };
  37. ImageKnob(Window* parent, const Image& image, Orientation orientation = Vertical);
  38. ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical);
  39. ImageKnob(const ImageKnob& imageKnob);
  40. float getValue() const;
  41. void setOrientation(Orientation orientation);
  42. void setRange(float min, float max);
  43. void setValue(float value, bool sendCallback = false);
  44. void setCallback(Callback* callback);
  45. protected:
  46. void onDisplay() override;
  47. bool onMouse(int button, bool press, int x, int y) override;
  48. bool onMotion(int x, int y) override;
  49. private:
  50. Image fImage;
  51. float fMinimum;
  52. float fMaximum;
  53. float fValue;
  54. Orientation fOrientation;
  55. bool fDragging;
  56. int fLastX;
  57. int fLastY;
  58. Callback* fCallback;
  59. bool fIsImgVertical;
  60. int fImgLayerSize;
  61. int fImgLayerCount;
  62. Rectangle<int> fKnobArea;
  63. };
  64. // -------------------------------------------------
  65. END_NAMESPACE_DGL
  66. #endif // __DGL_IMAGE_KNOB_HPP__