summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-01 15:04:10 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-07-01 16:43:05 +0100
commit7dda48d56f2d10bd6220fba19168ee1a70ecc05f (patch)
tree7038d51388b59b0d01700369f43f6bc711313f72 /vcl
parent8f7f2dc7a8aa6639f41c51216a4b54c4bb885fd4 (diff)
Related: fdo#80633 cache optimal size
Change-Id: Ic2c3aefebd3061d294f339c6d262a3c3e381fbe4
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/window.h2
-rw-r--r--vcl/source/window/tabdlg.cxx4
-rw-r--r--vcl/source/window/window.cxx2
-rw-r--r--vcl/source/window/window2.cxx31
4 files changed, 25 insertions, 14 deletions
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index ccecb3d63c86..e97eabc8d397 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -242,6 +242,8 @@ public:
sal_Int32 mnBottomBorder;
sal_Int32 mnWidthRequest;
sal_Int32 mnHeightRequest;
+ sal_Int32 mnOptimalWidthCache;
+ sal_Int32 mnOptimalHeightCache;
long mnX;
long mnY;
long mnAbsScreenX;
diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx
index 3c36eaeac288..7ce61365f480 100644
--- a/vcl/source/window/tabdlg.cxx
+++ b/vcl/source/window/tabdlg.cxx
@@ -50,7 +50,7 @@ void TabDialog::ImplPosControls()
pTabControl = pChild;
else if ( pTabControl )
{
- Size aOptimalSize(pChild->GetOptimalSize());
+ Size aOptimalSize(pChild->get_preferred_size());
long nTxtWidth = aOptimalSize.Width();
if ( nTxtWidth > aCtrlSize.Width() )
aCtrlSize.Width() = nTxtWidth;
@@ -80,7 +80,7 @@ void TabDialog::ImplPosControls()
Point aTabOffset( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+nOffY );
if (isContainerWindow(*pTabControl))
- pTabControl->SetSizePixel(pTabControl->GetOptimalSize());
+ pTabControl->SetSizePixel(pTabControl->get_preferred_size());
Size aTabSize = pTabControl->GetSizePixel();
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index af060f2470b0..469933829ec3 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -608,6 +608,8 @@ WindowImpl::WindowImpl( WindowType nType )
mnBottomBorder = 0; // bottom border
mnWidthRequest = -1; // width request
mnHeightRequest = -1; // height request
+ mnOptimalWidthCache = -1; // optimal width cache
+ mnOptimalHeightCache = -1; // optimal height cache
mnX = 0; // X-Position to Parent
mnY = 0; // Y-Position to Parent
mnAbsScreenX = 0; // absolute X-position on screen, used for RTL window positioning
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 24ed6fabbe93..52ccd629f6b0 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1428,6 +1428,8 @@ void Window::queue_resize()
bool bSomeoneCares = queue_ungrouped_resize(this);
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ pWindowImpl->mnOptimalWidthCache = -1;
+ pWindowImpl->mnOptimalHeightCache = -1;
if (pWindowImpl->m_xSizeGroup && pWindowImpl->m_xSizeGroup->get_mode() != VCL_SIZE_GROUP_NONE)
{
std::set<Window*> &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
@@ -1689,26 +1691,31 @@ void Window::set_width_request(sal_Int32 nWidthRequest)
}
}
-namespace
+Size Window::get_ungrouped_preferred_size() const
{
- Size get_ungrouped_preferred_size(const Window &rWindow)
+ Size aRet(get_width_request(), get_height_request());
+ if (aRet.Width() == -1 || aRet.Height() == -1)
{
- Size aRet(rWindow.get_width_request(), rWindow.get_height_request());
- if (aRet.Width() == -1 || aRet.Height() == -1)
+ //cache gets blown away by queue_resize
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ if (pWindowImpl->mnOptimalWidthCache == -1 || pWindowImpl->mnOptimalHeightCache == -1)
{
- Size aOptimal = rWindow.GetOptimalSize();
- if (aRet.Width() == -1)
- aRet.Width() = aOptimal.Width();
- if (aRet.Height() == -1)
- aRet.Height() = aOptimal.Height();
+ Size aOptimal(GetOptimalSize());
+ pWindowImpl->mnOptimalWidthCache = aOptimal.Width();
+ pWindowImpl->mnOptimalHeightCache = aOptimal.Height();
}
- return aRet;
+
+ if (aRet.Width() == -1)
+ aRet.Width() = pWindowImpl->mnOptimalWidthCache;
+ if (aRet.Height() == -1)
+ aRet.Height() = pWindowImpl->mnOptimalHeightCache;
}
+ return aRet;
}
Size Window::get_preferred_size() const
{
- Size aRet(get_ungrouped_preferred_size(*this));
+ Size aRet(get_ungrouped_preferred_size());
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
if (pWindowImpl->m_xSizeGroup)
@@ -1726,7 +1733,7 @@ Size Window::get_preferred_size() const
continue;
if (bIgnoreInHidden && !pOther->IsVisible())
continue;
- Size aOtherSize = get_ungrouped_preferred_size(*pOther);
+ Size aOtherSize = pOther->get_ungrouped_preferred_size();
if (eMode == VCL_SIZE_GROUP_BOTH || eMode == VCL_SIZE_GROUP_HORIZONTAL)
aRet.Width() = std::max(aRet.Width(), aOtherSize.Width());
if (eMode == VCL_SIZE_GROUP_BOTH || eMode == VCL_SIZE_GROUP_VERTICAL)