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>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/view/view.h>
40 * View is a control to add layers and a background.
41 * @see Dali::Toolkit::View for more details.
43 class View : public Control
46 typedef std::map<unsigned int,Layer> LayerContainer;
47 typedef std::map<unsigned int,Layer>::iterator LayerIt;
48 typedef std::map<unsigned int,Layer>::const_iterator LayerConstIt;
51 * Orientation declaration used internally to rotate the view.
52 * The angles associated with each enum value could be changed with the SetOrientationFunction method.
56 PORTRAIT, ///< portrait orientation.
57 LANDSCAPE, ///< landscape orientation.
58 PORTRAIT_INVERSE, ///< portrait inverse orientation.
59 LANDSCAPE_INVERSE ///< landscape inverse orientation.
65 * Create an initialized View.
66 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
67 * @return A handle to a newly allocated Dali resource.
69 static Toolkit::View New( bool fullscreen );
72 * @copydoc Dali::Toolkit::View::GetContentLayer()
74 Layer GetContentLayer( unsigned int index ) const;
77 * @copydoc Dali::Toolkit::View::AddContentLayer()
79 unsigned int AddContentLayer( Layer layer );
82 * @copydoc Dali::Toolkit::View::RemoveContentLayer()
84 void RemoveContentLayer( Layer layer );
87 * @copydoc Dali::Toolkit::View::GetBackgroundLayer()
89 Layer GetBackgroundLayer() const;
92 * @copydoc Dali::Toolkit::View::SetBackground()
94 void SetBackground( ImageActor image );
97 * @copydoc Dali::Toolkit::View::SetOrientationFunction()
99 void SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse );
102 * @copydoc Dali::Toolkit::View::OrientationChanged()
105 void OrientationChanged( Dali::Orientation orientation );
108 * @copydoc Dali::Toolkit::View::SetAutoRotate()
111 void SetAutoRotate( bool enabled );
116 * @copydoc Dali::Toolkit::View::AnimationStartedSignalOrientation()
118 Toolkit::View::OrientationAnimationStartedSignalV2& OrientationAnimationStartedSignal();
121 * Connects a callback function with the object's signals.
122 * @param[in] object The object providing the signal.
123 * @param[in] tracker Used to disconnect the signal.
124 * @param[in] signalName The signal to connect to.
125 * @param[in] functor A newly allocated FunctorDelegate.
126 * @return True if the signal was connected.
127 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
129 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
131 private: // From Control
134 * @copydoc Toolkit::Control::OnInitialize()
136 virtual void OnInitialize();
143 * It initializes View members.
144 * It initializes orientations as follows: portrait 0, landscape 90, portrait inverse 180, landscape inverse 270.
145 * @param fullscreen If true, the view's size is going to be set with the Dali::Stage size. Otherwise a size must be provided.
147 View(bool fullscreen);
150 * A reference counted object may only be deleted by calling Unreference()
155 * Return an orientation for the given angle in degrees.
156 * @param degree angle in degrees.
157 * @return An internal orientation.
159 View::Orientation DegreeToViewOrientation( Degree degree );
162 * Find a layer in the layer container. Non const method
164 LayerIt FindLayer( Layer layer );
167 int mOrientation; ///< Stores the given orientation in degrees.
168 bool mFullScreen; ///< Stores if the view is fullscreen or not.
169 LayerContainer mContentLayers; ///< Layer container.
170 unsigned int mNextLayerIndex; ///< Next index to be used when a layer is added.
171 Layer mBackgroundLayer; ///< The background layer.
172 Animation mRotateAnimation; ///< The animation which rotates the view (and all layers added to it)
173 float mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation.
174 bool mAutoRotateEnabled; ///< Whether the view rotates if the OrientationChanged method is called.
176 Toolkit::View::OrientationAnimationStartedSignalV2 mOrientationAnimationStartedSignalV2;
179 } // namespace Internal
182 // Helpers for public-api forwarding methods
184 inline Toolkit::Internal::View& GetImpl( Toolkit::View& view )
186 DALI_ASSERT_ALWAYS( view );
188 Dali::RefObject& handle = view.GetImplementation();
190 return static_cast<Toolkit::Internal::View&>( handle );
193 inline const Toolkit::Internal::View& GetImpl( const Toolkit::View& view )
195 DALI_ASSERT_ALWAYS( view );
197 const Dali::RefObject& handle = view.GetImplementation();
199 return static_cast<const Toolkit::Internal::View&>( handle );
202 } // namespace Toolkit
206 #endif // __DALI_TOOLKIT_INTERNAL_VIEW_H__