Cleanup
[carla.git] / source / frontend / widgets / paramspinbox.hpp
blob2f236774ae882720529411e6fa2feb82b5d4cfbe
1 /*
2 * Parameter SpinBox, 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 modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * 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 PARAMSPINBOX_HPP_INCLUDED
19 #define PARAMSPINBOX_HPP_INCLUDED
21 #include "CarlaJuceUtils.hpp"
23 #include <QtCore/Qt>
25 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
26 # include <QtWidgets/QProgressBar>
27 #else
28 # include <QtGui/QProgressBar>
29 #endif
31 class TextCallback
33 public:
34 virtual ~TextCallback();
35 virtual const char* textCallBack() = 0;
38 class ParamProgressBar : public QProgressBar
40 Q_OBJECT
42 public:
43 ParamProgressBar(QWidget* parent);
45 void set_minimum(float value);
46 void set_maximum(float value);
47 void set_value(float value);
48 void set_label(QString label);
49 void set_text_call(TextCallback* textCall);
51 signals:
52 void valueChangedFromBar(float value);
54 protected:
55 void handleMouseEventPos(const QPoint& pos);
56 void mousePressEvent(QMouseEvent* event) override;
57 void mouseMoveEvent(QMouseEvent* event) override;
58 void mouseReleaseEvent(QMouseEvent* event) override;
59 void paintEvent(QPaintEvent* event) override;
61 private:
62 bool m_leftClickDown;
63 float m_minimum;
64 float m_maximum;
65 float m_rvalue;
66 QString m_label;
67 QString m_preLabel;
69 TextCallback* m_textCall;
71 CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParamProgressBar)
74 #endif // PARAMSPINBOX_HPP_INCLUDED