From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- svx/source/sidebar/glow/GlowPropertyPanel.cxx | 162 ++++++++++++++++++++++++++ svx/source/sidebar/glow/GlowPropertyPanel.hxx | 64 ++++++++++ 2 files changed, 226 insertions(+) create mode 100644 svx/source/sidebar/glow/GlowPropertyPanel.cxx create mode 100644 svx/source/sidebar/glow/GlowPropertyPanel.hxx (limited to 'svx/source/sidebar/glow') diff --git a/svx/source/sidebar/glow/GlowPropertyPanel.cxx b/svx/source/sidebar/glow/GlowPropertyPanel.cxx new file mode 100644 index 000000000..acb63e090 --- /dev/null +++ b/svx/source/sidebar/glow/GlowPropertyPanel.cxx @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 "GlowPropertyPanel.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace svx::sidebar +{ +GlowPropertyPanel::GlowPropertyPanel(vcl::Window* pParent, + const css::uno::Reference& rxFrame, + SfxBindings* pBindings) + : PanelLayout(pParent, "GlowPropertyPanel", "svx/ui/sidebarglow.ui", rxFrame) + , maGlowColorController(SID_ATTR_GLOW_COLOR, *pBindings, *this) + , maGlowRadiusController(SID_ATTR_GLOW_RADIUS, *pBindings, *this) + , maGlowTransparencyController(SID_ATTR_GLOW_TRANSPARENCY, *pBindings, *this) + , mpBindings(pBindings) + , mxGlowRadius(m_xBuilder->weld_metric_spin_button("LB_GLOW_RADIUS", FieldUnit::POINT)) + , mxLBGlowColor(new ColorListBox(m_xBuilder->weld_menu_button("LB_GLOW_COLOR"), GetFrameWeld())) + , mxGlowTransparency( + m_xBuilder->weld_metric_spin_button("LB_GLOW_TRANSPARENCY", FieldUnit::PERCENT)) + , mxFTRadius(m_xBuilder->weld_label("radius")) + , mxFTColor(m_xBuilder->weld_label("color")) + , mxFTTransparency(m_xBuilder->weld_label("transparency")) +{ + Initialize(); +} + +GlowPropertyPanel::~GlowPropertyPanel() { disposeOnce(); } + +void GlowPropertyPanel::dispose() +{ + mxFTRadius.reset(); + mxGlowRadius.reset(); + mxFTColor.reset(); + mxLBGlowColor.reset(); + mxFTTransparency.reset(); + mxGlowTransparency.reset(); + + maGlowColorController.dispose(); + maGlowRadiusController.dispose(); + maGlowTransparencyController.dispose(); + PanelLayout::dispose(); +} + +void GlowPropertyPanel::Initialize() +{ + mxLBGlowColor->SetSelectHdl(LINK(this, GlowPropertyPanel, ModifyGlowColorHdl)); + mxGlowRadius->connect_value_changed(LINK(this, GlowPropertyPanel, ModifyGlowRadiusHdl)); + mxGlowTransparency->connect_value_changed( + LINK(this, GlowPropertyPanel, ModifyGlowTransparencyHdl)); +} + +IMPL_LINK_NOARG(GlowPropertyPanel, ModifyGlowColorHdl, ColorListBox&, void) +{ + XColorItem aItem(SDRATTR_GLOW_COLOR, mxLBGlowColor->GetSelectEntryColor()); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_COLOR, SfxCallMode::RECORD, { &aItem }); +} + +IMPL_LINK_NOARG(GlowPropertyPanel, ModifyGlowRadiusHdl, weld::MetricSpinButton&, void) +{ + SdrMetricItem aItem(SDRATTR_GLOW_RADIUS, mxGlowRadius->get_value(FieldUnit::MM_100TH)); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_RADIUS, SfxCallMode::RECORD, { &aItem }); +} + +IMPL_LINK_NOARG(GlowPropertyPanel, ModifyGlowTransparencyHdl, weld::MetricSpinButton&, void) +{ + SdrPercentItem aItem(SDRATTR_GLOW_TRANSPARENCY, + mxGlowTransparency->get_value(FieldUnit::PERCENT)); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_TRANSPARENCY, SfxCallMode::RECORD, + { &aItem }); +} + +void GlowPropertyPanel::UpdateControls() +{ + const bool bEnabled = mxGlowRadius->get_value(FieldUnit::MM_100TH) != 0; + mxLBGlowColor->set_sensitive(bEnabled); + mxGlowTransparency->set_sensitive(bEnabled); + mxFTColor->set_sensitive(bEnabled); + mxFTTransparency->set_sensitive(bEnabled); +} + +void GlowPropertyPanel::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) +{ + switch (nSID) + { + case SID_ATTR_GLOW_COLOR: + { + if (eState >= SfxItemState::DEFAULT) + { + const XColorItem* pColorItem = dynamic_cast(pState); + if (pColorItem) + { + mxLBGlowColor->SelectEntry(pColorItem->GetColorValue()); + } + } + } + break; + case SID_ATTR_GLOW_RADIUS: + { + if (eState >= SfxItemState::DEFAULT) + { + const SdrMetricItem* pRadiusItem = dynamic_cast(pState); + if (pRadiusItem) + { + mxGlowRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH); + } + } + } + break; + case SID_ATTR_GLOW_TRANSPARENCY: + { + if (eState >= SfxItemState::DEFAULT) + { + if (auto pItem = dynamic_cast(pState)) + { + mxGlowTransparency->set_value(pItem->GetValue(), FieldUnit::PERCENT); + } + } + } + break; + } + UpdateControls(); +} + +VclPtr +GlowPropertyPanel::Create(vcl::Window* pParent, + const css::uno::Reference& rxFrame, + SfxBindings* pBindings) +{ + if (pParent == nullptr) + throw css::lang::IllegalArgumentException( + "no parent Window given to GlowPropertyPanel::Create", nullptr, 0); + if (!rxFrame.is()) + throw css::lang::IllegalArgumentException("no XFrame given to GlowPropertyPanel::Create", + nullptr, 1); + if (pBindings == nullptr) + throw css::lang::IllegalArgumentException( + "no SfxBindings given to GlowPropertyPanel::Create", nullptr, 2); + + return VclPtr::Create(pParent, rxFrame, pBindings); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/glow/GlowPropertyPanel.hxx b/svx/source/sidebar/glow/GlowPropertyPanel.hxx new file mode 100644 index 000000000..aaffa44e4 --- /dev/null +++ b/svx/source/sidebar/glow/GlowPropertyPanel.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/. + */ +#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_GLOW_GLOWPROPERTYPANEL_HXX +#define INCLUDED_SVX_SOURCE_SIDEBAR_GLOW_GLOWPROPERTYPANEL_HXX + +#include +#include +#include + +class ColorListBox; + +namespace svx::sidebar +{ +class GlowPropertyPanel : public PanelLayout, + public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +{ +public: + GlowPropertyPanel(vcl::Window* pParent, const css::uno::Reference& rxFrame, + SfxBindings* pBindings); + virtual ~GlowPropertyPanel() override; + virtual void dispose() override; + + static VclPtr Create(vcl::Window* pParent, + const css::uno::Reference& rxFrame, + SfxBindings* pBindings); + + virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, + const SfxPoolItem* pState) override; + + virtual void GetControlState(const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override{}; + +private: + sfx2::sidebar::ControllerItem maGlowColorController; + sfx2::sidebar::ControllerItem maGlowRadiusController; + sfx2::sidebar::ControllerItem maGlowTransparencyController; + + SfxBindings* mpBindings; + + std::unique_ptr mxGlowRadius; + std::unique_ptr mxLBGlowColor; + std::unique_ptr mxGlowTransparency; + std::unique_ptr mxFTRadius; + std::unique_ptr mxFTColor; + std::unique_ptr mxFTTransparency; + + void Initialize(); + void UpdateControls(); + + DECL_LINK(ModifyGlowColorHdl, ColorListBox&, void); + DECL_LINK(ModifyGlowRadiusHdl, weld::MetricSpinButton&, void); + DECL_LINK(ModifyGlowTransparencyHdl, weld::MetricSpinButton&, void); +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3