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 
11 namespace Midi
12 {
13 class NoteView;
14 class View final : public Process::LayerView
15 {
16  W_OBJECT(View)
17 public:
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 
29 public:
30  void deleteRequested() W_SIGNAL(deleteRequested);
31 
32 private:
33  bool canEdit() const;
34  void paint_impl(QPainter*) const override;
35  void heightChanged(qreal h) override;
36  void widthChanged(qreal w) override;
37  void mousePressEvent(QGraphicsSceneMouseEvent*) override;
38  void mouseMoveEvent(QGraphicsSceneMouseEvent*) override;
39  void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
40  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
41  void keyPressEvent(QKeyEvent*) override;
42  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
43 
44  void updateBackground(double height);
45 
46  QPainterPath m_selectArea;
47  double m_defaultW; // Covers the [ 0; 1 ] area
48  int m_min{0}, m_max{127};
49 
50  QPixmap m_textCache;
51  QPixmap m_bgCache;
52 
53  mutable std::vector<QPainter::PixmapFragment> m_fragmentCache;
54 };
55 }
Definition: MidiView.hpp:15
Definition: LayerView.hpp:21
Definition: MidiNote.hpp:11
Definition: LFO_v2.hpp:68