22 #include <QGraphicsRectItem>
34 class PianoKey :
public QGraphicsRectItem
37 explicit PianoKey(QGraphicsItem * parent =
nullptr ): QGraphicsRectItem(parent),
42 PianoKey(
const QRectF &rect,
const bool black,
const int note);
43 void paint(QPainter *painter,
const QStyleOptionGraphicsItem *, QWidget *)
override;
44 int getNote()
const {
return m_note; }
45 void setBrush(
const QBrush& b) { m_brush = b; }
46 void setPressedBrush(
const QBrush& b) { m_selectedBrush = b; }
48 bool isPressed()
const {
return m_pressed; }
49 void setPressed(
bool p);
50 int getDegree()
const {
return m_note % 12; }
51 int getType()
const {
return (m_black ? 1 : 0); }
52 bool isBlack()
const {
return m_black; }
53 QPixmap& getPixmap()
const;
54 QRectF pixmapRect()
const;
56 static const PianoPalette keyPalette;
60 QBrush m_selectedBrush;