(Vector) Reset the current frame when stopped
[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) 2014 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/public-api/controls/control-impl.h>
28 #include <dali-toolkit/devel-api/controls/magnifier/magnifier.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 class Magnifier;
40
41 typedef IntrusivePtr<Magnifier>    MagnifierPtr;
42
43 /**
44  * @copydoc Toolkit::Magnifier
45  */
46 class Magnifier : public Control
47 {
48 public:
49
50   /**
51    * Create a new Magnifier.
52    * @return A public handle to the newly allocated Magnifier.
53    */
54   static Dali::Toolkit::Magnifier New();
55
56 public:
57
58   /**
59    * @copydoc Toolkit::ImageView::SetSourceActor
60    */
61   void SetSourceActor(Actor actor);
62
63   /**
64    * Returns whether the frame is visible or not.
65    * @return true if frame is visible, false if not.
66    */
67   bool GetFrameVisibility() const;
68
69   /**
70    * Sets whether the frame part of the magnifier should be visible or not.
71    * @param[in] visible true to display frame, false to hide frame.
72    */
73   void SetFrameVisibility(bool visible);
74
75   /**
76    * Get the magnification factor of the magnifier
77    * The larger the value the larger the contents magnified.
78    * A value of 1.0f indications 1x magnification.
79    * @return Magnification factor is returned
80    */
81   float GetMagnificationFactor() const;
82
83   /**
84    * Set the magnification factor of the magnifier
85    * The larger the value the larger the contents magnified.
86    * A value of 1.0f indications 1x magnification.
87    * @param[in] value Magnification factor.
88    */
89   void SetMagnificationFactor(float value);
90
91   /**
92    * Update magnification
93    */
94   void Update();
95
96   // Properties
97
98   /**
99    * Called when a property of an object of this type is set.
100    * @param[in] object The object whose property is set.
101    * @param[in] index The property index.
102    * @param[in] value The new property value.
103    */
104   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
105
106   /**
107    * Called to retrieve a property of an object of this type.
108    * @param[in] object The object whose property is to be retrieved.
109    * @param[in] index The property index.
110    * @return The current value of the property.
111    */
112   static Property::Value GetProperty( BaseObject* object, Property::Index index );
113
114 protected:
115
116   /**
117    * Construct a new Magnifier.
118    */
119   Magnifier();
120
121   /**
122    * 2nd-phase initialization.
123    */
124   void Initialize();
125
126   /**
127    * A reference counted object may only be deleted by calling Unreference()
128    */
129   virtual ~Magnifier();
130
131 private:
132
133   /**
134    * Initializes the render task required to render contents.
135    */
136   void InitializeRenderTask();
137
138 private:
139
140   virtual void OnSizeSet(const Vector3& targetSize);
141
142 private:
143
144   // Undefined
145   Magnifier(const Magnifier&);
146
147   // Undefined
148   Magnifier& operator=(const Magnifier& rhs);
149
150 private:
151
152   RenderTask mTask;                             ///< Render Task to render the source actor contents.
153   CameraActor mCameraActor;                     ///< CameraActor attached to RenderTask
154   Actor mFrame;                                 ///< The Magnifier Frame
155   Actor mSourceActor;                           ///< Source Delegate Actor represents the source position to read.
156   float mDefaultCameraDistance;                 ///< Default RenderTask's camera distance from target.
157   Vector3 mActorSize;                           ///< The Actor size
158   float mMagnificationFactor;                   ///< Magnification factor 1.0f is default. same as content.
159 };
160
161 } // namespace Internal
162
163 // Helpers for public-api forwarding methods
164
165 inline Toolkit::Internal::Magnifier& GetImpl(Toolkit::Magnifier& pub)
166 {
167   DALI_ASSERT_ALWAYS(pub);
168
169   Dali::RefObject& handle = pub.GetImplementation();
170
171   return static_cast<Toolkit::Internal::Magnifier&>(handle);
172 }
173
174 inline const Toolkit::Internal::Magnifier& GetImpl(const Toolkit::Magnifier& pub)
175 {
176   DALI_ASSERT_ALWAYS(pub);
177
178   const Dali::RefObject& handle = pub.GetImplementation();
179
180   return static_cast<const Toolkit::Internal::Magnifier&>(handle);
181 }
182
183 } // namespace Toolkit
184
185 } // namespace Dali
186
187 #endif // __DALI_TOOLKIT_INTERNAL_MAGNIFIER_H__