LibreOffice Module svx (master)  1
EffectPropertyPanel.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
10 #include <sal/config.h>
11 
12 #include "EffectPropertyPanel.hxx"
13 
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>
21 
22 namespace svx::sidebar
23 {
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("glowcolorlabel"))
40  , mxSoftEdgeRadius(m_xBuilder->weld_metric_spin_button("SB_SOFTEDGE_RADIUS", FieldUnit::POINT))
41 {
42  Initialize();
43 }
44 
46 {
47  mxGlowRadius.reset();
48  mxLBGlowColor.reset();
49  mxGlowTransparency.reset();
50  mxFTRadiusSoftEdge.reset();
51  mxFTColor.reset();
52  mxFTTransparency.reset();
53  mxSoftEdgeRadius.reset();
54  mxFTRadiusGlow.reset();
55 
60 }
61 
63 {
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));
70 }
71 
73 {
74  SdrMetricItem aItem(SDRATTR_SOFTEDGE_RADIUS, mxSoftEdgeRadius->get_value(FieldUnit::MM_100TH));
75  mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_SOFTEDGE_RADIUS, SfxCallMode::RECORD,
76  { &aItem });
77 }
78 
79 IMPL_LINK_NOARG(EffectPropertyPanel, ModifyGlowColorHdl, ColorListBox&, void)
80 {
81  XColorItem aItem(SDRATTR_GLOW_COLOR, mxLBGlowColor->GetSelectEntryColor());
82  mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_COLOR, SfxCallMode::RECORD, { &aItem });
83 }
84 
86 {
87  SdrMetricItem aItem(SDRATTR_GLOW_RADIUS, mxGlowRadius->get_value(FieldUnit::MM_100TH));
88  mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_RADIUS, SfxCallMode::RECORD, { &aItem });
89 }
90 
91 IMPL_LINK_NOARG(EffectPropertyPanel, ModifyGlowTransparencyHdl, weld::MetricSpinButton&, void)
92 {
94  mxGlowTransparency->get_value(FieldUnit::PERCENT));
95  mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_TRANSPARENCY, SfxCallMode::RECORD,
96  { &aItem });
97 }
98 
100 {
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);
106 }
107 
109  const SfxPoolItem* pState)
110 {
111  switch (nSID)
112  {
113  case SID_ATTR_SOFTEDGE_RADIUS:
114  {
115  if (eState >= SfxItemState::DEFAULT)
116  {
117  const SdrMetricItem* pRadiusItem = dynamic_cast<const SdrMetricItem*>(pState);
118  if (pRadiusItem)
119  {
120  mxSoftEdgeRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH);
121  }
122  }
123  }
124  break;
125  case SID_ATTR_GLOW_COLOR:
126  {
127  if (eState >= SfxItemState::DEFAULT)
128  {
129  const XColorItem* pColorItem = dynamic_cast<const XColorItem*>(pState);
130  if (pColorItem)
131  {
132  mxLBGlowColor->SelectEntry(pColorItem->GetColorValue());
133  }
134  }
135  }
136  break;
137  case SID_ATTR_GLOW_RADIUS:
138  {
139  if (eState >= SfxItemState::DEFAULT)
140  {
141  const SdrMetricItem* pRadiusItem = dynamic_cast<const SdrMetricItem*>(pState);
142  if (pRadiusItem)
143  {
144  mxGlowRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH);
145  }
146  }
147  }
148  break;
149  case SID_ATTR_GLOW_TRANSPARENCY:
150  {
151  if (eState >= SfxItemState::DEFAULT)
152  {
153  if (auto pItem = dynamic_cast<const SdrPercentItem*>(pState))
154  {
155  mxGlowTransparency->set_value(pItem->GetValue(), FieldUnit::PERCENT);
156  }
157  }
158  }
159  break;
160  }
161  UpdateControls();
162 }
163 
164 std::unique_ptr<PanelLayout> EffectPropertyPanel::Create(weld::Widget* pParent,
165  SfxBindings* pBindings)
166 {
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);
173 
174  return std::make_unique<EffectPropertyPanel>(pParent, pBindings);
175 }
176 }
177 
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< XColorItem > SDRATTR_GLOW_COLOR(SDRATTR_GLOW_FIRST+1)
sal_Int32 GetValue() const
FieldUnit
IMPL_LINK_NOARG(AreaPropertyPanelBase, ToolbarHdl_Impl, const OString &, void)
std::unique_ptr< ColorListBox > mxLBGlowColor
std::unique_ptr< weld::Label > mxFTRadiusGlow
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, SfxBindings *pBindings)
std::unique_ptr< weld::MetricSpinButton > mxGlowRadius
const Color & GetColorValue() const
Definition: xattr.cxx:295
constexpr TypedWhichId< SdrPercentItem > SDRATTR_GLOW_TRANSPARENCY(SDRATTR_GLOW_FIRST+2)
std::unique_ptr< weld::Label > mxFTColor
std::unique_ptr< weld::MetricSpinButton > mxGlowTransparency
virtual void dispose()
sfx2::sidebar::ControllerItem maGlowTransparencyController
virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, const SfxPoolItem *pState) override
sfx2::sidebar::ControllerItem maGlowColorController
SfxItemState
std::unique_ptr< weld::MetricSpinButton > mxSoftEdgeRadius
std::unique_ptr< weld::Label > mxFTRadiusSoftEdge
sfx2::sidebar::ControllerItem maGlowRadiusController
constexpr TypedWhichId< SdrMetricItem > SDRATTR_GLOW_RADIUS(SDRATTR_GLOW_FIRST+0)
std::unique_ptr< weld::Label > mxFTTransparency
sfx2::sidebar::ControllerItem maSoftEdgeRadiusController
virtual weld::Window * GetFrameWeld() const
constexpr TypedWhichId< SdrMetricItem > SDRATTR_SOFTEDGE_RADIUS(SDRATTR_SOFTEDGE_FIRST+0)
EffectPropertyPanel(weld::Widget *pParent, SfxBindings *pBindings)