Mercurial > hg > svgui
comparison view/PaneStack.cpp @ 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 | 01a41a37bd26 |
children | c6f5c822b10d |
comparison
equal
deleted
inserted
replaced
1605:ae2d5f8ff005 | 1606:d6976d231efb |
---|---|
30 #include <QPalette> | 30 #include <QPalette> |
31 #include <QLabel> | 31 #include <QLabel> |
32 #include <QPushButton> | 32 #include <QPushButton> |
33 #include <QSplitter> | 33 #include <QSplitter> |
34 #include <QStackedWidget> | 34 #include <QStackedWidget> |
35 #include <QResizeEvent> | |
35 | 36 |
36 #include <iostream> | 37 #include <iostream> |
37 | 38 |
38 //#define DEBUG_PANE_STACK 1 | 39 //#define DEBUG_PANE_STACK 1 |
39 | 40 |
223 av->setViewAbove(m_panes[i-1].pane); | 224 av->setViewAbove(m_panes[i-1].pane); |
224 av->setViewBelow(m_panes[i].pane); | 225 av->setViewBelow(m_panes[i].pane); |
225 av->show(); | 226 av->show(); |
226 } | 227 } |
227 } | 228 } |
229 | |
230 adjustAlignmentViewHeights(size().height()); | |
228 } | 231 } |
229 | 232 |
230 void | 233 void |
231 PaneStack::unlinkAlignmentViews() | 234 PaneStack::unlinkAlignmentViews() |
232 { | 235 { |
233 for (int i = 0; in_range_for(m_panes, i); ++i) { | 236 for (int i = 0; in_range_for(m_panes, i); ++i) { |
234 auto av = m_panes[i].alignmentView; | 237 auto av = m_panes[i].alignmentView; |
235 if (!av) continue; | 238 if (!av) continue; |
236 av->setViewAbove(nullptr); | 239 av->setViewAbove(nullptr); |
237 av->setViewBelow(nullptr); | 240 av->setViewBelow(nullptr); |
241 } | |
242 } | |
243 | |
244 void | |
245 PaneStack::resizeEvent(QResizeEvent *ev) | |
246 { | |
247 adjustAlignmentViewHeights(ev->size().height()); | |
248 } | |
249 | |
250 void | |
251 PaneStack::adjustAlignmentViewHeights(int forMyHeight) | |
252 { | |
253 if (!(m_options & int(Option::ShowAlignmentViews))) return; | |
254 if (!(m_options & int(Option::NoUserResize))) return; | |
255 if (!isVisible()) return; | |
256 | |
257 int heightPerPane = forMyHeight / int(m_panes.size()); | |
258 | |
259 SVCERR << "heightPerPane = " << heightPerPane << " (" | |
260 << forMyHeight << "/" << m_panes.size() << ")" << endl; | |
261 | |
262 int roomForAlignmentView = heightPerPane / 4; | |
263 int min = ViewManager::scalePixelSize(6); | |
264 int max = ViewManager::scalePixelSize(25); | |
265 int alignmentHeight = roomForAlignmentView; | |
266 if (alignmentHeight < min) { | |
267 alignmentHeight = min; | |
268 } | |
269 if (alignmentHeight > max) { | |
270 alignmentHeight = max; | |
271 } | |
272 | |
273 SVCERR << "alignmentHeight = " << alignmentHeight << endl; | |
274 | |
275 for (int i = 0; in_range_for(m_panes, i); ++i) { | |
276 auto av = m_panes[i].alignmentView; | |
277 if (!av) continue; | |
278 av->setFixedHeight(alignmentHeight); | |
238 } | 279 } |
239 } | 280 } |
240 | 281 |
241 void | 282 void |
242 PaneStack::setPropertyStackMinWidth(int mw) | 283 PaneStack::setPropertyStackMinWidth(int mw) |