#define __DALI_INTERNAL_STAGE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// INTERNAL INCLUDES
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/common/stage.h>
+#include <dali/devel-api/common/stage-devel.h>
#include <dali/public-api/object/base-object.h>
#include <dali/integration-api/context-notifier.h>
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/event/actors/layer-impl.h>
+#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/object-registry-impl.h>
#include <dali/internal/event/common/stage-def.h>
#include <dali/internal/event/render-tasks/render-task-defaults.h>
#include <dali/public-api/math/vector4.h>
#include <dali/public-api/render-tasks/render-task.h>
-#ifdef DYNAMICS_SUPPORT
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
-#include <dali/internal/event/dynamics/dynamics-notifier.h>
-#endif
-
namespace Dali
{
namespace Integration
{
class SystemOverlay;
-class DynamicsFactory;
+class RenderController;
}
namespace Internal
/**
* Implementation of Stage
*/
-class Stage : public BaseObject, public RenderTaskDefaults, public Integration::ContextNotifierInterface
+class Stage : public BaseObject, public RenderTaskDefaults, public Integration::ContextNotifierInterface, public EventThreadServices
{
public:
* @param[in] propertyNotificationManager
* @param[in] updateManager
* @param[in] notificationManager
+ * @param[in] renderController
*/
static StagePtr New( AnimationPlaylist& playlist,
PropertyNotificationManager& propertyNotificationManager,
SceneGraph::UpdateManager& updateManager,
- NotificationManager& notificationManager );
+ NotificationManager& notificationManager,
+ Integration::RenderController& renderController );
/**
* Initialize the stage.
/**
* @copydoc Dali::Stage::GetCurrent()
+ * @note this version is for internal usage so it does not assert
*/
static StagePtr GetCurrent();
Layer& GetRootActor();
/**
- * Retrieve the UpdateManager associated with this Stage
- * @return The UpdateManager.
- */
- SceneGraph::UpdateManager& GetUpdateManager();
-
- /**
- * Helper for actors, to retrieve the current Event buffer index.
- * @return The buffer index.
- */
- BufferIndex GetEventBufferIndex() const
- {
- // inlined as its called often from event thread
- return mUpdateManager.GetEventBufferIndex();
- }
-
- /**
- * Retrieve the interface for accessing update-thread data.
- * @return The EventToUpdate interface.
- */
- EventToUpdate& GetUpdateInterface();
-
- /**
* Returns the animation playlist.
* @return reference to the animation playlist.
*/
void Remove( Actor& actor );
/**
- * Sets the size of the stage and indirectly, the root actor.
- * @param [in] width The new width.
- * @param [in] height The new height.
+ * Used to calculate the size of the stage and indirectly, the root actor.
+ * @param [in] width The new surface width.
+ * @param [in] height The new surface height.
*/
- void SetSize( float width, float height );
+ void SurfaceResized( float width, float height );
+
+ /**
+ * Sets the top margin size.
+ * Available stage size is reduced by this size.
+ * The stage is located below the size at the top of the display
+ * initial size is zero before it is assigned
+ * @param[in] margin margin size
+ */
+ void SetTopMargin( unsigned int margin );
/**
* Returns the size of the Stage in pixels as a Vector.
void CreateDefaultCameraActor();
/**
+ * Set position of default camera for current stage size
+ */
+ void SetDefaultCameraPosition();
+
+ /**
* From RenderTaskDefaults; retrieve the default root actor.
* @return The default root actor.
*/
*/
void SetDpi( Vector2 dpi );
-#ifdef DYNAMICS_SUPPORT
-
- /**
- * Return the Dynamics Simulation Notifier object
- * @return The Dynamics Simulation Notifier object
- */
- DynamicsNotifier& GetDynamicsNotifier();
-
- /**
- * @copydoc Dali::Stage::InitializeDynamics
- */
- DynamicsWorldPtr InitializeDynamics(DynamicsWorldConfigPtr config);
-
- /**
- * @copydoc Dali::Stage::GetDynamicsWorld
- */
- DynamicsWorldPtr GetDynamicsWorld();
-
- /**
- * @copydoc Dali::Stage::TerminateDynamics
- */
- void TerminateDynamics();
-
-#endif // DYNAMICS_SUPPORT
-
NotificationManager& GetNotificationManager()
{
return mNotificationManager;
}
-
/**
* @copydoc Dali::Stage::KeepRendering()
*/
void EmitKeyEventSignal(const KeyEvent& event);
/**
+ * Used by the KeyEventProcessor to emit KeyEventGenerated signals.
+ * @param[in] event The key event.
+ * @return The return is true if KeyEvent is consumed, otherwise false.
+ */
+ bool EmitKeyEventGeneratedSignal(const KeyEvent& event);
+
+ /**
* Emits the event processing finished signal.
*
* @see Dali::Stage::SignalEventProcessingFinished()
/**
* Emits the touched signal.
+ * @param[in] touchEvent The touch event details (Old API).
* @param[in] touch The touch event details.
*/
- void EmitTouchedSignal( const TouchEvent& touch );
+ void EmitTouchedSignal( const TouchEvent& touchEvent, const Dali::TouchData& touch );
+
+ /**
+ * Used by the EventProcessor to emit wheel event signals.
+ * @param[in] event The wheel event.
+ */
+ void EmitWheelEventSignal( const WheelEvent& event );
/**
* Emits the scene created.
/**
* @copydoc Dali::Stage::KeyEventSignal()
*/
- Dali::Stage::KeyEventSignalV2& KeyEventSignal();
+ Dali::Stage::KeyEventSignalType& KeyEventSignal();
/**
* @copydoc Dali::Stage::SignalEventProcessingFinished()
*/
- Dali::Stage::EventProcessingFinishedSignalV2& EventProcessingFinishedSignal();
+ Dali::Stage::EventProcessingFinishedSignalType& EventProcessingFinishedSignal();
/**
* @copydoc Dali::Stage::TouchedSignal()
*/
- Dali::Stage::TouchedSignalV2& TouchedSignal();
+ Dali::Stage::TouchedSignalType& TouchedSignal();
+
+ /**
+ * @copydoc Dali::Stage::TouchSignal()
+ */
+ Dali::Stage::TouchSignalType& TouchSignal();
+
+ /**
+ * @copydoc Dali::Stage::WheelEventSignal()
+ */
+ Dali::Stage::WheelEventSignalType& WheelEventSignal();
/**
* @copydoc Dali::Stage::ContextLostSignal()
/**
* @copydoc Dali::Stage::SceneCreatedSignal()
*/
- Dali::Stage::SceneCreatedSignalV2& SceneCreatedSignal();
+ Dali::Stage::SceneCreatedSignalType& SceneCreatedSignal();
+
+ /**
+ * @copydoc Dali::DevelStage::KeyEventGeneratedSignal()
+ */
+ Dali::DevelStage::KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
private: // Implementation of ContextNotificationInterface:
*/
virtual void NotifyContextRegained();
+public: // Implementation of EventThreadServices
+
+ /**
+ * @copydoc EventThreadServices::RegisterObject
+ */
+ virtual void RegisterObject( BaseObject* object);
+
+ /**
+ * @copydoc EventThreadServices::UnregisterObject
+ */
+ virtual void UnregisterObject( BaseObject* object);
+
+ /**
+ * @copydoc EventThreadServices::GetUpdateManager
+ */
+ virtual SceneGraph::UpdateManager& GetUpdateManager();
+
+ /**
+ * @copydoc EventThreadServices::GetRenderController
+ */
+ virtual Integration::RenderController& GetRenderController();
+
+ /**
+ * @copydoc EventThreadServices::ReserveMessageSlot
+ */
+ virtual unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene );
+
+ /**
+ * @copydoc EventThreadServices::GetEventBufferIndex
+ */
+ virtual BufferIndex GetEventBufferIndex() const;
+
+ /**
+ * @copydoc EventThreadServices::ForceNextUpdate
+ */
+ virtual void ForceNextUpdate();
+
+ /**
+ * @copydoc EventThreadServices::IsNextUpdateForced
+ */
+ virtual bool IsNextUpdateForced();
+
+ /**
+ * Request that the depth tree is rebuilt
+ */
+ void RequestRebuildDepthTree();
+
+ /**
+ * Rebuilds the depth tree at the end of the event frame if
+ * it was requested this frame.
+ */
+ void RebuildDepthTree();
+
private:
/**
Stage( AnimationPlaylist& playlist,
PropertyNotificationManager& propertyNotificationManager,
SceneGraph::UpdateManager& updateManager,
- NotificationManager& notificationManager );
+ NotificationManager& notificationManager,
+ Integration::RenderController& renderController );
/**
* A reference counted object may only be deleted by calling Unreference()
NotificationManager& mNotificationManager;
- // The Actual size of the stage.
+ Integration::RenderController& mRenderController;
+
+ // The stage-size may be less than surface-size (reduced by top-margin)
Vector2 mSize;
+ Vector2 mSurfaceSize;
// Cached for public GetBackgroundColor()
Vector4 mBackgroundColor;
ViewMode mViewMode;
float mStereoBase;
+ unsigned int mTopMargin;
Vector2 mDpi;
// The object registry
ObjectRegistryPtr mObjectRegistry;
-#ifdef DYNAMICS_SUPPORT
-
- DynamicsNotifier mDynamicsNotifier;
-
- // The Dynamics simulation world object
- Integration::DynamicsFactory* mDynamicsFactory; // Not owned pointer to DynamicsFactory (PlatformAbstraction will clean up)
- DynamicsWorldPtr mDynamicsWorld;
-
-#endif // DYNAMICS_SUPPORT
-
// The list of render-tasks
IntrusivePtr<RenderTaskList> mRenderTaskList;
Integration::SystemOverlay* mSystemOverlay; ///< SystemOverlay stage access
+ bool mDepthTreeDirty; ///< True if the depth tree needs recalculating
+ bool mForceNextUpdate; ///< True if the next rendering is really required.
+
// The key event signal
- Dali::Stage::KeyEventSignalV2 mKeyEventSignalV2;
+ Dali::Stage::KeyEventSignalType mKeyEventSignal;
+ Dali::DevelStage::KeyEventGeneratedSignalType mKeyEventGeneratedSignal;
// The event processing finished signal
- Dali::Stage::EventProcessingFinishedSignalV2 mEventProcessingFinishedSignalV2;
+ Dali::Stage::EventProcessingFinishedSignalType mEventProcessingFinishedSignal;
+
+ // The touched signals
+ Dali::Stage::TouchedSignalType mTouchedSignal;
+ Dali::Stage::TouchSignalType mTouchSignal;
- // The touched signal
- Dali::Stage::TouchedSignalV2 mTouchedSignalV2;
+ // The wheel event signal
+ Dali::Stage::WheelEventSignalType mWheelEventSignal;
Dali::Stage::ContextStatusSignal mContextLostSignal;
Dali::Stage::ContextStatusSignal mContextRegainedSignal;
- Dali::Stage::SceneCreatedSignalV2 mSceneCreatedSignal;
+ Dali::Stage::SceneCreatedSignalType mSceneCreatedSignal;
};
} // namespace Internal