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