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