Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
686:f46da276b21c | 687:502fe55c2184 |
---|---|
578 QList<int> sizes = m_splitter->sizes(); | 578 QList<int> sizes = m_splitter->sizes(); |
579 if (sizes.empty()) return; | 579 if (sizes.empty()) return; |
580 | 580 |
581 int count = sizes.size(); | 581 int count = sizes.size(); |
582 | 582 |
583 int total = 0; | 583 int fixed = 0, variable = 0, total = 0; |
584 int varicount = 0; | |
585 | |
584 for (int i = 0; i < count; ++i) { | 586 for (int i = 0; i < count; ++i) { |
585 total += sizes[i]; | 587 total += sizes[i]; |
586 } | 588 } |
587 | 589 |
590 variable = total; | |
591 | |
592 for (int i = 0; i < count; ++i) { | |
593 int minh = m_panes[i].pane->minimumSize().height(); | |
594 if (minh == m_panes[i].pane->maximumSize().height()) { | |
595 fixed += minh; | |
596 variable -= minh; | |
597 } else { | |
598 varicount++; | |
599 } | |
600 } | |
601 | |
588 if (total == 0) return; | 602 if (total == 0) return; |
589 | 603 |
590 sizes.clear(); | 604 sizes.clear(); |
591 | 605 |
592 int each = total / count; | 606 int each = (varicount > 0 ? (variable / varicount) : 0); |
593 int remaining = total; | 607 int remaining = total; |
594 | 608 |
595 for (int i = 0; i < count; ++i) { | 609 for (int i = 0; i < count; ++i) { |
596 if (i == count - 1) { | 610 if (i == count - 1) { |
597 sizes.push_back(remaining); | 611 sizes.push_back(remaining); |
598 } else { | 612 } else { |
599 sizes.push_back(each); | 613 int minh = m_panes[i].pane->minimumSize().height(); |
600 remaining -= each; | 614 if (minh == m_panes[i].pane->maximumSize().height()) { |
615 sizes.push_back(minh); | |
616 remaining -= minh; | |
617 } else { | |
618 sizes.push_back(each); | |
619 remaining -= each; | |
620 } | |
601 } | 621 } |
602 } | 622 } |
603 | 623 |
604 /* | 624 /* |
605 cerr << "sizes: "; | 625 cerr << "sizes: "; |
610 */ | 630 */ |
611 | 631 |
612 m_splitter->setSizes(sizes); | 632 m_splitter->setSizes(sizes); |
613 } | 633 } |
614 | 634 |
615 |