Collection of tools useful for audio production
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.

91 lines
2.2KB

  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 COPYING file
  16. */
  17. #ifndef __PIXMAPDIAL_HPP__
  18. #define __PIXMAPDIAL_HPP__
  19. #include <QtGui/QPixmap>
  20. #include <QtWidgets/QDial>
  21. class PixmapDial : public QDial
  22. {
  23. public:
  24. enum CustomPaint {
  25. CUSTOM_PAINT_NULL = 0,
  26. CUSTOM_PAINT_CARLA_WET = 1,
  27. CUSTOM_PAINT_CARLA_VOL = 2,
  28. CUSTOM_PAINT_CARLA_L = 3,
  29. CUSTOM_PAINT_CARLA_R = 4
  30. };
  31. PixmapDial(QWidget* parent);
  32. int getSize() const;
  33. void setCustomPaint(CustomPaint paint);
  34. void setEnabled(bool enabled);
  35. void setLabel(QString label);
  36. void setPixmap(int pixmapId);
  37. QSize minimumSizeHint() const;
  38. QSize sizeHint() const;
  39. protected:
  40. void updateSizes();
  41. void enterEvent(QEvent* event);
  42. void leaveEvent(QEvent* event);
  43. void paintEvent(QPaintEvent* event);
  44. void resizeEvent(QResizeEvent* event);
  45. private:
  46. enum Orientation {
  47. HORIZONTAL = 0,
  48. VERTICAL = 1
  49. };
  50. static const unsigned short HOVER_MIN = 0;
  51. static const unsigned short HOVER_MAX = 9;
  52. // -------------------------------------
  53. QPixmap fPixmap;
  54. QString fPixmapNum;
  55. CustomPaint fCustomPaint;
  56. Orientation fOrientation;
  57. bool fHovered;
  58. unsigned short fHoverStep;
  59. QString fLabel;
  60. QPointF fLabelPos;
  61. QFont fLabelFont;
  62. int fLabelWidth;
  63. int fLabelHeight;
  64. QLinearGradient fLabelGradient;
  65. QRectF fLabelGradientRect;
  66. QColor fColor1;
  67. QColor fColor2;
  68. QColor fColorT[2];
  69. int fWidth, fHeight, fSize, fCount;
  70. };
  71. #endif // __PIXMAPDIAL_HPP__