From 298daf3ef0031e7c38fc4ca64f0152c54a6abe40 Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Mon, 9 Dec 2019 04:51:14 +0900 Subject: [PATCH] Add NO_ORIENTATION_PREFERENCE type to unset the preferred orientation For unseting the preferred orientation for window, NO_ORIENTATION_PREFERENCE type is added to WindowOrientation enum. To unset the preferred orientation, SetPreferredOrienation() should be called with NO_ORIENTATION_PREFERENCE. Change-Id: Ia2de67d6533cef59b58340fca51286239c1a297d --- dali/internal/window-system/common/window-impl.cpp | 59 +++++++++++++++++----- dali/internal/window-system/common/window-impl.h | 5 ++ dali/public-api/adaptor-framework/window.h | 10 +++- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 1e9e79b..3001f7a 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -74,7 +74,7 @@ Window::Window() mResizeEnabled( false ), mType( Dali::Window::NORMAL ), mParentWindow( NULL ), - mPreferredAngle( 0 ), + mPreferredAngle( Dali::Window::NO_ORIENTATION_PREFERENCE ), mRotationAngle( 0 ), mWindowWidth( 0 ), mWindowHeight( 0 ), @@ -211,29 +211,36 @@ Dali::RenderTaskList Window::GetRenderTaskList() const void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation ) { + if( IsOrientationAvailable( orientation ) == false ) + { + return; + } + bool found = false; - if( orientation <= Dali::Window::LANDSCAPE_INVERSE ) + int convertedAngle = ConvertToAngle( orientation ); + for( std::size_t i = 0; i < mAvailableAngles.size(); i++ ) { - int convertedAngle = ConvertToAngle( orientation ); - for( std::size_t i = 0; i < mAvailableAngles.size(); i++ ) + if( mAvailableAngles[i] == convertedAngle ) { - if( mAvailableAngles[i] == convertedAngle ) - { - found = true; - break; - } + found = true; + break; } + } - if( !found ) - { - mAvailableAngles.push_back( convertedAngle ); - SetAvailableAnlges( mAvailableAngles ); - } + if( !found ) + { + mAvailableAngles.push_back( convertedAngle ); + SetAvailableAnlges( mAvailableAngles ); } } void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation ) { + if( IsOrientationAvailable( orientation ) == false ) + { + return; + } + int convertedAngle = ConvertToAngle( orientation ); for( std::vector< int >::iterator iter = mAvailableAngles.begin(); iter != mAvailableAngles.end(); ++iter ) @@ -250,6 +257,10 @@ void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orienta void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) { + if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE ) + { + return; + } mPreferredAngle = ConvertToAngle( orientation ); mWindowBase->SetPreferredAngle( mPreferredAngle ); } @@ -298,6 +309,11 @@ int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation ) convertAngle = 270; break; } + case Dali::Window::NO_ORIENTATION_PREFERENCE: + { + convertAngle = -1; + break; + } } } return convertAngle; @@ -330,11 +346,26 @@ Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) orientation = Dali::Window::PORTRAIT_INVERSE; break; } + case -1: + { + orientation = Dali::Window::NO_ORIENTATION_PREFERENCE; + break; + } } } return orientation; } +bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const +{ + if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE ) + { + DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation ); + return false; + } + return true; +} + Dali::Any Window::GetNativeHandle() const { return mWindowSurface->GetNativeWindow(); diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index 229d091..d630238 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -419,6 +419,11 @@ private: */ Dali::Window::WindowOrientation ConvertToOrientation( int angle ); + /** + * @brief Check available window orientation for Available orientation. + */ + bool IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const; + private: // Dali::Internal::Adaptor::SceneHolder /** diff --git a/dali/public-api/adaptor-framework/window.h b/dali/public-api/adaptor-framework/window.h index fe28f45..f60cd58 100755 --- a/dali/public-api/adaptor-framework/window.h +++ b/dali/public-api/adaptor-framework/window.h @@ -78,6 +78,11 @@ public: /** * @brief Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing. + * + * This Enumeration is used the available orientation APIs and the preferred orientation. + * + * Especially, NO_ORIENTATION_PREFERENCE only has the effect for the preferred orientation. + * It is used to unset the preferred orientation with SetPreferredOrientation. * @SINCE_1_0.0 */ enum WindowOrientation @@ -85,7 +90,8 @@ public: PORTRAIT = 0, ///< Portrait orientation. The height of the display area is greater than the width. @SINCE_1_0.0 LANDSCAPE = 90, ///< Landscape orientation. A wide view area is needed. @SINCE_1_0.0 PORTRAIT_INVERSE = 180, ///< Portrait inverse orientation @SINCE_1_0.0 - LANDSCAPE_INVERSE = 270 ///< Landscape inverse orientation @SINCE_1_0.0 + LANDSCAPE_INVERSE = 270, ///< Landscape inverse orientation @SINCE_1_0.0 + NO_ORIENTATION_PREFERENCE = -1 ///< No orientation. It is for the preferred orientation. @SINCE_1_4.51 }; /** @@ -360,6 +366,8 @@ public: * @SINCE_1_0.0 * @param[in] orientation The preferred orientation * @pre Orientation is in the list of available orientations. + * + * @note To unset the preferred orientation, orientation should be set NO_ORIENTATION_PREFERENCE. */ void SetPreferredOrientation( WindowOrientation orientation ); -- 2.7.4