From 23f0d1f4ac05246b110a18f6970914eead5772a7 Mon Sep 17 00:00:00 2001 From: Sinjae Lee Date: Fri, 9 May 2014 22:57:43 +0900 Subject: [PATCH] (Indicator) Implemented AUTO visible mode for indicator Implemented AUTO visible mode for indicator For full screen application in portrait, or almost application in landscape mode, indicator should be hidden in default and it can be shown by user's touch The conditions for showing in AUTO mode - indicator want to notify something to user - user swipe down on top of the screen The conditions for hiding in AUTO mode - After n seconds - When user touch anywhere except for indicator area --- adaptors/tizen/internal/common/indicator-impl.cpp | 398 +++++++++++++++------ adaptors/tizen/internal/common/indicator-impl.h | 50 ++- adaptors/tizen/internal/common/window-impl.cpp | 104 +++--- adaptors/tizen/internal/common/window-impl.h | 9 +- .../public-api/adaptor-framework/common/window.cpp | 5 + .../public-api/adaptor-framework/common/window.h | 18 + 6 files changed, 422 insertions(+), 162 deletions(-) diff --git a/adaptors/tizen/internal/common/indicator-impl.cpp b/adaptors/tizen/internal/common/indicator-impl.cpp index f360303..7eb35a1 100644 --- a/adaptors/tizen/internal/common/indicator-impl.cpp +++ b/adaptors/tizen/internal/common/indicator-impl.cpp @@ -50,6 +50,17 @@ using Dali::Vector4; namespace { + +const float SLIDING_ANIMATION_DURATION( 0.2f ); // 200 milli seconds +const float AUTO_INDICATOR_STAY_DURATION(3.0f); // 3 seconds +const float SHOWING_DISTANCE_HEIGHT_RATE(0.33f); + +enum +{ + KEEP_SHOWING = -1, + HIDE_NOW = 0 +}; + const int NUM_GRADIENT_INTERVALS(5); // Number of gradient intervals const Dali::Vector4 GRADIENT_COLORS[NUM_GRADIENT_INTERVALS+1] = { @@ -87,17 +98,6 @@ const char* MESH_FRAGMENT_SHADER = // Copied from elm_win.h /** - * Defines the opacity modes of indicator that can be shown - */ -typedef enum -{ - ELM_WIN_INDICATOR_OPACITY_UNKNOWN, /**< Unknown indicator opacity mode */ - ELM_WIN_INDICATOR_OPAQUE, /**< Opacifies the indicator */ - ELM_WIN_INDICATOR_TRANSLUCENT, /**< Be translucent the indicator */ - ELM_WIN_INDICATOR_TRANSPARENT /**< Transparentizes the indicator */ -} Elm_Win_Indicator_Opacity_Mode; - -/** * Defines the type modes of indicator that can be shown * If the indicator can support several type of indicator, * you can use this enum value to deal with different type of indicator @@ -146,7 +146,7 @@ const int MSG_ID_INDICATOR_REPEAT_EVENT(0x10002); const int MSG_ID_INDICATOR_ROTATION(0x10003); const int MSG_ID_INDICATOR_OPACITY(0X1004); const int MSG_ID_INDICATOR_TYPE(0X1005); - +const int MSG_ID_INDICATOR_START_ANIMATION(0X10006); struct IpcDataUpdate { @@ -158,6 +158,12 @@ struct IpcDataResize int w, h; }; +struct IpcIndicatorDataAnimation +{ + unsigned int xwin; + double duration; +}; + struct IpcDataEvMouseUp { int b; @@ -369,43 +375,58 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat mRotation( 0 ), mImageWidth( 0 ), mImageHeight( 0 ), - mVisible( false ) + mVisible( Dali::Window::VISIBLE ), + mIsShowing( true ), + mIsAnimationPlaying( false ), + mTouchedDown( false ) { mIndicatorImageActor = Dali::ImageActor::New(); - mIndicatorImageActor.SetLeaveRequired(true); - mIndicatorImageActor.TouchedSignal().Connect( this, &Indicator::OnTouched ); - mIndicatorImageActor.SetBlendFunc(Dali::BlendingFactor::ONE, Dali::BlendingFactor::ONE_MINUS_SRC_ALPHA, + mIndicatorImageActor.SetBlendFunc( Dali::BlendingFactor::ONE, Dali::BlendingFactor::ONE_MINUS_SRC_ALPHA, Dali::BlendingFactor::ONE, Dali::BlendingFactor::ONE ); - mIndicatorImageActor.SetPositionInheritanceMode(USE_PARENT_POSITION); + + mIndicatorImageActor.SetParentOrigin( ParentOrigin::TOP_CENTER ); + mIndicatorImageActor.SetAnchorPoint( AnchorPoint::TOP_CENTER ); SetBackground(); - mBackgroundActor.SetPositionInheritanceMode(USE_PARENT_POSITION); + mBackgroundActor.SetParentOrigin( ParentOrigin::TOP_CENTER ); + mBackgroundActor.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + mBackgroundActor.SetZ(-0.01f); + + // add background to image actor to move it with indicator image + mIndicatorImageActor.Add( mBackgroundActor ); mIndicatorActor = Dali::Actor::New(); - mIndicatorActor.SetParentOrigin( ParentOrigin::CENTER ); - mIndicatorActor.SetAnchorPoint( AnchorPoint::CENTER ); - mIndicatorActor.Add(mBackgroundActor); - mIndicatorActor.Add(mIndicatorImageActor); + mIndicatorActor.Add( mIndicatorImageActor ); - if(mOrientation == Dali::Window::LANDSCAPE || mOrientation == Dali::Window::LANDSCAPE_INVERSE) + if( mOrientation == Dali::Window::LANDSCAPE || mOrientation == Dali::Window::LANDSCAPE_INVERSE ) { - mBackgroundActor.SetVisible(false); + mBackgroundActor.SetVisible( false ); } + // event handler + mEventActor = Dali::Actor::New(); + mEventActor.SetParentOrigin( ParentOrigin::TOP_CENTER ); + mEventActor.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + mEventActor.SetPosition(0.0f, 0.0f, 1.0f); + mEventActor.TouchedSignal().Connect( this, &Indicator::OnTouched ); + mEventActor.SetLeaveRequired( true ); + mIndicatorActor.Add( mEventActor ); + Open( orientation ); + // register indicator to accessibility manager Dali::AccessibilityManager accessibilityManager = AccessibilityManager::Get(); if(accessibilityManager) { - AccessibilityManager::GetImplementation( accessibilityManager ).SetIndicator(this); + AccessibilityManager::GetImplementation( accessibilityManager ).SetIndicator( this ); } } Indicator::~Indicator() { - if(mIndicatorImageActor) + if(mEventActor) { - mIndicatorImageActor.TouchedSignal().Disconnect( this, &Indicator::OnTouched ); + mEventActor.TouchedSignal().Disconnect( this, &Indicator::OnTouched ); } Disconnect(); } @@ -459,29 +480,42 @@ void Indicator::Close() mIndicatorImageActor.SetImage(emptyImage); } -void Indicator::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode, bool notifyService ) +void Indicator::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode ) { - if( mOpacityMode != mode || notifyService ) - { - // notify opacity mode to indicator service - SendOpacityMode(mode); - } - mOpacityMode = mode; SetBackground(); } -void Indicator::SetVisible( bool visibility ) +void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode ) { - if ( visibility != mVisible ) + if ( visibleMode != mVisible ) { - mVisible = visibility; - // If we were previously hidden, then we should update the image data before we display the indicator - if ( mVisible ) + if ( mVisible == Dali::Window::INVISIBLE ) { UpdateImageData(); } + + mVisible = visibleMode; + + if( mIndicatorImageActor.GetImage() ) + { + if( CheckVisibleState() && mVisible == Dali::Window::AUTO ) + { + // hide indicator + ShowIndicator( AUTO_INDICATOR_STAY_DURATION /* stay n sec */ ); + } + else if( CheckVisibleState() && mVisible == Dali::Window::VISIBLE ) + { + // show indicator + ShowIndicator( KEEP_SHOWING ); + } + else + { + // hide indicator + ShowIndicator( HIDE_NOW ); + } + } } } @@ -508,44 +542,95 @@ bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEv { const TouchPoint& touchPoint = touchEvent.GetPoint( 0 ); - switch( touchPoint.state ) + // Send touch event to indicator server when indicator is showing + if( CheckVisibleState() || mIsShowing ) { - case Dali::TouchPoint::Down: + switch( touchPoint.state ) { - IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); - IpcDataEvMouseDown ipcDown( touchEvent.time ); - mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); - mServerConnection->SendEvent( OP_EV_MOUSE_DOWN, &ipcDown, sizeof(ipcDown) ); - } - break; + case Dali::TouchPoint::Down: + { + IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); + IpcDataEvMouseDown ipcDown( touchEvent.time ); + mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); + mServerConnection->SendEvent( OP_EV_MOUSE_DOWN, &ipcDown, sizeof(ipcDown) ); - case Dali::TouchPoint::Motion: - { - IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); - mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); - } - break; + if( mVisible == Dali::Window::AUTO ) + { + // Stop hiding indicator + ShowIndicator( KEEP_SHOWING ); + mEventActor.SetSize( Dali::Stage::GetCurrent().GetSize() ); + } + } + break; - case Dali::TouchPoint::Up: - { - IpcDataEvMouseUp ipcUp( touchEvent.time ); - mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) ); - } - break; + case Dali::TouchPoint::Motion: + { + IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); + mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); + } + break; - case Dali::TouchPoint::Leave: - { - IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); - mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); - IpcDataEvMouseUp ipcOut( touchEvent.time ); - mServerConnection->SendEvent( OP_EV_MOUSE_OUT, &ipcOut, sizeof(ipcOut) ); + case Dali::TouchPoint::Up: + { + IpcDataEvMouseUp ipcUp( touchEvent.time ); + mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) ); + + if( mVisible == Dali::Window::AUTO ) + { + // Hide indicator + ShowIndicator( 0.5f /* hide after 0.5 sec */ ); + // TODO: not necessary if dali supports the event for both indicator and behind button + mEventActor.SetSize( mImageWidth, mImageHeight / 2 ); + } + } + break; + + case Dali::TouchPoint::Leave: + { + IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); + mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); + IpcDataEvMouseUp ipcOut( touchEvent.time ); + mServerConnection->SendEvent( OP_EV_MOUSE_OUT, &ipcOut, sizeof(ipcOut) ); + } + break; + + default: + break; } - break; + } + // show indicator when it is invisible + else if( !mIsShowing && ( CheckVisibleState() == false || mVisible == Dali::Window::AUTO ) ) + { + switch( touchPoint.state ) + { + case Dali::TouchPoint::Down: + { + mTouchedDown = true; + mTouchedYPosition = touchPoint.local.y; + } + break; - default: + case Dali::TouchPoint::Motion: + case Dali::TouchPoint::Up: + case Dali::TouchPoint::Leave: + { + if( mTouchedDown ) + { + if( touchPoint.local.y > mTouchedYPosition + mImageHeight * SHOWING_DISTANCE_HEIGHT_RATE ) + { + ShowIndicator( AUTO_INDICATOR_STAY_DURATION ); + mTouchedDown = false; + } + } + } break; + + default: + break; + } } } + return true; } @@ -575,32 +660,6 @@ int Indicator::OrientationToDegrees( Dali::Window::WindowOrientation orientation return degree; } -void Indicator::SendOpacityMode( Dali::Window::IndicatorBgOpacity mode ) -{ - Elm_Win_Indicator_Opacity_Mode windowIndicatorMode; - switch(mode) - { - case Dali::Window::OPAQUE: - windowIndicatorMode = ELM_WIN_INDICATOR_OPAQUE; - break; - case Dali::Window::TRANSPARENT: - windowIndicatorMode = ELM_WIN_INDICATOR_TRANSPARENT; - break; - case Dali::Window::TRANSLUCENT: - windowIndicatorMode = ELM_WIN_INDICATOR_TRANSLUCENT; - break; - } - - if( mServerConnection ) - { - mServerConnection->SendEvent( OP_MSG, - MSG_DOMAIN_CONTROL_INDICATOR, - MSG_ID_INDICATOR_OPACITY, - &windowIndicatorMode, sizeof( Elm_Win_Indicator_Opacity_Mode ) ); - } -} - - bool Indicator::Connect( Dali::Window::WindowOrientation orientation ) { DALI_ASSERT_DEBUG( mState == DISCONNECTED ); @@ -645,14 +704,7 @@ bool Indicator::Connect( const char *serviceName ) } } - if( connected ) - { - mState = CONNECTED; - int domain = MSG_DOMAIN_CONTROL_INDICATOR; - int refTo = MSG_ID_INDICATOR_ROTATION; - mServerConnection->SendEvent( OP_MSG, domain, refTo, &mRotation, sizeof(int) ); - } - else + if( !connected ) { StartReconnectionTimer(); } @@ -813,6 +865,8 @@ void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent ) if( mSharedFile != NULL ) { CreateNewImage(); + mEventActor.SetSize(mImageWidth, mImageHeight); + if( CheckVisibleState() ) { // set default indicator type (enable the quick panel) @@ -911,6 +965,7 @@ void Indicator::CreateNewPixmapImage() mIndicatorImageActor.SetImage( Dali::Image::New(*pixmapImage) ); mIndicatorImageActor.SetSize( mImageWidth, mImageHeight ); mIndicatorActor.SetSize( mImageWidth, mImageHeight ); + mEventActor.SetSize(mImageWidth, mImageHeight); SetBackground(); if( mBackgroundActor ) @@ -942,6 +997,7 @@ void Indicator::CreateNewImage() mIndicatorImageActor.SetImage( image ); mIndicatorImageActor.SetSize( mImageWidth, mImageHeight ); mIndicatorActor.SetSize( mImageWidth, mImageHeight ); + mEventActor.SetSize(mImageWidth, mImageHeight); SetBackground(); if( mBackgroundActor ) @@ -1015,6 +1071,12 @@ void Indicator::DataReceived( void* event ) { int msgDomain = epcEvent->ref; int msgId = epcEvent->ref_to; + + void *msgData = NULL; + int msgDataSize = 0; + msgData = epcEvent->data; + msgDataSize = epcEvent->size; + if( msgDomain == MSG_DOMAIN_CONTROL_INDICATOR ) { switch( msgId ) @@ -1026,6 +1088,24 @@ void Indicator::DataReceived( void* event ) OnIndicatorTypeChanged( *indicatorType ); break; } + + case MSG_ID_INDICATOR_START_ANIMATION: + { + if (msgDataSize != (int)sizeof(IpcIndicatorDataAnimation)) + { + DALI_LOG_ERROR("Message data is incorrect"); + break; + } + + IpcIndicatorDataAnimation *animData = static_cast(msgData); + + if(!CheckVisibleState()) + { + ShowIndicator( animData->duration /* n sec */ ); + } + break; + } + } } break; @@ -1050,8 +1130,7 @@ bool Indicator::CheckVisibleState() { if( mOrientation == Dali::Window::LANDSCAPE || mOrientation == Dali::Window::LANDSCAPE_INVERSE - || mOpacityMode == Dali::Window::TRANSPARENT - || mVisible == false ) + || (mVisible != Dali::Window::VISIBLE) ) { return false; } @@ -1099,6 +1178,119 @@ void Indicator::ConstructBackgroundMesh() mBackgroundActor.SetShaderEffect(shaderEffect); } +void Indicator::ShowIndicator(float duration) +{ + if( !mIndicatorAnimation ) + { + mIndicatorAnimation = Dali::Animation::New(SLIDING_ANIMATION_DURATION); + mIndicatorAnimation.FinishedSignal().Connect(this, &Indicator::OnAnimationFinished); + } + + if(mIsShowing && duration != 0) + { + // do not need to show it again + } + else if(!mIsShowing && mIsAnimationPlaying && duration == 0) + { + // do not need to hide it again + } + else + { + if(duration == 0) + { + mIndicatorAnimation.MoveTo(mIndicatorImageActor, Vector3(0, -mImageHeight, 0), Dali::AlphaFunctions::EaseOut); + + mIsShowing = false; + + OnIndicatorTypeChanged( INDICATOR_TYPE_2 ); // un-toucable + } + else + { + mIndicatorAnimation.MoveTo(mIndicatorImageActor, Vector3(0, 0, 0), Dali::AlphaFunctions::EaseOut); + + mIsShowing = true; + + OnIndicatorTypeChanged( INDICATOR_TYPE_1 ); // touchable + } + + mIndicatorAnimation.Play(); + mIsAnimationPlaying = true; + } + + if(duration > 0) + { + if(!mShowTimer) + { + mShowTimer = Dali::Timer::New(1000 * duration); + mShowTimer.TickSignal().Connect(this, &Indicator::OnShowTimer); + } + mShowTimer.SetInterval(1000* duration); + mShowTimer.Start(); + + if( mVisible == Dali::Window::AUTO ) + { + // check the stage touch + Dali::Stage::GetCurrent().TouchedSignal().Connect( this, &Indicator::OnStageTouched ); + } + } + else + { + if(mShowTimer && mShowTimer.IsRunning()) + { + mShowTimer.Stop(); + } + + if( mVisible == Dali::Window::AUTO ) + { + // check the stage touch + Dali::Stage::GetCurrent().TouchedSignal().Disconnect( this, &Indicator::OnStageTouched ); + } + } +} + +bool Indicator::OnShowTimer() +{ + // after time up, hide indicator + ShowIndicator( HIDE_NOW ); + + return false; +} + +void Indicator::OnAnimationFinished(Dali::Animation& animation) +{ + mIsAnimationPlaying = false; + + if( mIsShowing == false ) + { + // TODO: not necessary if dali supports the event for both indicator and behind button + mEventActor.SetSize(mImageWidth, mImageHeight /2); + } + else + { + mEventActor.SetSize(mImageWidth, mImageHeight); + } +} + +void Indicator::OnStageTouched(const Dali::TouchEvent& touchEvent) +{ + const TouchPoint& touchPoint = touchEvent.GetPoint( 0 ); + + // when stage is touched while indicator is showing temporary, hide it + if( mIsShowing && ( CheckVisibleState() == false || mVisible == Dali::Window::AUTO ) ) + { + switch( touchPoint.state ) + { + case Dali::TouchPoint::Down: + { + ShowIndicator( HIDE_NOW ); + break; + } + + default: + break; + } + } +} } // Adaptor } // Internal diff --git a/adaptors/tizen/internal/common/indicator-impl.h b/adaptors/tizen/internal/common/indicator-impl.h index 87962dd..eba1704 100644 --- a/adaptors/tizen/internal/common/indicator-impl.h +++ b/adaptors/tizen/internal/common/indicator-impl.h @@ -24,6 +24,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -195,15 +196,14 @@ public: /** * Set the opacity mode of the indicator background. * @param[in] mode opacity mode - * @param[in] notifyService True if need to notify the opacity mode to indicator service */ - void SetOpacityMode( Dali::Window::IndicatorBgOpacity mode, bool notifyService = false ); + void SetOpacityMode( Dali::Window::IndicatorBgOpacity mode ); /** * Set whether the indicator is visible or not. - * @param[in] visibility TRUE if visible. + * @param[in] visibleMode visible mode for indicator bar. */ - void SetVisible( bool visibility ); + void SetVisible( Dali::Window::IndicatorVisibleMode visibleMode ); /** * Check whether the indicator is connected to the indicator service. @@ -240,6 +240,12 @@ private: bool OnTouched(Dali::Actor indicator, const TouchEvent& touchEvent); /** + * Touch event callback on stage. + * @param[in] touchEvent The touch event + */ + void OnStageTouched(const Dali::TouchEvent& touchEvent); + + /** * Return the given orientation in degrees * @param[in] orientation The given indicator orientation * @return value of 0, 90, 180 or 270 @@ -247,11 +253,6 @@ private: int OrientationToDegrees( Dali::Window::WindowOrientation orientation ); /** - * Send opacity mode to indicator service - */ - void SendOpacityMode( Dali::Window::IndicatorBgOpacity mode ); - - /** * Connect to the indicator service matching the orientation * @param[in] orientation The current indicator orientation */ @@ -344,6 +345,25 @@ private: */ bool CheckVisibleState(); + /** + * Show/Hide indicator actor with effect + * @param[in] duration how long need to show the indicator, + * if it equal to 0, hide the indicator + * if it less than 0, show always + */ + void ShowIndicator(float duration); + + /** + * Showing timer callback + */ + bool OnShowTimer(); + + /** + * Showing animation finished callback + * @param[in] animation + */ + void OnAnimationFinished(Dali::Animation& animation); + private: // Implementation of ServerConnection::Observer /** * @copydoc Dali::Internal::Adaptor::ServerConnection::Observer::DataReceived() @@ -371,6 +391,7 @@ private: Dali::AnimatableMesh mBackgroundMesh; Dali::MeshActor mBackgroundActor; ///< Actor for background Dali::Actor mIndicatorActor; ///< Handle to topmost indicator actor + Dali::Actor mEventActor; ///< Handle to event Dali::Timer mReconnectTimer; ///< Reconnection timer SlotDelegate< Indicator > mConnection; @@ -388,7 +409,16 @@ private: int mRotation; ///< Orientation in degrees int mImageWidth; int mImageHeight; - bool mVisible; ///< Whether the indicator is visible + Dali::Window::IndicatorVisibleMode mVisible; ///< Whether the indicator is visible + + Dali::Timer mShowTimer; ///< Timer to show indicator + bool mIsShowing; ///< Whether the indicator is showing on the screen + Dali::Animation mIndicatorAnimation; ///< Animation to show/hide indicator image + + bool mIsAnimationPlaying; ///< Whether the animation is playing + bool mTouchedDown; ///< Whether the indicator area touched down + int mTouchedYPosition; ///< Indicator area touched position + }; } // Adaptor diff --git a/adaptors/tizen/internal/common/window-impl.cpp b/adaptors/tizen/internal/common/window-impl.cpp index 6ebedd5..f65716f 100644 --- a/adaptors/tizen/internal/common/window-impl.cpp +++ b/adaptors/tizen/internal/common/window-impl.cpp @@ -26,7 +26,6 @@ #include #include #include -#include // INTERNAL HEADERS #include @@ -239,11 +238,54 @@ RenderSurface* Window::GetSurface() void Window::ShowIndicator( bool show ) { DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "%s\n", show?"SHOW":"HIDE" ); + DALI_ASSERT_DEBUG(mOverlay); + if(show) + { + mIndicatorVisible = Dali::Window::VISIBLE; + } + else + { + mIndicatorVisible = Dali::Window::INVISIBLE; + } + + DoShowIndicator( mIndicatorOrientation ); +} + +void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode ) +{ + DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode ); DALI_ASSERT_DEBUG(mOverlay); - mShowIndicator = show; - DoShowIndicator( mShowIndicator, mIndicatorOrientation ); + ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface ); + DALI_ASSERT_DEBUG(x11Window); + Ecore_X_Window xWinId = x11Window->GetXWindow(); + + mIndicatorVisible = visibleMode; + + if ( mIndicatorVisible == Dali::Window::VISIBLE ) + { + // when the indicator is visible, set proper mode for indicator server according to bg mode + if ( mIndicatorOpacityMode == Dali::Window::OPAQUE ) + { + ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_OPAQUE); + } + else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT ) + { + ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT); + } + else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT ) + { + ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_BG_TRANSPARENT); + } + } + else + { + // when the indicator is not visible, set TRANSPARENT mode for indicator server + ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); // it means hidden indicator + } + + DoShowIndicator( mIndicatorOrientation ); } void Window::RotateIndicator(Dali::Window::WindowOrientation orientation) @@ -260,25 +302,6 @@ void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode if( mIndicator != NULL ) { mIndicator->SetOpacityMode( opacityMode ); - - ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface ); - if( x11Window ) - { - Ecore_X_Window win = x11Window->GetXWindow(); - - if (opacityMode == Dali::Window::OPAQUE) - { - ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE); - } - else if (opacityMode == Dali::Window::TRANSLUCENT) - { - ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT); - } - else if (opacityMode == Dali::Window::TRANSPARENT) - { - ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); - } - } } } @@ -297,7 +320,7 @@ void Window::SetClass(std::string name, std::string klass) Window::Window() : mSurface(NULL), - mShowIndicator(false), + mIndicatorVisible(Dali::Window::VISIBLE), mIndicatorIsShown(false), mShowRotatedIndicatorOnClose(false), mStarted(false), @@ -338,14 +361,14 @@ void Window::Initialize(const PositionSize& windowPosition, const std::string& n mEventHandler = new EventHandler( this ); } -void Window::DoShowIndicator( bool show, Dali::Window::WindowOrientation lastOrientation ) +void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation ) { if( mIndicator == NULL ) { - if( show ) + if( mIndicatorVisible != Dali::Window::INVISIBLE ) { mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, this ); - mIndicator->SetOpacityMode( mIndicatorOpacityMode, true ); + mIndicator->SetOpacityMode( mIndicatorOpacityMode ); Dali::Actor actor = mIndicator->GetActor(); SetIndicatorActorRotation(); mOverlay->Add(actor); @@ -354,9 +377,7 @@ void Window::DoShowIndicator( bool show, Dali::Window::WindowOrientation lastOri } else // Already have indicator { - Dali::Actor actor = mIndicator->GetActor(); - - if( show == true ) + if( mIndicatorVisible == Dali::Window::VISIBLE ) { // If we are resuming, and rotation has changed, if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation ) @@ -366,27 +387,16 @@ void Window::DoShowIndicator( bool show, Dali::Window::WindowOrientation lastOri mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion // Don't show actor - will contain indicator for old orientation. } - else - { - // show animation - Dali::Animation anim = Dali::Animation::New(INDICATOR_ANIMATION_DURATION); - anim.MoveTo(actor, 0, INDICATOR_SHOW_Y_POSITION, 0); - anim.Play(); - } - } - else - { - // hide animation - Dali::Animation anim = Dali::Animation::New(INDICATOR_ANIMATION_DURATION); - anim.MoveTo(actor, 0, INDICATOR_HIDE_Y_POSITION, 0); - anim.Play(); } } + // set indicator visible mode if( mIndicator != NULL ) { - mIndicator->SetVisible( show ); + mIndicator->SetVisible( mIndicatorVisible ); } + + bool show = (mIndicatorVisible != Dali::Window::INVISIBLE ); SetIndicatorProperties( show, lastOrientation ); mIndicatorIsShown = show; } @@ -463,7 +473,7 @@ void Window::IndicatorClosed( Indicator* indicator ) mIndicator->Open(mNextIndicatorOrientation); mIndicatorOrientation = mNextIndicatorOrientation; SetIndicatorActorRotation(); - DoShowIndicator(mShowIndicator, currentOrientation); + DoShowIndicator(currentOrientation); } } @@ -535,7 +545,7 @@ Dali::DragAndDropDetector Window::GetDragAndDropDetector() const void Window::OnStart() { - DoShowIndicator( mShowIndicator, mIndicatorOrientation ); + DoShowIndicator( mIndicatorOrientation ); } void Window::OnPause() @@ -549,7 +559,7 @@ void Window::OnResume() { // Restore own indicator opacity // Send opacity mode to indicator service when app resumed - mIndicator->SetOpacityMode( mIndicatorOpacityMode, true ); + mIndicator->SetOpacityMode( mIndicatorOpacityMode ); } } diff --git a/adaptors/tizen/internal/common/window-impl.h b/adaptors/tizen/internal/common/window-impl.h index c3db7cd..56d4c14 100644 --- a/adaptors/tizen/internal/common/window-impl.h +++ b/adaptors/tizen/internal/common/window-impl.h @@ -85,6 +85,11 @@ public: void ShowIndicator( bool show ); /** + * @copydoc Dali::Window::ShowIndicator() + */ + void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode ); + + /** * @copydoc Dali::Window::SetIndicatorBgOpacity() */ void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity ); @@ -181,7 +186,7 @@ private: * Shows / hides the indicator bar. * Handles close/open if rotation changes whilst hidden */ - void DoShowIndicator( bool show, Dali::Window::WindowOrientation lastOrientation ); + void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation ); /** * Close current indicator and open a connection onto the new indicator service. @@ -243,7 +248,7 @@ private: typedef std::vector DiscardedIndicators; RenderSurface* mSurface; - bool mShowIndicator:1; ///< public state + Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state bool mIndicatorIsShown:1; ///< private state bool mShowRotatedIndicatorOnClose:1; bool mStarted:1; diff --git a/adaptors/tizen/public-api/adaptor-framework/common/window.cpp b/adaptors/tizen/public-api/adaptor-framework/common/window.cpp index eb02295..376c100 100644 --- a/adaptors/tizen/public-api/adaptor-framework/common/window.cpp +++ b/adaptors/tizen/public-api/adaptor-framework/common/window.cpp @@ -43,6 +43,11 @@ void Window::ShowIndicator( bool show ) GetImplementation(*this).ShowIndicator( show ); } +void Window::ShowIndicator( IndicatorVisibleMode visibleMode ) +{ + GetImplementation(*this).ShowIndicator( visibleMode ); +} + void Window::SetIndicatorBgOpacity( IndicatorBgOpacity opacity ) { GetImplementation(*this).SetIndicatorBgOpacity( opacity ); diff --git a/capi/dali/public-api/adaptor-framework/common/window.h b/capi/dali/public-api/adaptor-framework/common/window.h index 517b5bc..a50f520 100644 --- a/capi/dali/public-api/adaptor-framework/common/window.h +++ b/capi/dali/public-api/adaptor-framework/common/window.h @@ -76,6 +76,17 @@ public: TRANSPARENT = 0 // Fully transparent indicator Bg }; + /** + * @brief Visible mode of the indicator. + */ + enum IndicatorVisibleMode + { + INVISIBLE = 0, // hide indicator + VISIBLE = 1, // show indicator + AUTO = 2 // hide in default, will show when necessary + }; + + // Methods /** @@ -108,10 +119,17 @@ public: /** * @brief This sets whether the indicator bar should be shown or not. * @param[in] show - true if the indicator bar should be shown + * @deprecated use "void ShowIndicator( IndicatorVisibleMode visibleMode )" */ void ShowIndicator( bool show ); /** + * @brief This sets whether the indicator bar should be shown or not. + * @param[in] visibleMode visible mode for indicator bar, VISIBLE in default + */ + void ShowIndicator( IndicatorVisibleMode visibleMode ); + + /** * @brief This sets the opacity mode of indicator bar. * @param[in] opacity - The opacity mode */ -- 2.7.4