f0c91333adf365e2b5e5e5a3369c7f4282004ee8
[platform/core/uifw/dali-toolkit.git] / optional / 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/public-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    * @copydoc Toolkit::ImageView::SetSourcePosition
65    */
66   void SetSourcePosition(const Vector3& position);
67
68   /**
69    * @copydoc Toolkit::ImageView::GetFrameVisibility
70    */
71   bool GetFrameVisibility() const;
72
73   /**
74    * @copydoc Toolkit::ImageView::SetFrameVisibility
75    */
76   void SetFrameVisibility(bool visible);
77
78   /**
79    * @copydoc Toolkit::ImageView::GetMagnificationFactor
80    */
81   float GetMagnificationFactor() const;
82
83   /**
84    * @copydoc Toolkit::ImageView::SetMagnificationFactor
85    */
86   void SetMagnificationFactor(float value);
87
88   /**
89    * Update magnification
90    */
91   void Update();
92
93 protected:
94
95   /**
96    * Construct a new Magnifier.
97    */
98   Magnifier();
99
100   /**
101    * 2nd-phase initialization.
102    */
103   void Initialize();
104
105   /**
106    * A reference counted object may only be deleted by calling Unreference()
107    */
108   virtual ~Magnifier();
109
110 private:
111
112   /**
113    * Initializes the render task required to render contents.
114    */
115   void InitializeRenderTask();
116
117 private:
118
119   virtual void OnControlSizeSet(const Vector3& targetSize);
120
121 private:
122
123   // Undefined
124   Magnifier(const Magnifier&);
125
126   // Undefined
127   Magnifier& operator=(const Magnifier& rhs);
128
129 private:
130
131   RenderTask mTask;                             ///< Render Task to render the source actor contents.
132   CameraActor mCameraActor;                     ///< CameraActor attached to RenderTask
133   Layer mFrameLayer;                            ///< Frame is placed on separate layer added to stage.
134   Property::Index mPropertySourcePosition;      ///< Source Position ("source-position")
135   Actor mSourceActor;                           ///< Source Delegate Actor represents the source position to read.
136   float mDefaultCameraDistance;                 ///< Default RenderTask's camera distance from target.
137   Vector3 mActorSize;                           ///< The Actor size
138   float mMagnificationFactor;                   ///< Magnification factor 1.0f is default. same as content.
139 };
140
141 } // namespace Internal
142
143 // Helpers for public-api forwarding methods
144
145 inline Toolkit::Internal::Magnifier& GetImpl(Toolkit::Magnifier& pub)
146 {
147   DALI_ASSERT_ALWAYS(pub);
148
149   Dali::RefObject& handle = pub.GetImplementation();
150
151   return static_cast<Toolkit::Internal::Magnifier&>(handle);
152 }
153
154 inline const Toolkit::Internal::Magnifier& GetImpl(const Toolkit::Magnifier& pub)
155 {
156   DALI_ASSERT_ALWAYS(pub);
157
158   const Dali::RefObject& handle = pub.GetImplementation();
159
160   return static_cast<const Toolkit::Internal::Magnifier&>(handle);
161 }
162
163 } // namespace Toolkit
164
165 } // namespace Dali
166
167 #endif // __DALI_TOOLKIT_INTERNAL_MAGNIFIER_H__