author | waspe <waspe> | 2004-01-24 13:44:29 (UTC) |
---|---|---|
committer | waspe <waspe> | 2004-01-24 13:44:29 (UTC) |
commit | 5f333c6832ff429a00498e6a36be950525541a2a (patch) (unidiff) | |
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 | |||
@@ -40,3 +40,3 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c | |||
40 | 40 | ||
41 | QScrollView* scrollview=new QScrollView(this); | 41 | scrollview=new QScrollView(this); |
42 | scrollview->setVScrollBarMode(QScrollView::AlwaysOn); | 42 | scrollview->setVScrollBarMode(QScrollView::AlwaysOn); |
@@ -48,3 +48,2 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c | |||
48 | scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 48 | scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
49 | //scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)); | ||
50 | masterlayout->addWidget(scrollview); | 49 | masterlayout->addWidget(scrollview); |
@@ -94,2 +93,3 @@ void Menu::InstEditDialog::saveInstrument() | |||
94 | { | 93 | { |
94 | //auto delete is set to true so widgets _should_ be deleted | ||
95 | stringlist.clear(); | 95 | stringlist.clear(); |
@@ -99,3 +99,5 @@ void Menu::InstEditDialog::loadInstrument() | |||
99 | { | 99 | { |
100 | stringlist.clear(); | ||
100 | Instrument inst=data->getInstrument(instid); | 101 | Instrument inst=data->getInstrument(instid); |
102 | qDebug("load Instrument : %d strings",inst.noOfStrings()); | ||
101 | for(uint s=0;s<inst.noOfStrings();s++) | 103 | 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 | |||
@@ -29,2 +29,3 @@ namespace Menu | |||
29 | 29 | ||
30 | QScrollView* scrollview; | ||
30 | QVBox* stringwidget; | 31 | 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 | |||
@@ -55,2 +55,8 @@ void Graph::FretBoard::resizeEvent(QResizeEvent* re) | |||
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) |
@@ -123,5 +129,3 @@ void Graph::FretBoard::paintScale(QPainter* p) | |||
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 | ||
@@ -138,9 +142,32 @@ void Graph::FretBoard::paintScale(QPainter* p) | |||
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); |
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 | |||
@@ -43,2 +43,4 @@ namespace Graph | |||
43 | virtual ~FretBoard(); | 43 | virtual ~FretBoard(); |
44 | signals: | ||
45 | void pressed(); | ||
44 | private slots: | 46 | private slots: |
@@ -48,2 +50,3 @@ namespace Graph | |||
48 | void resizeEvent(QResizeEvent* re); | 50 | void resizeEvent(QResizeEvent* re); |
51 | void mouseReleaseEvent(QMouseEvent* me); | ||
49 | void paintBoard(QPainter* p); | 52 | void paintBoard(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 | |||
@@ -19,4 +19,7 @@ MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) | |||
19 | fretboard=new Graph::FretBoard(data,mainwidget); | 19 | fretboard=new Graph::FretBoard(data,mainwidget); |
20 | connect(fretboard,SIGNAL(pressed()),this,SLOT(fretboardPressed())); | ||
20 | mainlayout->addWidget(fretboard); | 21 | mainlayout->addWidget(fretboard); |
21 | 22 | ||
23 | showmenu=true; | ||
24 | |||
22 | } | 25 | } |
@@ -27,2 +30,16 @@ MainWidget::~MainWidget() | |||
27 | //**************************************************************************** | 30 | //**************************************************************************** |
31 | void MainWidget::fretboardPressed() | ||
32 | { | ||
33 | if(showmenu) | ||
34 | { | ||
35 | menuwidget->hide(); | ||
36 | showmenu=false; | ||
37 | } | ||
38 | else | ||
39 | { | ||
40 | menuwidget->show(); | ||
41 | showmenu=true; | ||
42 | } | ||
43 | } | ||
44 | //**************************************************************************** | ||
28 | //**************************************************************************** | 45 | //**************************************************************************** |
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 | |||
@@ -16,2 +16,3 @@ private: | |||
16 | Graph::FretBoard* fretboard; | 16 | Graph::FretBoard* fretboard; |
17 | bool showmenu; | ||
17 | public: | 18 | public: |
@@ -19,2 +20,4 @@ public: | |||
19 | virtual ~MainWidget(); | 20 | virtual ~MainWidget(); |
21 | private slots: | ||
22 | void fretboardPressed(); | ||
20 | }; | 23 | }; |
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 | |||
@@ -78,5 +78,14 @@ int Instrument::noOfOctaves() | |||
78 | { | 78 | { |
79 | int lowest=strings[0]; | 79 | return (int) ceil((highestNote()-lowestNote())/12.0); |
80 | int highest=strings[strings.count()-1]+frets; | 80 | } |
81 | return (int) ceil((highest-lowest)/12.0); | 81 | //**************************************************************************** |
82 | int Instrument::lowestNote() | ||
83 | { | ||
84 | return strings[0]; | ||
85 | |||
86 | } | ||
87 | //**************************************************************************** | ||
88 | int Instrument::highestNote() | ||
89 | { | ||
90 | return strings[strings.count()-1]+frets; | ||
82 | } | 91 | } |
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 | |||
@@ -34,2 +34,4 @@ namespace Data | |||
34 | int noOfOctaves(); | 34 | int noOfOctaves(); |
35 | int lowestNote(); | ||
36 | int highestNote(); | ||
35 | }; | 37 | }; |