From 29c6342708cc8c8953c50687036c3450fd2bf374 Mon Sep 17 00:00:00 2001 From: "taeyoon0.lee" Date: Fri, 17 Feb 2017 21:23:07 +0900 Subject: [PATCH] Added internal property for retry text and text input - Internal property for handling retry text - Added text item in property::map for text property (loading and retry) Change-Id: I629cff864781015af24ba07831aa5028915f8121 --- .../internal/widget_view/widget_view_impl.cpp | 104 ++++++++++++++++++++- .../internal/widget_view/widget_view_impl.h | 11 +++ 2 files changed, 110 insertions(+), 5 deletions(-) diff --git a/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp b/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp index 6f6ff65..cf85465 100644 --- a/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp +++ b/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp @@ -79,8 +79,10 @@ DALI_PROPERTY_REGISTRATION( Dali::WidgetView, WidgetView, "permanentDelete", BOO // Internal property // ToDo it should be changed public property. const int TERMINATE_WIDGET = Dali::WidgetView::WidgetView::Property::PERMANENT_DELETE+1; +const int RETRY_TEXT = TERMINATE_WIDGET+1; Dali::PropertyRegistration internalProperty1( typeRegistration, "terminateWidget", TERMINATE_WIDGET, Property::BOOLEAN, Dali::WidgetView::Internal::WidgetView::SetProperty, Dali::WidgetView::Internal::WidgetView::GetProperty ); +Dali::PropertyRegistration internalProperty2( typeRegistration, "retryText", RETRY_TEXT, Property::MAP, Dali::WidgetView::Internal::WidgetView::SetProperty, Dali::WidgetView::Internal::WidgetView::GetProperty ); // Signals DALI_SIGNAL_REGISTRATION( Dali::WidgetView, WidgetView, "widgetAdded", SIGNAL_WIDGET_ADDED ) @@ -101,9 +103,11 @@ DALI_TYPE_REGISTRATION_END() struct wl_buffer* preBuffer; +const char* const STATE_TEXT( "stateText" ); const char* const FONT_STYLE( "fontStyle" ); const char* const TEXT_POINT_SIZE( "textPointSize" ); const char* const TEXT_COLOR( "textColor" ); +const char* const TEXT_VISIBLE( "textVisible" ); //ToDo: it should be removed after retry text property is public one static void OnBufferUpdated( struct tizen_remote_surface *surface, uint32_t type, struct wl_buffer *buffer, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, @@ -180,7 +184,9 @@ WidgetView::WidgetView() mUpdatePeriod( 0.0 ), mPreviewVisible( true ), mLoadingTextVisible( true ), + mLoadingTextString(), mRetryTextVisible( true ), + mRetryTextString(), mRetryState( false ), mPermanentDelete( false ), mWatcherHandle( NULL ), @@ -200,7 +206,9 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI mUpdatePeriod( updatePeriod ), mPreviewVisible( true ), mLoadingTextVisible( true ), + mLoadingTextString(), mRetryTextVisible( true ), + mRetryTextString(), mRetryState( false ), mPermanentDelete( false ), mWatcherHandle( NULL ), @@ -333,17 +341,38 @@ void WidgetView::SetLoadingTextVisible( bool visible ) if( visible ) { - mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) ); + mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, + ( mLoadingTextString.empty() )? GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) : mLoadingTextString ); } mLoadingText.SetVisible( visible ); } } +void WidgetView::SetRetryTextVisible( bool visible ) +{ + if( mRetryText && mRetryTextVisible != visible ) + { + mRetryTextVisible = visible; + + if( visible ) + { + mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT, + ( mRetryTextString.empty() )? GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) : mRetryTextString ); + } + mRetryText.SetVisible( visible ); + } +} + bool WidgetView::IsLoadingTextVisible() { return mLoadingTextVisible; } +bool WidgetView::IsRetryTextVisible() +{ + return mRetryTextVisible; +} + void WidgetView::ActivateFaultedWidget() { if( mPid < 0 ) @@ -620,6 +649,16 @@ void WidgetView::SetProperty( BaseObject* object, Property::Index index, const P impl.TerminateWidget(); } } + case RETRY_TEXT: + { + Property::Map map; + + if( value.Get( map ) ) + { + impl.SetRetryTextPropertyMap( map ); + } + break; + } } } } @@ -780,7 +819,7 @@ void WidgetView::OnInitialize() mStateTextActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Loading text - mLoadingText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) ); + mLoadingText = Toolkit::TextLabel::New( ( mLoadingTextString.empty() )? GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) : mLoadingTextString ); mLoadingText.SetParentOrigin( ParentOrigin::CENTER ); mLoadingText.SetAnchorPoint( AnchorPoint::CENTER ); mLoadingText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -793,7 +832,7 @@ void WidgetView::OnInitialize() mStateTextActor.Add( mLoadingText ); // Retry text - mRetryText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) ); + mRetryText = Toolkit::TextLabel::New( ( mRetryTextString.empty() )? GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) : mRetryTextString ); mRetryText.SetParentOrigin( ParentOrigin::CENTER ); mRetryText.SetAnchorPoint( AnchorPoint::CENTER ); mRetryText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -1021,7 +1060,8 @@ void WidgetView::ShowLoadingState( bool show ) if( mLoadingText && mLoadingTextVisible ) { - mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) ); + mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, + ( mLoadingTextString.empty() )? GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) : mLoadingTextString ); mLoadingText.SetVisible( show ); } } @@ -1035,7 +1075,8 @@ void WidgetView::ShowRetryState( bool show ) if( mRetryText && mRetryTextVisible ) { - mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) ); + mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT, + ( mRetryTextString.empty() )? GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) : mRetryTextString ); mRetryText.SetVisible( show ); mRetryState = show; } @@ -1045,6 +1086,14 @@ void WidgetView::SetLoadingTextPropertyMap( Property::Map map ) { if( mLoadingText ) { + Property::Value* loadingText = map.Find( STATE_TEXT ); + std::string text; + if( loadingText && loadingText->Get( text ) ) + { + mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, text ); + mLoadingTextString = text; + } + Property::Value* fontStyle = map.Find( FONT_STYLE ); std::string style; @@ -1071,6 +1120,51 @@ void WidgetView::SetLoadingTextPropertyMap( Property::Map map ) } } +void WidgetView::SetRetryTextPropertyMap( Property::Map map ) +{ + if( mRetryText ) + { + Property::Value* retryText = map.Find( STATE_TEXT ); + std::string text; + if( retryText && retryText->Get( text ) ) + { + mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT, text ); + mRetryTextString = text; + } + + Property::Value* fontStyle = map.Find( FONT_STYLE ); + std::string style; + + if( fontStyle && fontStyle->Get( style ) ) + { + mRetryText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, style ); + } + + Property::Value* textPointSize = map.Find( TEXT_POINT_SIZE ); + float size = 0.f; + + if( textPointSize && textPointSize->Get( size ) ) + { + mRetryText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, size ); + } + + Property::Value* textColor = map.Find( TEXT_COLOR ); + Vector4 color; + + if( textColor && textColor->Get( color ) ) + { + mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, color ); + } + + Property::Value* textVisible = map.Find( TEXT_VISIBLE ); + bool visible = true; + if( textVisible && textVisible->Get( visible ) ) + { + SetRetryTextVisible( visible ); + } + } +} + float WidgetView::TextPixelToPointSize( int pixelSize ) { Dali::Vector2 dpi = Dali::Stage::GetCurrent().GetDpi(); diff --git a/widget_viewer_dali/internal/widget_view/widget_view_impl.h b/widget_viewer_dali/internal/widget_view/widget_view_impl.h index e27786f..aaaffbc 100644 --- a/widget_viewer_dali/internal/widget_view/widget_view_impl.h +++ b/widget_viewer_dali/internal/widget_view/widget_view_impl.h @@ -118,8 +118,12 @@ public: // Internal API void SetLoadingTextVisible( bool visible ); + void SetRetryTextVisible( bool visible ); + bool IsLoadingTextVisible(); + bool IsRetryTextVisible(); + bool IsWidgetFaulted(); void SetPermanentDelete( bool permanentDelete ); @@ -144,6 +148,8 @@ public: // Internal API void SetLoadingTextPropertyMap( Dali::Property::Map map ); + void SetRetryTextPropertyMap( Dali::Property::Map map ); + void ShowLoadingState( bool show ); void ShowRetryState( bool show ); @@ -269,9 +275,14 @@ private: float mUpdatePeriod; bool mPreviewVisible; + bool mLoadingTextVisible; + std::string mLoadingTextString; + bool mRetryTextVisible; + std::string mRetryTextString; bool mRetryState; + bool mPermanentDelete; screen_connector_toolkit_h mWatcherHandle; tizen_remote_surface* mRemoteSurface; -- 2.7.4