diff 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
line wrap: on
line diff
--- a/layer/NoteLayer.cpp	Thu May 11 11:35:46 2006 +0000
+++ b/layer/NoteLayer.cpp	Thu May 11 15:02:14 2006 +0000
@@ -71,6 +71,7 @@
     PropertyList list;
     list.push_back("Colour");
     list.push_back("Vertical Scale");
+    list.push_back("Scale Units");
     return list;
 }
 
@@ -79,12 +80,14 @@
 {
     if (name == "Colour") return tr("Colour");
     if (name == "Vertical Scale") return tr("Vertical Scale");
+    if (name == "Scale Units") return tr("Pitch Units");
     return "";
 }
 
 Layer::PropertyType
-NoteLayer::getPropertyType(const PropertyName &) const
+NoteLayer::getPropertyType(const PropertyName &name) const
 {
+    if (name == "Scale Units") return UnitsProperty;
     return ValueProperty;
 }
 
@@ -115,6 +118,13 @@
 	
 	deft = int(m_verticalScale);
 
+    } else if (name == "Scale Units") {
+
+        if (m_model) {
+            deft = UnitDatabase::getInstance()->getUnitId
+                (m_model->getScaleUnits());
+        }
+
     } else {
 	
 	deft = Layer::getPropertyRangeAndValue(name, min, max);
@@ -163,6 +173,12 @@
 	}
     } else if (name == "Vertical Scale") {
 	setVerticalScale(VerticalScale(value));
+    } else if (name == "Scale Units") {
+        if (m_model) {
+            m_model->setScaleUnits
+                (UnitDatabase::getInstance()->getUnitById(value));
+            emit modelChanged();
+        }
     }
 }
 
@@ -660,7 +676,8 @@
          ItemEditDialog::ShowTime |
          ItemEditDialog::ShowDuration |
          ItemEditDialog::ShowValue |
-         ItemEditDialog::ShowText);
+         ItemEditDialog::ShowText,
+         m_model->getScaleUnits());
 
     dialog->setFrameTime(note.frame);
     dialog->setValue(note.value);