drumstick 2.3.1
pianokey.h
Go to the documentation of this file.
1/*
2 Virtual Piano Widget for Qt5
3 Copyright (C) 2008-2021, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4
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 3 of the License, or
8 (at your option) 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 You should have received a copy of the GNU General Public License along
16 with this program; If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef PIANOKEY_H_
20#define PIANOKEY_H_
21
22#include <QGraphicsRectItem>
23#include <QBrush>
24
30namespace drumstick { namespace widgets {
31
32 class PianoPalette;
33
34 class PianoKey : public QGraphicsRectItem
35 {
36 public:
37 explicit PianoKey(QGraphicsItem * parent = nullptr ): QGraphicsRectItem(parent),
38 m_pressed(false),
39 m_note(0),
40 m_black(false),
41 m_usePixmap(true)
42 { }
43 PianoKey(const QRectF &rect, const bool black, const int note);
44 void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override;
45 int getNote() const { return m_note; }
46 void setBrush(const QBrush& b) { m_brush = b; }
47 void setPressedBrush(const QBrush& b) { m_selectedBrush = b; }
48 void resetBrush();
49 bool isPressed() const { return m_pressed; }
50 void setPressed(bool p);
51 int getDegree() const { return m_note % 12; }
52 int getType() const { return (m_black ? 1 : 0); }
53 bool isBlack() const { return m_black; }
54 const QPixmap& getPixmap() const;
55 void setPixmap(const QPixmap& p);
56 QRectF pixmapRect() const;
57 bool getUsePixmap() const;
58 void setUsePixmap(bool usePixmap);
59
60 static const PianoPalette keyPalette;
61
62 private:
63 bool m_pressed;
64 QBrush m_selectedBrush;
65 QBrush m_brush;
66 int m_note;
67 bool m_black;
68 QPixmap m_pixmap;
69 bool m_usePixmap;
70 };
71
72}} // namespace drumstick::widgets
73
74#endif /*PIANOKEY_H_*/
Drumstick common.
Definition: alsaclient.cpp:68