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 | |
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
-rw-r--r-- | noncore/multimedia/tonleiter/editinst.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editinst.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/fretboard.cpp | 43 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/fretboard.h | 3 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/mainwidget.cpp | 17 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/mainwidget.h | 3 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdatahelper.cpp | 15 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdatahelper.h | 2 |
8 files changed, 77 insertions, 13 deletions
diff --git a/noncore/multimedia/tonleiter/editinst.cpp b/noncore/multimedia/tonleiter/editinst.cpp index 120c3ac..f172ef8 100644 --- a/noncore/multimedia/tonleiter/editinst.cpp +++ b/noncore/multimedia/tonleiter/editinst.cpp @@ -39,5 +39,5 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c masterlayout->addWidget(addhighButton); - QScrollView* scrollview=new QScrollView(this); + scrollview=new QScrollView(this); scrollview->setVScrollBarMode(QScrollView::AlwaysOn); scrollview->setHScrollBarMode(QScrollView::AlwaysOff); @@ -47,5 +47,4 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c scrollview->addChild(stringwidget); scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); - //scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)); masterlayout->addWidget(scrollview); @@ -93,4 +92,5 @@ void Menu::InstEditDialog::deleteString(int id) void Menu::InstEditDialog::saveInstrument() { + //auto delete is set to true so widgets _should_ be deleted stringlist.clear(); } @@ -98,5 +98,7 @@ void Menu::InstEditDialog::saveInstrument() void Menu::InstEditDialog::loadInstrument() { + stringlist.clear(); Instrument inst=data->getInstrument(instid); + qDebug("load Instrument : %d strings",inst.noOfStrings()); for(uint s=0;s<inst.noOfStrings();s++) { diff --git a/noncore/multimedia/tonleiter/editinst.h b/noncore/multimedia/tonleiter/editinst.h index 948a2de..a90c9ec 100644 --- a/noncore/multimedia/tonleiter/editinst.h +++ b/noncore/multimedia/tonleiter/editinst.h @@ -28,4 +28,5 @@ namespace Menu QSpinBox* stringBox; + QScrollView* scrollview; QVBox* stringwidget; 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) } //**************************************************************************** +void Graph::FretBoard::mouseReleaseEvent(QMouseEvent* me) +{ + Q_UNUSED(me); + emit pressed(); +} +//**************************************************************************** void Graph::FretBoard::paintBoard(QPainter* p) { @@ -122,7 +128,5 @@ void Graph::FretBoard::paintScale(QPainter* p) 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++) @@ -137,11 +141,34 @@ void Graph::FretBoard::paintScale(QPainter* p) 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); diff --git a/noncore/multimedia/tonleiter/fretboard.h b/noncore/multimedia/tonleiter/fretboard.h index 458c733..bb696fb 100644 --- a/noncore/multimedia/tonleiter/fretboard.h +++ b/noncore/multimedia/tonleiter/fretboard.h @@ -42,4 +42,6 @@ namespace Graph FretBoard(TonleiterData* data,QWidget* parent,const char* name="FretBoard",WFlags f=0); virtual ~FretBoard(); + signals: + void pressed(); private slots: void dataChange(); @@ -47,4 +49,5 @@ namespace Graph void paintEvent(QPaintEvent* pe); void resizeEvent(QResizeEvent* re); + void mouseReleaseEvent(QMouseEvent* me); void paintBoard(QPainter* p); void paintFrets(QPainter* p); diff --git a/noncore/multimedia/tonleiter/mainwidget.cpp b/noncore/multimedia/tonleiter/mainwidget.cpp index f09207b..b9c3d01 100644 --- a/noncore/multimedia/tonleiter/mainwidget.cpp +++ b/noncore/multimedia/tonleiter/mainwidget.cpp @@ -18,6 +18,9 @@ MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) fretboard=new Graph::FretBoard(data,mainwidget); + connect(fretboard,SIGNAL(pressed()),this,SLOT(fretboardPressed())); mainlayout->addWidget(fretboard); + showmenu=true; + } //**************************************************************************** @@ -26,3 +29,17 @@ MainWidget::~MainWidget() } //**************************************************************************** +void MainWidget::fretboardPressed() +{ + if(showmenu) + { + menuwidget->hide(); + showmenu=false; + } + else + { + menuwidget->show(); + showmenu=true; + } +} +//**************************************************************************** //**************************************************************************** diff --git a/noncore/multimedia/tonleiter/mainwidget.h b/noncore/multimedia/tonleiter/mainwidget.h index 9bb593c..5c0a1f8 100644 --- a/noncore/multimedia/tonleiter/mainwidget.h +++ b/noncore/multimedia/tonleiter/mainwidget.h @@ -15,7 +15,10 @@ private: Menu::MenuWidget* menuwidget; Graph::FretBoard* fretboard; + bool showmenu; public: MainWidget(QWidget* parent=0,const char* name="MainWidget",WFlags f=0); virtual ~MainWidget(); +private slots: + void fretboardPressed(); }; diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp index 156dba5..d904a71 100644 --- a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp @@ -77,7 +77,16 @@ int Instrument::string(int id) int Instrument::noOfOctaves() { - int lowest=strings[0]; - int highest=strings[strings.count()-1]+frets; - return (int) ceil((highest-lowest)/12.0); + return (int) ceil((highestNote()-lowestNote())/12.0); +} +//**************************************************************************** +int Instrument::lowestNote() +{ + return strings[0]; + +} +//**************************************************************************** +int Instrument::highestNote() +{ + return strings[strings.count()-1]+frets; } //**************************************************************************** diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.h b/noncore/multimedia/tonleiter/tonleiterdatahelper.h index e4153d7..061c781 100644 --- a/noncore/multimedia/tonleiter/tonleiterdatahelper.h +++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.h @@ -33,4 +33,6 @@ namespace Data int string(int id); int noOfOctaves(); + int lowestNote(); + int highestNote(); }; |