From 02d7786f13e79e8864f5a16880d5f1f645848e1f Mon Sep 17 00:00:00 2001 From: Kingsley Stephens Date: Tue, 16 Dec 2014 16:22:53 +0000 Subject: [PATCH] Add SceneCreated signal to stage. Change-Id: I61ae741964c2f2087a7463152f4071d2a0ce1ade --- automated-tests/src/dali/utc-Dali-Stage.cpp | 35 +++++++++++++++++++++++++++++ dali/integration-api/core.cpp | 5 +++++ dali/integration-api/core.h | 5 +++++ dali/internal/common/core-impl.cpp | 5 +++++ dali/internal/common/core-impl.h | 5 +++++ dali/internal/event/common/stage-impl.cpp | 11 +++++++++ dali/internal/event/common/stage-impl.h | 12 ++++++++++ dali/public-api/common/stage.cpp | 6 ++++- dali/public-api/common/stage.h | 15 ++++++++++++- 9 files changed, 97 insertions(+), 2 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp index 0f850e3..95e8570 100644 --- a/automated-tests/src/dali/utc-Dali-Stage.cpp +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -155,6 +155,25 @@ struct ContextStatusFunctor bool& mCalledFlag; }; +struct SceneCreatedStatusFunctor +{ + SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag ) + { + mCalledFlag = false; + } + + void operator()() + { + mCalledFlag = true; + } + void Reset() + { + mCalledFlag = false; + } + + bool& mCalledFlag; +}; + } // unnamed namespace @@ -638,3 +657,19 @@ int UtcDaliStageContextLostRegainedSignals(void) END_TEST; } + +int UtcDaliStageSceneCreatedSignal(void) +{ + TestApplication app; + Stage stage = Stage::GetCurrent(); + + bool signalCalled = false; + SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled ); + stage.SceneCreatedSignal().Connect(&app, sceneCreatedFunctor ); + + Integration::Core& core = app.GetCore(); + core.SceneCreated(); + DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali/integration-api/core.cpp b/dali/integration-api/core.cpp index 45e2be5..9824d8e 100644 --- a/dali/integration-api/core.cpp +++ b/dali/integration-api/core.cpp @@ -92,6 +92,11 @@ void Core::Resume() mImpl->Resume(); } +void Core::SceneCreated() +{ + mImpl->SceneCreated(); +} + void Core::QueueEvent(const Event& event) { mImpl->QueueEvent(event); diff --git a/dali/integration-api/core.h b/dali/integration-api/core.h index 9645475..91a7880 100644 --- a/dali/integration-api/core.h +++ b/dali/integration-api/core.h @@ -304,6 +304,11 @@ public: void Resume(); /** + * Notify Core that the scene has been created. + */ + void SceneCreated(); + + /** * Queue an event with Core. * Pre-processing of events may be beneficial e.g. a series of motion events could be throttled, so that only the last event is queued. * Multi-threading note: this method should be called from the main thread. diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index 97787c7..54de232 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -298,6 +298,11 @@ void Core::Resume() ProcessEvents(); } +void Core::SceneCreated() +{ + mStage->EmitSceneCreatedSignal(); +} + void Core::QueueEvent( const Integration::Event& event ) { mEventProcessor->QueueEvent( event ); diff --git a/dali/internal/common/core-impl.h b/dali/internal/common/core-impl.h index b456e82..6e88bc4 100644 --- a/dali/internal/common/core-impl.h +++ b/dali/internal/common/core-impl.h @@ -148,6 +148,11 @@ public: void Resume(); /** + * @copydoc Dali::Integration::Core::SceneCreated() + */ + void SceneCreated(); + + /** * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&) */ void QueueEvent( const Integration::Event& event ); diff --git a/dali/internal/event/common/stage-impl.cpp b/dali/internal/event/common/stage-impl.cpp index d26f950..0d463e5 100644 --- a/dali/internal/event/common/stage-impl.cpp +++ b/dali/internal/event/common/stage-impl.cpp @@ -506,6 +506,12 @@ void Stage::EmitTouchedSignal( const TouchEvent& touch ) mTouchedSignalV2.Emit( touch ); } + +void Stage::EmitSceneCreatedSignal() +{ + mSceneCreatedSignal.Emit(); +} + Dali::Stage::KeyEventSignalV2& Stage::KeyEventSignal() { return mKeyEventSignalV2; @@ -531,6 +537,11 @@ Dali::Stage::ContextStatusSignal& Stage::ContextRegainedSignal() return mContextRegainedSignal; } +Dali::Stage::SceneCreatedSignalV2& Stage::SceneCreatedSignal() +{ + return mSceneCreatedSignal; +} + void Stage::NotifyContextLost() { mContextLostSignal.Emit(); diff --git a/dali/internal/event/common/stage-impl.h b/dali/internal/event/common/stage-impl.h index a0e9d6a..9eef682 100644 --- a/dali/internal/event/common/stage-impl.h +++ b/dali/internal/event/common/stage-impl.h @@ -358,6 +358,11 @@ public: void EmitTouchedSignal( const TouchEvent& touch ); /** + * Emits the scene created. + */ + void EmitSceneCreatedSignal(); + + /** * @copydoc Dali::Stage::KeyEventSignal() */ Dali::Stage::KeyEventSignalV2& KeyEventSignal(); @@ -382,6 +387,11 @@ public: */ Dali::Stage::ContextStatusSignal& ContextRegainedSignal(); + /** + * @copydoc Dali::Stage::SceneCreatedSignal() + */ + Dali::Stage::SceneCreatedSignalV2& SceneCreatedSignal(); + private: // Implementation of ContextNotificationInterface: /** @@ -472,6 +482,8 @@ private: Dali::Stage::ContextStatusSignal mContextLostSignal; Dali::Stage::ContextStatusSignal mContextRegainedSignal; + + Dali::Stage::SceneCreatedSignalV2 mSceneCreatedSignal; }; } // namespace Internal diff --git a/dali/public-api/common/stage.cpp b/dali/public-api/common/stage.cpp index f70b46d..e0fdb94 100644 --- a/dali/public-api/common/stage.cpp +++ b/dali/public-api/common/stage.cpp @@ -185,7 +185,6 @@ Stage::TouchedSignalV2& Stage::TouchedSignal() return GetImplementation(*this).TouchedSignal(); } - Stage::ContextStatusSignal& Stage::ContextLostSignal() { return GetImplementation(*this).ContextLostSignal(); @@ -196,4 +195,9 @@ Stage::ContextStatusSignal& Stage::ContextRegainedSignal() return GetImplementation(*this).ContextRegainedSignal(); } +Stage::SceneCreatedSignalV2& Stage::SceneCreatedSignal() +{ + return GetImplementation(*this).SceneCreatedSignal(); +} + } // namespace Dali diff --git a/dali/public-api/common/stage.h b/dali/public-api/common/stage.h index 9ef998e..7a984df 100644 --- a/dali/public-api/common/stage.h +++ b/dali/public-api/common/stage.h @@ -54,7 +54,8 @@ public: typedef SignalV2< void (const KeyEvent&)> KeyEventSignalV2; ///< Key event signal type typedef SignalV2< void () > EventProcessingFinishedSignalV2; ///< Event Processing finished signal type typedef SignalV2< void (const TouchEvent&)> TouchedSignalV2; ///< Touched signal type - typedef SignalV2< void () > ContextStatusSignal; // Context status signal type + typedef SignalV2< void () > ContextStatusSignal; ///< Context status signal type + typedef SignalV2< void () > SceneCreatedSignalV2; ///< Scene created signal type static const Vector4 DEFAULT_BACKGROUND_COLOR; ///< Default black background. static const Vector4 DEBUG_BACKGROUND_COLOR; ///< Green background, useful when debugging. @@ -301,6 +302,18 @@ public: */ ContextStatusSignal& ContextRegainedSignal(); + /** + * @brief This signal is emitted after the initial scene is created. It will be triggered after the + * application init signal. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName(); + * @endcode + * @return The signal to connect to. + */ + SceneCreatedSignalV2& SceneCreatedSignal(); + public: // Not intended for application developers /** -- 2.7.4