MuseScore  3.4
Music composition and notation
pianolevels.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 __PIANOLEVELS_H__
21 #define __PIANOLEVELS_H__
22 
23 #include <QWidget>
24 
25 #include "libmscore/pos.h"
26 
27 namespace Ms {
28 
29 class Score;
30 class Staff;
31 class Chord;
32 class Note;
33 class NoteEvent;
34 class PianoItem;
35 
36 
37 
38 //---------------------------------------------------------
39 // PianoLevels
40 //---------------------------------------------------------
41 
42 class PianoLevels : public QWidget
43 {
44  Q_OBJECT
45 
46  enum DragStyle {
48  };
49 
51  int _xpos;
52  qreal _xZoom;
56  int _tuplet;
57  int _subdiv;
59  int vMargin;
60  int levelLen;
61  int pickRadius = 4;
62 
63  bool mouseDown;
64  QPointF mouseDownPos;
65  QPointF lastMousePos;
66  int dragging = false;
68  Note* singleNoteDrag = nullptr;
70 
72 
73  QList<Note*> noteList;
74 
75  virtual void paintEvent(QPaintEvent*);
76  virtual void mousePressEvent(QMouseEvent*);
77  virtual void mouseReleaseEvent(QMouseEvent* event);
78  virtual void mouseMoveEvent(QMouseEvent* event);
79  virtual void leaveEvent(QEvent*);
80 
81  int pixelXToTick(int pixX);
82  int tickToPixelX(int tick);
83  int valToPixelY(int value);
84  int pixelYToVal(int value);
85  int noteStartTick(Note* note, NoteEvent* evt);
86  void moveLocator(QMouseEvent*);
87  void addChord(Chord* chord, int voice);
88  void clearNoteData();
89 
90  bool pickNoteEvent(int x, int y, bool selectedOnly,
91  Note*& pickedNote, NoteEvent*& pickedNoteEvent);
92  void adjustLevelLerp(int tick0, int value0, int tick1, int value1, bool selectedOnly = true);
93  void adjustLevel(Note* note, NoteEvent* noteEvt, int value);
94 
95 signals:
96  void posChanged(const Pos&);
97  void tupletChanged(int);
98  void subdivChanged(int);
99  void levelsIndexChanged(int);
100  void locatorMoved(int idx, const Pos&);
101  void noteLevelsChanged();
102 
103 public slots:
104  void setXpos(int);
105  void setTuplet(int);
106  void setSubdiv(int);
107  void setXZoom(qreal);
108  void setPos(const Pos&);
109  void setLevelsIndex(int index);
110 
111 public:
112  PianoLevels(QWidget *parent = 0);
113  ~PianoLevels();
114 
115  void setScore(Score*, Pos* locator);
116  Staff* staff() { return _staff; }
117  void setStaff(Staff*, Pos* locator);
118  void updateNotes();
119  int tuplet() const { return _tuplet; }
120  int subdiv() const { return _subdiv; }
121 
122  int xpos() const { return _xpos; }
123  qreal xZoom() const { return _xZoom; }
124 };
125 
126 }
127 #endif // __PIANOLEVELS_H__
void setScore(Score *, Pos *locator)
Definition: pianolevels.cpp:73
int tuplet() const
Definition: pianolevels.h:119
int _tuplet
Definition: pianolevels.h:56
Pos * _locator
Definition: pianolevels.h:54
void locatorMoved(int idx, const Pos &)
int levelLen
Definition: pianolevels.h:60
void posChanged(const Pos &)
~PianoLevels()
Definition: pianolevels.cpp:64
Global staff data not directly related to drawing.
Definition: staff.h:62
void noteLevelsChanged()
Definition: noteevent.h:25
QList< Note * > noteList
Definition: pianolevels.h:73
void adjustLevel(Note *note, NoteEvent *noteEvt, int value)
Definition: pianolevels.cpp:372
Note * singleNoteDrag
Definition: pianolevels.h:68
Staff * staff()
Definition: pianolevels.h:116
QPointF lastMousePos
Definition: pianolevels.h:65
virtual void paintEvent(QPaintEvent *)
Definition: pianolevels.cpp:115
void updateNotes()
Definition: pianolevels.cpp:611
int vMargin
Definition: pianolevels.h:59
int dragging
Definition: pianolevels.h:66
void setSubdiv(int)
Definition: pianolevels.cpp:662
QPointF mouseDownPos
Definition: pianolevels.h:64
int valToPixelY(int value)
Definition: pianolevels.cpp:300
int pickRadius
Definition: pianolevels.h:61
void setXpos(int)
Definition: pianolevels.cpp:86
virtual void mouseReleaseEvent(QMouseEvent *event)
Definition: pianolevels.cpp:459
int pixelYToVal(int value)
Definition: pianolevels.cpp:314
Pos _cursor
Definition: pianolevels.h:53
Definition: pianolevels.h:47
Definition: score.h:391
void tupletChanged(int)
int _levelsIndex
Definition: pianolevels.h:58
DragStyle
Definition: pianolevels.h:46
void adjustLevelLerp(int tick0, int value0, int tick1, int value1, bool selectedOnly=true)
Definition: pianolevels.cpp:389
virtual void leaveEvent(QEvent *)
Definition: pianolevels.cpp:547
void clearNoteData()
Definition: pianolevels.cpp:640
qreal xZoom() const
Definition: pianolevels.h:123
DragStyle dragStyle
Definition: pianolevels.h:67
void moveLocator(QMouseEvent *)
Definition: pianolevels.cpp:532
bool mouseDown
Definition: pianolevels.h:63
void setStaff(Staff *, Pos *locator)
Definition: pianolevels.cpp:580
void addChord(Chord *chord, int voice)
Definition: pianolevels.cpp:596
void subdivChanged(int)
Definition: pianolevels.h:47
Definition: aeolus.cpp:26
Staff * _staff
Definition: pianolevels.h:55
virtual void mousePressEvent(QMouseEvent *)
Definition: pianolevels.cpp:438
int minBeatGap
Definition: pianolevels.h:71
int _xpos
Definition: pianolevels.h:51
Graphic representation of a chord.
Definition: chord.h:55
int xpos() const
Definition: pianolevels.h:122
void setTuplet(int)
Definition: pianolevels.cpp:649
void levelsIndexChanged(int)
Definition: pianolevels.h:42
Score * _score
Definition: pianolevels.h:50
int noteStartTick(Note *note, NoteEvent *evt)
Definition: pianolevels.cpp:287
int _subdiv
Definition: pianolevels.h:57
int pixelXToTick(int pixX)
Definition: pianolevels.cpp:97
Graphic representation of a note.
Definition: note.h:212
virtual void mouseMoveEvent(QMouseEvent *event)
Definition: pianolevels.cpp:482
void setPos(const Pos &)
Definition: pianolevels.cpp:558
NoteEvent * singleNoteEventDrag
Definition: pianolevels.h:69
int tickToPixelX(int tick)
Definition: pianolevels.cpp:106
qreal _xZoom
Definition: pianolevels.h:52
bool pickNoteEvent(int x, int y, bool selectedOnly, Note *&pickedNote, NoteEvent *&pickedNoteEvent)
Definition: pianolevels.cpp:326
int subdiv() const
Definition: pianolevels.h:120
PianoLevels(QWidget *parent=0)
Definition: pianolevels.cpp:44
Definition: pos.h:42
void setLevelsIndex(int index)
Definition: pianolevels.cpp:675
void setXZoom(qreal)
Definition: pianolevels.cpp:570