Loading...
Searching...
No Matches
MidiView.hpp
1#pragma once
2#include <Process/LayerView.hpp>
3
4#include <Midi/MidiProcess.hpp>
5
6#include <QPainter>
7#include <QPainterPath>
8
9#include <verdigris>
10
11namespace Midi
12{
13class NoteView;
14class SCORE_PLUGIN_MIDI_EXPORT View final : public Process::LayerView
15{
16 W_OBJECT(View)
17public:
18 View(QGraphicsItem* parent);
19
20 ~View() override;
21 double defaultWidth() const noexcept { return m_defaultW; }
22 void setDefaultWidth(double w);
23
24 void setRange(int, int);
25 std::pair<int, int> range() const { return {m_min, m_max}; }
26 NoteData noteAtPos(QPointF point) const;
27 int visibleCount() const;
28
29public:
30 void deleteRequested() W_SIGNAL(deleteRequested);
32 void transposeRequested(int semitones) W_SIGNAL(transposeRequested, semitones);
33
34private:
35 bool canEdit() const;
36 void paint_impl(QPainter*) const override;
37 void heightChanged(qreal h) override;
38 void widthChanged(qreal w) override;
39 void mousePressEvent(QGraphicsSceneMouseEvent*) override;
40 void mouseMoveEvent(QGraphicsSceneMouseEvent*) override;
41 void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
42 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
43 void keyPressEvent(QKeyEvent*) override;
44 void dropEvent(QGraphicsSceneDragDropEvent* event) override;
45
46 void updateBackground(double height);
47
48 QPainterPath m_selectArea;
49 double m_defaultW; // Covers the [ 0; 1 ] area
50 int m_min{0}, m_max{127};
51
52 QPixmap m_textCache;
53 QPixmap m_bgCache;
54
55 mutable std::vector<QPainter::PixmapFragment> m_fragmentCache;
56};
57}
Definition MidiView.hpp:15
void transposeRequested(int semitones)
Up / Down: a semitone; with Shift, an octave.
Definition LayerView.hpp:21
Definition MidiNote.hpp:12
Definition MIDISync.hpp:128