MuseScore/mscore/pianoview.h
Mark McKay 63d2db7b14 fix #273601: Updated UI for pianoroll editor.
Updating main piano roll display to have 12 rows per octave.

Updating piano keyboard to track main piano roll window.

Moving PianoKeyboard to its own file.

Better tracking of playhead during playback.

Drawing beat lines within measure.

Scrollbars now adjusted for stasis when zooming in the pianoview.

Piano ruler now showing tick marks respecting zoom level.

Fixing scroll issue during playback.

Taking direct control of selection.

PianoItem is no longer a Qt object.

Preping  for note group drag.

Can now drag pitch changes.

Adjusting viewport pos when staff set.

Removing CMakeLists.txt

Adding CMakeLists.txt back in.

Cleaning things up for resubmission.

Now displaying drumset names in PianoKeyboard when relevant.

Updating tracking signal in Pianoroll Editor.  Cleanup.

Locator lines no longer Qt objects.  Removing redundant note move on
mouse up.

Now adjusting final event for playback.

Now showing note voice name.  Using Tpc to use note name tha reflects
accidentals.

Better checking for Position when opening Pianoroll window.
Adding note for ctrl-click on rest.

Swithing velocity type will now also adjust to equivilent velocity
value.  Better checking for single note selection.

Pianoroll window.  Adding note for ctrl-click on rest.
equivilent velocity value.  Better checking for single note selection.

Ctrl-click now adds note to selection.

Note up/down now correct direction for drumroll

Fixing calcuation for switching note velocity.

Can now horiz resize piano keyboard.

Setting up new PianoLevels control for setting note event values.

Now drawing subbeat divisions.

Can now cut notes.

User can now select data type to display.

Can now use mouse to adjust levels.

Adding undo to note event changes.  Now smoother transition between
absolute and offset level values.

Smoother update communication between controls.

Adding labels to piano levels.  Removing unneccary blocking of scene()
in pianoview.

Now handles adjusting level with 1px wide mouse sweep.

mouse sweep.
'c8199ac5a'.

fix #273601: Updated UI for pianoroll editor.

Now handling setting null staff.  Adding missing .h files to CMakeLists.txt

Removing undo step to avoid selection problem.

Adding tool tip display.

Keyboard display now adjusting to reflect transposition of instrument.

Now showing part name in Piano Roll editor.

Moving color display options into preferences.

Levels editor now using preferences too.

Fixing incorrent note being highlighted in piano roll editor.  Base color now used for coloring levels panel.

Cleaning code

Investigating cut/pasete actions.

Adding popup menu.

Encapsulating selection into a command.  Creating minimal popup menu.

Can now insert notes of arbitrary duraition to piano roll.

Adding dark and light color schemes to piano roll editor.

Can now set subbeats to non powers of 2.

Fixing bad rebase.

Holding shift will clamp values to mousedown position.

Adding dropdown to modify which white lines are shown behind notes.
2018-10-21 04:27:23 -04:00

172 lines
4.6 KiB
C++

//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2009-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __PIANOVIEW_H__
#define __PIANOVIEW_H__
#include "libmscore/pos.h"
namespace Ms {
class Score;
class Staff;
class Chord;
class ChordRest;
class Note;
class NoteEvent;
class PianoView;
enum class NoteSelectType {
REPLACE = 0,
XOR,
ADD,
SUBTRACT,
FIRST
};
enum class DragStyle {
NONE = 0,
SELECTION_RECT,
MOVE_NOTES
};
struct BarPattern {
QString name;
char isWhiteKey[12]; //Set to 1 for white keys, 0 for black
};
//---------------------------------------------------------
// PianoItem
//---------------------------------------------------------
class PianoItem {
Note* _note;
PianoView* _pianoView;
void paintNoteBlock(QPainter* painter, NoteEvent* evt);
QRect boundingRectTicks(NoteEvent* evt);
QRect boundingRectPixels(NoteEvent* evt);
bool intersectsBlock(int startTick, int endTick, int highPitch, int lowPitch, NoteEvent* evt);
public:
PianoItem(Note*, PianoView*);
~PianoItem() {}
Note* note() { return _note; }
void paint(QPainter* painter);
bool intersects(int startTick, int endTick, int highPitch, int lowPitch);
QRect boundingRect();
NoteEvent* getTweakNoteEvent();
};
//---------------------------------------------------------
// PianoView
//---------------------------------------------------------
class PianoView : public QGraphicsView {
Q_OBJECT
public:
static const BarPattern barPatterns[];
private:
Staff* _staff;
Chord* chord;
Pos trackingPos; //Track mouse position
Pos* _locator;
int ticks;
TType _timeType;
int _noteHeight;
qreal _xZoom;
int _tuplet; //Tuplet divisions
int _subdiv; //Beat subdivisions
int _barPattern;
bool _playEventsView;
bool mouseDown;
bool dragStarted;
QPointF mouseDownPos;
QPointF lastMousePos;
DragStyle dragStyle;
int lastDragPitch;
bool inProgressUndoEvent;
QList<PianoItem*> noteList;
virtual void drawBackground(QPainter* painter, const QRectF& rect);
void addChord(Chord* chord, int voice);
void updateBoundingSize();
void clearNoteData();
void selectNotes(int startTick, int endTick, int lowPitch, int highPitch, NoteSelectType selType);
void showPopupMenu(const QPoint& pos);
bool cutChordRest(ChordRest* e, int track, int cutTick, ChordRest*& cr0, ChordRest*& cr1);
QAction* getAction(const char* id);
protected:
virtual void wheelEvent(QWheelEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void leaveEvent(QEvent*);
virtual void contextMenuEvent(QContextMenuEvent *event);
signals:
void xZoomChanged(qreal);
void tupletChanged(int);
void subdivChanged(int);
void barPatternChanged(int);
void noteHeightChanged(int);
void pitchChanged(int);
void trackingPosChanged(const Pos&);
void selectionChanged();
public slots:
void moveLocator(int);
void updateNotes();
void setXZoom(int);
void setTuplet(int);
void setSubdiv(int);
void setBarPattern(int);
public:
PianoView();
~PianoView();
Staff* staff() { return _staff; }
void setStaff(Staff*, Pos* locator);
void ensureVisible(int tick);
int noteHeight() { return _noteHeight; }
qreal xZoom() { return _xZoom; }
int tuplet() { return _tuplet; }
int subdiv() { return _subdiv; }
int barPattern() { return _barPattern; }
QList<QGraphicsItem*> items() { return scene()->selectedItems(); }
int pixelXToTick(int pixX);
int tickToPixelX(int tick);
int pixelYToPitch(int pixY) { return (int)floor(128 - pixY / (qreal)_noteHeight); }
PianoItem* pickNote(int tick, int pitch);
QList<PianoItem*> getSelectedItems();
QList<PianoItem*> getItems();
bool playEventsView() { return _playEventsView; }
};
} // namespace Ms
#endif