Diffstat (limited to 'noncore/multimedia/tonleiter/fretboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/tonleiter/fretboard.cpp | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/noncore/multimedia/tonleiter/fretboard.cpp b/noncore/multimedia/tonleiter/fretboard.cpp index 7936c83..7e63e01 100644 --- a/noncore/multimedia/tonleiter/fretboard.cpp +++ b/noncore/multimedia/tonleiter/fretboard.cpp | |||
@@ -54,4 +54,10 @@ void Graph::FretBoard::resizeEvent(QResizeEvent* re) | |||
54 | } | 54 | } |
55 | //**************************************************************************** | 55 | //**************************************************************************** |
56 | void Graph::FretBoard::mouseReleaseEvent(QMouseEvent* me) | ||
57 | { | ||
58 | Q_UNUSED(me); | ||
59 | emit pressed(); | ||
60 | } | ||
61 | //**************************************************************************** | ||
56 | void Graph::FretBoard::paintBoard(QPainter* p) | 62 | void Graph::FretBoard::paintBoard(QPainter* p) |
57 | { | 63 | { |
@@ -122,7 +128,5 @@ void Graph::FretBoard::paintScale(QPainter* p) | |||
122 | int scaleid=data->getCurrentScaleID(); | 128 | int scaleid=data->getCurrentScaleID(); |
123 | Scale scale=data->getScale(scaleid); | 129 | Scale scale=data->getScale(scaleid); |
124 | 130 | int baseoctave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),inst.lowestNote()); | |
125 | int colorstart=255%inst.noOfOctaves(); | ||
126 | int colorintervall=(255-colorstart)/inst.noOfOctaves(); | ||
127 | 131 | ||
128 | for(int s=0;s<inst.noOfStrings();s++) | 132 | for(int s=0;s<inst.noOfStrings();s++) |
@@ -137,11 +141,34 @@ void Graph::FretBoard::paintScale(QPainter* p) | |||
137 | int x=(int)(fretdist*f)+xmin; | 141 | int x=(int)(fretdist*f)+xmin; |
138 | 142 | ||
139 | int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note); | 143 | //no more than six octaves can be visualised (there is a zero octave) |
140 | if(octave>5) octave=5; | 144 | int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note)-baseoctave; |
145 | if(octave<0) | ||
146 | qDebug("%d,%d",octave,baseoctave); | ||
147 | if(octave>5) | ||
148 | { | ||
149 | qDebug("octave out of range"); | ||
150 | octave=5; | ||
151 | } | ||
152 | |||
141 | p->setPen(QColor(255,0,0)); | 153 | p->setPen(QColor(255,0,0)); |
142 | int c=colorstart+octave*colorintervall; | 154 | int c= ( (note-12*baseoctave) - (12*octave+data->getCurrentBaseNote()) )*15; |
143 | QColor dotcolor(c,c,255); | 155 | if(c<0 || c>255) |
144 | p->setBrush(dotcolor); | 156 | qDebug("%d = %d - ( %d + %d)",c,note,12*octave,data->getCurrentBaseNote()); |
157 | QColor dotcolor(255,255,255); | ||
158 | |||
159 | if(octave==0) | ||
160 | dotcolor=QColor(c,c,255); | ||
161 | else if(octave==1) | ||
162 | dotcolor=QColor(c,255,c); | ||
163 | else if(octave==2) | ||
164 | dotcolor=QColor(255,c,c); | ||
165 | else if(octave==3) | ||
166 | dotcolor=QColor(255,255,c); | ||
167 | else if(octave==4) | ||
168 | dotcolor=QColor(255,c,255); | ||
169 | else | ||
170 | dotcolor=QColor(c,255,255); | ||
145 | 171 | ||
172 | p->setBrush(dotcolor); | ||
146 | p->drawEllipse(x-dotsize/2,y-dotsize/2,dotsize,dotsize); | 173 | p->drawEllipse(x-dotsize/2,y-dotsize/2,dotsize,dotsize); |
147 | 174 | ||