diff view/Pane.cpp @ 592:a13aa5320221 sonification

Extends the audio feedback of the piano scale to the Spectrum layer (horizontal piano keyboard). Increase of the piano keyboard width (SpectrogramLayer) and height (SpectrumLayer) for layout purposes. A get method should be added to obtain the scale size parameter outside the layer class.
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Wed, 06 Jul 2011 18:05:42 +0100
parents 241929c5d57c
children c080d14ff414
line wrap: on
line diff
--- a/view/Pane.cpp	Fri Jun 24 16:42:48 2011 +0100
+++ b/view/Pane.cpp	Wed Jul 06 18:05:42 2011 +0100
@@ -14,7 +14,6 @@
 */
 
 #include "Pane.h"
-#include "layer/Layer.h"
 #include "data/model/Model.h"
 #include "base/ZoomConstraint.h"
 #include "base/RealTime.h"
@@ -1290,7 +1289,65 @@
     m_resizing = false;
     m_editing = false;
     m_releasing = false;
-    
+
+    bool scaleclick = false;
+
+    Layer *layer = getTopLayer();
+    if (layer) {
+        LayerFactory::LayerType type = LayerFactory::getInstance()->getLayerType(layer);
+
+        //std::cerr << "hello before switch: " << LayerFactory::getInstance()->getLayerTypeName(type) << std::endl;
+
+        switch(type) {
+
+            case LayerFactory::Spectrogram:
+            {
+                std::cerr << "hello spectrogram ("<< e->x() <<", " << e->y() << ")" << std::endl;                
+            }
+            case LayerFactory::MelodicRangeSpectrogram:
+            {
+                std::cerr << "hello melodic ("<< e->x() <<", " << e->y() << ")" << std::endl;
+                int sw = getVerticalScaleWidth();
+                int pkhms = 20; //this value should be retrieved from SpectrogramLayer
+                int slb = sw - pkhms - 1; //scale left border
+
+                //std::cerr << "slb: "<< slb << std::endl;
+
+                if ((e->x() < sw)&&(e->x() > slb)) {
+                    scaleclick = true;
+                }
+                break;
+            }
+            case LayerFactory::Spectrum:
+            {
+                std::cerr << "hello spectrum ("<< e->x() <<", " << e->y() << ")" << std::endl;
+
+                int h = height();
+                int pkhs = 20; //this value should be retrieved from SpectrumLayer
+
+                int sh = h - pkhs - 1;
+
+                //if (e->y() < layer->getHorizontalScaleHeight(this)) {
+
+                if (e->y() > sh) {                    
+                    scaleclick = true;
+                 }
+                break;
+            }
+        }
+
+        if (scaleclick) {
+            // Click occurred over the layer's scale area.  Ask the layer
+            // to do something with it: if it does so (i.e. returns true),
+            // we've nothing else to do
+            if (layer->scaleClicked(this, e)) {
+                m_clickedInRange = false;
+                emit paneInteractedWith();
+                return;
+            }
+        }
+    }
+    /*
     if (e->x() < getVerticalScaleWidth()) {
         // Click occurred over the layer's scale area.  Ask the layer
         // to do something with it: if it does so (i.e. returns true),
@@ -1304,6 +1361,7 @@
             }
         }
     }
+    */
 
     if (mode == ViewManager::NavigateMode ||
         (e->buttons() & Qt::MidButton) ||