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; ///< current drop target during dragMove 39 QRectF dropRectangle; ///< current drop rectangle during dragMove 40 QLineF dropAnchor; ///< line to current anchor point during dragMove 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); geometry()81 virtual const QRect geometry() const override { return QFrame::geometry(); } 82 }; 83 84 //--------------------------------------------------------- 85 // DragTransitionExampleView 86 //--------------------------------------------------------- 87 88 class DragTransitionExampleView : public QEventTransition 89 { 90 ExampleView* canvas; 91 92 protected: 93 virtual void onTransition(QEvent* e); 94 95 public: DragTransitionExampleView(ExampleView * c)96 DragTransitionExampleView(ExampleView* c) 97 : QEventTransition(c, QEvent::MouseMove), canvas(c) {} 98 }; 99 100 } // namespace Ms 101 #endif 102 103