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.

97 lines
2.3KB

  1. /*
  2. * Pixmap Dial, a custom Qt4 widget
  3. * Copyright (C) 2011-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 General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the GPL.txt file
  16. */
  17. #ifndef __PIXMAPDIAL_HPP__
  18. #define __PIXMAPDIAL_HPP__
  19. #include "CarlaDefines.hpp"
  20. #include <QtGui/QPixmap>
  21. #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
  22. # include <QtWidgets/QDial>
  23. #else
  24. # include <QtGui/QDial>
  25. #endif
  26. class PixmapDial : public QDial
  27. {
  28. public:
  29. enum CustomPaint {
  30. CUSTOM_PAINT_NULL = 0,
  31. CUSTOM_PAINT_CARLA_WET = 1,
  32. CUSTOM_PAINT_CARLA_VOL = 2,
  33. CUSTOM_PAINT_CARLA_L = 3,
  34. CUSTOM_PAINT_CARLA_R = 4
  35. };
  36. PixmapDial(QWidget* parent);
  37. int getSize() const;
  38. void setCustomPaint(CustomPaint paint);
  39. void setEnabled(bool enabled);
  40. void setLabel(QString label);
  41. void setPixmap(int pixmapId);
  42. QSize minimumSizeHint() const;
  43. QSize sizeHint() const;
  44. protected:
  45. void updateSizes();
  46. void enterEvent(QEvent* event);
  47. void leaveEvent(QEvent* event);
  48. void paintEvent(QPaintEvent* event);
  49. void resizeEvent(QResizeEvent* event);
  50. private:
  51. enum Orientation {
  52. HORIZONTAL = 0,
  53. VERTICAL = 1
  54. };
  55. static const unsigned short HOVER_MIN = 0;
  56. static const unsigned short HOVER_MAX = 9;
  57. // -------------------------------------
  58. QPixmap m_pixmap;
  59. QString m_pixmap_n_str;
  60. CustomPaint m_custom_paint;
  61. Orientation m_orientation;
  62. bool m_hovered;
  63. unsigned short m_hover_step;
  64. QString m_label;
  65. QPointF m_label_pos;
  66. int m_label_width;
  67. int m_label_height;
  68. QLinearGradient m_label_gradient;
  69. QRectF m_label_gradient_rect;
  70. QColor m_color1;
  71. QColor m_color2;
  72. QColor m_colorT[2];
  73. int p_width, p_height, p_size, p_count;
  74. };
  75. #endif // __PIXMAPDIAL_HPP__