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
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
22namespace 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 , mxFTColor(m_xBuilder->weld_label("glowcolorlabel"))
38 , mxSoftEdgeRadius(m_xBuilder->weld_metric_spin_button("SB_SOFTEDGE_RADIUS", FieldUnit::POINT))
39{
40 Initialize();
41}
42
44{
45 mxGlowRadius.reset();
46 mxLBGlowColor.reset();
47 mxGlowTransparency.reset();
48 mxFTColor.reset();
49 mxFTTransparency.reset();
50 mxSoftEdgeRadius.reset();
51
56}
57
59{
60 mxGlowRadius->connect_value_changed(LINK(this, EffectPropertyPanel, ModifyGlowRadiusHdl));
61 mxLBGlowColor->SetSelectHdl(LINK(this, EffectPropertyPanel, ModifyGlowColorHdl));
62 mxGlowTransparency->connect_value_changed(
63 LINK(this, EffectPropertyPanel, ModifyGlowTransparencyHdl));
64 mxSoftEdgeRadius->connect_value_changed(
65 LINK(this, EffectPropertyPanel, ModifySoftEdgeRadiusHdl));
66}
67
69{
70 SdrMetricItem aItem(SDRATTR_SOFTEDGE_RADIUS, mxSoftEdgeRadius->get_value(FieldUnit::MM_100TH));
71 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_SOFTEDGE_RADIUS, SfxCallMode::RECORD,
72 { &aItem });
73}
74
76{
77 XColorItem aItem(SDRATTR_GLOW_COLOR, mxLBGlowColor->GetSelectEntryColor());
78 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_COLOR, SfxCallMode::RECORD, { &aItem });
79}
80
82{
83 SdrMetricItem aItem(SDRATTR_GLOW_RADIUS, mxGlowRadius->get_value(FieldUnit::MM_100TH));
84 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_RADIUS, SfxCallMode::RECORD, { &aItem });
85}
86
88{
90 mxGlowTransparency->get_value(FieldUnit::PERCENT));
91 mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_TRANSPARENCY, SfxCallMode::RECORD,
92 { &aItem });
93}
94
96{
97 const bool bEnabled = mxGlowRadius->get_value(FieldUnit::MM_100TH) != 0;
98 mxLBGlowColor->set_sensitive(bEnabled);
99 mxGlowTransparency->set_sensitive(bEnabled);
100 mxFTColor->set_sensitive(bEnabled);
101 mxFTTransparency->set_sensitive(bEnabled);
102}
103
105 const SfxPoolItem* pState)
106{
107 switch (nSID)
108 {
109 case SID_ATTR_SOFTEDGE_RADIUS:
110 {
111 if (eState >= SfxItemState::DEFAULT)
112 {
113 const SdrMetricItem* pRadiusItem = dynamic_cast<const SdrMetricItem*>(pState);
114 if (pRadiusItem)
115 {
116 mxSoftEdgeRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH);
117 }
118 }
119 }
120 break;
121 case SID_ATTR_GLOW_COLOR:
122 {
123 if (eState >= SfxItemState::DEFAULT)
124 {
125 const XColorItem* pColorItem = dynamic_cast<const XColorItem*>(pState);
126 if (pColorItem)
127 {
128 mxLBGlowColor->SelectEntry(pColorItem->GetColorValue());
129 }
130 }
131 }
132 break;
133 case SID_ATTR_GLOW_RADIUS:
134 {
135 if (eState >= SfxItemState::DEFAULT)
136 {
137 const SdrMetricItem* pRadiusItem = dynamic_cast<const SdrMetricItem*>(pState);
138 if (pRadiusItem)
139 {
140 mxGlowRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH);
141 }
142 }
143 }
144 break;
145 case SID_ATTR_GLOW_TRANSPARENCY:
146 {
147 if (eState >= SfxItemState::DEFAULT)
148 {
149 if (auto pItem = dynamic_cast<const SdrPercentItem*>(pState))
150 {
151 mxGlowTransparency->set_value(pItem->GetValue(), FieldUnit::PERCENT);
152 }
153 }
154 }
155 break;
156 }
158}
159
160std::unique_ptr<PanelLayout> EffectPropertyPanel::Create(weld::Widget* pParent,
161 SfxBindings* pBindings)
162{
163 if (pParent == nullptr)
164 throw css::lang::IllegalArgumentException(
165 "no parent Window given to EffectPropertyPanel::Create", nullptr, 0);
166 if (pBindings == nullptr)
167 throw css::lang::IllegalArgumentException(
168 "no SfxBindings given to EffectPropertyPanel::Create", nullptr, 2);
169
170 return std::make_unique<EffectPropertyPanel>(pParent, pBindings);
171}
172}
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetValue() const
virtual weld::Window * GetFrameWeld() const
virtual void dispose()
const Color & GetColorValue() const
Definition: xattr.cxx:302
sfx2::sidebar::ControllerItem maGlowRadiusController
virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, const SfxPoolItem *pState) override
std::unique_ptr< weld::MetricSpinButton > mxSoftEdgeRadius
std::unique_ptr< weld::Label > mxFTTransparency
std::unique_ptr< weld::MetricSpinButton > mxGlowRadius
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, SfxBindings *pBindings)
std::unique_ptr< ColorListBox > mxLBGlowColor
std::unique_ptr< weld::MetricSpinButton > mxGlowTransparency
EffectPropertyPanel(weld::Widget *pParent, SfxBindings *pBindings)
std::unique_ptr< weld::Label > mxFTColor
sfx2::sidebar::ControllerItem maSoftEdgeRadiusController
sfx2::sidebar::ControllerItem maGlowTransparencyController
sfx2::sidebar::ControllerItem maGlowColorController
FieldUnit
IMPL_LINK_NOARG(AreaPropertyPanelBase, ToolbarHdl_Impl, const OUString &, void)
SfxItemState
constexpr TypedWhichId< SdrPercentItem > SDRATTR_GLOW_TRANSPARENCY(SDRATTR_GLOW_FIRST+2)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_GLOW_RADIUS(SDRATTR_GLOW_FIRST+0)
constexpr TypedWhichId< XColorItem > SDRATTR_GLOW_COLOR(SDRATTR_GLOW_FIRST+1)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_SOFTEDGE_RADIUS(SDRATTR_SOFTEDGE_FIRST+0)