Mercurial > hg > svgui
changeset 1606:d6976d231efb
Reduce heights of alignment views if (they are visible and) we are squashed for space
author | Chris Cannam |
---|---|
date | Wed, 06 May 2020 09:08:37 +0100 |
parents | ae2d5f8ff005 |
children | 52d4bfba5b3d |
files | view/PaneStack.cpp view/PaneStack.h |
diffstat | 2 files changed, 44 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <QPushButton> #include <QSplitter> #include <QStackedWidget> +#include <QResizeEvent> #include <iostream> @@ -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<PaneRec>::iterator i = m_panes.begin();
--- 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; };