MuseScore  3.4
Music composition and notation
exampleview.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2013 Werner Schweer and others
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENSE.GPL
11 //=============================================================================
12 
13 #ifndef __EXAMPLEVIEW_H__
14 #define __EXAMPLEVIEW_H__
15 
16 #include "libmscore/mscoreview.h"
17 
18 namespace Ms {
19 
20 class Element;
21 class Score;
22 class Note;
23 class Chord;
24 class Icon;
25 enum class Grip : int;
26 
27 //---------------------------------------------------------
28 // ExampleView
29 //---------------------------------------------------------
30 
31 class ExampleView : public QFrame, public MuseScoreView {
32  Q_OBJECT
33 
34  QTransform _matrix, imatrix;
35  QColor _fgColor;
36  QPixmap* _fgPixmap;
37  Element* dragElement = 0;
38  const Element* dropTarget = 0;
39  QRectF dropRectangle;
40  QLineF dropAnchor;
41 
42  QStateMachine* sm;
43  QPointF startMove;
44 
45  void drawElements(QPainter& painter, const QList<Element*>& el);
46  void setDropTarget(const Element* el);
47 
48  virtual void paintEvent(QPaintEvent*);
49  virtual void dragEnterEvent(QDragEnterEvent*);
50  virtual void dragLeaveEvent(QDragLeaveEvent*);
51  virtual void dragMoveEvent(QDragMoveEvent*);
52  virtual void wheelEvent(QWheelEvent*);
53  virtual void dropEvent(QDropEvent*);
54  virtual void mousePressEvent(QMouseEvent*);
55  void constraintCanvas(int *dxx);
56  virtual QSize sizeHint() const;
57 
58  signals:
59  void noteClicked(Note*);
60  void beamPropertyDropped(Chord*, Icon*);
61 
62  public:
63  ExampleView(QWidget* parent = 0);
64  ~ExampleView();
65  void resetMatrix();
66  virtual void layoutChanged();
67  virtual void dataChanged(const QRectF&);
68  virtual void updateAll();
69  virtual void adjustCanvasPosition(const Element* el, bool playBack);
70  virtual void setScore(Score*);
71  virtual void removeScore();
72 
73  virtual void changeEditElement(Element*);
74  virtual QCursor cursor() const;
75  virtual void setCursor(const QCursor&);
76  virtual void setDropRectangle(const QRectF&);
77  virtual void cmdAddSlur(Note* firstNote, Note* lastNote);
78  virtual Element* elementNear(QPointF);
79  virtual void drawBackground(QPainter*, const QRectF&) const;
80  void dragExampleView(QMouseEvent* ev);
81  virtual const QRect geometry() const override { return QFrame::geometry(); }
82  };
83 
84 //---------------------------------------------------------
85 // DragTransitionExampleView
86 //---------------------------------------------------------
87 
88 class DragTransitionExampleView : public QEventTransition
89  {
91 
92  protected:
93  virtual void onTransition(QEvent* e);
94 
95  public:
97  : QEventTransition(c, QEvent::MouseMove), canvas(c) {}
98  };
99 
100 } // namespace Ms
101 #endif
102 
QColor _fgColor
Definition: exampleview.h:35
ExampleView * canvas
Definition: exampleview.h:90
Base class of score layout elements.
Definition: element.h:158
QLineF dropAnchor
line to current anchor point during dragMove
Definition: exampleview.h:40
DragTransitionExampleView(ExampleView *c)
Definition: exampleview.h:96
Definition: icon.h:26
Definition: score.h:391
QStateMachine * sm
Definition: exampleview.h:42
QPointF startMove
Definition: exampleview.h:43
QPixmap * _fgPixmap
Definition: exampleview.h:36
QTransform imatrix
Definition: exampleview.h:34
Definition: exampleview.h:88
Grip
Definition: element.h:43
Definition: aeolus.cpp:26
Graphic representation of a chord.
Definition: chord.h:55
virtual const QRect geometry() const override
Definition: exampleview.h:81
QRectF dropRectangle
current drop rectangle during dragMove
Definition: exampleview.h:39
Graphic representation of a note.
Definition: note.h:212
Definition: exampleview.h:31
Definition: mscoreview.h:32