diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-11-13 09:44:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-11-13 09:49:18 +0000 |
commit | 1e1bcd008ec2767a24bebbd5f3059d73cc54f6df (patch) | |
tree | 105a8685c45e04858dc0f64898cde9240fbc317b /vcl/source | |
parent | 19f4ebd8a54da0ae03b9cc8481613e5cd20ee1e7 (diff) |
favour expandables over non-expandables for shrinking scenario
if grid contents change their mind and want to be bigger than
available space, then somethings got to give, prefer expandables
as shrinkables too
Change-Id: Iefd87adb722548c11df04f194cf6d6e17665289a
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/window/layout.cxx | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 548e06e8d3c0..be6cbe4b9003 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -729,24 +729,27 @@ void VclGrid::setAllocation(const Size& rAllocation) for (sal_Int32 x = 0; x < nMaxX; ++x) aWidths[x].m_nValue = nAvailableWidth/nMaxX; } - else + else if (rAllocation.Width() != aRequisition.Width()) { - long nExtraWidth = 0; + sal_Int32 nExpandables = 0; + for (sal_Int32 x = 0; x < nMaxX; ++x) + if (aWidths[x].m_bExpand) + ++nExpandables; + long nExtraWidthForExpanders = nExpandables ? (rAllocation.Width() - aRequisition.Width()) / nExpandables : 0; + if (rAllocation.Width() < aRequisition.Width()) - nExtraWidth = (rAllocation.Width() - aRequisition.Width()) / nMaxX; - else { - sal_Int32 nExpandables = 0; + long nExtraWidth = (rAllocation.Width() - aRequisition.Width() - nExtraWidthForExpanders * nExpandables) / nMaxX; + for (sal_Int32 x = 0; x < nMaxX; ++x) - if (aWidths[x].m_bExpand) - ++nExpandables; - nExtraWidth = nExpandables ? (rAllocation.Width() - aRequisition.Width()) / nExpandables : 0; + aWidths[x].m_nValue += nExtraWidth; } - if (nExtraWidth) + + if (nExtraWidthForExpanders) { for (sal_Int32 x = 0; x < nMaxX; ++x) if (aWidths[x].m_bExpand) - aWidths[x].m_nValue += nExtraWidth; + aWidths[x].m_nValue += nExtraWidthForExpanders; } } @@ -756,24 +759,27 @@ void VclGrid::setAllocation(const Size& rAllocation) for (sal_Int32 y = 0; y < nMaxY; ++y) aHeights[y].m_nValue = nAvailableHeight/nMaxY; } - else + else if (rAllocation.Height() != aRequisition.Height()) { - long nExtraHeight = 0; + sal_Int32 nExpandables = 0; + for (sal_Int32 y = 0; y < nMaxY; ++y) + if (aHeights[y].m_bExpand) + ++nExpandables; + long nExtraHeightForExpanders = nExpandables ? (rAllocation.Height() - aRequisition.Height()) / nExpandables : 0; + if (rAllocation.Height() < aRequisition.Height()) - nExtraHeight = (rAllocation.Height() - aRequisition.Height()) / nMaxY; - else { - sal_Int32 nExpandables = 0; + long nExtraHeight = (rAllocation.Height() - aRequisition.Height() - nExtraHeightForExpanders * nExpandables) / nMaxY; + for (sal_Int32 y = 0; y < nMaxY; ++y) - if (aHeights[y].m_bExpand) - ++nExpandables; - nExtraHeight = nExpandables ? (rAllocation.Height() - aRequisition.Height()) / nExpandables : 0; + aHeights[y].m_nValue += nExtraHeight; } - if (nExtraHeight) + + if (nExtraHeightForExpanders) { for (sal_Int32 y = 0; y < nMaxY; ++y) if (aHeights[y].m_bExpand) - aHeights[y].m_nValue += nExtraHeight; + aHeights[y].m_nValue += nExtraHeightForExpanders; } } |