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
This commit is contained in:
@@ -729,24 +729,27 @@ void VclGrid::setAllocation(const Size& rAllocation)
|
|||||||
for (sal_Int32 x = 0; x < nMaxX; ++x)
|
for (sal_Int32 x = 0; x < nMaxX; ++x)
|
||||||
aWidths[x].m_nValue = nAvailableWidth/nMaxX;
|
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())
|
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)
|
for (sal_Int32 x = 0; x < nMaxX; ++x)
|
||||||
if (aWidths[x].m_bExpand)
|
aWidths[x].m_nValue += nExtraWidth;
|
||||||
++nExpandables;
|
|
||||||
nExtraWidth = nExpandables ? (rAllocation.Width() - aRequisition.Width()) / nExpandables : 0;
|
|
||||||
}
|
}
|
||||||
if (nExtraWidth)
|
|
||||||
|
if (nExtraWidthForExpanders)
|
||||||
{
|
{
|
||||||
for (sal_Int32 x = 0; x < nMaxX; ++x)
|
for (sal_Int32 x = 0; x < nMaxX; ++x)
|
||||||
if (aWidths[x].m_bExpand)
|
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)
|
for (sal_Int32 y = 0; y < nMaxY; ++y)
|
||||||
aHeights[y].m_nValue = nAvailableHeight/nMaxY;
|
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())
|
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)
|
for (sal_Int32 y = 0; y < nMaxY; ++y)
|
||||||
if (aHeights[y].m_bExpand)
|
aHeights[y].m_nValue += nExtraHeight;
|
||||||
++nExpandables;
|
|
||||||
nExtraHeight = nExpandables ? (rAllocation.Height() - aRequisition.Height()) / nExpandables : 0;
|
|
||||||
}
|
}
|
||||||
if (nExtraHeight)
|
|
||||||
|
if (nExtraHeightForExpanders)
|
||||||
{
|
{
|
||||||
for (sal_Int32 y = 0; y < nMaxY; ++y)
|
for (sal_Int32 y = 0; y < nMaxY; ++y)
|
||||||
if (aHeights[y].m_bExpand)
|
if (aHeights[y].m_bExpand)
|
||||||
aHeights[y].m_nValue += nExtraHeight;
|
aHeights[y].m_nValue += nExtraHeightForExpanders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user