File: Draw.h

package info (click to toggle)
pianobooster 0.6.7~svn156-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 2,796 kB
  • ctags: 1,930
  • sloc: cpp: 11,738; makefile: 66; ansic: 26
file content (120 lines) | stat: -rw-r--r-- 3,443 bytes parent folder | download
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
/*********************************************************************************/
/*!
@file           Draw.h

@brief          .

@author         L. J. Barman

    Copyright (c)   2008-2009, L. J. Barman, all rights reserved

    This file is part of the PianoBooster application

    PianoBooster is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    PianoBooster is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PianoBooster.  If not, see <http://www.gnu.org/licenses/>.

*/
/*********************************************************************************/
#ifndef __DRAW_H__
#define __DRAW_H__

#ifdef __APPLE__
  #include <OpenGL/gl.h>
  #include <OpenGL/glu.h>
#else
  #include <GL/gl.h>
  #include <GL/glu.h>
#endif

#define HORIZONTAL_SPACING_FACTOR   (0.75) // defines the speed of the scrolling


#include "StavePosition.h"

#include "Symbol.h"


class CSettings;
class CSlot;

class CScrollProperties
{
public:
    CScrollProperties()
    {
        m_horizontal = false;
    }
    bool horizontal() { return m_horizontal; }
private:
    bool m_horizontal;

};

class CDraw
{
public:
    CDraw(CSettings* settings)
    {
        m_settings = settings;
        m_displayHand = PB_PART_both;
        m_forceCompileRedraw = 1;
        m_scrollProperties = &m_scrollPropertiesHorizontal;

    }

    void scrollVertex(float x, float y)
    {
        if (m_scrollProperties->horizontal())
            glVertex2f (x,y);
        else
            glVertex2f (y,x);
    }

    void drawSymbol(CSymbol symbol, float x, float y, CSlot* slot = 0);
    void drawSymbol(CSymbol symbol, float x);
    void drawSlot(CSlot* slot);

    static void setDisplayHand(whichPart_t hand)
    {
        m_displayHand = hand;
        m_forceCompileRedraw = 1;
    }
    static whichPart_t getDisplayHand()    {return m_displayHand;}
    static void drColour(CColour colour) { glColor3f(colour.red, colour.green, colour.blue);}
    static void forceCompileRedraw(int value = 1) {    m_forceCompileRedraw = value; }

protected:
    static whichPart_t m_displayHand;
    static int getCompileRedrawCount() {  return m_forceCompileRedraw; }

    void oneLine(float x1, float y1, float x2, float y2);
    void drawStaves(float startX, float endX);
    void drawKeySignature(int key);
    void drawNoteName(int midiNote, float x, float y, int type);
    CSettings* m_settings;

private:
    void drawStaveNoteName(CSymbol symbol, float x, float y);
    bool drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColour colour, bool playable);

    void checkAccidental(CSymbol symbol, float x, float y);
    void drawStaveExtentsion(CSymbol symbol, float x, int noteWidth, bool playable);
    static int m_forceCompileRedraw;
    const static int m_beatMarkerHeight = 10; // The height of the beat markers in the stave positions

    CScrollProperties *m_scrollProperties;
    CScrollProperties m_scrollPropertiesHorizontal;
    CScrollProperties m_scrollPropertiesVertical;
};

#endif //__DRAW_H__