From 5758c4f1e9f6c1d3bcb8ab02489105ef83d0abeb Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Wed, 18 May 2016 16:14:10 +0900 Subject: [PATCH] [widget-viewer-dali] Add widget event notification Change-Id: I9ed79f56789aac78244a84e1c49ea93303beed0e --- internal/widget_view/widget_view_impl.cpp | 95 ++++++++++++++++++++-- internal/widget_view/widget_view_impl.h | 49 +++++++++-- .../widget_view_manager_impl.cpp | 28 ++++++- .../widget_view_manager/widget_view_manager_impl.h | 4 +- public_api/widget_view/widget_view.cpp | 33 +++++++- public_api/widget_view/widget_view.h | 64 +++++++++++++-- .../widget_view_manager/widget_view_manager.cpp | 4 +- .../widget_view_manager/widget_view_manager.h | 4 +- 8 files changed, 253 insertions(+), 28 deletions(-) diff --git a/internal/widget_view/widget_view_impl.cpp b/internal/widget_view/widget_view_impl.cpp index 8e78c69..7c7f930 100644 --- a/internal/widget_view/widget_view_impl.cpp +++ b/internal/widget_view/widget_view_impl.cpp @@ -47,10 +47,10 @@ Integration::Log::Filter* gWidgetViewLogging = Integration::Log::Filter::New( D } // unnamed namespace -Dali::WidgetView::WidgetView WidgetView::New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ) +Dali::WidgetView::WidgetView WidgetView::New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ) { // Create the implementation, temporarily owned on stack - IntrusivePtr< WidgetView > internalWidgetView = new WidgetView( widgetId, contentInfo, width, height, period ); + IntrusivePtr< WidgetView > internalWidgetView = new WidgetView( widgetId, contentInfo, width, height, updatePeriod ); // Pass ownership to CustomActor Dali::WidgetView::WidgetView widgetView( *internalWidgetView ); @@ -72,14 +72,14 @@ WidgetView::WidgetView() mWidth( 0 ), mHeight( 0 ), mPid( 0 ), - mPeriod( 0.0 ), + mUpdatePeriod( 0.0 ), mPreviewEnabled( true ), mStateTextEnabled( true ), mPermanentDelete( true ) { } -WidgetView::WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ) +WidgetView::WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ) : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ), mWidgetId( widgetId ), mInstanceId(), @@ -89,7 +89,7 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI mWidth( width ), mHeight( height ), mPid( 0 ), - mPeriod( period ), + mUpdatePeriod( updatePeriod ), mPreviewEnabled( true ), mStateTextEnabled( true ), mPermanentDelete( true ) @@ -185,9 +185,9 @@ const std::string& WidgetView::GetTitle() return mTitle; } -double WidgetView::GetPeriod() const +double WidgetView::GetUpdatePeriod() const { - return mPeriod; + return mUpdatePeriod; } void WidgetView::Show() @@ -306,15 +306,66 @@ void WidgetView::AddObjectView( Pepper::ObjectView objectView ) // Emit signal Dali::WidgetView::WidgetView handle( GetOwner() ); mWidgetAddedSignal.Emit( handle ); + + DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::AddObjectView: ObjectView is added.\n" ); } void WidgetView::RemoveObjectView() { + // Enable preview and text + if( mPreviewEnabled ) + { + mPreviewImage.SetVisible( true ); + } + + if( mStateTextEnabled ) + { + mStateText.SetVisible( true ); + } + // Emit signal Dali::WidgetView::WidgetView handle( GetOwner() ); mWidgetDeletedSignal.Emit( handle ); mObjectView.Reset(); + + DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::RemoveObjectView: ObjectView is removed.\n" ); +} + +void WidgetView::SendWidgetEvent( int event ) +{ + Dali::WidgetView::WidgetView handle( GetOwner() ); + + DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::SendWidgetEvent: event = %d widget = %s\n", event, mWidgetId.c_str() ); + + // Emit signal + switch( event ) + { + case WIDGET_INSTANCE_EVENT_UPDATE: + { + mWidgetContentUpdatedSignal.Emit( handle ); + break; + } + case WIDGET_INSTANCE_EVENT_PERIOD_CHANGED: + { + mWidgetUpdatePeriodChangedSignal.Emit( handle ); + break; + } + case WIDGET_INSTANCE_EVENT_SIZE_CHANGED: + { + mWidgetResizedSignal.Emit( handle ); + break; + } + case WIDGET_INSTANCE_EVENT_EXTRA_UPDATED: + { + mWidgetExtraInfoUpdatedSignal.Emit( handle ); + break; + } + default: + { + break; + } + } } Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetAddedSignal() @@ -327,6 +378,31 @@ Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetDeletedSig return mWidgetDeletedSignal; } +Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetAbortedSignal() +{ + return mWidgetAbortedSignal; +} + +Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetResized() +{ + return mWidgetResizedSignal; +} + +Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetContentUpdated() +{ + return mWidgetContentUpdatedSignal; +} + +Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetExtraInfoUpdated() +{ + return mWidgetExtraInfoUpdatedSignal; +} + +Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetView::WidgetUpdatePeriodChanged() +{ + return mWidgetUpdatePeriodChangedSignal; +} + void WidgetView::OnInitialize() { char* instanceId = NULL; @@ -409,6 +485,11 @@ void WidgetView::OnInitialize() if( mPid < 0) { DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() ); + + // Emit signal + Dali::WidgetView::WidgetView handle( GetOwner() ); + mWidgetAbortedSignal.Emit( handle ); + return; } diff --git a/internal/widget_view/widget_view_impl.h b/internal/widget_view/widget_view_impl.h index e14960d..4a53d77 100644 --- a/internal/widget_view/widget_view_impl.h +++ b/internal/widget_view/widget_view_impl.h @@ -44,7 +44,7 @@ public: /** * @copydoc Dali::WidgetView::WidgetView::New */ - static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ); + static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ); /** * @copydoc Dali::WidgetView::WidgetView::GetWidgetId @@ -67,9 +67,9 @@ public: const std::string& GetTitle(); /** - * @copydoc Dali::WidgetView::WidgetView::GetPeriod + * @copydoc Dali::WidgetView::WidgetView::GetUpdatePeriod */ - double GetPeriod() const; + double GetUpdatePeriod() const; /** * @copydoc Dali::WidgetView::WidgetView::Show @@ -124,11 +124,45 @@ public: void AddObjectView( Pepper::ObjectView objectView ); void RemoveObjectView(); + void SendWidgetEvent( int event ); + public: //Signals + /** + * @copydoc Dali::WidgetView::WidgetView::WidgetAddedSignal + */ Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal(); + + /** + * @copydoc Dali::WidgetView::WidgetView::WidgetDeletedSignal + */ Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal(); + /** + * @copydoc Dali::WidgetView::WidgetView::WidgetAbortedSignal + */ + Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAbortedSignal(); + + /** + * @copydoc Dali::WidgetView::WidgetView::WidgetResized + */ + Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetResized(); + + /** + * @copydoc Dali::WidgetView::WidgetView::WidgetContentUpdated + */ + Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetContentUpdated(); + + /** + * @copydoc Dali::WidgetView::WidgetView::WidgetExtraInfoUpdated + */ + Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetExtraInfoUpdated(); + + /** + * @copydoc Dali::WidgetView::WidgetView::WidgetUpdatePeriodChanged + */ + Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetUpdatePeriodChanged(); + protected: /** @@ -139,7 +173,7 @@ protected: /** * Construct a new WidgetView. */ - WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ); + WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ); /** * A reference counted object may only be deleted by calling Unreference() @@ -177,7 +211,7 @@ private: int mWidth; int mHeight; int mPid; - double mPeriod; + double mUpdatePeriod; bool mPreviewEnabled; bool mStateTextEnabled; @@ -186,6 +220,11 @@ private: // Signals Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAddedSignal; Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetDeletedSignal; + Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAbortedSignal; + Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetResizedSignal; + Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetContentUpdatedSignal; + Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetExtraInfoUpdatedSignal; + Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetUpdatePeriodChangedSignal; }; } // namespace Internal diff --git a/internal/widget_view_manager/widget_view_manager_impl.cpp b/internal/widget_view_manager/widget_view_manager_impl.cpp index 4896691..4f9ef78 100644 --- a/internal/widget_view_manager/widget_view_manager_impl.cpp +++ b/internal/widget_view_manager/widget_view_manager_impl.cpp @@ -85,6 +85,7 @@ WidgetViewManager::WidgetViewManager() WidgetViewManager::~WidgetViewManager() { + widget_instance_unlisten_event( WidgetViewManager::WidgetEventCallback ); widget_instance_fini(); } @@ -104,6 +105,7 @@ int WidgetViewManager::Initialize( Application application, const std::string& n // init widget service widget_instance_init( name.c_str() ); + widget_instance_listen_event( WidgetViewManager::WidgetEventCallback, this ); DALI_LOG_INFO( gWidgetViewManagerLogging, Debug::Verbose, "WidgetViewManager::Initialize: success.\n" ); @@ -112,10 +114,10 @@ int WidgetViewManager::Initialize( Application application, const std::string& n return WIDGET_ERROR_NONE; } -Dali::WidgetView::WidgetView WidgetViewManager::AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ) +Dali::WidgetView::WidgetView WidgetViewManager::AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ) { // Add a new widget view - Dali::WidgetView::WidgetView widgetView = Dali::WidgetView::WidgetView::New( widgetId, contentInfo, width, height, period ); + Dali::WidgetView::WidgetView widgetView = Dali::WidgetView::WidgetView::New( widgetId, contentInfo, width, height, updatePeriod ); std::string instanceId = widgetView.GetInstanceId(); @@ -169,6 +171,28 @@ void WidgetViewManager::OnObjectViewDeleted( Pepper::Compositor compositor, Pepp DALI_LOG_INFO( gWidgetViewManagerLogging, Debug::Verbose, "WidgetViewManager::OnObjectViewDeleted: ObjectView is deleted!\n" ); } +int WidgetViewManager::WidgetEventCallback( const char* widgetId, const char* instanceId, int event, void* data ) +{ + WidgetViewManager* widgetViewManager = static_cast< WidgetViewManager* >( data ); + + if( widgetViewManager->mWidgetViewContainer.size() > 0) + { + WidgetViewIter iter = widgetViewManager->mWidgetViewContainer.find( std::string( instanceId ) ); + if( iter != widgetViewManager->mWidgetViewContainer.end() ) + { + Dali::WidgetView::WidgetView widgetView = iter->second; + + Dali::WidgetView::GetImplementation( widgetView ).SendWidgetEvent( event ); + + return 0; + } + } + + DALI_LOG_INFO( gWidgetViewManagerLogging, Debug::Verbose, "WidgetViewManager::WidgetEventCallback: WidgetView is not found! [%s, %s]\n", widgetId, instanceId ); + + return 0; +} + } // namespace Internal } // namespace WidgetView diff --git a/internal/widget_view_manager/widget_view_manager_impl.h b/internal/widget_view_manager/widget_view_manager_impl.h index 9dfad85..3403384 100644 --- a/internal/widget_view_manager/widget_view_manager_impl.h +++ b/internal/widget_view_manager/widget_view_manager_impl.h @@ -50,7 +50,7 @@ public: /** * @copydoc Dali::WidgetView::WidgetViewManager::AddWidget() */ - Dali::WidgetView::WidgetView AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ); + Dali::WidgetView::WidgetView AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ); private: @@ -72,6 +72,8 @@ private: void OnObjectViewAdded( Pepper::Compositor compositor, Pepper::ObjectView objectView ); void OnObjectViewDeleted( Pepper::Compositor compositor, Pepper::ObjectView objectView ); + static int WidgetEventCallback( const char* widgetId, const char* instanceId, int event, void* data ); + private: // Undefined diff --git a/public_api/widget_view/widget_view.cpp b/public_api/widget_view/widget_view.cpp index 5ab6395..7712b4c 100644 --- a/public_api/widget_view/widget_view.cpp +++ b/public_api/widget_view/widget_view.cpp @@ -27,9 +27,9 @@ namespace Dali namespace WidgetView { -WidgetView WidgetView::New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ) +WidgetView WidgetView::New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ) { - return Internal::WidgetView::New( widgetId, contentInfo, width, height, period ); + return Internal::WidgetView::New( widgetId, contentInfo, width, height, updatePeriod ); } WidgetView WidgetView::DownCast( BaseHandle handle ) @@ -79,9 +79,9 @@ const std::string& WidgetView::GetTitle() return Dali::WidgetView::GetImplementation( *this ).GetTitle(); } -double WidgetView::GetPeriod() const +double WidgetView::GetUpdatePeriod() const { - return Dali::WidgetView::GetImplementation( *this ).GetPeriod(); + return Dali::WidgetView::GetImplementation( *this ).GetUpdatePeriod(); } void WidgetView::Show() @@ -144,6 +144,31 @@ WidgetView::WidgetViewSignalType& WidgetView::WidgetDeletedSignal() return Dali::WidgetView::GetImplementation(*this).WidgetDeletedSignal(); } +WidgetView::WidgetViewSignalType& WidgetView::WidgetAbortedSignal() +{ + return Dali::WidgetView::GetImplementation(*this).WidgetAbortedSignal(); +} + +WidgetView::WidgetViewSignalType& WidgetView::WidgetResized() +{ + return Dali::WidgetView::GetImplementation(*this).WidgetResized(); +} + +WidgetView::WidgetViewSignalType& WidgetView::WidgetContentUpdated() +{ + return Dali::WidgetView::GetImplementation(*this).WidgetContentUpdated(); +} + +WidgetView::WidgetViewSignalType& WidgetView::WidgetExtraInfoUpdated() +{ + return Dali::WidgetView::GetImplementation(*this).WidgetExtraInfoUpdated(); +} + +WidgetView::WidgetViewSignalType& WidgetView::WidgetUpdatePeriodChanged() +{ + return Dali::WidgetView::GetImplementation(*this).WidgetUpdatePeriodChanged(); +} + WidgetView::WidgetView( Internal::WidgetView& implementation ) : Control( implementation ) { diff --git a/public_api/widget_view/widget_view.h b/public_api/widget_view/widget_view.h index 014d9c7..1575a2d 100644 --- a/public_api/widget_view/widget_view.h +++ b/public_api/widget_view/widget_view.h @@ -57,10 +57,10 @@ public: * @param[in] contentInfo Contents that will be given to the widget instance. * @param[in] width The widget width. * @param[in] height The widget height. - * @param[in] period The period of updating contents of the widget. + * @param[in] updatePeriod The period of updating contents of the widget. * @return A handle to WidgetView. */ - static WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ); + static WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ); /** * @brief Downcast a handle to WidgetView handle. @@ -148,14 +148,14 @@ public: const std::string& GetTitle(); /** - * @brief Get the update period of the widget. + * @brief Get the update period of the widget content. * * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/widget.viewer - * @return The update period of the widget. + * @return The update period of the widget content. */ - double GetPeriod() const; + double GetUpdatePeriod() const; /** * @brief Shows the widget. @@ -267,6 +267,8 @@ public: //Signals * @brief This signal is emitted when the widget is added. * * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/widget.viewer * @return The signal to connect to. */ WidgetViewSignalType& WidgetAddedSignal(); @@ -275,10 +277,62 @@ public: //Signals * @brief This signal is emitted when the widget is deleted. * * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/widget.viewer * @return The signal to connect to. */ WidgetViewSignalType& WidgetDeletedSignal(); + /** + * @brief This signal is emitted when the widget is aborted. + * + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/widget.viewer + * @return The signal to connect to. + */ + WidgetViewSignalType& WidgetAbortedSignal(); + + /** + * @brief This signal is emitted when the widget is resized. + * + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/widget.viewer + * @return The signal to connect to. + */ + WidgetViewSignalType& WidgetResized(); + + /** + * @brief This signal is emitted when the widget content is updated. + * + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/widget.viewer + * @return The signal to connect to. + */ + WidgetViewSignalType& WidgetContentUpdated(); + + /** + * @brief This signal is emitted when the widget extra info is updated. + * + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/widget.viewer + * @return The signal to connect to. + */ + WidgetViewSignalType& WidgetExtraInfoUpdated(); + + /** + * @brief This signal is emitted when the widget update period is changed. + * + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/widget.viewer + * @return The signal to connect to. + */ + WidgetViewSignalType& WidgetUpdatePeriodChanged(); + public: // Not intended for application developers /** diff --git a/public_api/widget_view_manager/widget_view_manager.cpp b/public_api/widget_view_manager/widget_view_manager.cpp index f06b4c8..00c292b 100644 --- a/public_api/widget_view_manager/widget_view_manager.cpp +++ b/public_api/widget_view_manager/widget_view_manager.cpp @@ -65,9 +65,9 @@ WidgetViewManager::WidgetViewManager( Internal::WidgetViewManager* implementatio { } -WidgetView WidgetViewManager::AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ) +WidgetView WidgetViewManager::AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ) { - return GetImplementation(*this).AddWidget( widgetId, contentInfo, width, height, period ); + return GetImplementation(*this).AddWidget( widgetId, contentInfo, width, height, updatePeriod ); } } // namespace WidgetView diff --git a/public_api/widget_view_manager/widget_view_manager.h b/public_api/widget_view_manager/widget_view_manager.h index c2ccd51..c2dcf55 100644 --- a/public_api/widget_view_manager/widget_view_manager.h +++ b/public_api/widget_view_manager/widget_view_manager.h @@ -119,10 +119,10 @@ public: * @param[in] contentInfo Contents that will be given to the widget instance. * @param[in] width The widget width. * @param[in] height The widget height. - * @param[in] period The period of updating contents of the widget. + * @param[in] updatePeriod The period of updating contents of the widget. * @return A handle to WidgetView. */ - WidgetView AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period ); + WidgetView AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, double updatePeriod ); public: // Not intended for application developers -- 2.7.4