From a48cf78fab4a283ef43c091e8c324c968377f9db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 30 Sep 2013 14:44:37 +0100 Subject: [PATCH] merge queue_layout and queue_resize so that any window derived class, and not just dialogs, can trigger layouting of their children. Merge together the handful of hacked-up impls of this. Do that then for the sidebar PanelLayout so that when the label of the custom animation frame changes that the frame allocates enough space for the new label to display fully Change-Id: I9a95f6c3f60cd6cea47656e66cb9ffcc154a3a5a --- cui/source/inc/treeopt.hxx | 2 +- cui/source/options/treeopt.cxx | 2 +- include/svtools/wizdlg.hxx | 2 +- include/svx/sidebar/PanelLayout.hxx | 11 +++++++++- include/vcl/dialog.hxx | 2 +- include/vcl/layout.hxx | 2 ++ include/vcl/tabctrl.hxx | 2 ++ include/vcl/window.hxx | 2 +- svtools/source/dialogs/wizdlg.cxx | 2 +- svx/source/sidebar/PanelLayout.cxx | 33 +++++++++++++++++++++++++++++ vcl/source/control/tabctrl.cxx | 6 ++++++ vcl/source/window/dialog.cxx | 4 ++-- vcl/source/window/layout.cxx | 6 ++++++ vcl/source/window/window2.cxx | 20 +++-------------- 14 files changed, 70 insertions(+), 26 deletions(-) diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx index 396834566c87..adf6563a630e 100644 --- a/cui/source/inc/treeopt.hxx +++ b/cui/source/inc/treeopt.hxx @@ -186,7 +186,7 @@ private: VectorOfNodes LoadNodes( Module* pModule, const OUString& rExtensionId ); void InsertNodes( const VectorOfNodes& rNodeList ); - virtual void queue_layout(); + virtual void queue_resize(); void SetPaneSize(Window *pPane); protected: diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 3239304719b9..01c9f22a2276 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -930,7 +930,7 @@ bool OfaTreeOptionsDialog::hasTreePendingLayout() const return maTreeLayoutTimer.IsActive(); } -void OfaTreeOptionsDialog::queue_layout() +void OfaTreeOptionsDialog::queue_resize() { if (hasTreePendingLayout()) return; diff --git a/include/svtools/wizdlg.hxx b/include/svtools/wizdlg.hxx index 82212b3208c7..92a26ee376c4 100644 --- a/include/svtools/wizdlg.hxx +++ b/include/svtools/wizdlg.hxx @@ -263,7 +263,7 @@ public: virtual void ActivatePage(); virtual long DeactivatePage(); - virtual void queue_layout(); + virtual void queue_resize(); sal_Bool ShowPrevPage(); sal_Bool ShowNextPage(); diff --git a/include/svx/sidebar/PanelLayout.hxx b/include/svx/sidebar/PanelLayout.hxx index 3395e7f9aab7..2fa82ee2d84d 100644 --- a/include/svx/sidebar/PanelLayout.hxx +++ b/include/svx/sidebar/PanelLayout.hxx @@ -14,19 +14,28 @@ #include #include +#include #include /// This class is the base for the Widget Layout-based sidebar panels. class SVX_DLLPUBLIC PanelLayout : public Control, public VclBuilderContainer { +private: + Timer m_aPanelLayoutTimer; + bool m_bInClose; + bool hasPanelPendingLayout() const; + + DECL_DLLPRIVATE_LINK( ImplHandlePanelLayoutTimerHdl, void* ); + public: PanelLayout(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const com::sun::star::uno::Reference &rFrame); - virtual ~PanelLayout() {} + virtual ~PanelLayout(); virtual Size GetOptimalSize() const; virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL); + virtual void queue_resize(); }; #endif diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 4e20d633e54d..afaea70ab27f 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -104,7 +104,7 @@ public: bool isLayoutEnabled() const; void setOptimalLayoutSize(); bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; } - virtual void queue_layout(); + virtual void queue_resize(); virtual bool set_property(const OString &rKey, const OString &rValue); VclButtonBox* get_action_area(); VclBox* get_content_area(); diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index 47b9593f3fbc..0fa87ecab24f 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -39,6 +39,8 @@ public: { m_bLayoutDirty = true; } + + virtual void queue_resize(); protected: //these are the two that need to be implemented by //containers, figure out how much space you want... diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index 383c9236b700..53b3572feb15 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -201,6 +201,8 @@ public: { mbLayoutDirty = true; } + + virtual void queue_resize(); }; #endif // _SV_TABCTRL_HXX diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 4408adb98381..e255272ef6d8 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1074,7 +1074,7 @@ public: * * akin to gtk_widget_queue_resize */ - void queue_resize(); + virtual void queue_resize(); /* * Sets the "width-request" property diff --git a/svtools/source/dialogs/wizdlg.cxx b/svtools/source/dialogs/wizdlg.cxx index df05a6239cc1..153a29e28566 100644 --- a/svtools/source/dialogs/wizdlg.cxx +++ b/svtools/source/dialogs/wizdlg.cxx @@ -119,7 +119,7 @@ bool WizardDialog::hasWizardPendingLayout() const return maWizardLayoutTimer.IsActive(); } -void WizardDialog::queue_layout() +void WizardDialog::queue_resize() { if (hasWizardPendingLayout()) return; diff --git a/svx/source/sidebar/PanelLayout.cxx b/svx/source/sidebar/PanelLayout.cxx index 003ca3e1ecf3..e31c75b2619b 100644 --- a/svx/source/sidebar/PanelLayout.cxx +++ b/svx/source/sidebar/PanelLayout.cxx @@ -12,9 +12,18 @@ PanelLayout::PanelLayout(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const com::sun::star::uno::Reference &rFrame) : Control(pParent) + , m_bInClose(false) { SetStyle(GetStyle() | WB_DIALOGCONTROL); m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame); + m_aPanelLayoutTimer.SetTimeout(50); + m_aPanelLayoutTimer.SetTimeoutHdl( LINK( this, PanelLayout, ImplHandlePanelLayoutTimerHdl ) ); +} + +PanelLayout::~PanelLayout() +{ + m_bInClose = true; + m_aPanelLayoutTimer.Stop(); } Size PanelLayout::GetOptimalSize() const @@ -25,6 +34,30 @@ Size PanelLayout::GetOptimalSize() const return Control::GetOptimalSize(); } +bool PanelLayout::hasPanelPendingLayout() const +{ + return m_aPanelLayoutTimer.IsActive(); +} + +void PanelLayout::queue_resize() +{ + if (m_bInClose) + return; + if (hasPanelPendingLayout()) + return; + if (!isLayoutEnabled(this)) + return; + m_aPanelLayoutTimer.Start(); +} + +IMPL_LINK( PanelLayout, ImplHandlePanelLayoutTimerHdl, void*, EMPTYARG ) +{ + Window *pChild = GetWindow(WINDOW_FIRSTCHILD); + assert(pChild); + VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel()); + return 0; +} + void PanelLayout::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags) { bool bCanHandleSmallerWidth = false; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 3504b900c0c0..93ee0cdbabcc 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2361,4 +2361,10 @@ Size TabControl::GetOptimalSize() const return calculateRequisition(); } +void TabControl::queue_resize() +{ + markLayoutDirty(); + Window::queue_resize(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index ef14a796970d..17f0e37492aa 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1254,7 +1254,7 @@ IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG ) return 0; } -void Dialog::queue_layout() +void Dialog::queue_resize() { if (hasPendingLayout() || isCalculatingInitialLayoutSize()) return; @@ -1267,7 +1267,7 @@ void Dialog::queue_layout() void Dialog::Resize() { - queue_layout(); + queue_resize(); } bool Dialog::set_property(const OString &rKey, const OString &rValue) diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index e7f5e1b9c867..dff2546fc18c 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -156,6 +156,12 @@ void VclContainer::SetSizePixel(const Size& rAllocation) } } +void VclContainer::queue_resize() +{ + markLayoutDirty(); + Window::queue_resize(); +} + void VclBox::accumulateMaxes(const Size &rChildSize, Size &rSize) const { long nSecondaryChildDimension = getSecondaryDimension(rChildSize); diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index aa919519995c..475181cc4373 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1732,34 +1732,20 @@ namespace { bool bSomeoneCares = false; - Dialog *pDialog = NULL; - - Window *pWindow = pOrigWindow; - - while (pWindow) + Window *pWindow = pOrigWindow->GetParent(); + if (pWindow) { if (isContainerWindow(*pWindow)) { - VclContainer *pContainer = static_cast(pWindow); - pContainer->markLayoutDirty(); bSomeoneCares = true; } else if (pWindow->GetType() == WINDOW_TABCONTROL) { - TabControl *pTabControl = static_cast(pWindow); - pTabControl->markLayoutDirty(); bSomeoneCares = true; } - else if (pWindow->IsDialog()) - { - pDialog = dynamic_cast(pWindow); - break; - } - pWindow = pWindow->GetParent(); + pWindow->queue_resize(); } - if (pDialog && pDialog != pOrigWindow) - pDialog->queue_layout(); return bSomeoneCares; } }