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.

pixmapdial.hpp 2.2KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 <QtGui/QPixmap>
  20. #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
  21. # include <QtWidgets/QDial>
  22. #else
  23. # include <QtGui/QDial>
  24. #endif
  25. class PixmapDial : public QDial
  26. {
  27. public:
  28. enum CustomPaint {
  29. CUSTOM_PAINT_NULL = 0,
  30. CUSTOM_PAINT_CARLA_WET = 1,
  31. CUSTOM_PAINT_CARLA_VOL = 2,
  32. CUSTOM_PAINT_CARLA_L = 3,
  33. CUSTOM_PAINT_CARLA_R = 4
  34. };
  35. PixmapDial(QWidget* parent);
  36. int getSize() const;
  37. void setCustomPaint(CustomPaint paint);
  38. void setEnabled(bool enabled);
  39. void setLabel(QString label);
  40. void setPixmap(int pixmapId);
  41. QSize minimumSizeHint() const;
  42. QSize sizeHint() const;
  43. protected:
  44. void updateSizes();
  45. void enterEvent(QEvent* event);
  46. void leaveEvent(QEvent* event);
  47. void paintEvent(QPaintEvent* event);
  48. void resizeEvent(QResizeEvent* event);
  49. private:
  50. enum Orientation {
  51. HORIZONTAL = 0,
  52. VERTICAL = 1
  53. };
  54. static const unsigned short HOVER_MIN = 0;
  55. static const unsigned short HOVER_MAX = 9;
  56. // -------------------------------------
  57. QPixmap m_pixmap;
  58. QString m_pixmap_n_str;
  59. CustomPaint m_custom_paint;
  60. Orientation m_orientation;
  61. bool m_hovered;
  62. unsigned short m_hover_step;
  63. QString m_label;
  64. QPointF m_label_pos;
  65. int m_label_width;
  66. int m_label_height;
  67. QLinearGradient m_label_gradient;
  68. QRectF m_label_gradient_rect;
  69. QColor m_color1;
  70. QColor m_color2;
  71. QColor m_colorT[2];
  72. int p_width, p_height, p_size, p_count;
  73. };
  74. #endif // __PIXMAPDIAL_HPP__