summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-02-01 13:28:07 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-09-28 08:48:08 +0100
commit2b05e3f639b88d0db23691f846eeb615048efe05 (patch)
tree5ace2721f896f598f6f706ae3c8cd8a7dab86d52
parente333190a695ed21fd02c4417f826e4e280b63402 (diff)
reduce flicker with another timer
-rw-r--r--vcl/inc/vcl/dialog.hxx5
-rw-r--r--vcl/source/window/dialog.cxx14
-rw-r--r--vcl/source/window/window.cxx39
3 files changed, 37 insertions, 21 deletions
diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx
index b75f643e462b..a1941c29eafa 100644
--- a/vcl/inc/vcl/dialog.hxx
+++ b/vcl/inc/vcl/dialog.hxx
@@ -32,6 +32,7 @@
#include <tools/solar.h>
#include <vcl/dllapi.h>
#include <vcl/syswin.hxx>
+#include <vcl/timer.hxx>
// parameter to pass to the dialogue constructor if really no parent is wanted
// whereas NULL chooses the deafult dialogue parent
@@ -40,7 +41,6 @@
// ----------
// - Dialog -
// ----------
-
struct DialogImpl;
class VCL_DLLPUBLIC Dialog : public SystemWindow
@@ -54,6 +54,7 @@ private:
sal_Bool mbOldSaveBack;
sal_Bool mbInClose;
sal_Bool mbModalMode;
+ Timer maLayoutTimer;
SAL_DLLPRIVATE void ImplInitDialogData();
SAL_DLLPRIVATE void ImplInitSettings();
@@ -63,6 +64,7 @@ private:
SAL_DLLPRIVATE Dialog & operator= (const Dialog &);
DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* );
+ DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* );
protected:
using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
@@ -70,6 +72,7 @@ protected:
public:
SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; }
+ SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
protected:
Dialog( WindowType nType );
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index ec8ee7289583..f984ddc8e435 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -284,6 +284,10 @@ void Dialog::ImplInitDialogData()
mbModalMode = sal_False;
mnMousePositioned = 0;
mpDialogImpl = new DialogImpl;
+
+ //To-Do, reuse maResizeTimer
+ maLayoutTimer.SetTimeout(50);
+ maLayoutTimer.SetTimeoutHdl( LINK( this, Dialog, ImplHandleLayoutTimerHdl ) );
}
// -----------------------------------------------------------------------
@@ -981,7 +985,7 @@ Size Dialog::GetOptimalSize(WindowSizeType eType) const
return Size(std::min(aMax.Width(), aSize.Width()), std::min(aMax.Height(), aSize.Height()));
}
-void Dialog::Resize()
+IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG )
{
if (isLayoutEnabled())
{
@@ -991,6 +995,14 @@ void Dialog::Resize()
Point aPos(mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder);
GetChild(0)->SetPosSizePixel(aPos, aSize);
}
+ return 0;
+}
+
+void Dialog::Resize()
+{
+ if (hasPendingLayout())
+ return;
+ maLayoutTimer.Start();
}
// -----------------------------------------------------------------------
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 35df88732ec9..5b4cdaacb804 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2477,6 +2477,9 @@ void Window::ImplPostPaint()
IMPL_LINK_NOARG(Window, ImplHandlePaintHdl)
{
+ if (IsDialog() && static_cast<const Dialog*>(this)->hasPendingLayout())
+ return 0;
+
// save paint events until resizing is done
if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
mpWindowImpl->mpFrameData->maPaintTimer.Start();
@@ -9577,29 +9580,27 @@ Selection Window::GetSurroundingTextSelection() const
void Window::queueResize()
{
Dialog *pParent = GetParentDialog();
- if (pParent && pParent->isLayoutEnabled())
+ if (!pParent)
+ return;
+ if (!pParent->isLayoutEnabled())
+ return;
+ if (!pParent->IsReallyShown())
{
- //To-Do: integrate with mpWindowImpl->mpFrameData->maResizeTimer.SetTimeout( 50 );
- if (pParent->IsReallyShown())
- {
- pParent->Resize();
- }
- else
- {
- //resize dialog to fit requisition
- //To-Do: honour explicit sizes ?
- const Box *pContainer = dynamic_cast<const Box*>(pParent->GetChild(0));
- Size aSize = pContainer->GetOptimalSize(WINDOWSIZE_PREFERRED);
+ //resize dialog to fit requisition
+ //To-Do: honour explicit sizes ?
+ const Box *pContainer = dynamic_cast<const Box*>(pParent->GetChild(0));
+ Size aSize = pContainer->GetOptimalSize(WINDOWSIZE_PREFERRED);
- Size aMax = pParent->GetOptimalSize(WINDOWSIZE_MAXIMUM);
- aSize.Width() = std::min(aMax.Width(), aSize.Width());
- aSize.Height() = std::min(aMax.Height(), aSize.Height());
+ Size aMax = pParent->GetOptimalSize(WINDOWSIZE_MAXIMUM);
+ aSize.Width() = std::min(aMax.Width(), aSize.Width());
+ aSize.Height() = std::min(aMax.Height(), aSize.Height());
- pParent->SetMinOutputSizePixel(aSize);
- pParent->SetSizePixel(aSize);
- pParent->Resize();
- }
+ pParent->SetMinOutputSizePixel(aSize);
+ pParent->SetSizePixel(aSize);
}
+ if (pParent->hasPendingLayout())
+ return;
+ pParent->Resize();
}
void Window::setChildAnyProperty(const rtl::OString &rString, const Any &rValue)