# HG changeset patch # User Chris Cannam # Date 1588752517 -3600 # Node ID d6976d231efb597c3eac0731ac0d40d202c6a59b # Parent ae2d5f8ff00528b8d734e040b309cc437ea12052 Reduce heights of alignment views if (they are visible and) we are squashed for space diff -r ae2d5f8ff005 -r d6976d231efb view/PaneStack.cpp --- a/view/PaneStack.cpp Thu Apr 30 14:47:13 2020 +0100 +++ b/view/PaneStack.cpp Wed May 06 09:08:37 2020 +0100 @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -225,6 +226,8 @@ av->show(); } } + + adjustAlignmentViewHeights(size().height()); } void @@ -239,6 +242,44 @@ } void +PaneStack::resizeEvent(QResizeEvent *ev) +{ + adjustAlignmentViewHeights(ev->size().height()); +} + +void +PaneStack::adjustAlignmentViewHeights(int forMyHeight) +{ + if (!(m_options & int(Option::ShowAlignmentViews))) return; + if (!(m_options & int(Option::NoUserResize))) return; + if (!isVisible()) return; + + int heightPerPane = forMyHeight / int(m_panes.size()); + + SVCERR << "heightPerPane = " << heightPerPane << " (" + << forMyHeight << "/" << m_panes.size() << ")" << endl; + + int roomForAlignmentView = heightPerPane / 4; + int min = ViewManager::scalePixelSize(6); + int max = ViewManager::scalePixelSize(25); + int alignmentHeight = roomForAlignmentView; + if (alignmentHeight < min) { + alignmentHeight = min; + } + if (alignmentHeight > max) { + alignmentHeight = max; + } + + SVCERR << "alignmentHeight = " << alignmentHeight << endl; + + for (int i = 0; in_range_for(m_panes, i); ++i) { + auto av = m_panes[i].alignmentView; + if (!av) continue; + av->setFixedHeight(alignmentHeight); + } +} + +void PaneStack::setPropertyStackMinWidth(int mw) { for (std::vector::iterator i = m_panes.begin(); diff -r ae2d5f8ff005 -r d6976d231efb view/PaneStack.h --- a/view/PaneStack.h Thu Apr 30 14:47:13 2020 +0100 +++ b/view/PaneStack.h Wed May 06 09:08:37 2020 +0100 @@ -160,6 +160,9 @@ void unlinkAlignmentViews(); void relinkAlignmentViews(); + void resizeEvent(QResizeEvent *) override; + void adjustAlignmentViewHeights(int forMyHeight); + LayoutStyle m_layoutStyle; };