(Properties) Added ability to add non-animatable event-thread only properties via...
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.h
1 #ifndef __DALI_INTERNAL_CAMERA_ACTOR_H__
2 #define __DALI_INTERNAL_CAMERA_ACTOR_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUES
21 #include <dali/public-api/object/ref-object.h>
22 #include <dali/public-api/actors/camera-actor.h>
23 #include <dali/internal/event/actors/actor-impl.h>
24 #include <dali/internal/event/actors/actor-declarations.h>
25 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 /**
34  * An actor with a conveniently pre-attached CameraAttachment.
35  */
36 class CameraActor : public Actor
37 {
38 public:
39
40   /**
41    * Create an initialised camera actor.
42    *
43    * Sets the default camera perspective projection for the given canvas size. @see SetPerspectiveProjection().
44    *
45    * @param[in] size The canvas size.
46    *
47    * @return A smart-pointer to a newly allocated camera actor.
48    */
49   static CameraActorPtr New( const Size& size );
50
51   /**
52    * @copydoc Dali::Actor::OnInitialize
53    */
54   void OnInitialize();
55
56   /**
57    * Retrieve the camera attachment.
58    * @return The attachment.
59    */
60   CameraAttachment& GetCameraAttachment()
61   {
62     return *mCameraAttachment;
63   }
64
65   /**
66    * @copydoc Dali::CameraActor::SetType
67    */
68   void SetType( Dali::Camera::Type type );
69
70   /**
71    * @copydoc Dali::CameraActor::GetType
72    */
73   Dali::Camera::Type GetType() const;
74
75   /**
76    * @copydoc Dali::CameraActor::SetProjectionMode
77    */
78   void SetProjectionMode( Dali::Camera::ProjectionMode mode );
79
80   /**
81    * @copydoc Dali::CameraActor::GetProjectionMode
82    */
83   Dali::Camera::ProjectionMode GetProjectionMode() const;
84
85   /**
86    * @copydoc Dali::CameraActor::SetFieldOfView
87    */
88   void SetFieldOfView( float fieldOfView );
89
90   /**
91    * @copydoc Dali::CameraActor::GetFieldOfView
92    */
93   float GetFieldOfView( ) const;
94
95   /**
96    * @copydoc Dali::CameraActor::SetAspectRatio
97    */
98   void SetAspectRatio( float aspectRatio );
99
100   /**
101    * @copydoc Dali::CameraActor::GetAspectRatio
102    */
103   float GetAspectRatio( ) const;
104
105   /**
106    * @copydoc Dali::CameraActor::SetNearClippingPlane
107    */
108   void SetNearClippingPlane( float nearClippingPlane );
109
110   /**
111    * @copydoc Dali::CameraActor::GetNearClippingPlane
112    */
113   float GetNearClippingPlane( ) const;
114
115   /**
116    * @copydoc Dali::CameraActor::SetFarClippingPlane
117    */
118   void SetFarClippingPlane( float farClippingPlane );
119
120   /**
121    * @copydoc Dali::CameraActor::GetFarClippingPlane
122    */
123   float GetFarClippingPlane( ) const;
124
125   /**
126    * @copydoc Dali::CameraActor::SetTargetPosition
127    */
128   void SetTargetPosition( const Vector3& targetPosition );
129
130   /**
131    * @copydoc Dali::CameraActor::GetTargetPosition
132    */
133   Vector3 GetTargetPosition() const;
134
135   /**
136    * @copydoc Dali::CameraActor::SetInvertYAxis
137    */
138   void SetInvertYAxis(bool invertYAxis);
139
140   /**
141    * @copydoc Dali::CameraActor::GetCurrentInvertYAxis
142    */
143   bool GetInvertYAxis() const;
144
145   /**
146    * @copydoc Dali::CameraActor::SetPerspectiveProjection()
147    */
148   void SetPerspectiveProjection( const Size& size );
149
150   /**
151    * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
152    */
153   void SetOrthographicProjection( const Vector2& size );
154
155   /**
156    * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
157    */
158   void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
159
160   /**
161    * Build a picking ray with this camera and given screen coordinates
162    * @param [in] screenCoordinates the ray passed through
163    * @param [in] viewport to use
164    * @param [out] rayOrigin for the picking ray
165    * @param [out] rayDirection for the picking ray
166    * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
167    */
168   bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
169
170   /**
171    * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
172    * @return The view-matrix.
173    */
174   const Matrix& GetViewMatrix() const;
175
176   /**
177    * Retrieve the projection-matrix; This will only be valid when the actor is on-stage.
178    * @return The projection-matrix.
179    */
180   const Matrix& GetProjectionMatrix() const;
181
182 public: // properties
183
184   /**
185    * copydoc Dali::Internal::ProxyObject
186    */
187   virtual unsigned int GetDefaultPropertyCount() const;
188
189   /**
190    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
191    */
192   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
193
194   /**
195    * copydoc Dali::Internal::ProxyObject
196    */
197   virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
198
199   /**
200    * copydoc Dali::Internal::ProxyObject
201    */
202   virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
203
204   /**
205    * copydoc Dali::Internal::ProxyObject
206    */
207   virtual const std::string& GetDefaultPropertyName( Property::Index index ) const;
208
209   /**
210    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
211    */
212   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
213
214   /**
215    * copydoc Dali::Internal::ProxyObject
216    */
217   virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
218
219   /**
220    * copydoc Dali::Internal::ProxyObject
221    */
222   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
223
224   /**
225    * copydoc Dali::Internal::ProxyObject
226    */
227   virtual bool IsDefaultPropertyWritable( Property::Index index ) const ;
228
229   /**
230    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
231    */
232   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
233
234   /**
235    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
236    */
237   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
238
239 protected:
240
241   /**
242    * Protected constructor; see also CameraActor::New()
243    */
244   CameraActor();
245
246   /**
247    * A reference counted object may only be deleted by calling Unreference()
248    */
249   virtual ~CameraActor();
250
251 private:
252   CameraAttachmentPtr mCameraAttachment;
253   static bool mFirstInstance ;
254   static DefaultPropertyLookup* mDefaultCameraActorPropertyLookup; ///< Default properties
255 };
256
257 } // namespace Internal
258
259 // Helpers for public-api forwarding methods
260
261 inline Internal::CameraActor& GetImplementation(Dali::CameraActor& camera)
262 {
263   DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
264
265   BaseObject& handle = camera.GetBaseObject();
266
267   return static_cast<Internal::CameraActor&>(handle);
268 }
269
270 inline const Internal::CameraActor& GetImplementation(const Dali::CameraActor& camera)
271 {
272   DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
273
274   const BaseObject& handle = camera.GetBaseObject();
275
276   return static_cast<const Internal::CameraActor&>(handle);
277 }
278
279 } // namespace Dali
280
281 #endif // __DALI_INTERNAL_CAMERA_ACTOR_H__