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 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
11 // http://floralicense.org/license/
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.
21 #include <dali/dali.h>
24 #include <dali-toolkit/public-api/controls/control-impl.h>
25 #include <dali-toolkit/public-api/controls/view/view.h>
39 * View is a control to add layers and a background.
40 * @see Dali::Toolkit::View for more details.
42 class View : public Control
45 typedef std::map<unsigned int,Layer> LayerContainer;
46 typedef std::map<unsigned int,Layer>::iterator LayerIt;
47 typedef std::map<unsigned int,Layer>::const_iterator LayerConstIt;
50 * Orientation declaration used internally to rotate the view.
51 * The angles associated with each enum value could be changed with the SetOrientationFunction method.
55 PORTRAIT, ///< portrait orientation.
56 LANDSCAPE, ///< landscape orientation.
57 PORTRAIT_INVERSE, ///< portrait inverse orientation.
58 LANDSCAPE_INVERSE ///< landscape inverse orientation.
64 * Create an initialized View.
65 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
66 * @return A handle to a newly allocated Dali resource.
68 static Toolkit::View New( bool fullscreen );
71 * @copydoc Dali::Toolkit::View::GetContentLayer()
73 Layer GetContentLayer( unsigned int index ) const;
76 * @copydoc Dali::Toolkit::View::AddContentLayer()
78 unsigned int AddContentLayer( Layer layer );
81 * @copydoc Dali::Toolkit::View::RemoveContentLayer()
83 void RemoveContentLayer( Layer layer );
86 * @copydoc Dali::Toolkit::View::GetBackgroundLayer()
88 Layer GetBackgroundLayer() const;
91 * @copydoc Dali::Toolkit::View::SetBackground()
93 void SetBackground( ImageActor image );
96 * @copydoc Dali::Toolkit::View::SetOrientationFunction()
98 void SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse );
101 * @copydoc Dali::Toolkit::View::OrientationChanged()
104 void OrientationChanged( Dali::Orientation orientation );
107 * @copydoc Dali::Toolkit::View::SetAutoRotate()
110 void SetAutoRotate( bool enabled );
115 * @copydoc Dali::Toolkit::View::AnimationStartedSignalOrientation()
117 Toolkit::View::OrientationAnimationStartedSignalV2& OrientationAnimationStartedSignal();
120 * Connects a callback function with the object's signals.
121 * @param[in] object The object providing the signal.
122 * @param[in] tracker Used to disconnect the signal.
123 * @param[in] signalName The signal to connect to.
124 * @param[in] functor A newly allocated FunctorDelegate.
125 * @return True if the signal was connected.
126 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
128 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
130 private: // From Control
133 * @copydoc Toolkit::Control::OnInitialize()
135 virtual void OnInitialize();
142 * It initializes View members.
143 * It initializes orientations as follows: portrait 0, landscape 90, portrait inverse 180, landscape inverse 270.
144 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
146 View(bool fullscreen);
149 * A reference counted object may only be deleted by calling Unreference()
154 * Return an orientation for the given angle in degrees.
155 * @param degree angle in degrees.
156 * @return An internal orientation.
158 View::Orientation DegreeToViewOrientation( Degree degree );
161 * Find a layer in the layer container. Non const method
163 LayerIt FindLayer( Layer layer );
166 int mOrientation; ///< Stores the given orientation in degrees.
167 bool mFullScreen; ///< Stores if the view is fullscreen or not.
168 LayerContainer mContentLayers; ///< Layer container.
169 unsigned int mNextLayerIndex; ///< Next index to be used when a layer is added.
170 Layer mBackgroundLayer; ///< The background layer.
171 Animation mRotateAnimation; ///< The animation which rotates the view (and all layers added to it)
172 float mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation.
173 bool mAutoRotateEnabled; ///< Whether the view rotates if the OrientationChanged method is called.
175 Toolkit::View::OrientationAnimationStartedSignalV2 mOrientationAnimationStartedSignalV2;
178 } // namespace Internal
181 // Helpers for public-api forwarding methods
183 inline Toolkit::Internal::View& GetImpl( Toolkit::View& view )
185 DALI_ASSERT_ALWAYS( view );
187 Dali::RefObject& handle = view.GetImplementation();
189 return static_cast<Toolkit::Internal::View&>( handle );
192 inline const Toolkit::Internal::View& GetImpl( const Toolkit::View& view )
194 DALI_ASSERT_ALWAYS( view );
196 const Dali::RefObject& handle = view.GetImplementation();
198 return static_cast<const Toolkit::Internal::View&>( handle );
201 } // namespace Toolkit
205 #endif // __DALI_TOOLKIT_INTERNAL_VIEW_H__