File: chordview.h

package info (click to toggle)
musescore3 3.2.3%2Bdfsg2-11
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 210,672 kB
  • sloc: cpp: 291,093; xml: 200,238; sh: 3,779; ansic: 1,447; python: 393; makefile: 240; perl: 82; pascal: 79
file content (136 lines) | stat: -rw-r--r-- 3,876 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//=============================================================================
//  MuseScore
//  Music Composition & Notation
//
//  Copyright (C) 2002-2012 Werner Schweer
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2
//  as published by the Free Software Foundation and appearing in
//  the file LICENCE.GPL
//=============================================================================

#ifndef __CHORDVIEW_H__
#define __CHORDVIEW_H__

#include "libmscore/pos.h"

namespace Ms {

class Staff;
class Chord;
class Note;
class NoteEvent;
class ChordItem;
class ChordView;

enum { GripTypeItem = QGraphicsItem::UserType, ChordTypeItem };

//---------------------------------------------------------
//   GripItem
//---------------------------------------------------------

class GripItem : public QGraphicsRectItem {
      ChordItem* _event;
      int _gripType;          // 0 - start grip   1 - end grip
      ChordView* _view;


      virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);

   protected:
      virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);

   public:
      GripItem(int gripType, ChordView*);
      virtual int type() const    { return GripTypeItem; }
      ChordItem* event() const    { return _event; }
      void setEvent(ChordItem* e) { _event = e; }
      };

//---------------------------------------------------------
//   ChordItem
//---------------------------------------------------------

class ChordItem : public QGraphicsRectItem {
      ChordView* _view;
      Note*      _note;
      NoteEvent* _event;
      bool       _current;

      virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0);
      virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);

   public:
      ChordItem(ChordView*, Note*, NoteEvent*);
      virtual int type() const { return ChordTypeItem; }
      NoteEvent* event() const { return _event; }
      Note* note() const       { return _note;  }
      bool current() const     { return _current; }
      void setCurrent(bool v);
      };

//---------------------------------------------------------
//   ChordView
//---------------------------------------------------------

class ChordView : public QGraphicsView {
      Q_OBJECT

      Chord* chord;
      Note* _curNote;
      int _locator;
      int _pos;
      QGraphicsLineItem* locatorLine;
      int ticks;
      int magStep;
      GripItem* lg;
      GripItem* rg;
      ChordItem* curEvent;

      bool _evenGrid;
      bool _dirty;

      virtual void drawBackground(QPainter*, const QRectF& rect);

   protected:
      virtual void wheelEvent(QWheelEvent*);
      virtual void mouseMoveEvent(QMouseEvent*);
      virtual void leaveEvent(QEvent*);
      virtual void mousePressEvent(QMouseEvent*);

   signals:
      void magChanged(double, double);
      void xposChanged(int);
      void pitchChanged(int);
      void posChanged(int);

   protected slots:
      void deleteItem();

   public slots:
      void moveLocator();
      void selectionChanged();

   public:
      ChordView();
      void setChord(Chord*);
      void ensureVisible(int tick);
      QList<QGraphicsItem*> items() { return scene()->selectedItems(); }
      bool evenGrid() const         { return _evenGrid; }
      void setEvenGrid(bool val)    { _evenGrid = val;  }
      GripItem* rightGrip() const   { return rg;       }
      void setCurItem(ChordItem*);
      bool dirty() const            { return _dirty; }
      void setDirty(bool b)         { _dirty = b; }
      Note* curNote() const         { return _curNote; }

      static int pos2pix(int pos);
      static int pix2pos(int pix);
      static int y2pitch(int pix);
      static int pitch2y(int pitch);
      };


} // namespace Ms
#endif