Mercurial > hg > svgui
diff view/PaneStack.cpp @ 687:502fe55c2184 tonioni
If any panes have a fixed size, respect that when resizing pane stack sizes
author | Chris Cannam |
---|---|
date | Fri, 29 Nov 2013 14:50:33 +0000 |
parents | 1a0dfcbffaf1 |
children | 833cd1b8014f |
line wrap: on
line diff
--- a/view/PaneStack.cpp Thu Nov 28 16:49:30 2013 +0000 +++ b/view/PaneStack.cpp Fri Nov 29 14:50:33 2013 +0000 @@ -580,24 +580,44 @@ int count = sizes.size(); - int total = 0; + int fixed = 0, variable = 0, total = 0; + int varicount = 0; + for (int i = 0; i < count; ++i) { total += sizes[i]; } + variable = total; + + for (int i = 0; i < count; ++i) { + int minh = m_panes[i].pane->minimumSize().height(); + if (minh == m_panes[i].pane->maximumSize().height()) { + fixed += minh; + variable -= minh; + } else { + varicount++; + } + } + if (total == 0) return; sizes.clear(); - int each = total / count; + int each = (varicount > 0 ? (variable / varicount) : 0); int remaining = total; for (int i = 0; i < count; ++i) { if (i == count - 1) { sizes.push_back(remaining); } else { - sizes.push_back(each); - remaining -= each; + int minh = m_panes[i].pane->minimumSize().height(); + if (minh == m_panes[i].pane->maximumSize().height()) { + sizes.push_back(minh); + remaining -= minh; + } else { + sizes.push_back(each); + remaining -= each; + } } } @@ -612,4 +632,3 @@ m_splitter->setSizes(sizes); } -