diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-14 12:05:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-06-14 16:43:24 +0200 |
commit | 574d02a7a81f99d08512410fcd3262b41db8c209 (patch) | |
tree | 3fdeacdebcca37187a1e817bda3566a0d5ee36b7 | |
parent | 5615b7d643da3ba5319e9e9acaa5e943ffbbcf7e (diff) |
do setPreviewsToSamePlace at SfxTabDialogController display time
Change-Id: Ia38c1a577b7d054ab4e7e70a8f2cbce16a3573f5
Reviewed-on: https://gerrit.libreoffice.org/55793
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/sfx2/tabdlg.hxx | 2 | ||||
-rw-r--r-- | include/vcl/layout.hxx | 8 | ||||
-rw-r--r-- | include/vcl/vclenum.hxx | 7 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 9 | ||||
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 31 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 26 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 46 |
7 files changed, 121 insertions, 8 deletions
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx index bdae835ffca2..163693d9fe9b 100644 --- a/include/sfx2/tabdlg.hxx +++ b/include/sfx2/tabdlg.hxx @@ -239,6 +239,7 @@ private: std::unique_ptr<weld::Button> m_xUserBtn; std::unique_ptr<weld::Button> m_xCancelBtn; std::unique_ptr<weld::Button> m_xResetBtn; + std::unique_ptr<weld::SizeGroup> m_xSizeGroup; SfxItemSet* m_pSet; std::unique_ptr<SfxItemSet> m_pOutSet; @@ -250,6 +251,7 @@ private: DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool); SAL_DLLPRIVATE void Init_Impl(bool bFmtFlag); SAL_DLLPRIVATE void CreatePages(); + SAL_DLLPRIVATE void setPreviewsToSamePlace(); protected: virtual short Ok(); diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index d2fefe01f875..298601da6e8f 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -564,14 +564,6 @@ public: virtual void Command(const CommandEvent& rCEvt) override; }; -enum class VclSizeGroupMode -{ - NONE, - Horizontal, - Vertical, - Both -}; - class VCL_DLLPUBLIC VclSizeGroup { private: diff --git a/include/vcl/vclenum.hxx b/include/vcl/vclenum.hxx index 8697465af32d..0de6703f6aba 100644 --- a/include/vcl/vclenum.hxx +++ b/include/vcl/vclenum.hxx @@ -242,6 +242,13 @@ enum class VclMessageType Error }; +enum class VclSizeGroupMode +{ + NONE, + Horizontal, + Vertical, + Both +}; #endif // INCLUDED_VCL_VCLENUM_HXX diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 86718d52a642..d0c5c220f375 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -864,6 +864,14 @@ public: virtual ~Menu() {} }; +class VCL_DLLPUBLIC SizeGroup +{ +public: + virtual void add_widget(weld::Widget* pWidget) = 0; + virtual void set_mode(VclSizeGroupMode eMode) = 0; + virtual ~SizeGroup() {} +}; + class VCL_DLLPUBLIC Builder { private: @@ -914,6 +922,7 @@ public: void* pUserData = nullptr, bool bTakeOwnership = false) = 0; virtual Menu* weld_menu(const OString& id, bool bTakeOwnership = true) = 0; + virtual SizeGroup* create_size_group() = 0; virtual ~Builder() {} }; diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 5521fe9a0305..48e721c2baf7 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -1957,6 +1957,35 @@ void SfxTabDialogController::CreatePages() } } +void SfxTabDialogController::setPreviewsToSamePlace() +{ + //where tab pages have the same basic layout with a preview on the right, + //get both of their non-preview areas to request the same size so that the + //preview appears in the same place in each one so flipping between tabs + //isn't distracting as it jumps around + std::vector<std::unique_ptr<weld::Widget>> aGrids; + for (auto pDataObject : m_pImpl->aData) + { + if (pDataObject->pTabPage) + continue; + if (!pDataObject->pTabPage->m_xBuilder) + continue; + weld::Widget* pGrid = pDataObject->pTabPage->m_xBuilder->weld_widget("maingrid"); + if (!pGrid) + continue; + aGrids.emplace_back(pGrid); + } + + m_xSizeGroup.reset(); + + if (aGrids.size() <= 1) + return; + + m_xSizeGroup.reset(m_xBuilder->create_size_group()); + for (auto& rGrid : aGrids) + m_xSizeGroup->add_widget(rGrid.get()); +} + void SfxTabDialogController::RemoveTabPage(const OString& rId) /* [Description] @@ -2000,6 +2029,8 @@ void SfxTabDialogController::Start_Impl() { CreatePages(); + setPreviewsToSamePlace(); + assert(m_pImpl->aData.size() == static_cast<size_t>(m_xTabCtrl->get_n_pages()) && "not all pages registered"); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 00ff6c6a9090..20f957af82d3 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -457,6 +457,27 @@ public: } }; +class SalInstanceSizeGroup : public weld::SizeGroup +{ +private: + std::shared_ptr<VclSizeGroup> m_xGroup; +public: + SalInstanceSizeGroup() + : m_xGroup(new VclSizeGroup) + { + } + virtual void add_widget(weld::Widget* pWidget) override + { + SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget); + assert(pVclWidget); + m_xGroup->insert(pVclWidget->getWidget()); + } + virtual void set_mode(VclSizeGroupMode eMode) override + { + m_xGroup->set_mode(eMode); + } +}; + class SalInstanceContainer : public SalInstanceWidget, public virtual weld::Container { private: @@ -2360,6 +2381,11 @@ public: return pMenu ? new SalInstanceMenu(pMenu, bTakeOwnership) : nullptr; } + virtual weld::SizeGroup* create_size_group() override + { + return new SalInstanceSizeGroup; + } + virtual ~SalInstanceBuilder() override { if (VclBuilderContainer* pOwnedToplevel = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get())) diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index cc927fe89742..47ef69b4077a 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1747,6 +1747,47 @@ public: } }; +class GtkInstanceSizeGroup : public weld::SizeGroup +{ +private: + GtkSizeGroup* m_pGroup; +public: + GtkInstanceSizeGroup() + : m_pGroup(gtk_size_group_new(GTK_SIZE_GROUP_NONE)) + { + } + virtual void add_widget(weld::Widget* pWidget) override + { + GtkInstanceWidget* pVclWidget = dynamic_cast<GtkInstanceWidget*>(pWidget); + assert(pVclWidget); + gtk_size_group_add_widget(m_pGroup, pVclWidget->getWidget()); + } + virtual void set_mode(VclSizeGroupMode eVclMode) override + { + GtkSizeGroupMode eGtkMode; + switch (eVclMode) + { + case VclSizeGroupMode::NONE: + eGtkMode = GTK_SIZE_GROUP_NONE; + break; + case VclSizeGroupMode::Horizontal: + eGtkMode = GTK_SIZE_GROUP_HORIZONTAL; + break; + case VclSizeGroupMode::Vertical: + eGtkMode = GTK_SIZE_GROUP_VERTICAL; + break; + case VclSizeGroupMode::Both: + eGtkMode = GTK_SIZE_GROUP_BOTH; + break; + } + gtk_size_group_set_mode(m_pGroup, eGtkMode); + } + virtual ~GtkInstanceSizeGroup() override + { + g_object_unref(m_pGroup); + } +}; + class GtkInstanceContainer : public GtkInstanceWidget, public virtual weld::Container { private: @@ -4885,6 +4926,11 @@ public: return nullptr; return new GtkInstanceMenu(pMenu, bTakeOwnership); } + + virtual weld::SizeGroup* create_size_group() override + { + return new GtkInstanceSizeGroup; + } }; void GtkInstanceWindow::help() |