Cleanup
[carla.git] / source / frontend / widgets / pixmapdial.hpp
blob29af51fcb5bd91804c0306305acba9251dcf6aa2
1 /*
2 * Pixmap Dial, a custom Qt4 widget
3 * Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
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.
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.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef PIXMAPDIAL_HPP_INCLUDED
19 #define PIXMAPDIAL_HPP_INCLUDED
21 #include "CarlaJuceUtils.hpp"
23 #include <QtGui/QPixmap>
25 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
26 # include <QtWidgets/QDial>
27 #else
28 # include <QtGui/QDial>
29 #endif
31 class PixmapDial : public QDial
33 public:
34 enum CustomPaint {
35 CUSTOM_PAINT_NULL = 0,
36 CUSTOM_PAINT_CARLA_WET = 1,
37 CUSTOM_PAINT_CARLA_VOL = 2,
38 CUSTOM_PAINT_CARLA_L = 3,
39 CUSTOM_PAINT_CARLA_R = 4
42 PixmapDial(QWidget* parent);
44 int getSize() const;
45 void setCustomPaint(CustomPaint paint);
46 void setEnabled(bool enabled);
47 void setLabel(QString label);
48 void setPixmap(int pixmapId);
50 QSize minimumSizeHint() const override;
51 QSize sizeHint() const override;
53 protected:
54 void updateSizes();
56 void enterEvent(QEvent* event) override;
57 void leaveEvent(QEvent* event) override;
58 void paintEvent(QPaintEvent* event) override;
59 void resizeEvent(QResizeEvent* event) override;
61 private:
62 enum Orientation {
63 HORIZONTAL = 0,
64 VERTICAL = 1
67 static const unsigned short HOVER_MIN = 0;
68 static const unsigned short HOVER_MAX = 9;
70 // -------------------------------------
72 QPixmap fPixmap;
73 QString fPixmapNum;
75 CustomPaint fCustomPaint;
76 Orientation fOrientation;
78 bool fHovered;
79 unsigned short fHoverStep;
81 QString fLabel;
82 QPointF fLabelPos;
83 QFont fLabelFont;
84 int fLabelWidth;
85 int fLabelHeight;
87 QLinearGradient fLabelGradient;
88 QRectF fLabelGradientRect;
90 QColor fColor1;
91 QColor fColor2;
92 QColor fColorT[2];
94 int fWidth, fHeight, fSize, fCount;
96 CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PixmapDial)
99 #endif // PIXMAPDIAL_HPP_INCLUDED