1 //=============================================================================
2 //  MusE Score
3 //  Linux Music Score Editor
4 //
5 //  Copyright (C) 2009 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 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19 
20 #ifndef __PIANO_RULER_H__
21 #define __PIANO_RULER_H__
22 
23 #include "libmscore/pos.h"
24 
25 namespace Ms {
26 
27 class Score;
28 
29 static const int pianoRulerHeight = 28;
30 static const int MAP_OFFSET = 480;
31 
32 //---------------------------------------------------------
33 //   PianoRuler
34 //---------------------------------------------------------
35 
36 class PianoRuler : public QWidget {
37       Q_OBJECT
38 
39       Score* _score;
40       Pos _cursor;
41       Pos* _locator;
42 
43       qreal _xZoom;
44       int _xpos;
45       TType _timeType;
46       QFont _font1, _font2;
47 
48       static QPixmap* markIcon[3];
49 
50       virtual void paintEvent(QPaintEvent*);
51       virtual void mousePressEvent(QMouseEvent*);
52       virtual void mouseMoveEvent(QMouseEvent* event);
53       virtual void leaveEvent(QEvent*);
54 
55       Pos pix2pos(int x) const;
56       int pos2pix(const Pos& p) const;
57       void moveLocator(QMouseEvent*);
58 
59    signals:
60       void posChanged(const Pos&);
61       void locatorMoved(int idx, const Pos&);
62 
63    public slots:
64       void setXpos(int);
65       void setXZoom(qreal);
66       void setPos(const Pos&);
67 
68    public:
69       PianoRuler(QWidget* parent = 0);
70       void setScore(Score*, Pos* locator);
xpos()71       int xpos() const { return _xpos; }
xZoom()72       qreal xZoom() const { return _xZoom; }
73       };
74 
75 
76 } // namespace Ms
77 #endif
78 
79 
80