[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / magnifier / magnifier-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_MAGNIFIER_H
2 #define DALI_TOOLKIT_INTERNAL_MAGNIFIER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/camera-actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/render-tasks/render-task.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/devel-api/controls/magnifier/magnifier.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Internal
35 {
36 class Magnifier;
37
38 typedef IntrusivePtr<Magnifier> MagnifierPtr;
39
40 /**
41  * @copydoc Toolkit::Magnifier
42  */
43 class Magnifier : public Control
44 {
45 public:
46   /**
47    * Create a new Magnifier.
48    * @return A public handle to the newly allocated Magnifier.
49    */
50   static Dali::Toolkit::Magnifier New();
51
52 public:
53   /**
54    * @copydoc Toolkit::ImageView::SetSourceActor
55    */
56   void SetSourceActor(Actor actor);
57
58   /**
59    * Returns whether the frame is visible or not.
60    * @return true if frame is visible, false if not.
61    */
62   bool GetFrameVisibility() const;
63
64   /**
65    * Sets whether the frame part of the magnifier should be visible or not.
66    * @param[in] visible true to display frame, false to hide frame.
67    */
68   void SetFrameVisibility(bool visible);
69
70   /**
71    * Get the magnification factor of the magnifier
72    * The larger the value the larger the contents magnified.
73    * A value of 1.0f indications 1x magnification.
74    * @return Magnification factor is returned
75    */
76   float GetMagnificationFactor() const;
77
78   /**
79    * Set the magnification factor of the magnifier
80    * The larger the value the larger the contents magnified.
81    * A value of 1.0f indications 1x magnification.
82    * @param[in] value Magnification factor.
83    */
84   void SetMagnificationFactor(float value);
85
86   /**
87    * Update magnification
88    */
89   void Update();
90
91   // Properties
92
93   /**
94    * Called when a property of an object of this type is set.
95    * @param[in] object The object whose property is set.
96    * @param[in] index The property index.
97    * @param[in] value The new property value.
98    */
99   static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
100
101   /**
102    * Called to retrieve a property of an object of this type.
103    * @param[in] object The object whose property is to be retrieved.
104    * @param[in] index The property index.
105    * @return The current value of the property.
106    */
107   static Property::Value GetProperty(BaseObject* object, Property::Index index);
108
109 protected:
110   /**
111    * Construct a new Magnifier.
112    */
113   Magnifier();
114
115   /**
116    * 2nd-phase initialization.
117    */
118   void Initialize();
119
120   /**
121    * A reference counted object may only be deleted by calling Unreference()
122    */
123   virtual ~Magnifier();
124
125 private:
126   /**
127    * Initializes the render task required to render contents.
128    */
129   void InitializeRenderTask();
130
131 private:
132   void OnSizeSet(const Vector3& targetSize) override;
133
134 private:
135   // Undefined
136   Magnifier(const Magnifier&);
137
138   // Undefined
139   Magnifier& operator=(const Magnifier& rhs);
140
141 private:
142   RenderTask  mTask;                  ///< Render Task to render the source actor contents.
143   CameraActor mCameraActor;           ///< CameraActor attached to RenderTask
144   Actor       mFrame;                 ///< The Magnifier Frame
145   Actor       mSourceActor;           ///< Source Delegate Actor represents the source position to read.
146   float       mDefaultCameraDistance; ///< Default RenderTask's camera distance from target.
147   Vector3     mActorSize;             ///< The Actor size
148   float       mMagnificationFactor;   ///< Magnification factor 1.0f is default. same as content.
149 };
150
151 } // namespace Internal
152
153 // Helpers for public-api forwarding methods
154
155 inline Toolkit::Internal::Magnifier& GetImpl(Toolkit::Magnifier& pub)
156 {
157   DALI_ASSERT_ALWAYS(pub);
158
159   Dali::RefObject& handle = pub.GetImplementation();
160
161   return static_cast<Toolkit::Internal::Magnifier&>(handle);
162 }
163
164 inline const Toolkit::Internal::Magnifier& GetImpl(const Toolkit::Magnifier& pub)
165 {
166   DALI_ASSERT_ALWAYS(pub);
167
168   const Dali::RefObject& handle = pub.GetImplementation();
169
170   return static_cast<const Toolkit::Internal::Magnifier&>(handle);
171 }
172
173 } // namespace Toolkit
174
175 } // namespace Dali
176
177 #endif // DALI_TOOLKIT_INTERNAL_MAGNIFIER_H