author | waspe <waspe> | 2004-01-24 13:44:29 (UTC) |
---|---|---|
committer | waspe <waspe> | 2004-01-24 13:44:29 (UTC) |
commit | 5f333c6832ff429a00498e6a36be950525541a2a (patch) (side-by-side diff) | |
tree | 035616d3cc11622f6d9b14245372362620327a46 /noncore/multimedia/tonleiter/fretboard.cpp | |
parent | d542ba6a426f9868d521dbd9eb502184086535fc (diff) | |
download | opie-5f333c6832ff429a00498e6a36be950525541a2a.zip opie-5f333c6832ff429a00498e6a36be950525541a2a.tar.gz opie-5f333c6832ff429a00498e6a36be950525541a2a.tar.bz2 |
new color scheme on fretboard, maekes each ocatave appear in different color
Diffstat (limited to 'noncore/multimedia/tonleiter/fretboard.cpp') (more/less context) (ignore 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 @@ -48,16 +48,22 @@ void Graph::FretBoard::paintEvent(QPaintEvent* pe) paintScale(&p); } //**************************************************************************** void Graph::FretBoard::resizeEvent(QResizeEvent* re) { Q_UNUSED(re); } //**************************************************************************** +void Graph::FretBoard::mouseReleaseEvent(QMouseEvent* me) +{ + Q_UNUSED(me); + emit pressed(); +} +//**************************************************************************** void Graph::FretBoard::paintBoard(QPainter* p) { //debug QColor bgc=QColor(142,138,120); p->setPen(QPen(bgc,5)); p->setBrush(QBrush(bgc)); p->drawRect(xmin,ymin,xwidth,yheight); @@ -116,38 +122,59 @@ void Graph::FretBoard::paintStrings(QPainter* p) } } //**************************************************************************** void Graph::FretBoard::paintScale(QPainter* p) { int dotsize=10; int scaleid=data->getCurrentScaleID(); Scale scale=data->getScale(scaleid); - - int colorstart=255%inst.noOfOctaves(); - int colorintervall=(255-colorstart)/inst.noOfOctaves(); + int baseoctave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),inst.lowestNote()); for(int s=0;s<inst.noOfStrings();s++) { int y=(int)(stringdist*s)+ymin; int stingid=inst.noOfStrings()-(s+1); for(int f=0;f<=inst.noOfFrets();f++) { int note=inst.string(stingid)+f; if(scale.noteInScale(data->getCurrentBaseNote(),note)) { int x=(int)(fretdist*f)+xmin; - int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note); - if(octave>5) octave=5; + //no more than six octaves can be visualised (there is a zero octave) + int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note)-baseoctave; + if(octave<0) + qDebug("%d,%d",octave,baseoctave); + if(octave>5) + { + qDebug("octave out of range"); + octave=5; + } + p->setPen(QColor(255,0,0)); - int c=colorstart+octave*colorintervall; - QColor dotcolor(c,c,255); - p->setBrush(dotcolor); + int c= ( (note-12*baseoctave) - (12*octave+data->getCurrentBaseNote()) )*15; + if(c<0 || c>255) + qDebug("%d = %d - ( %d + %d)",c,note,12*octave,data->getCurrentBaseNote()); + QColor dotcolor(255,255,255); + + if(octave==0) + dotcolor=QColor(c,c,255); + else if(octave==1) + dotcolor=QColor(c,255,c); + else if(octave==2) + dotcolor=QColor(255,c,c); + else if(octave==3) + dotcolor=QColor(255,255,c); + else if(octave==4) + dotcolor=QColor(255,c,255); + else + dotcolor=QColor(c,255,255); + p->setBrush(dotcolor); p->drawEllipse(x-dotsize/2,y-dotsize/2,dotsize,dotsize); if(data->isDrawNames()) { p->setPen(QColor(255,155,0)); p->drawText(x-dotsize/2,y-dotsize/2,Note::getNameOfNote(note)); } |