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.

ImageKnob.hpp 2.7KB

11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DGL_IMAGE_KNOB_HPP_INCLUDED
  17. #define DGL_IMAGE_KNOB_HPP_INCLUDED
  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 setStep(float step);
  44. void setValue(float value, bool sendCallback = false);
  45. void setRotationAngle(int angle);
  46. void setCallback(Callback* callback);
  47. protected:
  48. void onDisplay() override;
  49. bool onMouse(int button, bool press, int x, int y) override;
  50. bool onMotion(int x, int y) override;
  51. void onReshape(int width, int height) override;
  52. void onClose() override;
  53. private:
  54. Image fImage;
  55. float fMinimum;
  56. float fMaximum;
  57. float fStep;
  58. float fValue;
  59. float fValueTmp;
  60. Orientation fOrientation;
  61. int fRotationAngle;
  62. bool fDragging;
  63. int fLastX;
  64. int fLastY;
  65. Callback* fCallback;
  66. bool fIsImgVertical;
  67. int fImgLayerSize;
  68. int fImgLayerCount;
  69. Rectangle<int> fKnobArea;
  70. GLuint fTextureId;
  71. };
  72. // -----------------------------------------------------------------------
  73. END_NAMESPACE_DGL
  74. #endif // DGL_IMAGE_KNOB_HPP_INCLUDED