2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiScenesSceneManager.h
20 * @brief This is the header file for the %SceneManager class.
22 * This header file contains the declarations of the %SceneManager class.
25 #ifndef _FUI_SCENES_SCENE_MANAGER_H_
26 #define _FUI_SCENES_SCENE_MANAGER_H_
28 #include <FBaseTypes.h>
29 #include <FBaseString.h>
30 #include <FUiAnimAnimationBase.h>
31 #include <FUiScenesTypes.h>
34 namespace Tizen { namespace Ui { namespace Controls
39 namespace Tizen { namespace Base { namespace Collection
42 template<class Type> class IListT;
46 namespace Tizen { namespace Ui { namespace Scenes
50 class ForwardSceneTransition;
51 class BackwardSceneTransition;
54 class ISceneEventListener;
55 class ISceneManagerEventListener;
56 class ISceneAnimationProvider;
57 class ISceneTransitionPolicyProvider;
61 * @brief This class provides methods to manage scenes and scene states.
65 * @final This class is not intended for extension.
67 * The %SceneManager class provides methods to manage scenes and scene states. This class is simplified to a single method call for UI Scene transition that changes the GUI, such as
68 * form to form transition or tab to tab transition. @n
70 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/scene_management.htm">Scene Management</a> and <a href="../org.tizen.native.appprogramming/html/guide/ui/transition_animation.htm">Transition Animations</a>.
72 class _OSP_EXPORT_ SceneManager
73 : public Tizen::Base::Object
77 * Gets the %SceneManager instance.
81 * @return A pointer to the %SceneManager instance if successful, @n
82 * else @c null if it fails
83 * @exception E_SUCCESS The method is successful.
84 * @exception E_OUT_OF_MEMORY The memory is insufficient.
85 * @remarks The specific error code can be accessed using the GetLastResult() method.
87 static SceneManager* GetInstance(void);
90 * Registers a form factory. @n
91 * The IFormFactory::CreateFormN() method is called when a new form is required.
95 * @return An error code
96 * @param[in] formFactory The user-defined form factory instance
97 * @exception E_SUCCESS The method is successful.
99 * @see IFormFactory::CreateFormN()
101 result RegisterFormFactory(const IFormFactory& formFactory);
104 * Registers a panel factory. @n
105 * The IPanelFactory::CreatePanelN() method is called when a new panel is required.
109 * @return An error code
110 * @param[in] panelFactory The user-defined panel factory instance
111 * @exception E_SUCCESS The method is successful.
113 * @see IPanelFactory::CreatePanelN()
115 result RegisterPanelFactory(const IPanelFactory& panelFactory);
119 * A scene is combination of a form and a panel.
123 * @return An error code
124 * @param[in] sceneId The scene ID
125 * @param[in] formId The form ID string
126 * @param[in] panelId The panel ID string
127 * @exception E_SUCCESS The method is successful.
128 * @exception E_INVALID_ARG A specified input parameter is invalid.
129 * @exception E_OBJ_ALREADY_EXIST The specified @c sceneId already exists.
130 * @exception E_OUT_OF_MEMORY The memory is insufficient.
133 result RegisterScene(const SceneId& sceneId, const Tizen::Base::String& formId, const Tizen::Base::String& panelId);
136 * Registers scene(s) with the specified resource ID.
137 * The %RegisterScene() method does not remove a scene that is already registered.
141 * @return An error code
142 * @param[in] resourceId The resource ID of the scene(s)
143 * @exception E_SUCCESS The method is successful.
144 * @exception E_OUT_OF_MEMORY The memory is insufficient.
145 * @exception E_FILE_NOT_FOUND The corresponding resource file is not found.
146 * @exception E_OBJ_ALREADY_EXIST A scene ID already exists.
147 * @exception E_SYSTEM A system error has occurred.
148 * @remarks A duplicated scene (scene ID) will not be registered. Also it throws the E_OBJ_ALREADY_EXIST exception.
149 * @see UnregisterScene()
152 result RegisterScene(const Tizen::Base::String& resourceId);
155 * Unregisters the specified scene.
159 * @return An error code
160 * @param[in] sceneId The scene ID
161 * @exception E_SUCCESS The method is successful.
162 * @exception E_INVALID_ARG The specified input parameter is invalid.
163 * @exception E_OBJ_NOT_FOUND The specified @c sceneId does not exist.
164 * @see RegisterScene()
166 result UnregisterScene(const SceneId& sceneId);
169 * Adds a %SceneManager event listener.
173 * @return An error code
174 * @param[in] sceneManagerEventListener An instance of ISceneManagerEventListener to add
175 * @exception E_SUCCESS The method is successful.
176 * @exception E_OUT_OF_MEMORY The memory is insufficient.
177 * @exception E_OBJ_ALREADY_EXIST The listener with the specified type is already added.
178 * @see RemoveSceneManagerEventListener()
179 * @see ISceneManagerEventListener
180 * @see ISceneManagerEventListener::OnSceneTransitionCompleted()
181 * @see ISceneManagerEventListener::OnSceneTransitionStarted()
183 result AddSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener);
186 * Removes a %SceneManager event listener.
190 * @return An error code
191 * @param[in] sceneManagerEventListener An instance of ISceneManagerEventListener to remove
192 * @exception E_SUCCESS The method is successful.
193 * @exception E_OBJ_NOT_FOUND The specified listener is not found.
194 * @see AddSceneManagerEventListener()
195 * @see ISceneManagerEventListener
197 result RemoveSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener);
200 * Adds a Scene event listener.
204 * @return An error code
205 * @param[in] sceneId The target scene ID
206 * @param[in] sceneEventListener An instance of ISceneEventListener to add
207 * @exception E_SUCCESS The method is successful.
208 * @exception E_OUT_OF_MEMORY The memory is insufficient.
209 * @exception E_INVALID_ARG The specified @c sceneId is invalid.
210 * @exception E_OBJ_ALREADY_EXIST The listener with the specified type is already added.
211 * @see RemoveSceneEventListener()
212 * @see ISceneEventListener
213 * @see ISceneEventListener::OnSceneActivatedN()
214 * @see ISceneEventListener::OnSceneDeactivated()
216 result AddSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener);
219 * Removes a Scene event listener.
223 * @return An error code
224 * @param[in] sceneId The target scene ID
225 * @param[in] sceneEventListener An instance of ISceneEventListener to remove
226 * @exception E_SUCCESS The method is successful.
227 * @exception E_INVALID_ARG The specified @c sceneId is invalid.
228 * @exception E_OBJ_NOT_FOUND The specified @c sceneId is not found.
229 * @see AddSceneEventListener()
230 * @see ISceneEventListener
232 result RemoveSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener);
235 * Sets a Scene animation provider.
239 * @return An error code
240 * @param[in] sceneId The target scene ID
241 * @param[in] pSceneAnimationProvider An instance of ISceneAnimationProvider to set, @n else @c null to clear previous one
242 * @exception E_SUCCESS The method is successful.
243 * @exception E_INVALID_ARG The specified @c sceneId is invalid.
244 * @exception E_OBJ_NOT_FOUND The specified scene is not found.
245 * @see ISceneAnimationProvider
247 result SetSceneAnimationProvider(const SceneId& sceneId, ISceneAnimationProvider* pSceneAnimationProvider);
250 * Sets a Scene transition policy provider.
254 * @return An error code
255 * @param[in] pSceneTransitionPolicyProvider An instance of ISceneTransitionPolicyProvider to set, @n
256 * else @c null to clear previous one
257 * @exception E_SUCCESS The method is successful.
258 * @see ISceneTransitionPolicyProvider
259 * @see ISceneTransitionPolicyProvider::GetNextScene()
262 result SetSceneTransitionPolicyProvider(ISceneTransitionPolicyProvider* pSceneTransitionPolicyProvider);
265 * Sets the default values for the individual animation types.
269 * @return An error code
270 * @param[in] animationType The target animation type
271 * @param[in] duration The duration of the animation in milliseconds @n The maximum duration is one second.
272 * @param[in] interpolatorType The type of interpolator used for the intermediate value calculation of the animation
273 * @exception E_SUCCESS The method is successful.
274 * @exception E_INVALID_ARG A specified input parameter is invalid.
275 * @remarks It throws an E_INVALID_ARG exception if the animationType is SCENE_TRANSITION_ANIMATION_TYPE_NONE
276 * or SCENE_TRANSITION_ANIMATION_TYPE_CUSTOM.
280 result SetFormTransitionAnimationDefaultValues(SceneTransitionAnimationType animationType, long duration,
281 Tizen::Ui::Animations::AnimationInterpolatorType interpolatorType);
284 * Requests forward scene transition with the specified scene transition.
288 * @return An error code
289 * @param[in] sceneTransition The scene transition that describes the destination and options
290 * @param[in] pArgs A pointer to Tizen::Base::Collection::IList that contains the scene transition parameters
291 * @exception E_SUCCESS The method is successful.
292 * @exception E_INVALID_ARG A specified input parameter is invalid.
293 * @exception E_IN_PROGRESS A previous transition is in progress.
294 * @exception E_OUT_OF_MEMORY The memory is insufficient.
295 * @exception E_OBJ_NOT_FOUND The destination scene ID is not found in the registered scenes.
296 * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or
297 * ISceneTransitionPolicyProvider is not set.
298 * @exception E_SYSTEM A system error has occurred. @n
299 * (Internal logic or failed to create control from a factory).
300 * @remarks To use the policy provider operation, SceneTransition's destinationSceneId must be of length 0,
301 * also you must register the user-defined ISceneTransitionPolicyProvider and implement the
302 * ISceneTransitionPolicyProvider::GetNextScene() callback method.
304 result GoForward(const ForwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs = null);
307 * Requests forward scene transition with the specified transition ID.
311 * @return An error code
312 * @param[in] transitionId The transition ID that describes the destination and options
313 * @param[in] pArgs A pointer to Tizen::Base::Collection::IList that contains the scene transition parameters
314 * @exception E_SUCCESS The method is successful.
315 * @exception E_INVALID_ARG A specified input parameter is invalid.
316 * @exception E_IN_PROGRESS A previous transition is in progress.
317 * @exception E_OUT_OF_MEMORY The memory is insufficient.
318 * @exception E_OBJ_NOT_FOUND The destination scene ID is not found in the registered scenes.
319 * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or
320 * ISceneTransitionPolicyProvider is not set.
321 * @exception E_SYSTEM A system error has occurred. @n
322 * (Internal logic or failed to create control from a factory).
323 * @remarks To use the policy provider operation, SceneTransition's destinationSceneId must be of length 0,
324 * also you must register the user-defined ISceneTransitionPolicyProvider and implement the
325 * ISceneTransitionPolicyProvider::GetNextScene() callback method.
327 result GoForward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs = null);
330 * Requests backward scene transition with the specified scene transition.
334 * @return An error code
335 * @param[in] sceneTransition The scene transition that describes the destination and options
336 * @param[in] pArgs A pointer to Tizen::Base::Collection::IList that contains the scene transition parameters
337 * @exception E_SUCCESS The method is successful.
338 * @exception E_INVALID_ARG A specified input parameter is invalid.
339 * @exception E_IN_PROGRESS A previous transition is in progress.
340 * @exception E_OUT_OF_MEMORY The memory is insufficient.
341 * @exception E_OBJ_NOT_FOUND The scene ID of the previous scene in the internal history is not found in
342 * the current registered scenes.
343 * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or
344 * ISceneTransitionPolicyProvider is not set.
345 * @exception E_UNDERFLOW The scene history is empty.
346 * @exception E_SYSTEM A system error has occurred. @n
347 * (Internal logic or failed to create control from a factory).
348 * @remarks An item removed from the internal history except the E_SYSTEM exception case. @n
349 * For non-adjacent backward transition, the current scene and the scenes between the current scene and
350 * the requested scene would be destroyed if SCENE_DESTROY_OPTION_KEEP is not specified as destroyOption. @n
351 * If the destroy option is selected then the sibling panel scenes (sharing same base form) are also destroyed.
353 result GoBackward(const BackwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs = null);
356 * Requests backward scene transition with the specified transition ID.
360 * @return An error code
361 * @param[in] transitionId The transition ID that describes the destination and options
362 * @param[in] pArgs A pointer to Tizen::Base::Collection::IList that contains the scene transition parameters
363 * @exception E_SUCCESS The method is successful.
364 * @exception E_INVALID_ARG A specified input parameter is invalid.
365 * @exception E_IN_PROGRESS A previous transition is in progress.
366 * @exception E_OUT_OF_MEMORY The memory is insufficient.
367 * @exception E_OBJ_NOT_FOUND The scene ID of the previous scene in the internal history is not found in
368 * the current registered scenes.
369 * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or
370 * ISceneTransitionPolicyProvider is not set.
371 * @exception E_UNDERFLOW The scene history is empty.
372 * @exception E_SYSTEM A system error has occurred. @n
373 * (Internal logic or failed to create control from a factory).
374 * @remarks An item removed from the internal history except the E_SYSTEM exception case. @n
375 * For non-adjacent backward transition, the current scene and the scenes between the current scene and
376 * the requested scene would be destroyed if SCENE_DESTROY_OPTION_KEEP is not specified as destroyOption. @n
377 * If the destroy option is selected then the sibling panel scenes (sharing same base form) are also destroyed.
379 result GoBackward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs = null);
382 * Gets a pointer to the current Scene instance.
386 * @return A pointer to the current Scene instance
387 * @see GetCurrentSceneId()
389 Scene* GetCurrentScene(void) const;
392 * Gets the current scene ID string.
396 * @return The scene ID
397 * @see GetCurrentScene()
399 SceneId GetCurrentSceneId(void) const;
402 * Checks whether the Scene instance with the specified sceneId has been destroyed or not.
406 * @return @c true if the scene instance has not been destroyed, @n
408 * @param[in] sceneId The scene ID
409 * @remarks This method is useful to check state of the scene, because the scene lifetime is determined
410 * by scene transition option and user can destroy the scene in real time.
412 bool IsSceneAlive(const SceneId& sceneId) const;
415 * Destroys the specified scene.
419 * @return An error code
420 * @param[in] sceneId The scene ID
421 * @exception E_SUCCESS The method is successful.
422 * @exception E_INVALID_ARG The current scene cannot be destroyed.
423 * @exception E_OBJ_NOT_FOUND The specified @c sceneId does not exist.
424 * @exception E_SYSTEM A system error has occurred.
426 result DestroyScene(const SceneId& sceneId);
429 * Brings the current scene to the topmost to get back the control of scene management.
433 * @return An error code
434 * @exception E_SUCCESS The method is successful.
435 * @exception E_OPERATION_FAILED The current scene is invalid.
436 * @exception E_SYSTEM A system error has occurred.
437 * @remarks If a user sets a form as a current form on a frame by calling Tizen::Ui::Controls::Frame::SetCurrentForm(),
438 * they will no longer be under the control of %SceneManager. In this case,
439 * they can get back the control of scene management easily by calling this method.
440 * @see Tizen::Ui::Controls::Frame::SetCurrentForm()
442 result BringCurrentSceneToTop(void);
445 * Clears the scene history.
449 * @return An error code
450 * @exception E_SUCCESS The method is successful.
451 * @see AddToSceneHistory()
453 result ClearSceneHistory(void);
456 * Adds the scene to the scene history.
460 * @return An error code
461 * @param[in] sceneId The scene ID
462 * @exception E_SUCCESS The method is successful.
463 * @exception E_INVALID_ARG The specified input parameter is invalid.
464 * @exception E_OBJ_NOT_FOUND The specified @c sceneId is not found in the registered scenes.
465 * @exception E_OUT_OF_MEMORY The memory is insufficient.
466 * @see ClearSceneHistory()
468 result AddToSceneHistory(const SceneId& sceneId);
471 * Gets the scene history list.
475 * @return A pointer to the list that contains the scene history
476 * @exception E_SUCCESS The method is successful.
477 * @exception E_OUT_OF_MEMORY The memory is insufficient.
478 * @remarks The specific error code can be accessed using the GetLastResult() method.
480 Tizen::Base::Collection::IListT<SceneId>* GetSceneHistoryN(void) const;
484 * This default constructor is intentionally declared as private to implement the Singleton semantic.
491 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
495 SceneManager(const SceneManager& rhs);
498 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
502 SceneManager& operator =(const SceneManager& rhs);
505 * This destructor is intentionally declared as private to implement the Singleton semantic.
509 virtual ~SceneManager(void);
512 * Initializes the instance of the this class.
516 * @return An error code.
517 * @exception E_SUCCESS The method is successful.
518 * @exception E_SYSTEM A system error has occurred.
519 * @exception E_OUT_OF_MEMORY The memory is insufficient.
522 result Construct(void);
524 static void InitSingleton(void);
525 static void DestroySingleton(void);
528 friend class _SceneManagerImpl;
529 class _SceneManagerImpl* __pSceneManagerImpl;
530 static SceneManager* __pSceneManagerInstance;
533 } } } // Tizen::Ui::Scenes
535 #endif //_FUI_SCENES_SCENE_MANAGER_H_