Mercurial > hg > svgui
comparison layer/NoteLayer.cpp @ 100:0db5e7492ce8
* Add units repository, and unit property on time-value and note layers.
author | Chris Cannam |
---|---|
date | Thu, 11 May 2006 15:02:14 +0000 |
parents | 453f7da3534e |
children | 0f36cdf407a6 |
comparison
equal
deleted
inserted
replaced
99:453f7da3534e | 100:0db5e7492ce8 |
---|---|
69 NoteLayer::getProperties() const | 69 NoteLayer::getProperties() const |
70 { | 70 { |
71 PropertyList list; | 71 PropertyList list; |
72 list.push_back("Colour"); | 72 list.push_back("Colour"); |
73 list.push_back("Vertical Scale"); | 73 list.push_back("Vertical Scale"); |
74 list.push_back("Scale Units"); | |
74 return list; | 75 return list; |
75 } | 76 } |
76 | 77 |
77 QString | 78 QString |
78 NoteLayer::getPropertyLabel(const PropertyName &name) const | 79 NoteLayer::getPropertyLabel(const PropertyName &name) const |
79 { | 80 { |
80 if (name == "Colour") return tr("Colour"); | 81 if (name == "Colour") return tr("Colour"); |
81 if (name == "Vertical Scale") return tr("Vertical Scale"); | 82 if (name == "Vertical Scale") return tr("Vertical Scale"); |
83 if (name == "Scale Units") return tr("Pitch Units"); | |
82 return ""; | 84 return ""; |
83 } | 85 } |
84 | 86 |
85 Layer::PropertyType | 87 Layer::PropertyType |
86 NoteLayer::getPropertyType(const PropertyName &) const | 88 NoteLayer::getPropertyType(const PropertyName &name) const |
87 { | 89 { |
90 if (name == "Scale Units") return UnitsProperty; | |
88 return ValueProperty; | 91 return ValueProperty; |
89 } | 92 } |
90 | 93 |
91 int | 94 int |
92 NoteLayer::getPropertyRangeAndValue(const PropertyName &name, | 95 NoteLayer::getPropertyRangeAndValue(const PropertyName &name, |
112 | 115 |
113 if (min) *min = 0; | 116 if (min) *min = 0; |
114 if (max) *max = 2; | 117 if (max) *max = 2; |
115 | 118 |
116 deft = int(m_verticalScale); | 119 deft = int(m_verticalScale); |
120 | |
121 } else if (name == "Scale Units") { | |
122 | |
123 if (m_model) { | |
124 deft = UnitDatabase::getInstance()->getUnitId | |
125 (m_model->getScaleUnits()); | |
126 } | |
117 | 127 |
118 } else { | 128 } else { |
119 | 129 |
120 deft = Layer::getPropertyRangeAndValue(name, min, max); | 130 deft = Layer::getPropertyRangeAndValue(name, min, max); |
121 } | 131 } |
161 case 4: setBaseColour(QColor(200, 50, 255)); break; | 171 case 4: setBaseColour(QColor(200, 50, 255)); break; |
162 case 5: setBaseColour(QColor(255, 150, 50)); break; | 172 case 5: setBaseColour(QColor(255, 150, 50)); break; |
163 } | 173 } |
164 } else if (name == "Vertical Scale") { | 174 } else if (name == "Vertical Scale") { |
165 setVerticalScale(VerticalScale(value)); | 175 setVerticalScale(VerticalScale(value)); |
176 } else if (name == "Scale Units") { | |
177 if (m_model) { | |
178 m_model->setScaleUnits | |
179 (UnitDatabase::getInstance()->getUnitById(value)); | |
180 emit modelChanged(); | |
181 } | |
166 } | 182 } |
167 } | 183 } |
168 | 184 |
169 void | 185 void |
170 NoteLayer::setBaseColour(QColor colour) | 186 NoteLayer::setBaseColour(QColor colour) |
658 ItemEditDialog *dialog = new ItemEditDialog | 674 ItemEditDialog *dialog = new ItemEditDialog |
659 (m_model->getSampleRate(), | 675 (m_model->getSampleRate(), |
660 ItemEditDialog::ShowTime | | 676 ItemEditDialog::ShowTime | |
661 ItemEditDialog::ShowDuration | | 677 ItemEditDialog::ShowDuration | |
662 ItemEditDialog::ShowValue | | 678 ItemEditDialog::ShowValue | |
663 ItemEditDialog::ShowText); | 679 ItemEditDialog::ShowText, |
680 m_model->getScaleUnits()); | |
664 | 681 |
665 dialog->setFrameTime(note.frame); | 682 dialog->setFrameTime(note.frame); |
666 dialog->setValue(note.value); | 683 dialog->setValue(note.value); |
667 dialog->setFrameDuration(note.duration); | 684 dialog->setFrameDuration(note.duration); |
668 dialog->setText(note.label); | 685 dialog->setText(note.label); |