Kaydet (Commit) 6019cd9b authored tarafından Caolán McNamara's avatar Caolán McNamara

want to be able to support non homogeneous buttons in buttonboxes

Change-Id: I7ea4c093d6318a24106542f851cfd58230bc3ea3
üst 079852ce
...@@ -1207,6 +1207,13 @@ public: ...@@ -1207,6 +1207,13 @@ public:
bool get_secondary() const; bool get_secondary() const;
void set_secondary(bool bSecondary); void set_secondary(bool bSecondary);
/*
* If true this child is exempted from homogenous sizing
* e.g. special button in a buttonbox
*/
bool get_non_homogeneous() const;
void set_non_homogeneous(bool bNonHomogeneous);
/* /*
* Sets a widget property * Sets a widget property
* *
......
...@@ -396,7 +396,8 @@ public: ...@@ -396,7 +396,8 @@ public:
mbVexpand:1, mbVexpand:1,
mbExpand:1, mbExpand:1,
mbFill:1, mbFill:1,
mbSecondary:1; mbSecondary:1,
mbNonHomogeneous:1;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer;
}; };
......
...@@ -2706,6 +2706,10 @@ void VclBuilder::applyPackingProperty(Window *pCurrent, ...@@ -2706,6 +2706,10 @@ void VclBuilder::applyPackingProperty(Window *pCurrent,
{ {
pCurrent->set_secondary(toBool(sValue)); pCurrent->set_secondary(toBool(sValue));
} }
else if (sKey == "non-homogeneous")
{
pCurrent->set_non_homogeneous(toBool(sValue));
}
else else
{ {
SAL_WARN("vcl.layout", "unknown packing: " << sKey.getStr()); SAL_WARN("vcl.layout", "unknown packing: " << sKey.getStr());
......
...@@ -377,16 +377,19 @@ static long getMaxNonOutlier(const std::vector<long> &rG, long nAvgDimension) ...@@ -377,16 +377,19 @@ static long getMaxNonOutlier(const std::vector<long> &rG, long nAvgDimension)
} }
static std::vector<long> setButtonSizes(const std::vector<long> &rG, static std::vector<long> setButtonSizes(const std::vector<long> &rG,
const std::vector<bool> &rNonHomogeneous,
long nAvgDimension, long nMaxNonOutlier, long nMinWidth) long nAvgDimension, long nMaxNonOutlier, long nMinWidth)
{ {
std::vector<long> aVec; std::vector<long> aVec;
//set everything < 1.5 times the average to the same width, leave the //set everything < 1.5 times the average to the same width, leave the
//outliers un-touched //outliers un-touched
std::vector<bool>::const_iterator aJ = rNonHomogeneous.begin();
for (std::vector<long>::const_iterator aI = rG.begin(), aEnd = rG.end(); for (std::vector<long>::const_iterator aI = rG.begin(), aEnd = rG.end();
aI != aEnd; ++aI) aI != aEnd; ++aI, ++aJ)
{ {
long nPrimaryChildDimension = *aI; long nPrimaryChildDimension = *aI;
if (nPrimaryChildDimension < nAvgDimension * 1.5) bool bNonHomogeneous = *aJ;
if (!bNonHomogeneous && nPrimaryChildDimension < nAvgDimension * 1.5)
{ {
aVec.push_back(std::max(nMaxNonOutlier, nMinWidth)); aVec.push_back(std::max(nMaxNonOutlier, nMinWidth));
} }
...@@ -413,7 +416,9 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() ...@@ -413,7 +416,9 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions()
bool bIgnoreSecondaryPacking = (m_eLayoutStyle == VCL_BUTTONBOX_SPREAD || m_eLayoutStyle == VCL_BUTTONBOX_CENTER); bool bIgnoreSecondaryPacking = (m_eLayoutStyle == VCL_BUTTONBOX_SPREAD || m_eLayoutStyle == VCL_BUTTONBOX_CENTER);
std::vector<long> aMainGroupSizes; std::vector<long> aMainGroupSizes;
std::vector<bool> aMainGroupNonHomogeneous;
std::vector<long> aSubGroupSizes; std::vector<long> aSubGroupSizes;
std::vector<bool> aSubGroupNonHomogeneous;
for (const Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT)) for (const Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT))
{ {
...@@ -426,11 +431,13 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() ...@@ -426,11 +431,13 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions()
nMainGroupSecondary = std::max(nMainGroupSecondary, getSecondaryDimension(aChildSize)); nMainGroupSecondary = std::max(nMainGroupSecondary, getSecondaryDimension(aChildSize));
//collect the primary dimensions //collect the primary dimensions
aMainGroupSizes.push_back(getPrimaryDimension(aChildSize)); aMainGroupSizes.push_back(getPrimaryDimension(aChildSize));
aMainGroupNonHomogeneous.push_back(pChild->get_non_homogeneous());
} }
else else
{ {
nSubGroupSecondary = std::max(nSubGroupSecondary, getSecondaryDimension(aChildSize)); nSubGroupSecondary = std::max(nSubGroupSecondary, getSecondaryDimension(aChildSize));
aSubGroupSizes.push_back(getPrimaryDimension(aChildSize)); aSubGroupSizes.push_back(getPrimaryDimension(aChildSize));
aSubGroupNonHomogeneous.push_back(pChild->get_non_homogeneous());
} }
} }
...@@ -468,8 +475,10 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() ...@@ -468,8 +475,10 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions()
long nMaxNonOutlier = std::max(nMaxMainNonOutlier, nMaxSubNonOutlier); long nMaxNonOutlier = std::max(nMaxMainNonOutlier, nMaxSubNonOutlier);
aReq.m_aMainGroupDimensions = setButtonSizes(aMainGroupSizes, aReq.m_aMainGroupDimensions = setButtonSizes(aMainGroupSizes,
aMainGroupNonHomogeneous,
nAvgDimension, nMaxNonOutlier, nMinMainGroupPrimary); nAvgDimension, nMaxNonOutlier, nMinMainGroupPrimary);
aReq.m_aSubGroupDimensions = setButtonSizes(aSubGroupSizes, aReq.m_aSubGroupDimensions = setButtonSizes(aSubGroupSizes,
aSubGroupNonHomogeneous,
nAvgDimension, nMaxNonOutlier, nMinSubGroupPrimary); nAvgDimension, nMaxNonOutlier, nMinSubGroupPrimary);
} }
......
...@@ -295,6 +295,7 @@ WindowImpl::WindowImpl( WindowType nType ) ...@@ -295,6 +295,7 @@ WindowImpl::WindowImpl( WindowType nType )
mbExpand = false; mbExpand = false;
mbFill = true; mbFill = true;
mbSecondary = false; mbSecondary = false;
mbNonHomogeneous = false;
} }
WindowImpl::~WindowImpl() WindowImpl::~WindowImpl()
......
...@@ -2336,6 +2336,18 @@ void Window::set_secondary(bool bSecondary) ...@@ -2336,6 +2336,18 @@ void Window::set_secondary(bool bSecondary)
pWindowImpl->mbSecondary = bSecondary; pWindowImpl->mbSecondary = bSecondary;
} }
bool Window::get_non_homogeneous() const
{
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
return pWindowImpl->mbNonHomogeneous;
}
void Window::set_non_homogeneous(bool bNonHomogeneous)
{
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
pWindowImpl->mbNonHomogeneous = bNonHomogeneous;
}
void Window::add_to_size_group(boost::shared_ptr< VclSizeGroup > xGroup) void Window::add_to_size_group(boost::shared_ptr< VclSizeGroup > xGroup)
{ {
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
......
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