summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-06-16 13:29:15 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-28 08:48:31 +0100
commit43713eb40f464dfb457efa7659f85c4b60b7c611 (patch)
tree563efb04a138a408257fb058b5d9b8e52654a61e /vcl
parent00876d07c8d8a95e547bc2f4dcd176e6b8c8e3af (diff)
avoid redraws when size/pos is unchanged
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/layout.hxx2
-rw-r--r--vcl/source/window/dialog.cxx27
-rw-r--r--vcl/source/window/layout.cxx72
3 files changed, 69 insertions, 32 deletions
diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx
index b0fe34f09b60..e5308e1fba40 100644
--- a/vcl/inc/vcl/layout.hxx
+++ b/vcl/inc/vcl/layout.hxx
@@ -39,6 +39,8 @@ public:
virtual Size GetOptimalSize(WindowSizeType eType) const;
using Window::SetPosSizePixel;
virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize);
+ virtual void SetPosPixel(const Point& rAllocPos);
+ virtual void SetSizePixel(const Size& rAllocation);
virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
void set_border_width(int nBorderWidth)
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index c37ba2c9991d..3fca7b2b9670 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1172,9 +1172,7 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal
bool Dialog::isLayoutEnabled() const
{
//Child is a container => we're layout enabled
- bool bRet = dynamic_cast<const VclContainer*>(GetWindow(WINDOW_FIRSTCHILD));
- fprintf(stderr, "isLayoutEnabled is %d\n", bRet);
- return bRet;
+ return dynamic_cast<const VclContainer*>(GetWindow(WINDOW_FIRSTCHILD));
}
Size Dialog::GetOptimalSize(WindowSizeType eType) const
@@ -1184,27 +1182,18 @@ Size Dialog::GetOptimalSize(WindowSizeType eType) const
Size aSize = GetWindow(WINDOW_FIRSTCHILD)->GetOptimalSize(eType);
- fprintf(stderr, "dialog contents wanted to be %d %d\n", aSize.Width(),
- aSize.Height());
-
aSize.Height() += mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder
+ 2*m_nBorderWidth;
aSize.Width() += mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder
+ 2*m_nBorderWidth;
- fprintf(stderr, "stage 2 dialog wanted to be %d %d\n", aSize.Width(),
- aSize.Height());
-
- aSize = Window::CalcWindowSize(aSize);
-
- fprintf(stderr, "stage 3 dialog wanted to be %d %d\n", aSize.Width(),
- aSize.Height());
-
- return aSize;
+ return Window::CalcWindowSize(aSize);
}
IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG )
{
+ fprintf(stderr, "ImplHandleLayoutTimerHdl\n");
+
VclBox *pBox = dynamic_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD));
if (!pBox)
{
@@ -1213,19 +1202,11 @@ IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG )
}
Size aSize = GetSizePixel();
- fprintf(stderr, "stage 4 dialog claimed to be %d %d\n", aSize.Width(),
- aSize.Height());
-
aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder
+ 2 * m_nBorderWidth;
aSize.Height() -= mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder
+ 2 * m_nBorderWidth;
- fprintf(stderr, "stage 5 space for contents ends up as %d %d\n", aSize.Width(),
- aSize.Height());
- fprintf(stderr, "dialog got given %d %d\n", aSize.Width(),
- aSize.Height());
-
Point aPos(mpWindowImpl->mnLeftBorder + m_nBorderWidth,
mpWindowImpl->mnTopBorder + m_nBorderWidth);
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index e74ebdf33888..b4ca47224382 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -42,6 +42,8 @@ Size VclContainer::GetOptimalSize(WindowSizeType eType) const
void VclContainer::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
{
+ fprintf(stderr, "VclContainer::SetPosSizePixel\n");
+
Size aAllocation = rAllocation;
aAllocation.Width() -= m_nBorderWidth*2;
aAllocation.Height() -= m_nBorderWidth*2;
@@ -50,8 +52,44 @@ void VclContainer::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocati
aAllocPos.X() += m_nBorderWidth;
aAllocPos.Y() += m_nBorderWidth;
- Window::SetPosSizePixel(aAllocPos, aAllocation);
- setAllocation(aAllocation);
+ bool bPosChanged = aAllocPos != GetPosPixel();
+ bool bSizeChanged = aAllocation != GetSizePixel();
+ if (bPosChanged && bSizeChanged)
+ Window::SetPosSizePixel(aAllocPos, aAllocation);
+ else if (bPosChanged)
+ Window::SetPosPixel(aAllocPos);
+ else if (bSizeChanged)
+ Window::SetSizePixel(aAllocation);
+
+ if (bSizeChanged)
+ {
+ fprintf(stderr, "VclContainer::setAllocation\n");
+ setAllocation(aAllocation);
+ }
+}
+
+void VclContainer::SetPosPixel(const Point& rAllocPos)
+{
+ Point aAllocPos = rAllocPos;
+ aAllocPos.X() += m_nBorderWidth;
+ aAllocPos.Y() += m_nBorderWidth;
+
+ if (aAllocPos != GetPosPixel())
+ Window::SetPosPixel(aAllocPos);
+}
+
+void VclContainer::SetSizePixel(const Size& rAllocation)
+{
+ Size aAllocation = rAllocation;
+ aAllocation.Width() -= m_nBorderWidth*2;
+ aAllocation.Height() -= m_nBorderWidth*2;
+
+ if (aAllocation != GetSizePixel())
+ {
+ Window::SetSizePixel(aAllocation);
+ fprintf(stderr, "VclContainer::setAllocation\n");
+ setAllocation(aAllocation);
+ }
}
bool VclContainer::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
@@ -103,6 +141,22 @@ Size VclBox::calculateRequisition() const
return aSize;
}
+namespace
+{
+ //avoid redraws when size/pos is unchanged
+ void setPosSizePixel(Window &rWindow, const Point& rAllocPos, const Size& rAllocation)
+ {
+ bool bPosChanged = rAllocPos != rWindow.GetPosPixel();
+ bool bSizeChanged = rAllocation != rWindow.GetSizePixel();
+ if (bPosChanged && bSizeChanged)
+ rWindow.SetPosSizePixel(rAllocPos, rAllocation);
+ else if (bPosChanged)
+ rWindow.SetPosPixel(rAllocPos);
+ else if (bSizeChanged)
+ rWindow.SetSizePixel(rAllocation);
+ }
+}
+
void VclBox::setAllocation(const Size &rAllocation)
{
//SetBackground( Color(0x00, 0xFF, 0x00) );
@@ -207,7 +261,7 @@ void VclBox::setAllocation(const Size &rAllocation)
getPrimaryDimension(aBoxSize));
}
- pChild->SetPosSizePixel(aChildPos, aChildSize);
+ setPosSizePixel(*pChild, aChildPos, aChildSize);
}
}
}
@@ -336,7 +390,7 @@ void VclButtonBox::setAllocation(const Size &rAllocation)
setSecondaryDimension(aChildSize, getSecondaryDimension(aSize));
setPrimaryDimension(aChildSize, nHomogeneousDimension);
- pChild->SetPosSizePixel(aPos, aChildSize);
+ setPosSizePixel(*pChild, aPos, aChildSize);
nPrimaryCoordinate = getPrimaryCoordinate(aPos);
setPrimaryCoordinate(aPos, nPrimaryCoordinate + nHomogeneousDimension + m_nSpacing);
@@ -627,7 +681,7 @@ void VclGrid::setAllocation(const Size& rAllocation)
break;
}
- pChild->SetPosSizePixel(aChildPos, aChildSize);
+ setPosSizePixel(*pChild, aChildPos, aChildSize);
}
aAllocPos.Y() += aHeights[y] + get_row_spacing();
}
@@ -694,7 +748,7 @@ void VclBin::setAllocation(const Size &rAllocation)
{
Window *pChild = get_child();
if (pChild && pChild->IsVisible())
- pChild->SetPosSizePixel(Point(0, 0), rAllocation);
+ setPosSizePixel(*pChild, Point(0, 0), rAllocation);
}
//To-Do, hook a DecorationView into VclFrame ?
@@ -747,13 +801,13 @@ void VclFrame::setAllocation(const Size &rAllocation)
Size aLabelSize = pLabel->GetOptimalSize(WINDOWSIZE_PREFERRED);
aLabelSize.Height() = std::min(aLabelSize.Height(), aAllocation.Height());
aLabelSize.Width() = std::min(aLabelSize.Width(), aAllocation.Width());
- pLabel->SetPosSizePixel(aChildPos, aLabelSize);
+ setPosSizePixel(*pLabel, aChildPos, aLabelSize);
aAllocation.Height() -= aLabelSize.Height();
aChildPos.Y() += aLabelSize.Height();
}
if (pChild && pChild->IsVisible())
- pChild->SetPosSizePixel(aChildPos, aAllocation);
+ setPosSizePixel(*pChild, aChildPos, aAllocation);
}
Size VclAlignment::calculateRequisition() const
@@ -786,7 +840,7 @@ void VclAlignment::setAllocation(const Size &rAllocation)
aAllocation.Width() = rAllocation.Width() - (m_nLeftPadding + m_nRightPadding);
aAllocation.Height() = rAllocation.Height() - (m_nTopPadding + m_nBottomPadding);
- pChild->SetPosSizePixel(aChildPos, aAllocation);
+ setPosSizePixel(*pChild, aChildPos, aAllocation);
}
bool VclAlignment::set_property(const rtl::OString &rKey, const rtl::OString &rValue)