From 705dcfe362d4a6e99c1ef2b09a343cdbfe4f4674 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 12 Sep 2025 13:10:11 +0300 Subject: [PATCH] Add a Notebookbar widget for theme colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Banobe Pascal Change-Id: I1becca9852745b9972d270e280f386d1803d2731 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190867 Tested-by: Jenkins CollaboraOffice Reviewed-by: Szymon Kłos Reviewed-by: Samuel Mehrbrodt Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198151 Tested-by: Jenkins --- include/svx/dialog/ThemeColorsPaneBase.hxx | 54 +++++++ include/svx/dialog/ThemeDialog.hxx | 18 +-- .../org/openoffice/Office/UI/Controller.xcu | 11 ++ .../openoffice/Office/UI/GenericCommands.xcu | 8 + sd/Library_sd.mk | 1 + .../controller/ThemeColorsToolBoxControl.cxx | 150 ++++++++++++++++++ .../controller/ThemeColorsToolBoxControl.hxx | 68 ++++++++ sd/uiconfig/simpress/ui/notebookbar_online.ui | 24 +++ sd/util/sd.component | 4 + solenv/sanitizers/ui/modules/simpress.suppr | 1 + svx/Library_svx.mk | 1 + svx/UIConfig_svx.mk | 1 + svx/source/dialog/ThemeColorsPaneBase.cxx | 133 ++++++++++++++++ svx/source/dialog/ThemeDialog.cxx | 97 +---------- svx/uiconfig/ui/themeselectorpanel.ui | 49 ++++++ vcl/jsdialog/enabled.cxx | 1 + vcl/workben/cgmfuzzer.cxx | 2 + 17 files changed, 518 insertions(+), 105 deletions(-) create mode 100644 include/svx/dialog/ThemeColorsPaneBase.hxx create mode 100644 sd/source/ui/controller/ThemeColorsToolBoxControl.cxx create mode 100644 sd/source/ui/controller/ThemeColorsToolBoxControl.hxx create mode 100644 svx/source/dialog/ThemeColorsPaneBase.cxx create mode 100644 svx/uiconfig/ui/themeselectorpanel.ui diff --git a/include/svx/dialog/ThemeColorsPaneBase.hxx b/include/svx/dialog/ThemeColorsPaneBase.hxx new file mode 100644 index 000000000000..4ae2e0d609a3 --- /dev/null +++ b/include/svx/dialog/ThemeColorsPaneBase.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace model +{ +class Theme; +} +class VirtualDevice; + +namespace svx +{ +/// Base class for theme color selection functionality +class SVX_DLLPUBLIC ThemeColorsPaneBase +{ +protected: + std::unique_ptr mxIconViewThemeColors; + std::vector maColorSets; + std::shared_ptr mpCurrentColorSet; + + void initColorSets(model::Theme* pTheme = nullptr); + static VclPtr CreateColorSetPreview(const model::ColorSet& rColorSet); + +public: + explicit ThemeColorsPaneBase(std::unique_ptr xIconView); + virtual ~ThemeColorsPaneBase(); + + DECL_LINK(SelectionChangedHdl, weld::IconView&, void); + DECL_LINK(ItemActivatedHdl, weld::IconView&, bool); + + std::shared_ptr const& getCurrentColorSet() { return mpCurrentColorSet; } + +protected: + /// Override this to handle theme color activation + virtual void onColorSetActivated() {} +}; + +} // end svx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/svx/dialog/ThemeDialog.hxx b/include/svx/dialog/ThemeDialog.hxx index ebc73cffb296..caba5a768936 100644 --- a/include/svx/dialog/ThemeDialog.hxx +++ b/include/svx/dialog/ThemeDialog.hxx @@ -15,7 +15,7 @@ #include #include #include - +#include namespace model { class Theme; @@ -23,31 +23,25 @@ class Theme; namespace svx { -class SVX_DLLPUBLIC ThemeDialog final : public weld::GenericDialogController +class SVX_DLLPUBLIC ThemeDialog final : public weld::GenericDialogController, + public ThemeColorsPaneBase { private: model::Theme* mpTheme; std::shared_ptr mxSubDialog; - std::vector maColorSets; - std::unique_ptr mxIconViewThemeColors; std::unique_ptr mxAdd; - std::shared_ptr mpCurrentColorSet; - void runThemeColorEditDialog(); - void initColorSets(); - static VclPtr CreateColorSetPreview(const model::ColorSet& rColorSet); + +protected: + void onColorSetActivated() override; public: ThemeDialog(weld::Window* pParent, model::Theme* pTheme); virtual ~ThemeDialog() override; - DECL_LINK(ItemActivatedHdl, weld::IconView&, bool); - DECL_LINK(SelectionChangedHdl, weld::IconView&, void); DECL_LINK(ButtonClicked, weld::Button&, void); - - std::shared_ptr const& getCurrentColorSet() { return mpCurrentColorSet; } }; } // end svx namespace diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index 5d1209b5459c..4a25165d8f94 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -1116,6 +1116,17 @@ com.sun.star.comp.sd.SlideMasterPagesAllToolBoxControl + + + .uno:ThemeSelectorPanel + + + com.sun.star.presentation.PresentationDocument + + + com.sun.star.comp.sd.ThemeColorsToolBoxControl + + .uno:DefaultBullet diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 006c711018b8..ae2ce5696ca3 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -3539,6 +3539,14 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 1 + + + Theme... + + + 1 + + diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 4c6140046464..5b086b085966 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -231,6 +231,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/controller/slidelayoutcontroller \ sd/source/ui/controller/displaymodecontroller \ sd/source/ui/controller/SlideTransitionsToolBoxControl \ + sd/source/ui/controller/ThemeColorsToolBoxControl \ sd/source/ui/dlg/AnimationChildWindow \ sd/source/ui/dlg/LayerTabBar \ sd/source/ui/dlg/NavigatorChildWindow \ diff --git a/sd/source/ui/controller/ThemeColorsToolBoxControl.cxx b/sd/source/ui/controller/ThemeColorsToolBoxControl.cxx new file mode 100644 index 000000000000..3ada0c5a7f75 --- /dev/null +++ b/sd/source/ui/controller/ThemeColorsToolBoxControl.cxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "ThemeColorsToolBoxControl.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ThemeColorsToolBoxControl::ThemeColorsToolBoxControl() {} + +ThemeColorsToolBoxControl::~ThemeColorsToolBoxControl() {} + +void SAL_CALL ThemeColorsToolBoxControl::dispose() +{ + SolarMutexGuard aSolarMutexGuard; + m_xVclBox.disposeAndClear(); + svt::ToolboxController::dispose(); +} + +void SAL_CALL +ThemeColorsToolBoxControl::statusChanged(const css::frame::FeatureStateEvent& /*rEvent*/) +{ +} + +css::uno::Reference +ThemeColorsToolBoxControl::createItemWindow(const css::uno::Reference& rParent) +{ + css::uno::Reference xItemWindow; + + VclPtr pParent = VCLUnoHelper::GetWindow(rParent); + if (pParent) + { + SolarMutexGuard aSolarMutexGuard; + + sd::ViewShellBase* pViewShellBase = nullptr; + if (SfxViewShell* pViewShell = SfxViewShell::Current()) + { + pViewShellBase = dynamic_cast(pViewShell); + } + + if (pViewShellBase) + { + m_xVclBox = VclPtr::Create(pParent, *pViewShellBase); + xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox.get()); + } + } + return xItemWindow; +} + +void SAL_CALL ThemeColorsToolBoxControl::update() {} + +OUString SAL_CALL ThemeColorsToolBoxControl::getImplementationName() +{ + return u"com.sun.star.comp.sd.ThemeColorsToolBoxControl"_ustr; +} + +sal_Bool SAL_CALL ThemeColorsToolBoxControl::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence SAL_CALL ThemeColorsToolBoxControl::getSupportedServiceNames() +{ + return { u"com.sun.star.frame.ToolbarController"_ustr }; +} + +// Export function for service registration +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation( + css::uno::XComponentContext* /*rxContext*/, css::uno::Sequence const&) +{ + return cppu::acquire(new ThemeColorsToolBoxControl()); +} + +ThemeColorsPaneWrapper::ThemeColorsPaneWrapper(vcl::Window* pParent, sd::ViewShellBase& rBase) + : InterimItemWindow(pParent, u"svx/ui/themeselectorpanel.ui"_ustr, u"ThemeSelectorPanel"_ustr, + true, reinterpret_cast(SfxViewShell::Current())) + , svx::ThemeColorsPaneBase(m_xBuilder->weld_icon_view(u"iconview_theme_colors"_ustr)) + , mrViewShellBase(rBase) +{ + // Override selection handler to apply theme on single click + if (mxIconViewThemeColors) + mxIconViewThemeColors->connect_selection_changed( + LINK(this, ThemeColorsPaneWrapper, SelectionChangedHdl)); + + initColorSets(); + SetOptimalSize(); +} + +ThemeColorsPaneWrapper::~ThemeColorsPaneWrapper() { disposeOnce(); } + +void ThemeColorsPaneWrapper::SetOptimalSize() { SetSizePixel(GetOptimalSize()); } + +void ThemeColorsPaneWrapper::dispose() +{ + mxIconViewThemeColors.reset(); + InterimItemWindow::dispose(); +} + +void ThemeColorsPaneWrapper::onColorSetActivated() +{ + if (!mpCurrentColorSet) + return; + sd::DrawViewShell* pViewShell + = dynamic_cast(mrViewShellBase.GetMainViewShell().get()); + if (!pViewShell) + return; + SdrPageView* pPageView = pViewShell->GetDrawView()->GetSdrPageView(); + if (!pPageView) + return; + SdrPage* pPage = pPageView->GetPage(); + if (!pPage) + return; + SdrPage* pMasterPage = &pPage->TRG_GetMasterPage(); + if (!pMasterPage) + return; + sd::DrawDocShell* pDocShell = mrViewShellBase.GetDocShell(); + if (!pDocShell) + return; + + // Apply the theme + sd::ThemeColorChanger aChanger(pMasterPage, pDocShell); + aChanger.apply(mpCurrentColorSet); +} + +IMPL_LINK_NOARG(ThemeColorsPaneWrapper, SelectionChangedHdl, weld::IconView&, void) +{ + // Call base class selection handler first to update mpCurrentColorSet + svx::ThemeColorsPaneBase::SelectionChangedHdl(*mxIconViewThemeColors); + + // Apply theme on single-click + onColorSetActivated(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sd/source/ui/controller/ThemeColorsToolBoxControl.hxx b/sd/source/ui/controller/ThemeColorsToolBoxControl.hxx new file mode 100644 index 000000000000..9e9b876da7d8 --- /dev/null +++ b/sd/source/ui/controller/ThemeColorsToolBoxControl.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include + +namespace sd +{ +class ViewShellBase; +} + +// Used to put theme colors pane to the notebookbar + +class ThemeColorsPaneWrapper final : public InterimItemWindow, public svx::ThemeColorsPaneBase +{ +private: + sd::ViewShellBase& mrViewShellBase; + +public: + ThemeColorsPaneWrapper(vcl::Window* pParent, sd::ViewShellBase& rBase); + virtual ~ThemeColorsPaneWrapper() override; + virtual void dispose() override; + void SetOptimalSize(); + + DECL_LINK(SelectionChangedHdl, weld::IconView&, void); + +protected: + void onColorSetActivated() override; +}; + +class ThemeColorsToolBoxControl final + : public cppu::ImplInheritanceHelper +{ + VclPtr m_xVclBox; + +public: + ThemeColorsToolBoxControl(); + virtual ~ThemeColorsToolBoxControl() override; + + // XStatusListener + virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& rEvent) override; + + // XToolbarController + virtual css::uno::Reference + SAL_CALL createItemWindow(const css::uno::Reference& rParent) override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sd/uiconfig/simpress/ui/notebookbar_online.ui b/sd/uiconfig/simpress/ui/notebookbar_online.ui index 70f188a0f443..8acefe49ff98 100644 --- a/sd/uiconfig/simpress/ui/notebookbar_online.ui +++ b/sd/uiconfig/simpress/ui/notebookbar_online.ui @@ -121,6 +121,30 @@ 2 + + + True + False + 5 + + + True + False + .uno:ThemeSelectorPanel + True + + + False + True + + + + + False + True + 5 + + 0 diff --git a/sd/util/sd.component b/sd/util/sd.component index 2c7f94763b24..d8bbdf995752 100644 --- a/sd/util/sd.component +++ b/sd/util/sd.component @@ -49,6 +49,10 @@ constructor="com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation"> + + + diff --git a/solenv/sanitizers/ui/modules/simpress.suppr b/solenv/sanitizers/ui/modules/simpress.suppr index e8b3ce3f7d93..4b14930cf99d 100644 --- a/solenv/sanitizers/ui/modules/simpress.suppr +++ b/solenv/sanitizers/ui/modules/simpress.suppr @@ -29,4 +29,5 @@ sd/uiconfig/simpress/ui/notebookbar_online.ui://GtkToolButton[@id='Home-CharFont sd/uiconfig/simpress/ui/notebookbar_online.ui://GtkToolButton[@id='Home-FontHeight'] button-no-label sd/uiconfig/simpress/ui/notebookbar_online.ui://GtkToolButton[@id='MasterSlide-MasterSlidePane'] button-no-label sd/uiconfig/simpress/ui/notebookbar_online.ui://GtkToolButton[@id='Transitions-SlideTransitionsPane'] button-no-label +sd/uiconfig/simpress/ui/notebookbar_online.ui://GtkToolButton[@id='Theme-ThemeColorsPane'] button-no-label diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 677522593a25..87bffaaa54e8 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -176,6 +176,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/dialog/svxruler \ svx/source/dialog/swframeexample \ svx/source/dialog/swframeposstrings \ + svx/source/dialog/ThemeColorsPaneBase \ svx/source/dialog/ThemeDialog \ svx/source/dialog/ThemeColorEditDialog \ svx/source/dialog/txencbox \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index fc000f936e69..d09cbb46bdcc 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -147,6 +147,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/textunderlinecontrol \ svx/uiconfig/ui/themedialog \ svx/uiconfig/ui/themecoloreditdialog \ + svx/uiconfig/ui/themeselectorpanel \ svx/uiconfig/ui/toolbarpopover \ svx/uiconfig/ui/xmlsecstatmenu \ svx/uiconfig/ui/xformspage \ diff --git a/svx/source/dialog/ThemeColorsPaneBase.cxx b/svx/source/dialog/ThemeColorsPaneBase.cxx new file mode 100644 index 000000000000..8f44d18bc719 --- /dev/null +++ b/svx/source/dialog/ThemeColorsPaneBase.cxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include +#include + +namespace svx +{ +ThemeColorsPaneBase::ThemeColorsPaneBase(std::unique_ptr xIconView) + : mxIconViewThemeColors(std::move(xIconView)) +{ + if (mxIconViewThemeColors) + { + mxIconViewThemeColors->connect_selection_changed( + LINK(this, ThemeColorsPaneBase, SelectionChangedHdl)); + mxIconViewThemeColors->connect_item_activated( + LINK(this, ThemeColorsPaneBase, ItemActivatedHdl)); + } +} + +ThemeColorsPaneBase::~ThemeColorsPaneBase() = default; + +void ThemeColorsPaneBase::initColorSets(model::Theme* pTheme) +{ + maColorSets.clear(); + if (mxIconViewThemeColors) + mxIconViewThemeColors->clear(); + + if (pTheme) + maColorSets.push_back(*pTheme->getColorSet()); + + auto const& rColorSetVector = ColorSets::get().getColorSetVector(); + maColorSets.insert(maColorSets.end(), rColorSetVector.begin(), rColorSetVector.end()); + + if (mxIconViewThemeColors) + { + for (size_t i = 0; i < maColorSets.size(); ++i) + { + auto const& rColorSet = maColorSets[i]; + VclPtr pVirDev = CreateColorSetPreview(rColorSet); + Bitmap aBitmap(pVirDev->GetBitmap(Point(0, 0), pVirDev->GetOutputSizePixel())); + + OUString sId = OUString::number(i); + OUString sName = rColorSet.getName(); + mxIconViewThemeColors->insert(-1, &sName, &sId, &aBitmap, nullptr); + } + + if (!maColorSets.empty()) + { + mxIconViewThemeColors->select(0); + mpCurrentColorSet = std::make_shared(maColorSets[0]); + } + } +} + +VclPtr ThemeColorsPaneBase::CreateColorSetPreview(const model::ColorSet& rColorSet) +{ + VclPtr pVDev = VclPtr::Create(); + const Size aSize(100, 50); + pVDev->SetOutputSizePixel(aSize); + + const int nRows = 2; + const int nCols = 4; + const int nHorizontalPadding = 9; + const int nVerticalPadding = 3; + const int nMargin = 3; + + const int nAvailableWidth = aSize.Width() - (2 * nHorizontalPadding); + const int nAvailableHeight = aSize.Height() - (2 * nVerticalPadding); + const int nColorCellHeight = (nAvailableHeight - ((nRows - 1) * nMargin)) / nRows; + const int nColorCellWidth = (nAvailableWidth - ((nCols - 1) * nMargin)) / nCols; + + // Draw border around entire color set + pVDev->SetLineColor(COL_LIGHTGRAY); + pVDev->DrawRect(tools::Rectangle(Point(0, 0), aSize)); + + for (int i = 0; i < 8; ++i) + { + const int nCol = i / 2; + const int nRow = i % 2; + + const int nX = nHorizontalPadding + (nCol * (nColorCellWidth + nMargin)); + const int nY = nVerticalPadding + (nRow * (nColorCellHeight + nMargin)); + + const tools::Rectangle aRect(Point(nX, nY), Size(nColorCellWidth, nColorCellHeight)); + + Color aColor = rColorSet.getColor(static_cast(i + 2)); + + pVDev->SetLineColor(COL_LIGHTGRAY); + pVDev->SetFillColor(aColor); + pVDev->DrawRect(aRect); + } + return pVDev; +} + +IMPL_LINK_NOARG(ThemeColorsPaneBase, SelectionChangedHdl, weld::IconView&, void) +{ + if (!mxIconViewThemeColors) + return; + + OUString sId = mxIconViewThemeColors->get_selected_id(); + if (sId.isEmpty()) + return; + + sal_uInt32 nIndex = sId.toUInt32(); + + if (nIndex >= maColorSets.size()) + return; + + mpCurrentColorSet = std::make_shared(maColorSets[nIndex]); +} + +IMPL_LINK(ThemeColorsPaneBase, ItemActivatedHdl, weld::IconView&, /*rIconView*/, bool) +{ + SelectionChangedHdl(*mxIconViewThemeColors); + onColorSetActivated(); + return true; +} + +} // end svx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/svx/source/dialog/ThemeDialog.cxx b/svx/source/dialog/ThemeDialog.cxx index 8c1cde9ad0c0..51d216f8dcdf 100644 --- a/svx/source/dialog/ThemeDialog.cxx +++ b/svx/source/dialog/ThemeDialog.cxx @@ -19,22 +19,13 @@ namespace svx { ThemeDialog::ThemeDialog(weld::Window* pParent, model::Theme* pTheme) : GenericDialogController(pParent, u"svx/ui/themedialog.ui"_ustr, u"ThemeDialog"_ustr) + , ThemeColorsPaneBase(m_xBuilder->weld_icon_view(u"iconview_theme_colors"_ustr)) , mpTheme(pTheme) - , mxIconViewThemeColors(m_xBuilder->weld_icon_view(u"iconview_theme_colors"_ustr)) , mxAdd(m_xBuilder->weld_button(u"button_add"_ustr)) { - mxIconViewThemeColors->connect_item_activated(LINK(this, ThemeDialog, ItemActivatedHdl)); - mxIconViewThemeColors->connect_selection_changed(LINK(this, ThemeDialog, SelectionChangedHdl)); - mxAdd->connect_clicked(LINK(this, ThemeDialog, ButtonClicked)); - initColorSets(); - - if (!maColorSets.empty()) - { - mxIconViewThemeColors->select(0); - mpCurrentColorSet = std::make_shared(maColorSets[0]); - } + initColorSets(pTheme); } ThemeDialog::~ThemeDialog() @@ -43,87 +34,10 @@ ThemeDialog::~ThemeDialog() mxSubDialog->response(RET_CANCEL); } -void ThemeDialog::initColorSets() +void ThemeDialog::onColorSetActivated() { - if (mpTheme) - maColorSets.push_back(*mpTheme->getColorSet()); - - auto const& rColorSetVector = ColorSets::get().getColorSetVector(); - maColorSets.insert(maColorSets.end(), rColorSetVector.begin(), rColorSetVector.end()); - - for (size_t i = 0; i < maColorSets.size(); ++i) - { - auto const& rColorSet = maColorSets[i]; - VclPtr pVirDev = CreateColorSetPreview(rColorSet); - Bitmap aBitmap(pVirDev->GetBitmap(Point(0, 0), pVirDev->GetOutputSizePixel())); - - OUString sId = OUString::number(i); - OUString sName = rColorSet.getName(); - mxIconViewThemeColors->insert(-1, &sName, &sId, &aBitmap, nullptr); - } -} - -VclPtr ThemeDialog::CreateColorSetPreview(const model::ColorSet& rColorSet) -{ - VclPtr pVDev = VclPtr::Create(); - const Size aSize(100, 50); - pVDev->SetOutputSizePixel(aSize); - - const int nRows = 2; - const int nCols = 4; - const int nHorizontalPadding = 9; - const int nVerticalPadding = 3; - const int nMargin = 3; - - const int nAvailableWidth = aSize.Width() - (2 * nHorizontalPadding); - const int nAvailableHeight = aSize.Height() - (2 * nVerticalPadding); - - const int nColorCellHeight = (nAvailableHeight - ((nRows - 1) * nMargin)) / nRows; - const int nColorCellWidth = (nAvailableWidth - ((nCols - 1) * nMargin)) / nCols; - - // Draw border around entire color set - pVDev->SetLineColor(COL_LIGHTGRAY); - pVDev->DrawRect(tools::Rectangle(Point(0, 0), aSize)); - - for (int i = 0; i < 8; ++i) - { - const int nCol = i / 2; - const int nRow = i % 2; - - const int nX = nHorizontalPadding + (nCol * (nColorCellWidth + nMargin)); - const int nY = nVerticalPadding + (nRow * (nColorCellHeight + nMargin)); - - const tools::Rectangle aRect(Point(nX, nY), Size(nColorCellWidth, nColorCellHeight)); - - Color aColor = rColorSet.getColor(static_cast(i + 2)); - - pVDev->SetLineColor(COL_LIGHTGRAY); - pVDev->SetFillColor(aColor); - pVDev->DrawRect(aRect); - } - return pVDev; -} - -IMPL_LINK(ThemeDialog, ItemActivatedHdl, weld::IconView&, iter, bool) -{ - SelectionChangedHdl(iter); if (!comphelper::LibreOfficeKit::isActive()) m_xDialog->response(RET_OK); - return true; -} - -IMPL_LINK_NOARG(ThemeDialog, SelectionChangedHdl, weld::IconView&, void) -{ - OUString sId = mxIconViewThemeColors->get_selected_id(); - if (sId.isEmpty()) - return; - - sal_uInt32 nIndex = sId.toUInt32(); - - if (nIndex >= maColorSets.size()) - return; - - mpCurrentColorSet = std::make_shared(maColorSets[nIndex]); } void ThemeDialog::runThemeColorEditDialog() @@ -144,10 +58,7 @@ void ThemeDialog::runThemeColorEditDialog() if (!aColorSet.getName().isEmpty()) { ColorSets::get().insert(aColorSet); - maColorSets.clear(); - mxIconViewThemeColors->clear(); - - initColorSets(); + initColorSets(mpTheme); mxIconViewThemeColors->select(maColorSets.size() - 1); mpCurrentColorSet diff --git a/svx/uiconfig/ui/themeselectorpanel.ui b/svx/uiconfig/ui/themeselectorpanel.ui new file mode 100644 index 000000000000..906600629820 --- /dev/null +++ b/svx/uiconfig/ui/themeselectorpanel.ui @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + True + False + True + 6 + + + 360 + 65 + True + True + center + never + always + in + 70 + + + True + True + 6 + liststore1 + 3 + 70 + + + + + False + False + 0 + + + + diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 32c4b7fbcb96..4f9adaa52dd3 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -499,6 +499,7 @@ constexpr auto NotebookbarList { u"svx/ui/fontnamebox.ui" }, { u"svx/ui/fontsizebox.ui" }, { u"svx/ui/stylespreview.ui" }, + { u"svx/ui/themeselectorpanel.ui" }, // not interim builder, but regular builder: { u"modules/simpress/ui/masterpagepanelall.ui" }, { u"modules/simpress/ui/slidetransitionspanel.ui" } diff --git a/vcl/workben/cgmfuzzer.cxx b/vcl/workben/cgmfuzzer.cxx index ee794d2f6573..6ff52549e194 100644 --- a/vcl/workben/cgmfuzzer.cxx +++ b/vcl/workben/cgmfuzzer.cxx @@ -62,6 +62,7 @@ void com_sun_star_comp_sd_InsertSlideController_get_implementation( void ); void com_sun_star_comp_sd_SlideLayoutController_get_implementation( void ); void com_sun_star_comp_sd_DisplayModeController_get_implementation( void ); void com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation( void ); +void com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation( void ); void ucb_UcbCommandEnvironment_get_implementation( void ); void ucb_UcbContentProviderProxyFactory_get_implementation( void ); void ucb_UcbPropertiesManager_get_implementation( void ); @@ -130,6 +131,7 @@ lo_get_constructor_map(void) { "com_sun_star_comp_sd_SlideLayoutController_get_implementation", com_sun_star_comp_sd_SlideLayoutController_get_implementation }, { "com_sun_star_comp_sd_DisplayModeController_get_implementation", com_sun_star_comp_sd_DisplayModeController_get_implementation }, { "com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation", com_sun_star_comp_sd_SlideTransitionsToolBoxControl_get_implementation }, + { "com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation", com_sun_star_comp_sd_ThemeColorsToolBoxControl_get_implementation }, { "ucb_UcbCommandEnvironment_get_implementation", ucb_UcbCommandEnvironment_get_implementation, }, { "ucb_UcbContentProviderProxyFactory_get_implementation", ucb_UcbContentProviderProxyFactory_get_implementation }, { "ucb_UcbPropertiesManager_get_implementation", ucb_UcbPropertiesManager_get_implementation },