[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/sfx2 include/vcl sfx2/source vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Thu Jun 14 20:08:54 UTC 2018
include/sfx2/tabdlg.hxx | 2 +
include/vcl/layout.hxx | 8 -------
include/vcl/vclenum.hxx | 7 ++++++
include/vcl/weld.hxx | 9 ++++++++
sfx2/source/dialog/tabdlg.cxx | 31 ++++++++++++++++++++++++++++
vcl/source/app/salvtables.cxx | 26 +++++++++++++++++++++++
vcl/unx/gtk3/gtk3gtkinst.cxx | 46 ++++++++++++++++++++++++++++++++++++++++++
7 files changed, 121 insertions(+), 8 deletions(-)
New commits:
commit 98ac01e74ab95c735b7383601ad2e4ed09962184
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jun 14 12:05:10 2018 +0100
do setPreviewsToSamePlace at SfxTabDialogController display time
Change-Id: Ia38c1a577b7d054ab4e7e70a8f2cbce16a3573f5
Reviewed-on: https://gerrit.libreoffice.org/55810
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 3cb85718fc8f..26ff5ce47492 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 78ba325fd581..534cef32f2a5 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1963,6 +1963,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]
@@ -2006,6 +2035,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 8e9689c7c2c1..a703f1bc00f6 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -462,6 +462,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:
@@ -2365,6 +2386,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()
More information about the Libreoffice-commits
mailing list