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/dali.h>
23 #include <dali/public-api/common/map-wrapper.h>
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27 #include <dali-toolkit/public-api/controls/view/view.h>
41 * View is a control to add layers and a background.
42 * @see Dali::Toolkit::View for more details.
44 class View : public Control
47 typedef std::map<unsigned int,Layer> LayerContainer;
48 typedef std::map<unsigned int,Layer>::iterator LayerIt;
49 typedef std::map<unsigned int,Layer>::const_iterator LayerConstIt;
52 * Orientation declaration used internally to rotate the view.
53 * The angles associated with each enum value could be changed with the SetOrientationFunction method.
57 PORTRAIT, ///< portrait orientation.
58 LANDSCAPE, ///< landscape orientation.
59 PORTRAIT_INVERSE, ///< portrait inverse orientation.
60 LANDSCAPE_INVERSE ///< landscape inverse orientation.
66 * Create an initialized View.
67 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
68 * @return A handle to a newly allocated Dali resource.
70 static Toolkit::View New( bool fullscreen );
73 * @copydoc Dali::Toolkit::View::GetContentLayer()
75 Layer GetContentLayer( unsigned int index ) const;
78 * @copydoc Dali::Toolkit::View::AddContentLayer()
80 unsigned int AddContentLayer( Layer layer );
83 * @copydoc Dali::Toolkit::View::RemoveContentLayer()
85 void RemoveContentLayer( Layer layer );
88 * @copydoc Dali::Toolkit::View::GetBackgroundLayer()
90 Layer GetBackgroundLayer() const;
93 * @copydoc Dali::Toolkit::View::SetBackground()
95 void SetBackground( ImageActor image );
98 * @copydoc Dali::Toolkit::View::SetOrientationFunction()
100 void SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse );
103 * @copydoc Dali::Toolkit::View::OrientationChanged()
106 void OrientationChanged( Dali::Orientation orientation );
109 * @copydoc Dali::Toolkit::View::SetAutoRotate()
112 void SetAutoRotate( bool enabled );
117 * @copydoc Dali::Toolkit::View::AnimationStartedSignalOrientation()
119 Toolkit::View::OrientationAnimationStartedSignalV2& OrientationAnimationStartedSignal();
122 * Connects a callback function with the object's signals.
123 * @param[in] object The object providing the signal.
124 * @param[in] tracker Used to disconnect the signal.
125 * @param[in] signalName The signal to connect to.
126 * @param[in] functor A newly allocated FunctorDelegate.
127 * @return True if the signal was connected.
128 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
130 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
132 private: // From Control
135 * @copydoc Toolkit::Control::OnInitialize()
137 virtual void OnInitialize();
144 * It initializes View members.
145 * It initializes orientations as follows: portrait 0, landscape 90, portrait inverse 180, landscape inverse 270.
146 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
148 View(bool fullscreen);
151 * A reference counted object may only be deleted by calling Unreference()
156 * Return an orientation for the given angle in degrees.
157 * @param degree angle in degrees.
158 * @return An internal orientation.
160 View::Orientation DegreeToViewOrientation( Degree degree );
163 * Find a layer in the layer container. Non const method
165 LayerIt FindLayer( Layer layer );
168 int mOrientation; ///< Stores the given orientation in degrees.
169 bool mFullScreen; ///< Stores if the view is fullscreen or not.
170 LayerContainer mContentLayers; ///< Layer container.
171 unsigned int mNextLayerIndex; ///< Next index to be used when a layer is added.
172 Layer mBackgroundLayer; ///< The background layer.
173 Animation mRotateAnimation; ///< The animation which rotates the view (and all layers added to it)
174 float mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation.
175 bool mAutoRotateEnabled; ///< Whether the view rotates if the OrientationChanged method is called.
177 Toolkit::View::OrientationAnimationStartedSignalV2 mOrientationAnimationStartedSignalV2;
180 } // namespace Internal
183 // Helpers for public-api forwarding methods
185 inline Toolkit::Internal::View& GetImpl( Toolkit::View& view )
187 DALI_ASSERT_ALWAYS( view );
189 Dali::RefObject& handle = view.GetImplementation();
191 return static_cast<Toolkit::Internal::View&>( handle );
194 inline const Toolkit::Internal::View& GetImpl( const Toolkit::View& view )
196 DALI_ASSERT_ALWAYS( view );
198 const Dali::RefObject& handle = view.GetImplementation();
200 return static_cast<const Toolkit::Internal::View&>( handle );
203 } // namespace Toolkit
207 #endif // __DALI_TOOLKIT_INTERNAL_VIEW_H__