MidiPresenter.hpp
1 #pragma once
2 #include <Process/LayerPresenter.hpp>
3 
4 #include <Midi/Commands/MoveNotes.hpp>
5 #include <Midi/MidiProcess.hpp>
6 
7 #include <score/command/Dispatchers/SingleOngoingCommandDispatcher.hpp>
8 
9 #include <nano_observer.hpp>
10 class QMimeData;
11 namespace Midi
12 {
13 class NoteView;
14 class View;
15 class Note;
16 class Presenter final
18  , public Nano::Observer
19 {
20  W_OBJECT(Presenter)
21 public:
22  explicit Presenter(
23  const Midi::ProcessModel& model, View* view, const Process::Context& ctx,
24  QObject* parent);
25  ~Presenter() override;
26 
27  void setWidth(qreal width, qreal defaultWidth) override;
28  void setHeight(qreal height) override;
29 
30  void putToFront() override;
31  void putBehind() override;
32 
33  void on_zoomRatioChanged(ZoomRatio) override;
34 
35  void parentGeometryChanged() override;
36 
37  const Midi::ProcessModel& model() const noexcept;
38  const Midi::View& view() const noexcept;
39 
40  void on_deselectOtherNotes();
41  void on_duplicate();
42  void on_noteChanged(NoteView& v);
43  void on_noteChangeFinished(NoteView& v);
44  void on_noteScaled(const Note& note, double newScale);
45  void on_requestVelocityChange(const Note& note, double velocityDelta);
46  void on_velocityChangeFinished();
47  void on_noteSelectionChanged(NoteView*, bool ok);
48 
49 private:
50  void updateNote(NoteView&);
51  void on_noteAdded(const Note&);
52  void on_noteRemoving(const Note&);
53  void on_notesReplaced();
54  void on_drop(const QPointF& pos, const QMimeData&);
55 
56  std::vector<Id<Note>> selectedNotes() const;
57 
58  View* m_view{};
59  std::vector<NoteView*> m_notes;
60  std::vector<NoteView*> m_selectedNotes;
61 
64 
65  std::optional<int> m_origMovePitch{};
66  std::optional<double> m_origMoveStart{};
67 
68  ZoomRatio m_zr{};
69  void fillContextMenu(
70  QMenu& menu, QPoint pos, QPointF scenepos,
71  const Process::LayerContextMenuManager& cm) override;
72 };
73 }
The Note class.
Definition: MidiNote.hpp:59
Definition: MidiNoteView.hpp:11
Definition: MidiPresenter.hpp:19
Definition: MidiProcess.hpp:15
Definition: MidiView.hpp:15
Definition: LayerContextMenu.hpp:38
Definition: LayerPresenter.hpp:34
The SingleOngoingCommandDispatcher class.
Definition: SingleOngoingCommandDispatcher.hpp:17
Definition: ProcessContext.hpp:12