Internal::Control cleanup, remove dead an non-needed methods and adding missing test...
[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 #include <dali/public-api/actors/image-actor.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali-toolkit/devel-api/controls/magnifier/magnifier.h>
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 namespace Internal
38 {
39
40 class Magnifier;
41
42 typedef IntrusivePtr<Magnifier>    MagnifierPtr;
43
44 /**
45  * @copydoc Toolkit::Magnifier
46  */
47 class Magnifier : public Control
48 {
49 public:
50
51   /**
52    * Create a new Magnifier.
53    * @return A public handle to the newly allocated Magnifier.
54    */
55   static Dali::Toolkit::Magnifier New();
56
57 public:
58
59   /**
60    * @copydoc Toolkit::ImageView::SetSourceActor
61    */
62   void SetSourceActor(Actor actor);
63
64   /**
65    * @copydoc Toolkit::ImageView::SetSourcePosition
66    */
67   void SetSourcePosition(const Vector3& position);
68
69   /**
70    * @copydoc Toolkit::ImageView::GetFrameVisibility
71    */
72   bool GetFrameVisibility() const;
73
74   /**
75    * @copydoc Toolkit::ImageView::SetFrameVisibility
76    */
77   void SetFrameVisibility(bool visible);
78
79   /**
80    * @copydoc Toolkit::ImageView::GetMagnificationFactor
81    */
82   float GetMagnificationFactor() const;
83
84   /**
85    * @copydoc Toolkit::ImageView::SetMagnificationFactor
86    */
87   void SetMagnificationFactor(float value);
88
89   /**
90    * Update magnification
91    */
92   void Update();
93
94 protected:
95
96   /**
97    * Construct a new Magnifier.
98    */
99   Magnifier();
100
101   /**
102    * 2nd-phase initialization.
103    */
104   void Initialize();
105
106   /**
107    * A reference counted object may only be deleted by calling Unreference()
108    */
109   virtual ~Magnifier();
110
111 private:
112
113   /**
114    * Initializes the render task required to render contents.
115    */
116   void InitializeRenderTask();
117
118 private:
119
120   virtual void OnSizeSet(const Vector3& targetSize);
121
122 private:
123
124   // Undefined
125   Magnifier(const Magnifier&);
126
127   // Undefined
128   Magnifier& operator=(const Magnifier& rhs);
129
130 private:
131
132   RenderTask mTask;                             ///< Render Task to render the source actor contents.
133   CameraActor mCameraActor;                     ///< CameraActor attached to RenderTask
134   ImageActor mFrame;                            ///< The Magnifier Frame
135   Property::Index mPropertySourcePosition;      ///< Source Position ("source-position")
136   Actor mSourceActor;                           ///< Source Delegate Actor represents the source position to read.
137   float mDefaultCameraDistance;                 ///< Default RenderTask's camera distance from target.
138   Vector3 mActorSize;                           ///< The Actor size
139   float mMagnificationFactor;                   ///< Magnification factor 1.0f is default. same as content.
140 };
141
142 } // namespace Internal
143
144 // Helpers for public-api forwarding methods
145
146 inline Toolkit::Internal::Magnifier& GetImpl(Toolkit::Magnifier& pub)
147 {
148   DALI_ASSERT_ALWAYS(pub);
149
150   Dali::RefObject& handle = pub.GetImplementation();
151
152   return static_cast<Toolkit::Internal::Magnifier&>(handle);
153 }
154
155 inline const Toolkit::Internal::Magnifier& GetImpl(const Toolkit::Magnifier& pub)
156 {
157   DALI_ASSERT_ALWAYS(pub);
158
159   const Dali::RefObject& handle = pub.GetImplementation();
160
161   return static_cast<const Toolkit::Internal::Magnifier&>(handle);
162 }
163
164 } // namespace Toolkit
165
166 } // namespace Dali
167
168 #endif // __DALI_TOOLKIT_INTERNAL_MAGNIFIER_H__