diff view/PaneStack.cpp @ 1057:218be6cf2d4f spectrogram-minor-refactor

Merge from default branch
author Chris Cannam
date Mon, 13 Jun 2016 12:46:36 +0100
parents 36cddc3de023
children a34a2a25907c
line wrap: on
line diff
--- a/view/PaneStack.cpp	Wed Feb 03 16:51:37 2016 +0000
+++ b/view/PaneStack.cpp	Mon Jun 13 12:46:36 2016 +0100
@@ -21,6 +21,7 @@
 #include "widgets/ClickableLabel.h"
 #include "layer/Layer.h"
 #include "ViewManager.h"
+#include "AlignmentView.h"
 
 #include <QApplication>
 #include <QHBoxLayout>
@@ -40,6 +41,7 @@
     QFrame(parent),
     m_currentPane(0),
     m_showAccessories(true),
+    m_showAlignmentViews(false),
     m_splitter(new QSplitter),
     m_propertyStackStack(new QStackedWidget),
     m_viewManager(viewManager),
@@ -67,6 +69,15 @@
     m_showAccessories = show;
 }
 
+void
+PaneStack::setShowAlignmentViews(bool show)
+{
+    m_showAlignmentViews = show;
+    foreach (const PaneRec &r, m_panes) {
+        r.alignmentView->setVisible(m_showAlignmentViews);
+    }
+}
+
 Pane *
 PaneStack::addPane(bool suppressPropertyBox)
 {
@@ -112,6 +123,12 @@
     layout->addWidget(pane, 0, 1, 2, 1);
     layout->setColumnStretch(1, 20);
 
+    AlignmentView *av = new AlignmentView(frame);
+    av->setFixedHeight(40);//!!!
+    av->setVisible(m_showAlignmentViews);
+    av->setViewManager(m_viewManager);
+    layout->addWidget(av, 2, 1);
+
     QWidget *properties = 0;
     if (suppressPropertyBox) {
 	properties = new QFrame();
@@ -139,6 +156,7 @@
     rec.currentIndicator = currentIndicator;
     rec.frame = frame;
     rec.layout = layout;
+    rec.alignmentView = av;
     m_panes.push_back(rec);
 
     frame->setLayout(layout);
@@ -167,11 +185,34 @@
     }
 
     showOrHidePaneAccessories();
+    relinkAlignmentViews();
 
     return pane;
 }
 
 void
+PaneStack::relinkAlignmentViews()
+{
+    for (int i = 0; i < (int)m_panes.size(); ++i) {
+        m_panes[i].alignmentView->setViewAbove(m_panes[i].pane);
+        if (i + 1 < (int)m_panes.size()) {
+            m_panes[i].alignmentView->setViewBelow(m_panes[i+1].pane);
+        } else {
+            m_panes[i].alignmentView->setViewBelow(0);
+        }
+    }
+}
+
+void
+PaneStack::unlinkAlignmentViews()
+{
+    for (int i = 0; i < (int)m_panes.size(); ++i) {
+        m_panes[i].alignmentView->setViewAbove(0);
+        m_panes[i].alignmentView->setViewBelow(0);
+    }
+}
+
+void
 PaneStack::setPropertyStackMinWidth(int mw)
 {
     for (std::vector<PaneRec>::iterator i = m_panes.begin();
@@ -279,6 +320,7 @@
     }
 
     emit paneAboutToBeDeleted(pane);
+    unlinkAlignmentViews();
 
     cerr << "PaneStack::deletePane: about to delete parent " << pane->parent() << " of pane " << pane << endl;
 
@@ -303,6 +345,7 @@
     }
 
     showOrHidePaneAccessories();
+    relinkAlignmentViews();
 
     emit paneDeleted();
 }
@@ -362,6 +405,8 @@
 	++i;
     }
 
+    relinkAlignmentViews();
+
     cerr << "WARNING: PaneStack::hidePane(" << pane << "): Pane not found in visible panes" << endl;
 }
 
@@ -386,6 +431,8 @@
 	++i;
     }
 
+    relinkAlignmentViews();
+
     cerr << "WARNING: PaneStack::showPane(" << pane << "): Pane not found in hidden panes" << endl;
 }