summaryrefslogtreecommitdiff
authorwaspe <waspe>2004-01-24 13:44:29 (UTC)
committer waspe <waspe>2004-01-24 13:44:29 (UTC)
commit5f333c6832ff429a00498e6a36be950525541a2a (patch) (unidiff)
tree035616d3cc11622f6d9b14245372362620327a46
parentd542ba6a426f9868d521dbd9eb502184086535fc (diff)
downloadopie-5f333c6832ff429a00498e6a36be950525541a2a.zip
opie-5f333c6832ff429a00498e6a36be950525541a2a.tar.gz
opie-5f333c6832ff429a00498e6a36be950525541a2a.tar.bz2
new color scheme on fretboard, maekes each ocatave appear in different color
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/tonleiter/editinst.cpp6
-rw-r--r--noncore/multimedia/tonleiter/editinst.h1
-rw-r--r--noncore/multimedia/tonleiter/fretboard.cpp43
-rw-r--r--noncore/multimedia/tonleiter/fretboard.h3
-rw-r--r--noncore/multimedia/tonleiter/mainwidget.cpp17
-rw-r--r--noncore/multimedia/tonleiter/mainwidget.h3
-rw-r--r--noncore/multimedia/tonleiter/tonleiterdatahelper.cpp15
-rw-r--r--noncore/multimedia/tonleiter/tonleiterdatahelper.h2
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
@@ -17,91 +17,93 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c
17 boxInst=new QComboBox(this,"boxInst"); 17 boxInst=new QComboBox(this,"boxInst");
18 boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); 18 boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum));
19 connect(boxInst,SIGNAL(activated(int)),this,SLOT(setCurrentInstrumetID(int))); 19 connect(boxInst,SIGNAL(activated(int)),this,SLOT(setCurrentInstrumetID(int)));
20 for(int i=0;i<data->noOfInstruments();i++) 20 for(int i=0;i<data->noOfInstruments();i++)
21 { 21 {
22 Instrument inst=data->getInstrument(i); 22 Instrument inst=data->getInstrument(i);
23 QString name=inst.instName(); 23 QString name=inst.instName();
24 if(name.isNull()) continue; 24 if(name.isNull()) continue;
25 boxInst->insertItem(name,i); 25 boxInst->insertItem(name,i);
26 } 26 }
27 boxInst->setCurrentItem(instid); 27 boxInst->setCurrentItem(instid);
28 toplayout->addWidget(boxInst); 28 toplayout->addWidget(boxInst);
29 29
30 QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton"); 30 QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton");
31 connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument())); 31 connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument()));
32 toplayout->addWidget(addButton); 32 toplayout->addWidget(addButton);
33 33
34 QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton"); 34 QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton");
35 connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument())); 35 connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument()));
36 toplayout->addWidget(delButton); 36 toplayout->addWidget(delButton);
37 37
38 QPushButton* addhighButton=new QPushButton(tr("Add High String"),this,"addhighButton"); 38 QPushButton* addhighButton=new QPushButton(tr("Add High String"),this,"addhighButton");
39 masterlayout->addWidget(addhighButton); 39 masterlayout->addWidget(addhighButton);
40 40
41 QScrollView* scrollview=new QScrollView(this); 41 scrollview=new QScrollView(this);
42 scrollview->setVScrollBarMode(QScrollView::AlwaysOn); 42 scrollview->setVScrollBarMode(QScrollView::AlwaysOn);
43 scrollview->setHScrollBarMode(QScrollView::AlwaysOff); 43 scrollview->setHScrollBarMode(QScrollView::AlwaysOff);
44 stringwidget=new QVBox(scrollview->viewport()); 44 stringwidget=new QVBox(scrollview->viewport());
45 stringwidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); 45 stringwidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
46 stringwidget->setSpacing(10); 46 stringwidget->setSpacing(10);
47 scrollview->addChild(stringwidget); 47 scrollview->addChild(stringwidget);
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);
51 50
52 loadInstrument(); 51 loadInstrument();
53 52
54 QPushButton* addlowButton=new QPushButton(tr("Add Low String"),this,"addlowButton"); 53 QPushButton* addlowButton=new QPushButton(tr("Add Low String"),this,"addlowButton");
55 masterlayout->addWidget(addlowButton); 54 masterlayout->addWidget(addlowButton);
56 55
57 //make dialog fit the screen 56 //make dialog fit the screen
58 showMaximized(); 57 showMaximized();
59} 58}
60//**************************************************************************** 59//****************************************************************************
61Menu::InstEditDialog::~InstEditDialog() 60Menu::InstEditDialog::~InstEditDialog()
62{ 61{
63} 62}
64//**************************************************************************** 63//****************************************************************************
65void Menu::InstEditDialog::setCurrentInstrumetID(int id) 64void Menu::InstEditDialog::setCurrentInstrumetID(int id)
66{ 65{
67 saveInstrument(); 66 saveInstrument();
68 instid=id; 67 instid=id;
69 data->setCurrentInstrumetID(id); 68 data->setCurrentInstrumetID(id);
70 loadInstrument(); 69 loadInstrument();
71} 70}
72//**************************************************************************** 71//****************************************************************************
73void Menu::InstEditDialog::addInstrument() 72void Menu::InstEditDialog::addInstrument()
74{ 73{
75} 74}
76//**************************************************************************** 75//****************************************************************************
77void Menu::InstEditDialog::deleteInstrument() 76void Menu::InstEditDialog::deleteInstrument()
78{ 77{
79} 78}
80//**************************************************************************** 79//****************************************************************************
81void Menu::InstEditDialog::addLowString() 80void Menu::InstEditDialog::addLowString()
82{ 81{
83} 82}
84//**************************************************************************** 83//****************************************************************************
85void Menu::InstEditDialog::addHighString() 84void Menu::InstEditDialog::addHighString()
86{ 85{
87} 86}
88//**************************************************************************** 87//****************************************************************************
89void Menu::InstEditDialog::deleteString(int id) 88void Menu::InstEditDialog::deleteString(int id)
90{ 89{
91} 90}
92//**************************************************************************** 91//****************************************************************************
93void Menu::InstEditDialog::saveInstrument() 92void Menu::InstEditDialog::saveInstrument()
94{ 93{
94 //auto delete is set to true so widgets _should_ be deleted
95 stringlist.clear(); 95 stringlist.clear();
96} 96}
97//**************************************************************************** 97//****************************************************************************
98void Menu::InstEditDialog::loadInstrument() 98void 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++)
102 { 104 {
103 stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); 105 stringlist.append(new EditStringWidget(inst.string(s),stringwidget));
104 } 106 }
105} 107}
106//**************************************************************************** 108//****************************************************************************
107//**************************************************************************** 109//****************************************************************************
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
@@ -6,47 +6,48 @@
6#include <qscrollview.h> 6#include <qscrollview.h>
7#include <qspinbox.h> 7#include <qspinbox.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qlist.h> 9#include <qlist.h>
10#include <qvbox.h> 10#include <qvbox.h>
11 11
12 12
13#include "editstringwidget.h" 13#include "editstringwidget.h"
14 14
15using namespace Data; 15using namespace Data;
16 16
17 17
18namespace Menu 18namespace Menu
19{ 19{
20 class InstEditDialog : public QDialog 20 class InstEditDialog : public QDialog
21 { 21 {
22 Q_OBJECT 22 Q_OBJECT
23 private: 23 private:
24 TonleiterData* data; 24 TonleiterData* data;
25 int instid; 25 int instid;
26 26
27 QComboBox* boxInst; 27 QComboBox* boxInst;
28 QSpinBox* stringBox; 28 QSpinBox* stringBox;
29 29
30 QScrollView* scrollview;
30 QVBox* stringwidget; 31 QVBox* stringwidget;
31 32
32 //this is a QPtrList !! 33 //this is a QPtrList !!
33 typedef QList<EditStringWidget> StringWidgetList; 34 typedef QList<EditStringWidget> StringWidgetList;
34 StringWidgetList stringlist; 35 StringWidgetList stringlist;
35 public: 36 public:
36 InstEditDialog(TonleiterData* data,QWidget* parent,const char* name="InstEditDialog"); 37 InstEditDialog(TonleiterData* data,QWidget* parent,const char* name="InstEditDialog");
37 ~InstEditDialog(); 38 ~InstEditDialog();
38 private slots: 39 private slots:
39 void setCurrentInstrumetID(int id); 40 void setCurrentInstrumetID(int id);
40 void addInstrument(); 41 void addInstrument();
41 void deleteInstrument(); 42 void deleteInstrument();
42 43
43 void addLowString(); 44 void addLowString();
44 void addHighString(); 45 void addHighString();
45 void deleteString(int id); 46 void deleteString(int id);
46 private: 47 private:
47 void saveInstrument(); 48 void saveInstrument();
48 void loadInstrument(); 49 void loadInstrument();
49 }; 50 };
50}; 51};
51 52
52#endif //TONLEITER_EDIT_INSTRUMENT_DIALOG_H 53#endif //TONLEITER_EDIT_INSTRUMENT_DIALOG_H
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
@@ -32,48 +32,54 @@ void Graph::FretBoard::paintEvent(QPaintEvent* pe)
32 QRect mysize=rect(); 32 QRect mysize=rect();
33 33
34 xmargin=(int)(mysize.width()*0.05); 34 xmargin=(int)(mysize.width()*0.05);
35 xmin=2*xmargin; 35 xmin=2*xmargin;
36 xmax=mysize.width()-xmargin; 36 xmax=mysize.width()-xmargin;
37 xwidth=xmax-xmin; 37 xwidth=xmax-xmin;
38 38
39 ymargin=(int)(mysize.height()*0.1); 39 ymargin=(int)(mysize.height()*0.1);
40 ymin=ymargin; 40 ymin=ymargin;
41 ymax=mysize.height()-2*ymargin; 41 ymax=mysize.height()-2*ymargin;
42 yheight=ymax-ymin; 42 yheight=ymax-ymin;
43 43
44 QPainter p(this); 44 QPainter p(this);
45 paintBoard(&p); 45 paintBoard(&p);
46 paintFrets(&p); 46 paintFrets(&p);
47 paintStrings(&p); 47 paintStrings(&p);
48 paintScale(&p); 48 paintScale(&p);
49} 49}
50//**************************************************************************** 50//****************************************************************************
51void Graph::FretBoard::resizeEvent(QResizeEvent* re) 51void Graph::FretBoard::resizeEvent(QResizeEvent* re)
52{ 52{
53 Q_UNUSED(re); 53 Q_UNUSED(re);
54} 54}
55//**************************************************************************** 55//****************************************************************************
56void Graph::FretBoard::mouseReleaseEvent(QMouseEvent* me)
57{
58 Q_UNUSED(me);
59 emit pressed();
60}
61//****************************************************************************
56void Graph::FretBoard::paintBoard(QPainter* p) 62void Graph::FretBoard::paintBoard(QPainter* p)
57{ 63{
58 //debug 64 //debug
59 QColor bgc=QColor(142,138,120); 65 QColor bgc=QColor(142,138,120);
60 p->setPen(QPen(bgc,5)); 66 p->setPen(QPen(bgc,5));
61 p->setBrush(QBrush(bgc)); 67 p->setBrush(QBrush(bgc));
62 p->drawRect(xmin,ymin,xwidth,yheight); 68 p->drawRect(xmin,ymin,xwidth,yheight);
63 69
64} 70}
65//**************************************************************************** 71//****************************************************************************
66void Graph::FretBoard::paintFrets(QPainter* p) 72void Graph::FretBoard::paintFrets(QPainter* p)
67{ 73{
68 //draw frets 74 //draw frets
69 p->setPen(fretpen); 75 p->setPen(fretpen);
70 p->setBrush(markerbrush); 76 p->setBrush(markerbrush);
71 fretdist=(double)(xwidth)/(double)(inst.noOfFrets()); 77 fretdist=(double)(xwidth)/(double)(inst.noOfFrets());
72 78
73 int markerwidth = (int)(fretdist/4.0); 79 int markerwidth = (int)(fretdist/4.0);
74 if(markerwidth>5) 80 if(markerwidth>5)
75 markerwidth=5; 81 markerwidth=5;
76 else if(markerwidth<2) 82 else if(markerwidth<2)
77 markerwidth=2; 83 markerwidth=2;
78 84
79 for(int f=0;f<=inst.noOfFrets();f++) 85 for(int f=0;f<=inst.noOfFrets();f++)
@@ -100,60 +106,81 @@ void Graph::FretBoard::paintFrets(QPainter* p)
100} 106}
101//**************************************************************************** 107//****************************************************************************
102void Graph::FretBoard::paintStrings(QPainter* p) 108void Graph::FretBoard::paintStrings(QPainter* p)
103{ 109{
104 //draw strings 110 //draw strings
105 p->setPen(stringpen); 111 p->setPen(stringpen);
106 112
107 stringdist=(double)(yheight)/(double)(inst.noOfStrings()-1); 113 stringdist=(double)(yheight)/(double)(inst.noOfStrings()-1);
108 for(int s=0;s<inst.noOfStrings();s++) 114 for(int s=0;s<inst.noOfStrings();s++)
109 { 115 {
110 int stringpos=(int)(stringdist*s); 116 int stringpos=(int)(stringdist*s);
111 p->drawLine(xmin,stringpos+ymin,xmax,stringpos+ymin); 117 p->drawLine(xmin,stringpos+ymin,xmax,stringpos+ymin);
112 118
113 int stinglabelid=inst.noOfStrings()-(s+1); 119 int stinglabelid=inst.noOfStrings()-(s+1);
114 QString label=Note::getNameOfNote(inst.string(stinglabelid)); 120 QString label=Note::getNameOfNote(inst.string(stinglabelid));
115 p->drawText(xmargin/2,stringpos+ymin,label); 121 p->drawText(xmargin/2,stringpos+ymin,label);
116 } 122 }
117} 123}
118//**************************************************************************** 124//****************************************************************************
119void Graph::FretBoard::paintScale(QPainter* p) 125void Graph::FretBoard::paintScale(QPainter* p)
120{ 126{
121 int dotsize=10; 127 int dotsize=10;
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++)
129 { 133 {
130 int y=(int)(stringdist*s)+ymin; 134 int y=(int)(stringdist*s)+ymin;
131 int stingid=inst.noOfStrings()-(s+1); 135 int stingid=inst.noOfStrings()-(s+1);
132 for(int f=0;f<=inst.noOfFrets();f++) 136 for(int f=0;f<=inst.noOfFrets();f++)
133 { 137 {
134 int note=inst.string(stingid)+f; 138 int note=inst.string(stingid)+f;
135 if(scale.noteInScale(data->getCurrentBaseNote(),note)) 139 if(scale.noteInScale(data->getCurrentBaseNote(),note))
136 { 140 {
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
148 if(data->isDrawNames()) 175 if(data->isDrawNames())
149 { 176 {
150 p->setPen(QColor(255,155,0)); 177 p->setPen(QColor(255,155,0));
151 p->drawText(x-dotsize/2,y-dotsize/2,Note::getNameOfNote(note)); 178 p->drawText(x-dotsize/2,y-dotsize/2,Note::getNameOfNote(note));
152 } 179 }
153 180
154 } 181 }
155 } 182 }
156 } 183 }
157} 184}
158//**************************************************************************** 185//****************************************************************************
159//**************************************************************************** 186//****************************************************************************
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
@@ -20,37 +20,40 @@ namespace Graph
20 TonleiterData* data; 20 TonleiterData* data;
21 21
22 QPen fretpen; 22 QPen fretpen;
23 QBrush markerbrush; 23 QBrush markerbrush;
24 QPen stringpen; 24 QPen stringpen;
25 25
26 Instrument inst; 26 Instrument inst;
27 27
28 int xmargin; 28 int xmargin;
29 int xmin; 29 int xmin;
30 int xmax; 30 int xmax;
31 int xwidth; 31 int xwidth;
32 32
33 int ymargin; 33 int ymargin;
34 int ymin; 34 int ymin;
35 int ymax; 35 int ymax;
36 int yheight; 36 int yheight;
37 37
38 double fretdist; 38 double fretdist;
39 double stringdist; 39 double stringdist;
40 40
41 public: 41 public:
42 FretBoard(TonleiterData* data,QWidget* parent,const char* name="FretBoard",WFlags f=0); 42 FretBoard(TonleiterData* data,QWidget* parent,const char* name="FretBoard",WFlags f=0);
43 virtual ~FretBoard(); 43 virtual ~FretBoard();
44 signals:
45 void pressed();
44 private slots: 46 private slots:
45 void dataChange(); 47 void dataChange();
46 private: 48 private:
47 void paintEvent(QPaintEvent* pe); 49 void paintEvent(QPaintEvent* pe);
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);
50 void paintFrets(QPainter* p); 53 void paintFrets(QPainter* p);
51 void paintStrings(QPainter* p); 54 void paintStrings(QPainter* p);
52 void paintScale(QPainter* p); 55 void paintScale(QPainter* p);
53 }; 56 };
54}; 57};
55 58
56#endif //TONLEITER_FRET_BOARD_H 59#endif //TONLEITER_FRET_BOARD_H
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
@@ -1,28 +1,45 @@
1#include "mainwidget.h" 1#include "mainwidget.h"
2 2
3#include <qwidget.h> 3#include <qwidget.h>
4#include <qlayout.h> 4#include <qlayout.h>
5 5
6MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) 6MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f)
7:QMainWindow(parent,name,f) 7:QMainWindow(parent,name,f)
8{ 8{
9 setCaption("Tonleiter"); 9 setCaption("Tonleiter");
10 data=new Data::TonleiterData(this); 10 data=new Data::TonleiterData(this);
11 11
12 QWidget* mainwidget=new QWidget(this,"mainwidget"); 12 QWidget* mainwidget=new QWidget(this,"mainwidget");
13 setCentralWidget(mainwidget); 13 setCentralWidget(mainwidget);
14 QBoxLayout* mainlayout=new QBoxLayout(mainwidget,QBoxLayout::TopToBottom); 14 QBoxLayout* mainlayout=new QBoxLayout(mainwidget,QBoxLayout::TopToBottom);
15 15
16 menuwidget=new Menu::MenuWidget(data,mainwidget); 16 menuwidget=new Menu::MenuWidget(data,mainwidget);
17 mainlayout->addWidget(menuwidget); 17 mainlayout->addWidget(menuwidget);
18 18
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}
23//**************************************************************************** 26//****************************************************************************
24MainWidget::~MainWidget() 27MainWidget::~MainWidget()
25{ 28{
26} 29}
27//**************************************************************************** 30//****************************************************************************
31void 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
@@ -1,22 +1,25 @@
1#ifndef TONLEITER_MAINWIDGET_H 1#ifndef TONLEITER_MAINWIDGET_H
2#define TONLEITER_MAINWIDGET_H 2#define TONLEITER_MAINWIDGET_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5 5
6#include "fretboard.h" 6#include "fretboard.h"
7#include "menuwidget.h" 7#include "menuwidget.h"
8#include "tonleiterdata.h" 8#include "tonleiterdata.h"
9 9
10class MainWidget : public QMainWindow 10class MainWidget : public QMainWindow
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13private: 13private:
14 Data::TonleiterData* data; 14 Data::TonleiterData* data;
15 Menu::MenuWidget* menuwidget; 15 Menu::MenuWidget* menuwidget;
16 Graph::FretBoard* fretboard; 16 Graph::FretBoard* fretboard;
17 bool showmenu;
17public: 18public:
18 MainWidget(QWidget* parent=0,const char* name="MainWidget",WFlags f=0); 19 MainWidget(QWidget* parent=0,const char* name="MainWidget",WFlags f=0);
19 virtual ~MainWidget(); 20 virtual ~MainWidget();
21private slots:
22 void fretboardPressed();
20}; 23};
21 24
22#endif //TONLEITER_MAINWIDGET_H 25#endif //TONLEITER_MAINWIDGET_H
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
@@ -55,51 +55,60 @@ Instrument::~Instrument()
55} 55}
56//**************************************************************************** 56//****************************************************************************
57int Instrument::noOfStrings() 57int Instrument::noOfStrings()
58{ 58{
59 return (int)strings.count(); 59 return (int)strings.count();
60} 60}
61//**************************************************************************** 61//****************************************************************************
62int Instrument::noOfFrets() 62int Instrument::noOfFrets()
63{ 63{
64 return frets; 64 return frets;
65} 65}
66//**************************************************************************** 66//****************************************************************************
67QString Instrument::instName() 67QString Instrument::instName()
68{ 68{
69 return name; 69 return name;
70} 70}
71//**************************************************************************** 71//****************************************************************************
72int Instrument::string(int id) 72int Instrument::string(int id)
73{ 73{
74 return strings[id]; 74 return strings[id];
75} 75}
76//**************************************************************************** 76//****************************************************************************
77int Instrument::noOfOctaves() 77int 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//****************************************************************************
82int Instrument::lowestNote()
83{
84 return strings[0];
85
86}
87//****************************************************************************
88int Instrument::highestNote()
89{
90 return strings[strings.count()-1]+frets;
82} 91}
83//**************************************************************************** 92//****************************************************************************
84//**************************************************************************** 93//****************************************************************************
85Scale::Scale() 94Scale::Scale()
86{ 95{
87 name="UNDEFINED"; 96 name="UNDEFINED";
88} 97}
89//**************************************************************************** 98//****************************************************************************
90Scale::Scale(QString name,QValueList<int> halftones) 99Scale::Scale(QString name,QValueList<int> halftones)
91:name(name),halftones(halftones) 100:name(name),halftones(halftones)
92{ 101{
93} 102}
94//**************************************************************************** 103//****************************************************************************
95Scale::~Scale() 104Scale::~Scale()
96{ 105{
97} 106}
98//**************************************************************************** 107//****************************************************************************
99int Scale::noOfHaltones() 108int Scale::noOfHaltones()
100{ 109{
101 return (int)halftones.count(); 110 return (int)halftones.count();
102} 111}
103//**************************************************************************** 112//****************************************************************************
104int Scale::getHalfTone(int id) 113int Scale::getHalfTone(int id)
105{ 114{
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
@@ -11,45 +11,47 @@ namespace Data
11 const QString notenames[]={"A","Bb","B","C","C#","D","D#","E","F","F#","G","G#"}; 11 const QString notenames[]={"A","Bb","B","C","C#","D","D#","E","F","F#","G","G#"};
12 12
13 int getOctaveOfNote(int note); 13 int getOctaveOfNote(int note);
14 QString getNameOfNote(int note); 14 QString getNameOfNote(int note);
15 int getNoteFromName(QString name,int octave); 15 int getNoteFromName(QString name,int octave);
16 int octaveOfBaseNote(int base,int note); 16 int octaveOfBaseNote(int base,int note);
17 }; 17 };
18 18
19 class Instrument 19 class Instrument
20 { 20 {
21 private: 21 private:
22 QString name; 22 QString name;
23 int frets; 23 int frets;
24 QValueList<int> strings; 24 QValueList<int> strings;
25 public: 25 public:
26 Instrument(); 26 Instrument();
27 Instrument(QString name,int frets,QValueList<int> strings); 27 Instrument(QString name,int frets,QValueList<int> strings);
28 ~Instrument(); 28 ~Instrument();
29 public: 29 public:
30 int noOfStrings(); 30 int noOfStrings();
31 int noOfFrets(); 31 int noOfFrets();
32 QString instName(); 32 QString instName();
33 int string(int id); 33 int string(int id);
34 int noOfOctaves(); 34 int noOfOctaves();
35 int lowestNote();
36 int highestNote();
35 }; 37 };
36 38
37 class Scale 39 class Scale
38 { 40 {
39 private: 41 private:
40 QValueList<int> halftones; 42 QValueList<int> halftones;
41 QString name; 43 QString name;
42 public: 44 public:
43 Scale(); 45 Scale();
44 Scale(QString name,QValueList<int> halftones); 46 Scale(QString name,QValueList<int> halftones);
45 ~Scale(); 47 ~Scale();
46 public: 48 public:
47 int noOfHaltones(); 49 int noOfHaltones();
48 int getHalfTone(int id); 50 int getHalfTone(int id);
49 QString scaleName(); 51 QString scaleName();
50 bool noteInScale(int base,int note); 52 bool noteInScale(int base,int note);
51 }; 53 };
52}; 54};
53 55
54#endif //TONLEITER_DATA_HELPER_H 56#endif //TONLEITER_DATA_HELPER_H
55 57