Loading...
Searching...
No Matches
MidiPresenter.hpp
1#pragma once
2#include <ossia/detail/hash_map.hpp>
3
4#include <QPointer>
5#include <Process/LayerPresenter.hpp>
6
7#include <Midi/Commands/MoveNotes.hpp>
8#include <Midi/MidiProcess.hpp>
9
10#include <score/command/Dispatchers/SingleOngoingCommandDispatcher.hpp>
11
12#include <nano_observer.hpp>
13class QMimeData;
14namespace Midi
15{
16class NoteView;
17class View;
18class Note;
19class Presenter final
21 , public Nano::Observer
22{
23 W_OBJECT(Presenter)
24public:
25 explicit Presenter(
26 const Midi::ProcessModel& model, View* view, const Process::Context& ctx,
27 QObject* parent);
28 ~Presenter() override;
29
30 void setWidth(qreal width, qreal defaultWidth) override;
31 void setHeight(qreal height) override;
32
33 void putToFront() override;
34 void putBehind() override;
35
36 void on_zoomRatioChanged(ZoomRatio) override;
37
38 void parentGeometryChanged() override;
39 void on_focusChanged() override;
40
41 const Midi::ProcessModel& model() const noexcept;
42 const Midi::View& view() const noexcept;
43
44 void on_deselectOtherNotes();
45 void on_duplicate();
47 void on_noteChanged(NoteView& v, int semitones);
48 void on_noteChangeFinished(NoteView& v, int semitones);
49 void on_noteScaled(const Note& note, double newScale);
50 void on_transpose(int semitones);
51 void on_requestVelocityChange(const Note& note, double velocityDelta);
52 void on_velocityChangeFinished();
53 void on_noteSelectionChanged(NoteView*, bool ok);
54
55private:
59 bool eventFilter(QObject* watched, QEvent* event) override;
60 QPointer<QObject> m_keyWatched;
61
62 void updateNote(NoteView&);
63 void on_noteAdded(const Note&);
64 void on_noteRemoving(const Note&);
65 void on_notesReplaced();
66 void on_drop(const QPointF& pos, const QMimeData&);
67
68 std::vector<Id<Note>> selectedNotes() const;
69 void pushNoteSelection();
70
71 View* m_view{};
72 ossia::hash_map<const Note*, NoteView*> m_notes;
73 ossia::hash_set<NoteView*> m_selectedNotes;
74 bool m_selectionPushPending{};
75
78
79 std::optional<std::pair<int, int>> m_origMovePitches{}; // lowest, highest
80 std::optional<double> m_origMoveStart{};
81
82 ZoomRatio m_zr{};
83 void fillContextMenu(
84 QMenu& menu, QPoint pos, QPointF scenepos,
85 const Process::LayerContextMenuManager& cm) override;
86};
87}
The Note class.
Definition MidiNote.hpp:60
Definition MidiNoteView.hpp:11
Definition MidiPresenter.hpp:22
void on_noteChanged(NoteView &v, int semitones)
A drag of v by semitones, its time from where the view is.
Definition MidiPresenter.cpp:209
Definition MidiProcess.hpp:15
Definition MidiView.hpp:15
Definition LayerContextMenu.hpp:38
Definition LayerPresenter.hpp:34
The SingleOngoingCommandDispatcher class.
Definition SingleOngoingCommandDispatcher.hpp:18
Definition ProcessContext.hpp:12