changeset 6:27f9c1f11598 tip

* introduce layerInAView implementation that I just backed out of SV
author Chris Cannam
date Mon, 29 Jun 2009 13:07:15 +0000
parents b7e2027ec4bd
children
files main/MainWindow.cpp
diffstat 1 files changed, 38 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main/MainWindow.cpp	Tue Jun 09 15:26:13 2009 +0000
+++ b/main/MainWindow.cpp	Mon Jun 29 13:07:15 2009 +0000
@@ -1878,7 +1878,44 @@
 void
 MainWindow::layerInAView(Layer *layer, bool inAView)
 {
-    MainWindowBase::layerInAView(layer, inAView);
+//    std::cerr << "MainWindow::layerInAView(" << layer << "," << inAView << ")" << std::endl;
+
+    if (!inAView) removeLayerEditDialog(layer);
+
+    // Check whether we need to add or remove model from play source
+    Model *model = layer->getModel();
+    if (model) {
+        Model *source = model->getSourceModel();
+        if (inAView) {
+            m_playSource->addModel(model);
+            if (source && source != model) {
+                m_playSource->addModel(source);
+            }
+        } else {
+            bool found = false;
+            for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
+                Pane *pane = m_paneStack->getPane(i);
+                if (!pane) continue;
+                for (int j = 0; j < pane->getLayerCount(); ++j) {
+                    Layer *pl = pane->getLayer(j);
+                    if (pl && (pl->getModel() == model ||
+                               pl->getModel() == source)) {
+                        found = true;
+                        break;
+                    }
+                }
+                if (found) break;
+            }
+            if (!found) {
+                m_playSource->removeModel(model);
+                if (source && source != model) {
+                    m_playSource->removeModel(source);
+                }
+            }
+        }
+    }
+
+    updateMenuStates();
 }
 
 void