diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-12-30 15:54:34 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-12-30 15:56:28 +0000 |
commit | a73475cecdac393b40c34770be65be40bf05e011 (patch) | |
tree | 152bde6a97db82df7e628a0743f66f7741290680 | |
parent | 11d0c28601dc89c48e67a7b39ba82dd52e660334 (diff) |
DockingWindow will need a timer after all
to update layout after initial show when
contents change
Change-Id: I8edbe84fa366cdb04dbfe5e479dc01cbf04dbf4c
-rw-r--r-- | include/vcl/dockwin.hxx | 6 | ||||
-rw-r--r-- | vcl/source/window/dockwin.cxx | 32 |
2 files changed, 37 insertions, 1 deletions
diff --git a/include/vcl/dockwin.hxx b/include/vcl/dockwin.hxx index 6dfad81eb3a5..691478164b6c 100644 --- a/include/vcl/dockwin.hxx +++ b/include/vcl/dockwin.hxx @@ -247,6 +247,7 @@ private: sal_Int32 mnDockRight; sal_Int32 mnDockBottom; WinBits mnFloatBits; + Idle maLayoutIdle; bool mbDockCanceled:1, mbDockPrevented:1, mbFloatPrevented:1, @@ -268,6 +269,7 @@ private: SAL_DLLPRIVATE void ImplInitDockingWindowData(); SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox); + DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* ); // Copy assignment is forbidden and not implemented. SAL_DLLPRIVATE DockingWindow (const DockingWindow &); @@ -291,6 +293,7 @@ public: SAL_DLLPRIVATE bool ImplStartDocking( const Point& rPos ); SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; } + SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutIdle.IsActive(); } void doDeferredInit(WinBits nBits); protected: DockingWindow( WindowType nType ); @@ -361,9 +364,10 @@ public: void SetOutputSizePixel( const Size& rNewSize ) SAL_OVERRIDE; Size GetOutputSizePixel() const; - virtual void SetText( const OUString& rStr ) SAL_OVERRIDE; + virtual void SetText( const OUString& rStr ) SAL_OVERRIDE; virtual OUString GetText() const SAL_OVERRIDE; virtual Size GetOptimalSize() const SAL_OVERRIDE; + virtual void queue_resize(StateChangedType eReason = StateChangedType::LAYOUT) SAL_OVERRIDE; }; inline void DockingWindow::SetPin( bool bPin ) diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx index 95dd54b0400b..6d9186eca6ec 100644 --- a/vcl/source/window/dockwin.cxx +++ b/vcl/source/window/dockwin.cxx @@ -329,6 +329,10 @@ void DockingWindow::ImplInitDockingWindowData() mbIsCalculatingInitialLayoutSize = false; mbInitialLayoutDone = false; mpDialogParent = NULL; + + //To-Do, reuse maResizeTimer + maLayoutIdle.SetPriority(VCL_IDLE_PRIORITY_RESIZE); + maLayoutIdle.SetIdleHdl( LINK( this, DockingWindow, ImplHandleLayoutTimerHdl ) ); } void DockingWindow::ImplInit( vcl::Window* pParent, WinBits nStyle ) @@ -1078,6 +1082,8 @@ bool DockingWindow::isLayoutEnabled() const void DockingWindow::setOptimalLayoutSize() { + maLayoutIdle.Stop(); + //resize DockingWindow to fit requisition on initial show Window *pBox = GetWindow(WINDOW_FIRSTCHILD); @@ -1121,4 +1127,30 @@ Size DockingWindow::GetOptimalSize() const return Window::CalcWindowSize(aSize); } +void DockingWindow::queue_resize(StateChangedType /*eReason*/) +{ + if (hasPendingLayout() || isCalculatingInitialLayoutSize()) + return; + if (!isLayoutEnabled()) + return; + WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; + pWindowImpl->mnOptimalWidthCache = -1; + pWindowImpl->mnOptimalHeightCache = -1; + maLayoutIdle.Start(); +} + +IMPL_LINK(DockingWindow, ImplHandleLayoutTimerHdl, void*, EMPTYARG) +{ + if (!isLayoutEnabled()) + { + SAL_WARN("vcl.layout", "DockingWindow has become non-layout because extra children have been added directly to it."); + return 0; + } + + Window *pBox = GetWindow(WINDOW_FIRSTCHILD); + assert(pBox); + setPosSizeOnContainee(GetSizePixel(), *pBox); + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |