1 #ifndef __DALI_TOOLKIT_INTERNAL_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_VIEW_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/actors/layer.h>
23 #include <dali/public-api/animation/animation.h>
24 #include <dali/public-api/common/map-wrapper.h>
27 #include <dali-toolkit/public-api/controls/control-impl.h>
28 #include <dali-toolkit/public-api/controls/view/view.h>
42 * View is a control to add layers and a background.
43 * @see Dali::Toolkit::View for more details.
45 class View : public Control
48 typedef std::map<unsigned int,Layer> LayerContainer;
49 typedef std::map<unsigned int,Layer>::iterator LayerIt;
50 typedef std::map<unsigned int,Layer>::const_iterator LayerConstIt;
53 * Orientation declaration used internally to rotate the view.
54 * The angles associated with each enum value could be changed with the SetOrientationFunction method.
58 PORTRAIT, ///< portrait orientation.
59 LANDSCAPE, ///< landscape orientation.
60 PORTRAIT_INVERSE, ///< portrait inverse orientation.
61 LANDSCAPE_INVERSE ///< landscape inverse orientation.
67 * Create an initialized View.
68 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
69 * @return A handle to a newly allocated Dali resource.
71 static Toolkit::View New( bool fullscreen );
74 * @copydoc Dali::Toolkit::View::GetContentLayer()
76 Layer GetContentLayer( unsigned int index ) const;
79 * @copydoc Dali::Toolkit::View::AddContentLayer()
81 unsigned int AddContentLayer( Layer layer );
84 * @copydoc Dali::Toolkit::View::RemoveContentLayer()
86 void RemoveContentLayer( Layer layer );
89 * @copydoc Dali::Toolkit::View::GetBackgroundLayer()
91 Layer GetBackgroundLayer() const;
94 * @copydoc Dali::Toolkit::View::SetBackground()
96 void SetBackground( ImageActor image );
99 * @copydoc Dali::Toolkit::View::SetOrientationFunction()
101 void SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse );
104 * @copydoc Dali::Toolkit::View::OrientationChanged()
107 void OrientationChanged( Dali::Orientation orientation );
110 * @copydoc Dali::Toolkit::View::SetAutoRotate()
113 void SetAutoRotate( bool enabled );
118 * @copydoc Dali::Toolkit::View::AnimationStartedSignalOrientation()
120 Toolkit::View::OrientationAnimationStartedSignalType& OrientationAnimationStartedSignal();
123 * Connects a callback function with the object's signals.
124 * @param[in] object The object providing the signal.
125 * @param[in] tracker Used to disconnect the signal.
126 * @param[in] signalName The signal to connect to.
127 * @param[in] functor A newly allocated FunctorDelegate.
128 * @return True if the signal was connected.
129 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
131 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
133 private: // From Control
136 * @copydoc Toolkit::Control::OnInitialize()
138 virtual void OnInitialize();
145 * It initializes View members.
146 * It initializes orientations as follows: portrait 0, landscape 90, portrait inverse 180, landscape inverse 270.
147 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
149 View(bool fullscreen);
152 * A reference counted object may only be deleted by calling Unreference()
157 * Return an orientation for the given angle in degrees.
158 * @param degree angle in degrees.
159 * @return An internal orientation.
161 View::Orientation DegreeToViewOrientation( Degree degree );
164 * Find a layer in the layer container. Non const method
166 LayerIt FindLayer( Layer layer );
169 int mOrientation; ///< Stores the given orientation in degrees.
170 bool mFullScreen; ///< Stores if the view is fullscreen or not.
171 LayerContainer mContentLayers; ///< Layer container.
172 unsigned int mNextLayerIndex; ///< Next index to be used when a layer is added.
173 Layer mBackgroundLayer; ///< The background layer.
174 Animation mRotateAnimation; ///< The animation which rotates the view (and all layers added to it)
175 float mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation.
176 bool mAutoRotateEnabled; ///< Whether the view rotates if the OrientationChanged method is called.
178 Toolkit::View::OrientationAnimationStartedSignalType mOrientationAnimationStartedSignal;
181 } // namespace Internal
184 // Helpers for public-api forwarding methods
186 inline Toolkit::Internal::View& GetImpl( Toolkit::View& view )
188 DALI_ASSERT_ALWAYS( view );
190 Dali::RefObject& handle = view.GetImplementation();
192 return static_cast<Toolkit::Internal::View&>( handle );
195 inline const Toolkit::Internal::View& GetImpl( const Toolkit::View& view )
197 DALI_ASSERT_ALWAYS( view );
199 const Dali::RefObject& handle = view.GetImplementation();
201 return static_cast<const Toolkit::Internal::View&>( handle );
204 } // namespace Toolkit
208 #endif // __DALI_TOOLKIT_INTERNAL_VIEW_H__