changeset 296:ea37c229a578

* Fix #1757772 tempo, dynamic related plug-ins bug -- make auto-align only auto-align if there is a unit involved * Fix #1755366 text layer bug in retrieved session * Fix input model selection in plugin parameter dialog (was being ignored) * Use lighter background than the standard widget one for panes (assuming the widget background is light but not white) -- similarly darker if dark * Fix colour reference counting in loaded session in SingleColourLayer * Reset overview pane colour when switching dark background on or off
author Chris Cannam
date Tue, 14 Aug 2007 13:58:53 +0000
parents 5804703450d8
children 860f9ada4327
files layer/SingleColourLayer.cpp layer/TimeValueLayer.cpp layer/TimeValueLayer.h view/View.cpp widgets/PluginParameterDialog.cpp widgets/PluginParameterDialog.h
diffstat 6 files changed, 53 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SingleColourLayer.cpp	Mon Aug 13 14:53:28 2007 +0000
+++ b/layer/SingleColourLayer.cpp	Tue Aug 14 13:58:53 2007 +0000
@@ -141,9 +141,9 @@
         // means we're being called from the constructor, and this is
         // a virtual function
         hint = getDefaultColourHint(dark, impose);
-//        std::cerr << "hint = " << hint << ", impose = " << impose << std::endl;
+        std::cerr << "hint = " << hint << ", impose = " << impose << std::endl;
     } else {
-//        std::cerr << "(from ctor)" << std::endl;
+        std::cerr << "(from ctor)" << std::endl;
     }
 
     if (hint >= 0 && impose) {
@@ -164,15 +164,15 @@
             count = m_colourRefCount[index];
         }
 
-//        std::cerr << "index = " << index << ", count = " << count;
+        std::cerr << "index = " << index << ", count = " << count;
 
         if (bestColour < 0 || count < bestCount) {
             bestColour = index;
             bestCount = count;
-//            std::cerr << " *";
+            std::cerr << " *";
         }
 
-//        std::cerr << std::endl;
+        std::cerr << std::endl;
     }
     
     if (bestColour < 0) m_colour = 0;
@@ -273,14 +273,30 @@
     QString colourName = attributes.value("colourName");
     QString colourSpec = attributes.value("colour");
     QString darkbg = attributes.value("darkBackground");
-    m_colour = ColourDatabase::getInstance()->putStringValues
+
+    int colour = ColourDatabase::getInstance()->putStringValues
         (colourName, colourSpec, darkbg);
-    if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) {
-        m_colourRefCount[m_colour] = 1;
-    } else {
-        m_colourRefCount[m_colour]++;
+
+    m_colourExplicitlySet = true;
+
+    if (m_colour != colour) {
+
+        std::cerr << "SingleColourLayer::setProperties: changing colour from " << m_colour << " to " << colour << std::endl;
+
+        if (m_colourRefCount.find(m_colour) != m_colourRefCount.end() &&
+            m_colourRefCount[m_colour] > 0) {
+            m_colourRefCount[m_colour]--;
+        }
+
+        m_colour = colour;
+
+        if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) {
+            m_colourRefCount[m_colour] = 1;
+        } else {
+            m_colourRefCount[m_colour]++;
+        }
+
+        flagBaseColourChanged();
     }
-    m_colourExplicitlySet = true;
-    flagBaseColourChanged();
 }
 
--- a/layer/TimeValueLayer.cpp	Mon Aug 13 14:53:28 2007 +0000
+++ b/layer/TimeValueLayer.cpp	Tue Aug 14 13:58:53 2007 +0000
@@ -259,7 +259,7 @@
 bool
 TimeValueLayer::getDisplayExtents(float &min, float &max) const
 {
-    if (!m_model || m_verticalScale == AutoAlignScale) return false;
+    if (!m_model || shouldAutoAlign()) return false;
 
     min = m_model->getValueMinimum();
     max = m_model->getValueMaximum();
@@ -431,7 +431,7 @@
     max = 0.0;
     log = false;
 
-    if (m_verticalScale == AutoAlignScale) {
+    if (shouldAutoAlign()) {
 
         if (!v->getValueExtents(m_model->getScaleUnits(), min, max, log)) {
             min = m_model->getValueMinimum();
@@ -496,6 +496,14 @@
     return val;
 }
 
+bool
+TimeValueLayer::shouldAutoAlign() const
+{
+    if (!m_model) return false;
+    QString unit = m_model->getScaleUnits();
+    return (m_verticalScale == AutoAlignScale && unit != "");
+}
+
 QColor
 TimeValueLayer::getColourForValue(View *v, float val) const
 {
@@ -566,7 +574,7 @@
     if (v->shouldIlluminateLocalFeatures(this, localPos)) {
 	SparseTimeValueModel::PointList localPoints =
 	    getLocalPoints(v, localPos.x());
-        std::cerr << "TimeValueLayer: " << localPoints.size() << " local points" << std::endl;
+//        std::cerr << "TimeValueLayer: " << localPoints.size() << " local points" << std::endl;
 	if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame;
     }
 
--- a/layer/TimeValueLayer.h	Mon Aug 13 14:53:28 2007 +0000
+++ b/layer/TimeValueLayer.h	Tue Aug 14 13:58:53 2007 +0000
@@ -124,6 +124,7 @@
     int getYForValue(View *, float value) const;
     float getValueForY(View *, int y) const;
     QColor getColourForValue(View *v, float value) const;
+    bool shouldAutoAlign() const;
 
     SparseTimeValueModel::PointList getLocalPoints(View *v, int) const;
 
--- a/view/View.cpp	Mon Aug 13 14:53:28 2007 +0000
+++ b/view/View.cpp	Tue Aug 14 13:58:53 2007 +0000
@@ -471,7 +471,13 @@
     bool widgetLight =
         (widgetbg.red() + widgetbg.green() + widgetbg.blue()) > 384;
 
-    if (widgetLight == light) return widgetbg;
+    if (widgetLight == light) {
+        if (widgetLight) {
+            return widgetbg.light();
+        } else {
+            return widgetbg.dark();
+        }
+    }
     else if (light) return Qt::white;
     else return Qt::black;
 }
--- a/widgets/PluginParameterDialog.cpp	Mon Aug 13 14:53:28 2007 +0000
+++ b/widgets/PluginParameterDialog.cpp	Tue Aug 14 13:58:53 2007 +0000
@@ -439,11 +439,13 @@
 
     m_inputModelList = models;
     m_inputModels->addItems(TextAbbrev::abbreviate(models, 80));
+    m_inputModels->setCurrentIndex(0);
 
     if (lastModel != "") {
         for (int i = 0; i < models.size(); ++i) {
             if (lastModel == models[i]) {
                 m_inputModels->setCurrentIndex(i);
+                m_currentInputModel = models[i];
                 break;
             }
         }
@@ -457,10 +459,7 @@
 QString
 PluginParameterDialog::getInputModel() const
 {
-    if (!m_inputModels || !m_inputModels->isVisible()) return "";
-    int i = m_inputModels->currentIndex();
-    if (i >= m_inputModelList.size()) return "";
-    return m_inputModelList[i];
+    return m_currentInputModel;
 }
 
 void
@@ -547,7 +546,8 @@
 PluginParameterDialog::inputModelComboChanged(int index)
 {
     if (index >= m_inputModelList.size()) return;
-    emit inputModelChanged(m_inputModelList[index]);
+    m_currentInputModel = m_inputModelList[index];
+    emit inputModelChanged(m_currentInputModel);
 }
 
 void
--- a/widgets/PluginParameterDialog.h	Mon Aug 13 14:53:28 2007 +0000
+++ b/widgets/PluginParameterDialog.h	Tue Aug 14 13:58:53 2007 +0000
@@ -105,6 +105,7 @@
     QGroupBox *m_inputModelBox;
     QComboBox *m_inputModels;
     QStringList m_inputModelList;
+    QString m_currentInputModel;
 
     QPushButton *m_advancedButton;
     QWidget *m_advanced;