From: keonpyo.kong Date: Wed, 8 May 2013 09:00:39 +0000 (+0900) Subject: Modify GetUiBuilderOrientation X-Git-Tag: submit/tizen_2.1/20130514.054411~39^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28ff80e4d6ce22b0dca0c77cef2c0e6022b7c7d8;p=framework%2Fosp%2Fuifw.git Modify GetUiBuilderOrientation Change-Id: I3487b42825066c64c8649cb920f26f3d1bcde142 Signed-off-by: keonpyo.kong apply code review Change-Id: I71770c904f4ea7eefd1f1bdc362e2cf9e62545cd Signed-off-by: keonpyo.kong apply code review2 Change-Id: I01069b90f3f47406cde99b101be509a5d8a5f305 Signed-off-by: keonpyo.kong --- diff --git a/src/ui/FUi_ControlImpl.cpp b/src/ui/FUi_ControlImpl.cpp index 3779441..cc7f28c 100644 --- a/src/ui/FUi_ControlImpl.cpp +++ b/src/ui/FUi_ControlImpl.cpp @@ -53,6 +53,7 @@ #include "FUi_WindowImpl.h" #include "FUiAnim_VisualElement.h" #include "FUiAnim_VisualElementImpl.h" +#include "FUiCtrl_Popup.h" //#define _TC_PASS @@ -63,6 +64,7 @@ using namespace Tizen::Graphics; using namespace Tizen::Ui::Animations; using namespace Tizen::App; using namespace Tizen::Base::Utility; +using namespace Tizen::Ui::Controls; namespace Tizen { namespace Ui { @@ -3572,49 +3574,94 @@ _ControlImpl::GetSizeF(void) const return GetCore().GetSizeF(); } -void -_ControlImpl::UpdateBuilderBounds(const Tizen::Graphics::FloatRectangle& bounds) +_ControlOrientation +_ControlImpl::GetUiBuilderOrientation(void) const { - FloatRectangle builderBounds; _ControlOrientation controlOrientation = _CONTROL_ORIENTATION_PORTRAIT; - bool exist = GetBuilderBoundsF(controlOrientation, builderBounds); - if (exist) + + _Window* pWindow = GetCore().GetRootWindow(); + if (!pWindow) { - if (IsAttachedToMainTree()) + return controlOrientation; + } + + _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance(); + if (!pControlImplManager) + { + return controlOrientation; + } + + if (pWindow->IsOrientationRoot()) + { + // Frame + OrientationStatus status = pControlImplManager->GetFormOrientationStatus(this); + + if ((status == ORIENTATION_STATUS_LANDSCAPE) || (status == ORIENTATION_STATUS_LANDSCAPE_REVERSE)) { - _Window* pWindow = GetCore().GetRootWindow(); - if (pWindow->IsOrientationRoot()) - { - // Frame - _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance(); - OrientationStatus orientationStatus = pControlImplManager->GetFormOrientationStatus(this); + controlOrientation = _CONTROL_ORIENTATION_LANDSCAPE; + } + else + { + controlOrientation = _CONTROL_ORIENTATION_PORTRAIT; + } + } + else + { + // Ownee Window + bool owner = false; - if ((orientationStatus == ORIENTATION_STATUS_LANDSCAPE) || (orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)) - { - controlOrientation = _CONTROL_ORIENTATION_LANDSCAPE; - } - else - { - controlOrientation = _CONTROL_ORIENTATION_PORTRAIT; - } - } - else + Tizen::Ui::Controls::_Popup* pPopup = dynamic_cast(pWindow); + if (pPopup) + { + if (pWindow->IsOrientationCallbackModeEnabled() == false) { - // Window - controlOrientation = GetCore().GetOrientation(); + owner = true; } + } - if (controlOrientation == _CONTROL_ORIENTATION_LANDSCAPE) - { - SetBuilderBounds(_CONTROL_ORIENTATION_LANDSCAPE, bounds); - } - else + if (owner) + { + _Control* pOwner = pWindow->GetOwner(); + if (pOwner) { - SetBuilderBounds(_CONTROL_ORIENTATION_PORTRAIT, bounds); + _ControlImpl* pControlImpl = static_cast<_ControlImpl*>(pOwner->GetUserData()); + if (pControlImpl) + { + OrientationStatus status = pControlImplManager->GetFormOrientationStatus(pControlImpl); + if ((status == ORIENTATION_STATUS_LANDSCAPE) || (status == ORIENTATION_STATUS_LANDSCAPE_REVERSE)) + { + controlOrientation = _CONTROL_ORIENTATION_LANDSCAPE; + } + else + { + controlOrientation = _CONTROL_ORIENTATION_PORTRAIT; + } + } } } else { + controlOrientation = GetCore().GetOrientation(); + } + } + + return controlOrientation; +} + +void +_ControlImpl::UpdateBuilderBounds(const Tizen::Graphics::FloatRectangle& bounds) +{ + FloatRectangle builderBounds; + _ControlOrientation controlOrientation = GetUiBuilderOrientation(); + bool exist = GetBuilderBoundsF(controlOrientation, builderBounds); + if (exist) + { + if (IsAttachedToMainTree()) + { + SetBuilderBounds(controlOrientation, bounds); + } + else + { SetBuilderBounds(_CONTROL_ORIENTATION_PORTRAIT, bounds); SetBuilderBounds(_CONTROL_ORIENTATION_LANDSCAPE, bounds); } @@ -3625,7 +3672,7 @@ void _ControlImpl::UpdateBuilderSize(const Tizen::Graphics::FloatDimension& dimension) { FloatRectangle builderBounds; - _ControlOrientation controlOrientation = GetCore().GetOrientation(); + _ControlOrientation controlOrientation = GetUiBuilderOrientation(); bool exist = GetBuilderBoundsF(controlOrientation, builderBounds); if (exist) @@ -3636,6 +3683,21 @@ _ControlImpl::UpdateBuilderSize(const Tizen::Graphics::FloatDimension& dimension } } +void +_ControlImpl::UpdateBuilderPosition(const FloatPoint& position) +{ + FloatRectangle builderBounds; + _ControlOrientation controlOrientation = GetUiBuilderOrientation(); + + bool exist = GetBuilderBoundsF(controlOrientation, builderBounds); + if (exist) + { + builderBounds.x = position.x; + builderBounds.y = position.y; + UpdateBuilderBounds(builderBounds); + } +} + result _ControlImpl::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks) { @@ -3675,12 +3737,14 @@ _ControlImpl::SetBoundsAndUpdateLayoutF(const Tizen::Graphics::FloatRectangle& b result _ControlImpl::SetPosition(const Point& position) { + UpdateBuilderPosition(_CoordinateSystemUtils::ConvertToFloat(position)); return GetCore().SetPosition(position); } result _ControlImpl::SetPosition(const FloatPoint& position) { + UpdateBuilderPosition(position); return GetCore().SetPosition(position); } diff --git a/src/ui/FUi_ControlImplManager.cpp b/src/ui/FUi_ControlImplManager.cpp index 36d85f3..c3de664 100644 --- a/src/ui/FUi_ControlImplManager.cpp +++ b/src/ui/FUi_ControlImplManager.cpp @@ -348,15 +348,16 @@ _ControlImplManager::GetOrientationStatus(Orientation mode) const } OrientationStatus -_ControlImplManager::GetFormOrientationStatus(_ControlImpl* pControlImpl) +_ControlImplManager::GetFormOrientationStatus(const _ControlImpl* pControlImpl) const { - _FormImpl* pParentImpl = null; + const _FormImpl* pFormImpl = null; OrientationStatus orientation = ORIENTATION_STATUS_NONE; + while(pControlImpl) { - pParentImpl = dynamic_cast<_FormImpl*>(pControlImpl->GetParent()); + pFormImpl = dynamic_cast(pControlImpl); - if (pParentImpl != null) + if (pFormImpl) { break; } @@ -366,9 +367,9 @@ _ControlImplManager::GetFormOrientationStatus(_ControlImpl* pControlImpl) } } - if (pParentImpl) + if (pFormImpl) { - orientation = pParentImpl->GetOrientationStatus(); + orientation = pFormImpl->GetOrientationStatus(); } return orientation; diff --git a/src/ui/FUi_Window.cpp b/src/ui/FUi_Window.cpp index 14f13f2..26a0496 100644 --- a/src/ui/FUi_Window.cpp +++ b/src/ui/FUi_Window.cpp @@ -765,6 +765,7 @@ _Window::_Window() #endif , __preferredRotation(false) #endif + , __orientationCallbackMode(false) { SetControlDelegate(*this); SetWindowDelegate(*this); @@ -864,4 +865,16 @@ _Window::GetDimmingLayer(void) return __pDimmingLayer; } +void +_Window::SetOrientationCallbackModeEnabled(bool enable) +{ + __orientationCallbackMode = enable; +} + +bool +_Window::IsOrientationCallbackModeEnabled(void) const +{ + return __orientationCallbackMode; +} + }} // Tizen::Ui diff --git a/src/ui/controls/FUiCtrl_Popup.cpp b/src/ui/controls/FUiCtrl_Popup.cpp index 0974366..6b02ca6 100644 --- a/src/ui/controls/FUiCtrl_Popup.cpp +++ b/src/ui/controls/FUiCtrl_Popup.cpp @@ -580,5 +580,15 @@ _Popup::IsRotationSynchronized(void) const return true; } +void +_Popup::OnWindowStateChanged(void) +{ + SetOrientationCallbackModeEnabled(true); + + _Window::OnWindowStateChanged(); + + SetOrientationCallbackModeEnabled(false); +} + }}} // Tizen::Ui::Controls diff --git a/src/ui/inc/FUiCtrl_Popup.h b/src/ui/inc/FUiCtrl_Popup.h index 11059a4..7906aa9 100644 --- a/src/ui/inc/FUiCtrl_Popup.h +++ b/src/ui/inc/FUiCtrl_Popup.h @@ -107,6 +107,8 @@ public: virtual void UpdateClientBounds(const Tizen::Graphics::FloatDimension& size, Tizen::Graphics::FloatRectangle& clientBounds); virtual bool IsRotationSynchronized(void) const; + virtual void OnWindowStateChanged(void); + // Accessor public: void SetColor(const Tizen::Graphics::Color& color); diff --git a/src/ui/inc/FUi_ControlImpl.h b/src/ui/inc/FUi_ControlImpl.h index 0feb77a..adee9ce 100644 --- a/src/ui/inc/FUi_ControlImpl.h +++ b/src/ui/inc/FUi_ControlImpl.h @@ -318,6 +318,8 @@ public: result SetBuilderBounds(_ControlOrientation orientation, const Tizen::Graphics::FloatRectangle& bounds); void UpdateBuilderBounds(const Tizen::Graphics::FloatRectangle& bounds); void UpdateBuilderSize(const Tizen::Graphics::FloatDimension& dimension); + void UpdateBuilderPosition(const Tizen::Graphics::FloatPoint& position); + _ControlOrientation GetUiBuilderOrientation(void) const; // Layout bool IsLayoutable(void) const; diff --git a/src/ui/inc/FUi_ControlImplManager.h b/src/ui/inc/FUi_ControlImplManager.h index ae7e1e4..2010b9d 100644 --- a/src/ui/inc/FUi_ControlImplManager.h +++ b/src/ui/inc/FUi_ControlImplManager.h @@ -49,7 +49,7 @@ public: _WindowImpl* GetCurrentFrame(void) const; void OnScreenRotated(int rotation); - OrientationStatus GetFormOrientationStatus(_ControlImpl *pControlImpl); + OrientationStatus GetFormOrientationStatus(const _ControlImpl *pControlImpl) const; OrientationStatus GetOrientationStatus(Orientation mode) const; private: diff --git a/src/ui/inc/FUi_Window.h b/src/ui/inc/FUi_Window.h index 7c54b82..89e2b65 100644 --- a/src/ui/inc/FUi_Window.h +++ b/src/ui/inc/FUi_Window.h @@ -100,7 +100,7 @@ public: virtual result OnDetachingFromMainTree(void); virtual void OnFocusableStateChanged(bool focusalbeState); #if defined(WINDOW_BASE_ROTATE) - void OnWindowStateChanged(void); + virtual void OnWindowStateChanged(void); void SetPreferredRotation(bool enable); bool GetPreferredRotation(void) const; #if defined(WINDOW_OWNEE_PREFERRED) @@ -136,6 +136,9 @@ public: void SetDimmingLayer(_DimmingLayer* pLayer); _DimmingLayer* GetDimmingLayer(void); + void SetOrientationCallbackModeEnabled(bool enable); + bool IsOrientationCallbackModeEnabled(void) const; + protected: _Window(void); _IWindowDelegate& GetWindowDelegate(void) const; @@ -183,6 +186,8 @@ private: bool __preferredRotation; #endif + bool __orientationCallbackMode; + friend class _ControlManager; }; // _Window