MuseScore  3.4
Music composition and notation
pianokeyboard.h
Go to the documentation of this file.
1 //=============================================================================
2 // MusE Score
3 // Linux Music Score Editor
4 //
5 // Copyright (C) 2009 Werner Schweer and others
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2.
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
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19 
20 #ifndef __PIANO_KEYBOARD_H__
21 #define __PIANO_KEYBOARD_H__
22 
23 #include "piano.h"
24 
25 namespace Ms {
26 
27 class Staff;
28 
29 static const int PIANO_KEYBOARD_WIDTH = 100;
30 static const int BLACK_KEY_WIDTH = PIANO_KEYBOARD_WIDTH * 9 / 14;
31 const int MAX_KEY_HEIGHT = 20;
32 const int MIN_KEY_HEIGHT = 8;
33 const int DEFAULT_KEY_HEIGHT = 14;
34 const int BEAT_WIDTH_IN_PIXELS = 50;
35 const double X_ZOOM_RATIO = 1.1;
36 const double X_ZOOM_INITIAL = 0.1;
37 
38 
39 //Alternative implementation with evenly spaced notes
40 class PianoKeyboard : public QWidget {
41  Q_OBJECT
42 
43  static const QString pitchNames[];
44 
46  int _ypos;
47 
49  int yRange;
50  int curPitch;
53 
54  virtual void paintEvent(QPaintEvent*);
55  virtual void mousePressEvent(QMouseEvent*);
56  virtual void mouseReleaseEvent(QMouseEvent*);
57  virtual void mouseMoveEvent(QMouseEvent* event);
58  virtual void leaveEvent(QEvent*);
59 
60  signals:
61  void pitchChanged(int);
62  void keyPressed(int pitch);
63  void keyReleased(int pitch);
64 
65  public slots:
66  void setYpos(int val);
67  void setNoteHeight(int);
68  void setPitch(int);
69 
70  public:
71  PianoKeyboard(QWidget* parent = 0);
72  Staff* staff() { return _staff; }
73  void setStaff(Staff* staff);
75  };
76 
77 
78 } // namespace Ms
79 #endif
80 
int _ypos
Definition: pianokeyboard.h:46
Global staff data not directly related to drawing.
Definition: staff.h:62
int noteHeight
Definition: pianokeyboard.h:48
void keyReleased(int pitch)
Staff * staff()
Definition: pianokeyboard.h:72
int curKeyPressed
Definition: pianokeyboard.h:51
void setOrientation(PianoOrientation)
Definition: pianokeyboard.cpp:335
const double X_ZOOM_RATIO
Definition: pianokeyboard.h:35
virtual void leaveEvent(QEvent *)
Definition: pianokeyboard.cpp:311
PianoOrientation _orientation
Definition: pianokeyboard.h:45
void keyPressed(int pitch)
int curPitch
Definition: pianokeyboard.h:50
void setNoteHeight(int)
Definition: pianokeyboard.cpp:223
void setStaff(Staff *staff)
Definition: pianokeyboard.cpp:325
void setYpos(int val)
Definition: pianokeyboard.cpp:211
void setPitch(int)
Definition: pianokeyboard.cpp:235
PianoOrientation
Definition: piano.h:28
Definition: aeolus.cpp:26
const int MIN_KEY_HEIGHT
Definition: pianokeyboard.h:32
Staff * _staff
Definition: pianokeyboard.h:52
const int BEAT_WIDTH_IN_PIXELS
Definition: pianokeyboard.h:34
virtual void mousePressEvent(QMouseEvent *)
Definition: pianokeyboard.cpp:247
const int DEFAULT_KEY_HEIGHT
Definition: pianokeyboard.h:33
void pitchChanged(int)
const int MAX_KEY_HEIGHT
Definition: pianokeyboard.h:31
virtual void paintEvent(QPaintEvent *)
Definition: pianokeyboard.cpp:60
virtual void mouseMoveEvent(QMouseEvent *event)
Definition: pianokeyboard.cpp:274
int yRange
Definition: pianokeyboard.h:49
static const QString pitchNames[]
Definition: pianokeyboard.h:43
virtual void mouseReleaseEvent(QMouseEvent *)
Definition: pianokeyboard.cpp:264
Definition: pianokeyboard.h:40
const double X_ZOOM_INITIAL
Definition: pianokeyboard.h:36
PianoKeyboard(QWidget *parent=0)
Definition: pianokeyboard.cpp:38