cid#1557590 Data race condition
[LibreOffice.git] / include / svx / float3d.hxx
blobaa918ffe2f052b7d880caed16681c6f64178f425
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_FLOAT3D_HXX
21 #define INCLUDED_SVX_FLOAT3D_HXX
23 #include <memory>
24 #include <sfx2/ctrlitem.hxx>
25 #include <sfx2/dockwin.hxx>
26 #include <vcl/weld.hxx>
27 #include <svx/svxdllapi.h>
29 #include <svx/dlgctl3d.hxx>
32 enum class ViewType3D
34 Geo = 1,
35 Representation,
36 Light,
37 Texture,
38 Material
41 class FmFormModel;
42 class Svx3DCtrlItem;
43 class SvxConvertTo3DItem;
44 class ColorListBox;
46 struct Svx3DWinImpl;
48 class UNLESS_MERGELIBS(SVX_DLLPUBLIC) LightButton final
50 public:
51 explicit LightButton(std::unique_ptr<weld::ToggleButton> xButton);
53 void switchLightOn(bool bOn);
54 bool isLightOn() const { return m_bLightOn;}
56 bool get_active() const { return m_xButton->get_active(); }
57 void set_active(bool bActive) { m_xButton->set_active(bActive); }
59 TriState get_state() const { return m_xButton->get_state(); }
60 void set_state(TriState eState) { m_xButton->set_state(eState); }
62 weld::ToggleButton* get_widget() const { return m_xButton.get(); }
64 void connect_clicked(const Link<weld::Button&, void>& rLink)
66 m_xButton->connect_clicked(rLink);
69 bool get_prev_active() const { return m_bButtonPrevActive; }
70 void set_prev_active(bool bPrevActive) { m_bButtonPrevActive = bPrevActive; }
72 private:
73 std::unique_ptr<weld::ToggleButton> m_xButton;
74 bool m_bLightOn;
75 bool m_bButtonPrevActive;
78 class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DWin final : public SfxDockingWindow
80 friend class Svx3DChildWindow;
81 friend class Svx3DCtrlItem;
83 private:
84 std::unique_ptr<weld::ToggleButton> m_xBtnGeo;
85 std::unique_ptr<weld::ToggleButton> m_xBtnRepresentation;
86 std::unique_ptr<weld::ToggleButton> m_xBtnLight;
87 std::unique_ptr<weld::ToggleButton> m_xBtnTexture;
88 std::unique_ptr<weld::ToggleButton> m_xBtnMaterial;
89 std::unique_ptr<weld::ToggleButton> m_xBtnUpdate;
90 std::unique_ptr<weld::Button> m_xBtnAssign;
92 // geometry
93 std::unique_ptr<weld::Container> m_xFLGeometrie;
94 std::unique_ptr<weld::Label> m_xFtPercentDiagonal;
95 std::unique_ptr<weld::MetricSpinButton> m_xMtrPercentDiagonal;
96 std::unique_ptr<weld::Label> m_xFtBackscale;
97 std::unique_ptr<weld::MetricSpinButton> m_xMtrBackscale;
98 std::unique_ptr<weld::Label> m_xFtEndAngle;
99 std::unique_ptr<weld::MetricSpinButton> m_xMtrEndAngle;
100 std::unique_ptr<weld::Label> m_xFtDepth;
101 std::unique_ptr<weld::MetricSpinButton> m_xMtrDepth;
103 std::unique_ptr<weld::Container> m_xFLSegments;
104 std::unique_ptr<weld::SpinButton> m_xNumHorizontal;
105 std::unique_ptr<weld::SpinButton> m_xNumVertical;
107 std::unique_ptr<weld::Container> m_xFLNormals;
108 std::unique_ptr<weld::ToggleButton> m_xBtnNormalsObj;
109 std::unique_ptr<weld::ToggleButton> m_xBtnNormalsFlat;
110 std::unique_ptr<weld::ToggleButton> m_xBtnNormalsSphere;
111 std::unique_ptr<weld::ToggleButton> m_xBtnNormalsInvert;
112 std::unique_ptr<weld::ToggleButton> m_xBtnTwoSidedLighting;
113 std::unique_ptr<weld::ToggleButton> m_xBtnDoubleSided;
115 // presentation
116 std::unique_ptr<weld::Container> m_xFLRepresentation;
117 std::unique_ptr<weld::ComboBox> m_xLbShademode;
119 std::unique_ptr<weld::Container> m_xFLShadow;
120 std::unique_ptr<weld::ToggleButton> m_xBtnShadow3d;
121 std::unique_ptr<weld::Label> m_xFtSlant;
122 std::unique_ptr<weld::MetricSpinButton> m_xMtrSlant;
124 std::unique_ptr<weld::Container> m_xFLCamera;
125 std::unique_ptr<weld::MetricSpinButton> m_xMtrDistance;
126 std::unique_ptr<weld::MetricSpinButton> m_xMtrFocalLength;
128 // lighting
129 std::unique_ptr<weld::Container> m_xFLLight;
130 std::unique_ptr<LightButton> m_xBtnLight1;
131 std::unique_ptr<LightButton> m_xBtnLight2;
132 std::unique_ptr<LightButton> m_xBtnLight3;
133 std::unique_ptr<LightButton> m_xBtnLight4;
134 std::unique_ptr<LightButton> m_xBtnLight5;
135 std::unique_ptr<LightButton> m_xBtnLight6;
136 std::unique_ptr<LightButton> m_xBtnLight7;
137 std::unique_ptr<LightButton> m_xBtnLight8;
138 std::unique_ptr<ColorListBox> m_xLbLight1;
139 std::unique_ptr<ColorListBox> m_xLbLight2;
140 std::unique_ptr<ColorListBox> m_xLbLight3;
141 std::unique_ptr<ColorListBox> m_xLbLight4;
142 std::unique_ptr<ColorListBox> m_xLbLight5;
143 std::unique_ptr<ColorListBox> m_xLbLight6;
144 std::unique_ptr<ColorListBox> m_xLbLight7;
145 std::unique_ptr<ColorListBox> m_xLbLight8;
146 std::unique_ptr<weld::Button> m_xBtnLightColor;
147 std::unique_ptr<ColorListBox> m_xLbAmbientlight; // ListBox
148 std::unique_ptr<weld::Button> m_xBtnAmbientColor; // color button
150 // Textures
151 std::unique_ptr<weld::Container> m_xFLTexture;
152 std::unique_ptr<weld::ToggleButton> m_xBtnTexLuminance;
153 std::unique_ptr<weld::ToggleButton> m_xBtnTexColor;
154 std::unique_ptr<weld::ToggleButton> m_xBtnTexReplace;
155 std::unique_ptr<weld::ToggleButton> m_xBtnTexModulate;
156 std::unique_ptr<weld::ToggleButton> m_xBtnTexObjectX;
157 std::unique_ptr<weld::ToggleButton> m_xBtnTexParallelX;
158 std::unique_ptr<weld::ToggleButton> m_xBtnTexCircleX;
159 std::unique_ptr<weld::ToggleButton> m_xBtnTexObjectY;
160 std::unique_ptr<weld::ToggleButton> m_xBtnTexParallelY;
161 std::unique_ptr<weld::ToggleButton> m_xBtnTexCircleY;
162 std::unique_ptr<weld::ToggleButton> m_xBtnTexFilter;
164 // material
165 // material editor
166 std::unique_ptr<weld::Container> m_xFLMaterial;
167 std::unique_ptr<weld::ComboBox> m_xLbMatFavorites;
168 std::unique_ptr<ColorListBox> m_xLbMatColor;
169 std::unique_ptr<weld::Button> m_xBtnMatColor;
170 std::unique_ptr<ColorListBox> m_xLbMatEmission;
171 std::unique_ptr<weld::Button> m_xBtnEmissionColor;
173 std::unique_ptr<weld::Container> m_xFLMatSpecular;
174 std::unique_ptr<ColorListBox> m_xLbMatSpecular;
175 std::unique_ptr<weld::Button> m_xBtnSpecularColor;
176 std::unique_ptr<weld::MetricSpinButton> m_xMtrMatSpecularIntensity;
178 std::unique_ptr<Svx3DPreviewControl> m_xCtlPreview;
179 std::unique_ptr<weld::CustomWeld> m_xCtlPreviewWin;
181 std::unique_ptr<weld::Widget> m_xLightPreviewGrid;
182 std::unique_ptr<weld::Scale> m_xHoriScale;
183 std::unique_ptr<weld::Scale> m_xVertScale;
184 std::unique_ptr<weld::Button> m_xBtn_Corner;
185 std::unique_ptr<Svx3DLightControl> m_xLightPreview;
186 std::unique_ptr<weld::CustomWeld> m_xCtlLightPreviewWin;
187 std::unique_ptr<SvxLightCtl3D> m_xCtlLightPreview;
189 // bottom part
190 std::unique_ptr<weld::Button> m_xBtnConvertTo3D;
191 std::unique_ptr<weld::Button> m_xBtnLatheObject;
192 std::unique_ptr<weld::ToggleButton> m_xBtnPerspective;
194 // the rest ...
195 bool bUpdate;
196 ViewType3D eViewType;
198 // Model, Page, View etc. for favourites
199 std::unique_ptr<FmFormModel> pModel;
201 SfxBindings* pBindings;
202 std::unique_ptr<Svx3DCtrlItem> pControllerItem;
204 std::unique_ptr<SvxConvertTo3DItem> pConvertTo3DItem;
205 std::unique_ptr<SvxConvertTo3DItem> pConvertTo3DLatheItem;
207 std::unique_ptr<Svx3DWinImpl> mpImpl;
208 MapUnit ePoolUnit;
209 FieldUnit eFUnit;
211 // ItemSet used to remember set 2d attributes
212 std::unique_ptr<SfxItemSet> mpRemember2DAttributes;
214 DECL_DLLPRIVATE_LINK( ClickViewTypeHdl, weld::Button&, void );
215 DECL_DLLPRIVATE_LINK( ClickUpdateHdl, weld::Toggleable&, void );
216 DECL_DLLPRIVATE_LINK( ClickAssignHdl, weld::Button&, void );
217 DECL_DLLPRIVATE_LINK( ClickHdl, weld::Button&, void );
218 DECL_DLLPRIVATE_LINK( ClickColorHdl, weld::Button&, void );
219 DECL_DLLPRIVATE_LINK( SelectHdl, weld::ComboBox&, void );
220 DECL_DLLPRIVATE_LINK( SelectColorHdl, ColorListBox&, void );
221 DECL_DLLPRIVATE_LINK( ModifyMetricHdl, weld::MetricSpinButton&, void );
222 DECL_DLLPRIVATE_LINK( ModifySpinHdl, weld::SpinButton&, void );
223 void ClickLight(const LightButton& rBtn);
225 DECL_DLLPRIVATE_LINK( ChangeSelectionCallbackHdl, SvxLightCtl3D*, void );
227 SVX_DLLPRIVATE void Construct();
228 SVX_DLLPRIVATE void Reset();
230 SVX_DLLPRIVATE static void LBSelectColor( ColorListBox* pLb, const Color& rColor );
231 SVX_DLLPRIVATE sal_uInt16 GetLightSource( const LightButton* pBtn ) const;
232 SVX_DLLPRIVATE ColorListBox* GetCLbByButton( const LightButton* pBtn = nullptr );
233 SVX_DLLPRIVATE LightButton* GetLbByButton( const weld::Button* pBtn );
235 virtual void Resize() override;
237 public:
238 Svx3DWin( SfxBindings* pBindings, SfxChildWindow *pCW,
239 vcl::Window* pParent );
240 virtual ~Svx3DWin() override;
241 virtual void dispose() override;
243 void InitColorLB();
244 bool IsUpdateMode() const { return bUpdate; }
246 void Update( SfxItemSet const & rSet );
247 void GetAttr( SfxItemSet& rSet );
249 void UpdatePreview(); // upward (private)
250 void DocumentReload();
253 /*************************************************************************
255 |* Controller item for 3D Window (Floating/Docking)
257 \************************************************************************/
259 class Svx3DCtrlItem final : public SfxControllerItem
261 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSId, SfxItemState eState,
262 const SfxPoolItem* pState ) override;
264 public:
265 Svx3DCtrlItem( sal_uInt16, SfxBindings* );
268 /*************************************************************************
270 |* ControllerItem for State of a Slot
271 |* (SID_CONVERT_TO_3D, SID_CONVERT_TO_3D_LATHE_FAST)
273 \************************************************************************/
275 class SvxConvertTo3DItem final : public SfxControllerItem
277 bool bState;
279 virtual void StateChangedAtToolBoxControl(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState) override;
281 public:
282 SvxConvertTo3DItem(sal_uInt16 nId, SfxBindings* pBindings);
283 bool GetState() const { return bState; }
286 #endif // INCLUDED_SVX_FLOAT3D_HXX
288 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */