Modify GetUiBuilderOrientation
authorkeonpyo.kong <keonpyo.kong@samsung.com>
Wed, 8 May 2013 09:00:39 +0000 (18:00 +0900)
committerkeonpyo.kong <keonpyo.kong@samsung.com>
Wed, 8 May 2013 10:39:06 +0000 (19:39 +0900)
Change-Id: I3487b42825066c64c8649cb920f26f3d1bcde142
Signed-off-by: keonpyo.kong <keonpyo.kong@samsung.com>
apply code review

Change-Id: I71770c904f4ea7eefd1f1bdc362e2cf9e62545cd
Signed-off-by: keonpyo.kong <keonpyo.kong@samsung.com>
apply code review2

Change-Id: I01069b90f3f47406cde99b101be509a5d8a5f305
Signed-off-by: keonpyo.kong <keonpyo.kong@samsung.com>
src/ui/FUi_ControlImpl.cpp
src/ui/FUi_ControlImplManager.cpp
src/ui/FUi_Window.cpp
src/ui/controls/FUiCtrl_Popup.cpp
src/ui/inc/FUiCtrl_Popup.h
src/ui/inc/FUi_ControlImpl.h
src/ui/inc/FUi_ControlImplManager.h
src/ui/inc/FUi_Window.h

index 3779441..cc7f28c 100644 (file)
@@ -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<Tizen::Ui::Controls::_Popup*>(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);
 }
 
index 36d85f3..c3de664 100644 (file)
@@ -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<const _FormImpl*>(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;
index 14f13f2..26a0496 100644 (file)
@@ -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
index 0974366..6b02ca6 100644 (file)
@@ -580,5 +580,15 @@ _Popup::IsRotationSynchronized(void) const
        return true;
 }
 
+void
+_Popup::OnWindowStateChanged(void)
+{
+       SetOrientationCallbackModeEnabled(true);
+       
+       _Window::OnWindowStateChanged();
+
+       SetOrientationCallbackModeEnabled(false);
+}
+
 }}} // Tizen::Ui::Controls
 
index 11059a4..7906aa9 100644 (file)
@@ -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);
index 0feb77a..adee9ce 100644 (file)
@@ -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;
index ae7e1e4..2010b9d 100644 (file)
@@ -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:
index 7c54b82..89e2b65 100644 (file)
@@ -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