Mercurial > hg > svgui
diff view/PaneStack.cpp @ 320:984c1975f1ff
* Some tidying up to handling of alignment; add alignment status label to
pane; ensure alignment when dragging with mouse as well as when playing
author | Chris Cannam |
---|---|
date | Thu, 25 Oct 2007 14:32:23 +0000 |
parents | 2a50c1ecc990 |
children | 267586900360 |
line wrap: on
line diff
--- a/view/PaneStack.cpp Mon Oct 22 14:24:31 2007 +0000 +++ b/view/PaneStack.cpp Thu Oct 25 14:32:23 2007 +0000 @@ -503,3 +503,44 @@ emit dropAccepted(pane, text); } +void +PaneStack::sizePanesEqually() +{ + QList<int> sizes = m_splitter->sizes(); + if (sizes.empty()) return; + + int count = sizes.size(); + + int total = 0; + for (int i = 0; i < count; ++i) { + total += sizes[i]; + } + + if (total == 0) return; + + sizes.clear(); + + int each = total / count; + 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; + } + } + +/* + std::cerr << "sizes: "; + for (int i = 0; i < sizes.size(); ++i) { + std::cerr << sizes[i] << " "; + } + std::cerr << std::endl; +*/ + + m_splitter->setSizes(sizes); +} + +