bump product version to 7.2.5.1
[LibreOffice.git] / svx / source / sidebar / effect / EffectPropertyPanel.cxx
blob78424ccc21750eca0220169240d9714dcf8f05a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
12 #include "EffectPropertyPanel.hxx"
14 #include <sfx2/dispatch.hxx>
15 #include <svx/colorbox.hxx>
16 #include <svx/sdmetitm.hxx>
17 #include <svx/sdprcitm.hxx>
18 #include <svx/svddef.hxx>
19 #include <svx/svxids.hrc>
20 #include <svx/xcolit.hxx>
22 namespace svx::sidebar
24 EffectPropertyPanel::EffectPropertyPanel(weld::Widget* pParent, SfxBindings* pBindings)
25 : PanelLayout(pParent, "EffectPropertyPanel", "svx/ui/sidebareffect.ui")
26 , maGlowColorController(SID_ATTR_GLOW_COLOR, *pBindings, *this)
27 , maGlowRadiusController(SID_ATTR_GLOW_RADIUS, *pBindings, *this)
28 , maGlowTransparencyController(SID_ATTR_GLOW_TRANSPARENCY, *pBindings, *this)
29 , mxFTTransparency(m_xBuilder->weld_label("transparency"))
30 , maSoftEdgeRadiusController(SID_ATTR_SOFTEDGE_RADIUS, *pBindings, *this)
31 , mpBindings(pBindings)
32 , mxGlowRadius(m_xBuilder->weld_metric_spin_button("LB_GLOW_RADIUS", FieldUnit::POINT))
33 , mxLBGlowColor(new ColorListBox(m_xBuilder->weld_menu_button("LB_GLOW_COLOR"),
34 [this] { return GetFrameWeld(); }))
35 , mxGlowTransparency(
36 m_xBuilder->weld_metric_spin_button("LB_GLOW_TRANSPARENCY", FieldUnit::PERCENT))
37 , mxFTRadiusSoftEdge(m_xBuilder->weld_label("radiussoftedge"))
38 , mxFTRadiusGlow(m_xBuilder->weld_label("radiusglow"))
39 , mxFTColor(m_xBuilder->weld_label("color"))
40 , mxSoftEdgeRadius(m_xBuilder->weld_metric_spin_button("SB_SOFTEDGE_RADIUS", FieldUnit::POINT))
42 Initialize();
45 EffectPropertyPanel::~EffectPropertyPanel()
47 mxGlowRadius.reset();
48 mxLBGlowColor.reset();
49 mxGlowTransparency.reset();
50 mxFTRadiusSoftEdge.reset();
51 mxFTColor.reset();
52 mxFTTransparency.reset();
53 mxSoftEdgeRadius.reset();
54 mxFTRadiusGlow.reset();
56 maGlowColorController.dispose();
57 maGlowRadiusController.dispose();
58 maGlowTransparencyController.dispose();
59 maSoftEdgeRadiusController.dispose();
62 void EffectPropertyPanel::Initialize()
64 mxGlowRadius->connect_value_changed(LINK(this, EffectPropertyPanel, ModifyGlowRadiusHdl));
65 mxLBGlowColor->SetSelectHdl(LINK(this, EffectPropertyPanel, ModifyGlowColorHdl));
66 mxGlowTransparency->connect_value_changed(
67 LINK(this, EffectPropertyPanel, ModifyGlowTransparencyHdl));
68 mxSoftEdgeRadius->connect_value_changed(
69 LINK(this, EffectPropertyPanel, ModifySoftEdgeRadiusHdl));
72 IMPL_LINK_NOARG(EffectPropertyPanel, ModifySoftEdgeRadiusHdl, weld::MetricSpinButton&, void)
74 SdrMetricItem aItem(SDRATTR_SOFTEDGE_RADIUS, mxSoftEdgeRadius->get_value(FieldUnit::MM_100TH));
75 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_SOFTEDGE_RADIUS, SfxCallMode::RECORD,
76 { &aItem });
79 IMPL_LINK_NOARG(EffectPropertyPanel, ModifyGlowColorHdl, ColorListBox&, void)
81 XColorItem aItem(SDRATTR_GLOW_COLOR, mxLBGlowColor->GetSelectEntryColor());
82 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_COLOR, SfxCallMode::RECORD, { &aItem });
85 IMPL_LINK_NOARG(EffectPropertyPanel, ModifyGlowRadiusHdl, weld::MetricSpinButton&, void)
87 SdrMetricItem aItem(SDRATTR_GLOW_RADIUS, mxGlowRadius->get_value(FieldUnit::MM_100TH));
88 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_RADIUS, SfxCallMode::RECORD, { &aItem });
91 IMPL_LINK_NOARG(EffectPropertyPanel, ModifyGlowTransparencyHdl, weld::MetricSpinButton&, void)
93 SdrPercentItem aItem(SDRATTR_GLOW_TRANSPARENCY,
94 mxGlowTransparency->get_value(FieldUnit::PERCENT));
95 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_TRANSPARENCY, SfxCallMode::RECORD,
96 { &aItem });
99 void EffectPropertyPanel::UpdateControls()
101 const bool bEnabled = mxGlowRadius->get_value(FieldUnit::MM_100TH) != 0;
102 mxLBGlowColor->set_sensitive(bEnabled);
103 mxGlowTransparency->set_sensitive(bEnabled);
104 mxFTColor->set_sensitive(bEnabled);
105 mxFTTransparency->set_sensitive(bEnabled);
108 void EffectPropertyPanel::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState eState,
109 const SfxPoolItem* pState)
111 switch (nSID)
113 case SID_ATTR_SOFTEDGE_RADIUS:
115 if (eState >= SfxItemState::DEFAULT)
117 const SdrMetricItem* pRadiusItem = dynamic_cast<const SdrMetricItem*>(pState);
118 if (pRadiusItem)
120 mxSoftEdgeRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH);
124 break;
125 case SID_ATTR_GLOW_COLOR:
127 if (eState >= SfxItemState::DEFAULT)
129 const XColorItem* pColorItem = dynamic_cast<const XColorItem*>(pState);
130 if (pColorItem)
132 mxLBGlowColor->SelectEntry(pColorItem->GetColorValue());
136 break;
137 case SID_ATTR_GLOW_RADIUS:
139 if (eState >= SfxItemState::DEFAULT)
141 const SdrMetricItem* pRadiusItem = dynamic_cast<const SdrMetricItem*>(pState);
142 if (pRadiusItem)
144 mxGlowRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH);
148 break;
149 case SID_ATTR_GLOW_TRANSPARENCY:
151 if (eState >= SfxItemState::DEFAULT)
153 if (auto pItem = dynamic_cast<const SdrPercentItem*>(pState))
155 mxGlowTransparency->set_value(pItem->GetValue(), FieldUnit::PERCENT);
159 break;
161 UpdateControls();
164 std::unique_ptr<PanelLayout> EffectPropertyPanel::Create(weld::Widget* pParent,
165 SfxBindings* pBindings)
167 if (pParent == nullptr)
168 throw css::lang::IllegalArgumentException(
169 "no parent Window given to EffectPropertyPanel::Create", nullptr, 0);
170 if (pBindings == nullptr)
171 throw css::lang::IllegalArgumentException(
172 "no SfxBindings given to EffectPropertyPanel::Create", nullptr, 2);
174 return std::make_unique<EffectPropertyPanel>(pParent, pBindings);
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */