1 //=============================================================================
2 //  MuseScore
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 __FRETCANVAS_H__
21 #define __FRETCANVAS_H__
22 
23 namespace Ms {
24 
25 class Accidental;
26 class Clef;
27 class FretDiagram;
28 enum class FretDotType : signed char;
29 
30 //---------------------------------------------------------
31 //   FretCanvas
32 //---------------------------------------------------------
33 
34 class FretCanvas : public QFrame {
35       Q_OBJECT
36 
37       FretDiagram* diagram { nullptr };
38       int cstring          { 0 };
39       int cfret            { 0 };
40 
41       bool _automaticDotType    { true };
42       FretDotType _currentDtype;
43       bool _barreMode    { false };
44       bool _multidotMode { false };
45 
46       virtual void paintEvent(QPaintEvent*);
47       virtual void mousePressEvent(QMouseEvent*);
48       virtual void mouseMoveEvent(QMouseEvent*);
49 
50       void paintDotSymbol(QPainter& p, QPen& pen, qreal y, qreal x, qreal dotd, FretDotType dtype);
51       void getPosition(const QPointF& pos, int* string, int* fret);
52 
53    public:
54       FretCanvas(QWidget* parent = 0);
55       void setFretDiagram(FretDiagram* fd);
56 
setAutomaticDotType(bool v)57       void setAutomaticDotType(bool v)              { _automaticDotType = v; }
setCurrentDotType(FretDotType t)58       void setCurrentDotType(FretDotType t)         { _currentDtype = t; }
setBarreMode(bool v)59       void setBarreMode(bool v)                     { _barreMode = v; }
setMultidotMode(bool v)60       void setMultidotMode(bool v)                  { _multidotMode = v; }
61       void clear();
62 
63       };
64 
65 
66 } // namespace Ms
67 #endif
68 
69