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
@@ -33,25 +33,24 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c
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
@@ -87,21 +86,24 @@ void Menu::InstEditDialog::addHighString()
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
@@ -22,16 +22,17 @@ namespace Menu
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();
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)
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
@@ -116,38 +122,59 @@ void Graph::FretBoard::paintStrings(QPainter* p)
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
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
@@ -36,21 +36,24 @@ namespace Graph
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
@@ -12,17 +12,34 @@ MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f)
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
@@ -9,14 +9,17 @@
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
@@ -71,19 +71,28 @@ QString Instrument::instName()
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//****************************************************************************
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
@@ -27,16 +27,18 @@ namespace Data
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: