bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / dlgctl3d.hxx
blob82f544031a55de82072083f577049f908a1ae450
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_DLGCTL3D_HXX
21 #define INCLUDED_SVX_DLGCTL3D_HXX
23 #include <vcl/ctrl.hxx>
24 #include <vcl/scrbar.hxx>
25 #include <vcl/button.hxx>
26 #include <svl/itemset.hxx>
27 #include <svx/svxdllapi.h>
28 #include <basegfx/vector/b3dvector.hxx>
29 #include <memory>
31 class FmFormModel;
32 class FmFormPage;
33 class E3dView;
34 class E3dObject;
35 class E3dScene;
37 enum class SvxPreviewObjectType { SPHERE, CUBE };
39 class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DPreviewControl : public Control
41 protected:
42 std::unique_ptr<FmFormModel> mpModel;
43 FmFormPage* mpFmPage;
44 std::unique_ptr<E3dView> mp3DView;
45 E3dScene* mpScene;
46 E3dObject* mp3DObj;
47 SvxPreviewObjectType mnObjectType;
49 void Construct();
51 public:
52 Svx3DPreviewControl(vcl::Window* pParent, WinBits nStyle = 0);
53 virtual ~Svx3DPreviewControl() override;
54 virtual void dispose() override;
56 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
57 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
58 virtual void Resize() override;
59 virtual Size GetOptimalSize() const override;
61 virtual void SetObjectType(SvxPreviewObjectType nType);
62 SvxPreviewObjectType GetObjectType() const { return mnObjectType; }
63 SfxItemSet const & Get3DAttributes() const;
64 virtual void Set3DAttributes(const SfxItemSet& rAttr);
67 class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl
69 // Callback for interactive changes
70 Link<Svx3DLightControl*,void> maChangeCallback;
71 Link<Svx3DLightControl*,void> maSelectionChangeCallback;
73 // lights
74 sal_uInt32 maSelectedLight;
76 // extra objects for light control
77 E3dObject* mpExpansionObject;
78 E3dObject* mpLampBottomObject;
79 E3dObject* mpLampShaftObject;
80 std::vector< E3dObject* > maLightObjects;
82 // 3d rotations of object
83 double mfRotateX;
84 double mfRotateY;
85 double mfRotateZ;
87 // interaction parameters
88 Point maActionStartPoint;
89 double mfSaveActionStartHor;
90 double mfSaveActionStartVer;
91 double mfSaveActionStartRotZ;
93 bool mbMouseMoved : 1;
94 bool mbGeometrySelected : 1;
96 void Construct2();
97 void ConstructLightObjects();
98 void AdaptToSelectedLight();
99 void TrySelection(Point aPosPixel);
101 public:
102 Svx3DLightControl(vcl::Window* pParent, WinBits nStyle);
104 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
105 virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
106 virtual void Tracking( const TrackingEvent& rTEvt ) override;
107 virtual void Resize() override;
109 virtual void SetObjectType(SvxPreviewObjectType nType) override;
111 // register user callback
112 void SetChangeCallback(Link<Svx3DLightControl*,void> aNew) { maChangeCallback = aNew; }
113 void SetSelectionChangeCallback(Link<Svx3DLightControl*,void> aNew) { maSelectionChangeCallback = aNew; }
115 // selection checks
116 bool IsSelectionValid();
117 bool IsGeometrySelected() { return mbGeometrySelected; }
119 // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
120 void GetPosition(double& rHor, double& rVer);
121 void SetPosition(double fHor, double fVer);
123 // get/set rotation of 3D object
124 void SetRotation(double fRotX, double fRotY, double fRotZ);
125 void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
127 void SelectLight(sal_uInt32 nLightNumber);
128 virtual void Set3DAttributes(const SfxItemSet& rAttr) override;
129 sal_uInt32 GetSelectedLight() { return maSelectedLight; }
131 // light data access
132 bool GetLightOnOff(sal_uInt32 nNum) const;
133 Color GetLightColor(sal_uInt32 nNum) const;
134 basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
137 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLightCtl3D final : public Control
139 // local controls
140 VclPtr<Svx3DLightControl> maLightControl;
141 VclPtr<ScrollBar> maHorScroller;
142 VclPtr<ScrollBar> maVerScroller;
143 VclPtr<PushButton> maSwitcher;
145 // callback for interactive changes
146 Link<SvxLightCtl3D*,void> maUserInteractiveChangeCallback;
147 Link<SvxLightCtl3D*,void> maUserSelectionChangeCallback;
149 public:
150 SvxLightCtl3D(vcl::Window* pParent);
151 virtual ~SvxLightCtl3D() override;
152 virtual void dispose() override;
154 // react to size changes
155 virtual void Resize() override;
156 void NewLayout();
158 // check the selection for validity
159 void CheckSelection();
161 // bring further settings to the outside world
162 Svx3DLightControl& GetSvx3DLightControl() { return *maLightControl; }
164 // register user callback
165 void SetUserInteractiveChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserInteractiveChangeCallback = aNew; }
166 void SetUserSelectionChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; }
168 virtual void KeyInput( const KeyEvent& rKEvt ) override;
169 virtual void GetFocus() override;
170 virtual void LoseFocus() override;
172 virtual Size GetOptimalSize() const override;
174 private:
176 DECL_LINK( InternalInteractiveChange, Svx3DLightControl*, void);
177 DECL_LINK( InternalSelectionChange, Svx3DLightControl*, void);
178 DECL_LINK( ScrollBarMove, ScrollBar*, void);
179 DECL_LINK( ButtonPress, Button*, void);
181 // initialize local parameters
182 void Init();
184 void move( double fDeltaHor, double fDeltaVer );
187 #endif // _SCH_DLGCTL3D_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */