Cleanup
[carla.git] / source / frontend / widgets / pixmapkeyboard.hpp
blob519656971966a863ff30b12fb93f3ff6e0093f89
1 /*
2 * Pixmap Keyboard, 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 PIXMAPKEYBOARD_HPP_INCLUDED
19 #define PIXMAPKEYBOARD_HPP_INCLUDED
21 #include "CarlaJuceUtils.hpp"
23 #include <map>
24 #include <QtGui/QPixmap>
26 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
27 # include <QtWidgets/QWidget>
28 #else
29 # include <QtGui/QWidget>
30 #endif
32 class PixmapKeyboard : public QWidget
34 Q_OBJECT
36 public:
37 enum Color {
38 COLOR_CLASSIC = 0,
39 COLOR_ORANGE = 1
42 enum Orientation {
43 HORIZONTAL = 0,
44 VERTICAL = 1
47 PixmapKeyboard(QWidget* parent);
49 void allNotesOff();
50 void sendNoteOn(int note, bool sendSignal=true);
51 void sendNoteOff(int note, bool sendSignal=true);
53 void setMode(Orientation mode, Color color=COLOR_ORANGE);
54 void setOctaves(int octaves);
56 signals:
57 void noteOn(int);
58 void noteOff(int);
59 void notesOn();
60 void notesOff();
62 protected:
63 void handleMousePos(const QPoint&);
65 void keyPressEvent(QKeyEvent*) override;
66 void keyReleaseEvent(QKeyEvent*) override;
67 void mousePressEvent(QMouseEvent*) override;
68 void mouseMoveEvent(QMouseEvent*) override;
69 void mouseReleaseEvent(QMouseEvent*) override;
70 void paintEvent(QPaintEvent*) override;
72 private:
73 QPixmap fPixmap;
74 Orientation fPixmapMode;
76 QString fColorStr;
77 QFont fFont;
79 int fOctaves;
80 int fLastMouseNote;
81 int fWidth;
82 int fHeight;
84 QList<int> fEnabledKeys;
85 std::map<int, QRectF>& fMidiMap;
87 bool _isNoteBlack(int note) const;
88 const QRectF& _getRectFromMidiNote(int note) const;
90 CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PixmapKeyboard)
93 #endif // PIXMAPKEYBOARD_HPP_INCLUDED