Kaydet (Commit) 052a6a99 authored tarafından Caolán McNamara's avatar Caolán McNamara

honour child alignment in all layout widgets, not just grid

i.e. so that the original cmis checkin dialog of
207ed1b1
would have worked without rework as grid of
5cc34dc9

Change-Id: Ide047cfca63558867c427d4fcbb91ad182fb71e4
üst d00ee312
......@@ -33,6 +33,10 @@ public:
//while GetOptimalSize/get_preferred_size and SetPosSizePixel are
//oblivious to them
static Size getLayoutRequisition(const Window &rWindow);
static void setLayoutPosSize(Window &rWindow, const Point &rPos, const Size &rSize);
//applies the allocation pos and size onto rWindow via setLayoutPosSize taking into account
//the rWindows alignment desires within that allocation
static void setLayoutAllocation(Window &rWindow, const Point &rPos, const Size &rSize);
protected:
......
......@@ -25,7 +25,7 @@ Size VclContainer::GetOptimalSize(WindowSizeType eType) const
return calculateRequisition();
}
void VclContainer::setLayoutAllocation(Window &rWindow, const Point &rPos, const Size &rSize)
void VclContainer::setLayoutPosSize(Window &rWindow, const Point &rPos, const Size &rSize)
{
sal_Int32 nBorderWidth = rWindow.get_border_width();
sal_Int32 nLeft = rWindow.get_margin_left() + nBorderWidth;
......@@ -37,6 +37,67 @@ void VclContainer::setLayoutAllocation(Window &rWindow, const Point &rPos, const
rWindow.SetPosSizePixel(aPos, aSize);
}
void VclContainer::setLayoutAllocation(Window &rChild, const Point &rAllocPos, const Size &rChildAlloc)
{
VclAlign eHalign = rChild.get_halign();
VclAlign eValign = rChild.get_valign();
//typical case
if (eHalign == VCL_ALIGN_FILL && eValign == VCL_ALIGN_FILL)
{
setLayoutPosSize(rChild, rAllocPos, rChildAlloc);
return;
}
Point aChildPos(rAllocPos);
Size aChildSize(rChildAlloc);
Size aChildPreferredSize(getLayoutRequisition(rChild));
switch (eHalign)
{
case VCL_ALIGN_FILL:
break;
case VCL_ALIGN_START:
if (aChildPreferredSize.Width() < rChildAlloc.Width())
aChildSize.Width() = aChildPreferredSize.Width();
break;
case VCL_ALIGN_END:
if (aChildPreferredSize.Width() < rChildAlloc.Width())
aChildSize.Width() = aChildPreferredSize.Width();
aChildPos.X() += rChildAlloc.Width();
aChildPos.X() -= aChildSize.Width();
break;
case VCL_ALIGN_CENTER:
if (aChildPreferredSize.Width() < aChildSize.Width())
aChildSize.Width() = aChildPreferredSize.Width();
aChildPos.X() += (rChildAlloc.Width() - aChildSize.Width()) / 2;
break;
}
switch (eValign)
{
case VCL_ALIGN_FILL:
break;
case VCL_ALIGN_START:
if (aChildPreferredSize.Height() < rChildAlloc.Height())
aChildSize.Height() = aChildPreferredSize.Height();
break;
case VCL_ALIGN_END:
if (aChildPreferredSize.Height() < rChildAlloc.Height())
aChildSize.Height() = aChildPreferredSize.Height();
aChildPos.Y() += rChildAlloc.Height();
aChildPos.Y() -= aChildSize.Height();
break;
case VCL_ALIGN_CENTER:
if (aChildPreferredSize.Height() < aChildSize.Height())
aChildSize.Height() = aChildPreferredSize.Height();
aChildPos.Y() += (rChildAlloc.Height() - aChildSize.Height()) / 2;
break;
}
setLayoutPosSize(rChild, aChildPos, aChildSize);
}
Size VclContainer::getLayoutRequisition(const Window &rWindow)
{
sal_Int32 nBorderWidth = rWindow.get_border_width();
......@@ -804,60 +865,7 @@ void VclGrid::setAllocation(const Size& rAllocation)
aChildAlloc.Height() += aHeights[y+nSpanY].m_nValue;
aChildAlloc.Height() += get_row_spacing()*(nHeight-1);
Point aChildPos(aAllocPos);
Size aChildSize(aChildAlloc);
VclAlign eHalign = pChild->get_halign();
VclAlign eValign = pChild->get_valign();
Size aChildPreferredSize;
if (eHalign != VCL_ALIGN_FILL || eValign != VCL_ALIGN_FILL)
aChildPreferredSize = getLayoutRequisition(*pChild);
switch (eHalign)
{
case VCL_ALIGN_FILL:
break;
case VCL_ALIGN_START:
if (aChildPreferredSize.Width() < aChildAlloc.Width())
aChildSize.Width() = aChildPreferredSize.Width();
break;
case VCL_ALIGN_END:
if (aChildPreferredSize.Width() < aChildAlloc.Width())
aChildSize.Width() = aChildPreferredSize.Width();
aChildPos.X() += aChildAlloc.Width();
aChildPos.X() -= aChildSize.Width();
break;
case VCL_ALIGN_CENTER:
if (aChildPreferredSize.Width() < aChildSize.Width())
aChildSize.Width() = aChildPreferredSize.Width();
aChildPos.X() += (aChildAlloc.Width() - aChildSize.Width()) / 2;
break;
}
switch (eValign)
{
case VCL_ALIGN_FILL:
break;
case VCL_ALIGN_START:
if (aChildPreferredSize.Height() < aChildAlloc.Height())
aChildSize.Height() = aChildPreferredSize.Height();
break;
case VCL_ALIGN_END:
if (aChildPreferredSize.Height() < aChildAlloc.Height())
aChildSize.Height() = aChildPreferredSize.Height();
aChildPos.Y() += aChildAlloc.Height();
aChildPos.Y() -= aChildSize.Height();
break;
case VCL_ALIGN_CENTER:
if (aChildPreferredSize.Height() < aChildSize.Height())
aChildSize.Height() = aChildPreferredSize.Height();
aChildPos.Y() += (aChildAlloc.Height() - aChildSize.Height()) / 2;
break;
}
setLayoutAllocation(*pChild, aChildPos, aChildSize);
setLayoutAllocation(*pChild, aAllocPos, aChildAlloc);
}
aAllocPos.Y() += aHeights[y].m_nValue + get_row_spacing();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment