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 | |||
@@ -38,7 +38,7 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c | |||
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()); |
@@ -46,7 +46,6 @@ Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const c | |||
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(); |
@@ -92,12 +91,15 @@ void Menu::InstEditDialog::deleteString(int id) | |||
92 | //**************************************************************************** | 91 | //**************************************************************************** |
93 | void Menu::InstEditDialog::saveInstrument() | 92 | void 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 | //**************************************************************************** |
98 | void Menu::InstEditDialog::loadInstrument() | 98 | 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++) |
102 | { | 104 | { |
103 | stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); | 105 | stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); |
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 | |||
@@ -27,6 +27,7 @@ namespace Menu | |||
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 !! |
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 | |||
@@ -53,6 +53,12 @@ void Graph::FretBoard::resizeEvent(QResizeEvent* re) | |||
53 | Q_UNUSED(re); | 53 | Q_UNUSED(re); |
54 | } | 54 | } |
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) |
57 | { | 63 | { |
58 | //debug | 64 | //debug |
@@ -121,9 +127,7 @@ void Graph::FretBoard::paintScale(QPainter* p) | |||
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 | { |
@@ -136,13 +140,36 @@ void Graph::FretBoard::paintScale(QPainter* p) | |||
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()) |
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 | |||
@@ -41,11 +41,14 @@ namespace Graph | |||
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); |
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 | |||
@@ -17,12 +17,29 @@ MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) | |||
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 | //**************************************************************************** |
24 | MainWidget::~MainWidget() | 27 | MainWidget::~MainWidget() |
25 | { | 28 | { |
26 | } | 29 | } |
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 | |||
@@ -14,9 +14,12 @@ private: | |||
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; | ||
17 | public: | 18 | public: |
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(); |
21 | private 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 | |||
@@ -76,9 +76,18 @@ int Instrument::string(int id) | |||
76 | //**************************************************************************** | 76 | //**************************************************************************** |
77 | int Instrument::noOfOctaves() | 77 | 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 | } |
83 | //**************************************************************************** | 92 | //**************************************************************************** |
84 | //**************************************************************************** | 93 | //**************************************************************************** |
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 | |||
@@ -32,6 +32,8 @@ namespace Data | |||
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 |