1 //=============================================================================
2 //  MusE Score
3 //  Linux Music Score Editor
4 //
5 //  Copyright (C) 2010 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 __GRIDCANVAS_H__
21 #define __GRIDCANVAS_H__
22 
23 #include "libmscore/pitchvalue.h"
24 
25 namespace Ms {
26 
27 //---------------------------------------------------------
28 //   GridCanvas
29 //---------------------------------------------------------
30 
31 class GridCanvas : public QFrame {
32       Q_OBJECT
33 
34       QList<PitchValue> m_points;
35 
36       /// The number of rows and columns.
37       /// This is in fact the number of lines that are to be drawn.
38       int m_rows    = 0;
39       int m_columns = 0;
40       /// the interval between darker lines.
41       /// In the case of rows, since they represent the pitch, the primary lines represent semi-tones.
42       /// Moving from a primary line to another means changing the pitch of a semitone.
43       int m_primaryColumnsInterval = 0;
44       int m_primaryRowsInterval    = 0;
45 
46       /// Show negative pitch values. Happens in tremoloBarCanvas.
47       bool m_showNegativeRows = false;
48 
49       virtual void paintEvent(QPaintEvent*) override;
50       virtual void mousePressEvent(QMouseEvent*) override;
51 
52    public:
53       GridCanvas(QWidget* parent = nullptr);
points()54       const QList<PitchValue>& points() const    { return m_points; }
points()55       QList<PitchValue>& points()                { return m_points; }
setPoints(const QList<PitchValue> & p)56       void setPoints(const QList<PitchValue>& p) { m_points = p;    }
57 
58       /// number of lines to draw vertically
rows()59       int rows() const             { return m_rows;       }
setRows(int rows)60       void setRows(int rows)       { m_rows = rows;       }
61       /// number of lines to draw horizontally
columns()62       int columns() const          { return m_columns;    }
setColumns(int columns)63       void setColumns(int columns) { m_columns = columns; }
64 
65       /// number of secondary lines between primary ones when drawing the columns
primaryColumnsInterval()66       int primaryColumnsInterval() const           { return m_primaryColumnsInterval;     }
setPrimaryColumnsInterval(int interval)67       void setPrimaryColumnsInterval(int interval) { m_primaryColumnsInterval = interval; }
68       /// number of secondary lines between primary ones when drawing the rows
primaryRowsInterval()69       int primaryRowsInterval() const              { return m_primaryRowsInterval;        }
setPrimaryRowsInterval(int interval)70       void setPrimaryRowsInterval(int interval)    { m_primaryRowsInterval = interval;    }
71 
72       /// whether the canvas should allow negative pitches
showNegativeRows()73       bool showNegativeRows() const                   { return m_showNegativeRows;             }
setShowNegativeRows(bool showNegativeRows)74       void setShowNegativeRows(bool showNegativeRows) { m_showNegativeRows = showNegativeRows; }
75 
76    signals:
77       void canvasChanged();
78       };
79 
80 } // namespace Ms
81 #endif
82 
83