Add Window-based Rotation
authorChoi Munseok <ms47.choi@samsung.com>
Sat, 23 Mar 2013 06:13:47 +0000 (15:13 +0900)
committerChoi Munseok <ms47.choi@samsung.com>
Sat, 23 Mar 2013 06:13:47 +0000 (15:13 +0900)
Change-Id: I714ff48f58d51bb5f71c7b654706c00334a00902
Signed-off-by: Choi Munseok <ms47.choi@samsung.com>
13 files changed:
src/ui/FUi_ControlImplManager.cpp
src/ui/FUi_ControlManager.cpp
src/ui/FUi_EcoreEvas.cpp
src/ui/FUi_OrientationAgent.cpp
src/ui/FUi_OrientationAgent.h
src/ui/FUi_Window.cpp
src/ui/controls/FUiCtrl_FormImpl.cpp
src/ui/controls/FUiCtrl_FrameImpl.cpp
src/ui/inc/FUiCtrl_FormImpl.h
src/ui/inc/FUiCtrl_FrameImpl.h
src/ui/inc/FUi_EcoreEvas.h
src/ui/inc/FUi_Types.h
src/ui/inc/FUi_Window.h

index 6ffd2f8..31b0ad6 100644 (file)
@@ -245,6 +245,10 @@ _ControlImplManager::GetCurrentFrame(void) const
 void
 _ControlImplManager::OnScreenRotated(int rotation)
 {
+#if defined(WINDOW_BASE_ROTATE)
+       return;
+#endif
+
        _ControlManager* pCore = _ControlManager::GetInstance();
        SysAssert(pCore);
 
index 34c2a28..bf8e9b1 100644 (file)
@@ -545,6 +545,7 @@ _ControlManager::ActivateWindow(_Window& window)
 
        if (window.IsOrientationRoot() == false)
        {
+#if !defined(WINDOW_BASE_ROTATE)
                window.ChangeLayout(GetOrientation());
 
                _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas();
@@ -552,6 +553,14 @@ _ControlManager::ActivateWindow(_Window& window)
                {
                        pEcoreEvas->RotateWindow(window, ::Convert(__orientationStatus));
                }
+#else
+               // Initialize window rotation.
+               _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas();
+               if (pEcoreEvas)
+               {
+                       pEcoreEvas->SetWindowPreferredRotation(window, ::Convert(__orientationStatus));
+               }
+#endif
        }
 
        r = window.GetControlDelegate().OnAttached();
index ae99480..f598b09 100644 (file)
@@ -90,6 +90,41 @@ Ecore_X_Atom __atomAccessibility = 0;
 
 int __clipboardHeight = 0;
 
+#if defined(WINDOW_BASE_ROTATE)
+void
+OnWindowStateChanged(Ecore_Evas* pEcoreEvas)
+{
+       _ControlManager* pControlManager = _ControlManager::GetInstance();
+       if (!pControlManager)
+       {
+               return;
+       }
+
+       Ecore_X_Window targetWin = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
+
+       SysLog(NID_UI, "[Window-based Rotation][Window : 0x%x] OnWindowStateChanged is called.", targetWin);
+
+       int winCount = pControlManager->GetWindowCount();
+       for (int i = 0; i < winCount; i++)
+       {
+               _Window* pWindow = pControlManager->GetWindow(i);
+               if (!pWindow)
+               {
+                       continue;
+               }
+
+               Ecore_X_Window win = (Ecore_X_Window)pWindow->GetNativeHandle();
+
+               if (win == targetWin)
+               {
+                       pWindow->OnWindowStateChanged();
+
+                       return;
+               }
+       }
+}
+#endif
+
 Eina_Bool
 OnWindowPropertyChanged(void* pData, int type, void* pEvent)
 {
@@ -265,6 +300,7 @@ CATCH:
 Eina_Bool
 OnWindowShown(void* pData, int type, void* pEvent)
 {
+#if !defined(WINDOW_BASE_ROTATE)
        Ecore_X_Event_Window_Show* pEv = (Ecore_X_Event_Window_Show*) pEvent;
        if (!pEv)
        {
@@ -306,44 +342,11 @@ OnWindowShown(void* pData, int type, void* pEvent)
                        }
                }
        }
+#endif
 
        return ECORE_CALLBACK_PASS_ON;
 }
 
-// [ToDo] Remove API
-/*
-void
-OnAutoRotationChanged(runtime_info_key_e key, void* pUserData)
-{
-       if (key != RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED)
-       {
-               return;
-       }
-
-       bool autoRotationLock = false;
-       int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED, &autoRotationLock);
-
-       if (ret != RUNTIME_INFO_ERROR_NONE)
-       {
-               SysLog(NID_UI, "It's failed to get the flag of auto-rotation.");
-               return;
-       }
-
-       int angle = 0;
-
-       if (autoRotationLock == false)
-       {
-               angle = app_get_device_orientation();
-       }
-
-       _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance();
-       if (pControlImplManager)
-       {
-               pControlImplManager->OnScreenRotated(angle);
-       }
-}
-*/
-
 Eina_Bool
 OnAccessibilitySettingMessageReceived(void* pData, int type, void* pEvent)
 {
@@ -441,7 +444,9 @@ namespace
 {
 #define __UNUSED__
 
+#if !defined(WINDOW_BASE_ROTATE)
 Ecore_X_Atom __atomRotateAuto = 0;
+#endif
 
 enum _ClipType
 {
@@ -1096,6 +1101,10 @@ _EcoreEvas::~_EcoreEvas(void)
 void
 _EcoreEvas::RotateWindow(const _Window& window, int orientation)
 {
+#if defined(WINDOW_BASE_ROTATE)
+       return;
+#endif
+
        _EflLayer* pLayer = GetEflLayer(window);
        if (!pLayer)
        {
@@ -1182,6 +1191,75 @@ _EcoreEvas::RotateWindow(const _Window& window, int orientation)
        }
 }
 
+#if defined(WINDOW_BASE_ROTATE)
+void
+_EcoreEvas::UpdateWindowBounds(const _Window& window)
+{
+       _EflLayer* pLayer = GetEflLayer(window);
+       if (!pLayer)
+       {
+               return;
+       }
+
+       bool fullScreen = false;
+
+       _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Window*>(&window));
+
+       if (pFrame)
+       {
+               FrameShowMode showMode = pFrame->GetShowMode();
+               if (showMode == FRAME_SHOW_MODE_FULL_SCREEN)
+               {
+                       fullScreen = true;
+               }
+       }
+
+       _Window* pWindow = const_cast<_Window*>(&window);
+
+       if (pWindow->IsLayoutChangable() == true)
+       {
+               fullScreen = true;
+       }
+
+       Evas_Object* pWinObj = pLayer->GetElmWin();
+       Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
+
+       int rootW = 0;
+       int rootH = 0;
+       ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
+
+       int rotation = ecore_evas_rotation_get(pLayer->GetEcoreEvas());
+
+       if (fullScreen == false)
+       {
+               Rectangle winBounds = _CoordinateSystemUtils::Transform(window.GetBounds());
+
+               int winX = winBounds.x;
+               int winY = winBounds.y;
+
+               switch (rotation)
+               {
+               case 270:
+                       winX = rootW - winBounds.y - winBounds.height;
+                       winY = winBounds.x;
+                       break;
+               case 90:
+                       winX = winBounds.y;
+                       winY = rootH - winBounds.x - winBounds.width;
+                       break;
+               case 180:
+                       winX = rootW - winBounds.x - winBounds.width;
+                       winY = rootH - winBounds.y - winBounds.height;
+                       break;
+               default:
+                       break;
+               }
+
+               evas_object_move(pWinObj, winX, winY);
+               evas_object_resize(pWinObj, winBounds.width, winBounds.height);
+       }
+}
+#else
 void
 _EcoreEvas::SetWindowOrientationEnabled(const _Window& window, bool enable)
 {
@@ -1211,6 +1289,7 @@ _EcoreEvas::SetWindowOrientationEnabled(const _Window& window, bool enable)
        unsigned int supportRotation = (unsigned int)enable;
        ecore_x_window_prop_card32_set(win, __atomRotateAuto, &supportRotation, 1);
 }
+#endif
 
 _EflLayer*
 _EcoreEvas::GetEflLayer(const _Window& window) const
@@ -2080,11 +2159,6 @@ _EcoreEvas::SetWindowBounds(const _Window& window, const Rectangle& bounds)
        evas_object_move(pWinObject, winX, winY);
        evas_object_resize(pWinObject, winBounds.width, winBounds.height);
 
-       SysLog(NID_UI, "The window is moved to (%d, %d) and is resized to (%d, %d) with %d degree by setting bounds." , winX, winY, winBounds.width, winBounds.height, rotate);
-
-       // [SLP]
-       //Rectangle rectangle = GetIndicatorBounds(window);
-
        SetLastResult(E_SUCCESS);
 }
 
@@ -2105,23 +2179,44 @@ _EcoreEvas::SetWindowVisibleState(const _Window& window, bool visibleState)
 void
 _EcoreEvas::SetOwner(const _Window& ownee, const _Control& owner)
 {
-       _EflLayer* pOwneeLayer = GetEflLayer(ownee);
-       SysTryReturnVoidResult(NID_UI, pOwneeLayer, E_INVALID_ARG, "[E_INVALID_ARG] The ownee doesn't have a elf layer.");
-
        _Window* pOwnerWindow = owner.GetRootWindow();
        SysTryReturnVoidResult(NID_UI, pOwnerWindow, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a root window.");
 
        _EflLayer* pOwnerLayer = GetEflLayer(*pOwnerWindow);
        SysTryReturnVoidResult(NID_UI, pOwnerLayer, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a elf layer.");
 
-       Ecore_X_Window owneeWin = (Ecore_X_Window) ecore_evas_window_get(pOwneeLayer->GetEcoreEvas());
+       _EflLayer* pOwneeLayer = GetEflLayer(ownee);
+       SysTryReturnVoidResult(NID_UI, pOwneeLayer, E_INVALID_ARG, "[E_INVALID_ARG] The ownee doesn't have a elf layer.");
+
        Ecore_X_Window ownerWin = (Ecore_X_Window) ecore_evas_window_get(pOwnerLayer->GetEcoreEvas());
+       Ecore_X_Window owneeWin = (Ecore_X_Window) ecore_evas_window_get(pOwneeLayer->GetEcoreEvas());
 
        ecore_x_icccm_transient_for_unset(owneeWin);
        ecore_x_icccm_transient_for_set(owneeWin, ownerWin);
 
+#if !defined(WINDOW_BASE_ROTATE)
        int rotation = GetWindowRotation(*pOwnerWindow);
        RotateWindow(ownee, rotation);
+#else
+       int* rotations = null;
+       unsigned int count = 0;
+       Eina_Bool ret = ecore_evas_wm_rotation_available_rotations_get(pOwnerLayer->GetEcoreEvas(), &rotations, &count);
+
+       if (ret)
+       {
+               if (rotations)
+               {
+                       SetWindowPreferredRotation(ownee, -1);
+                       SetWindowAvailabledRotation(ownee, rotations, count);
+                       free(rotations);
+               }
+       }
+       else
+       {
+               int preferredRotation = ecore_evas_wm_rotation_preferred_rotation_get(pOwnerLayer->GetEcoreEvas());
+               SetWindowPreferredRotation(ownee, preferredRotation);
+       }
+#endif
 
        SetLastResult(E_SUCCESS);
 }
@@ -2139,6 +2234,48 @@ _EcoreEvas::GetWindowRotation(const _Window& window)
        return rotation;
 }
 
+#if defined(WINDOW_BASE_ROTATE)
+void
+_EcoreEvas::SetWindowPreferredRotation(const _Window& window, int rotation)
+{
+       _EflLayer* pLayer = GetEflLayer(window);
+       if (!pLayer)
+       {
+               return;
+       }
+
+       Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
+       SysLog(NID_UI, "[Window-based Rotation][Window : 0x%x] Set window preferred rotation(%d).", win, rotation);
+       ecore_evas_wm_rotation_preferred_rotation_set(pLayer->GetEcoreEvas(), rotation);
+}
+
+void
+_EcoreEvas::SetWindowAvailabledRotation(const _Window& window, int* rotations, unsigned int count)
+{
+       _EflLayer* pLayer = GetEflLayer(window);
+       if (!pLayer)
+       {
+               return;
+       }
+
+       Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
+       SysLog(NID_UI, "[Window-based Rotation][Window : 0x%x] Set window available rotation(%d).", win, count);
+       ecore_evas_wm_rotation_available_rotations_set(pLayer->GetEcoreEvas(), rotations, count);
+}
+
+void
+_EcoreEvas::RegisterWindowStateCallback(const _Window& window)
+{
+       _EflLayer* pLayer = GetEflLayer(window);
+       if (!pLayer)
+       {
+               return;
+       }
+
+       ecore_evas_callback_state_change_set(pLayer->GetEcoreEvas(), OnWindowStateChanged);
+}
+#endif
+
 // [ToDo] Remove API
 const _Control*
 _EcoreEvas::GetFrame(void) const
index e012783..56242fd 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <unique_ptr.h>
+#include <app.h>
 #include <FBaseSysLog.h>
 #include <FBaseColArrayList.h>
 #include "FUi_OrientationAgent.h"
@@ -76,6 +77,9 @@ _OrientationAgent::_OrientationAgent(Control& publicControl)
        , __firePublicEvent(false)
        , __statusChanged(false)
        , __updateStatus(true)
+#if defined(WINDOW_BASE_ROTATE)
+       , __draw(false)
+#endif
 {
        _PublicOrientationEvent* pPublicEvent = _PublicOrientationEvent::CreateInstanceN(publicControl);
 
@@ -145,6 +149,99 @@ _OrientationAgent::SetMode(Orientation mode)
 void
 _OrientationAgent::Update(bool draw)
 {
+#if defined(WINDOW_BASE_ROTATE)
+       _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
+       SysAssert(pImplManager);
+
+       _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl);
+       if (!pImpl)
+       {
+               return;
+       }
+
+       // Set window rotation.
+       _Form* pForm = dynamic_cast<_Form*>(&(pImpl->GetCore()));
+       if (pForm)
+       {
+               _Control* pParent = pForm->GetParent();
+               if (pParent)
+               {
+                       _Form* pCurrentForm = null;
+                       int childCount = pParent->GetChildCount();
+                       
+                       for (int i = childCount; i > 0; i--)
+                       {
+                               _Control* pChild = pParent->GetChild(i - 1);
+                       
+                               _Form* pChildForm = dynamic_cast<_Form*>(pChild);
+                               if (pChildForm)
+                               {
+                                       if (pChildForm->IsVisible())
+                                       {
+                                               pCurrentForm = pChildForm;
+
+                                               break;
+                                       }
+                               }
+                       }
+
+                       // Current Form
+                       if (pCurrentForm == pForm)
+                       {
+                               _Window* pWindow = pForm->GetRootWindow();
+                               if (pWindow)
+                               {
+                                       Rectangle bounds = pWindow->GetBounds();
+                                       SysLog(NID_UI, "[Window-based Rotation][Window : 0x%x, %d, %d, %d, %d, Form] Set window rotation with mode(%d).", 
+                                               pWindow->GetNativeHandle(), bounds.x, bounds.y, bounds.width, bounds.height, __mode);
+                                       SetRotation(*pWindow, __mode);
+                               }
+
+                               int owneeCount = pForm->GetOwneeCount();
+                               for (int i = 0; i < owneeCount; i++)
+                               {
+                                       _Window* pOwnee = pForm->GetOwnee(i);
+                       
+                                       if (pOwnee)
+                                       {
+                                               SetRotation(*pOwnee, __mode);
+                                       }
+                               }
+                       }
+               }
+       }
+       else
+       {
+               _Frame* pFrame = dynamic_cast<_Frame*>(&(pImpl->GetCore()));
+
+               if (pFrame)
+               {
+                       // Frame which has no forms
+                       int childCount = pFrame->GetChildCount();
+                       if (childCount == 0)
+                       {
+                               Rectangle bounds = pFrame->GetBounds();
+                               SysLog(NID_UI, "[Window-based Rotation][Window : 0x%x, %d, %d, %d, %d, Frame] Set window rotation with mode(%d).", 
+                                       pFrame->GetNativeHandle(), bounds.x, bounds.y, bounds.width, bounds.height, __mode);
+                               SetRotation(*pFrame, __mode);
+
+                               int owneeCount = pFrame->GetOwneeCount();
+                               
+                               for (int i = 0; i < owneeCount; i++)
+                               {
+                                       _Window* pOwnee = pFrame->GetOwnee(i);
+
+                                       if (pOwnee)
+                                       {
+                                               SetRotation(*pOwnee, __mode);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       __draw = draw;
+#else          
        _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
        SysAssert(pImplManager);
 
@@ -251,7 +348,89 @@ _OrientationAgent::Update(bool draw)
        // Despite not changing status, it needs to rotate screen.
        _ControlImpl* pControlImpl = _ControlImpl::GetInstance(__publicControl);
        pImplManager->RotateScreen(pControlImpl, status);
+#endif
+}
+
+#if defined(WINDOW_BASE_ROTATE)
+void
+_OrientationAgent::UpdateOrientation(void)
+{
+       _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+       if (!pEcoreEvas)
+       {
+               return;
+       }
+
+       _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl);
+       if (!pImpl)
+       {
+               return;
+}
+
+       int rotation = pEcoreEvas->GetWindowRotation(*(pImpl->GetCore().GetRootWindow()));
+
+       // Update evas objects.
+       OrientationStatus status = ORIENTATION_STATUS_NONE;
+       switch (rotation)
+       {
+       case 0:
+               status = ORIENTATION_STATUS_PORTRAIT;
+               break;
+       case 270:
+               status = ORIENTATION_STATUS_LANDSCAPE;
+               break;
+       case 180:
+               status = ORIENTATION_STATUS_PORTRAIT_REVERSE;
+               break;
+       case 90:
+               status = ORIENTATION_STATUS_LANDSCAPE_REVERSE;
+               break;
+       default:
+               break;
+       }
+
+       if (__updateStatus == true)
+       {
+               __statusChanged = false;
+               if (__status != status)
+               {
+                       __statusChanged = true;
+                       __updateStatus = false;
+               }
+       }
+
+       __status = status;
+
+       pEcoreEvas->AllowSetWindowBounds(false);
+       FireEvent(status);
+       pEcoreEvas->AllowSetWindowBounds(true);
+
+       // For the form to be made by Ui-Builder
+       if ((__draw == true) && (__statusChanged == true))
+       {
+               _ControlOrientation coreOrientation =
+                       (status == ORIENTATION_STATUS_PORTRAIT || status == ORIENTATION_STATUS_PORTRAIT_REVERSE) ?
+                       _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE;
+
+               Rectangle temp;
+               bool exist = pImpl->GetBuilderBounds(coreOrientation, temp);
+               if (exist)
+               {
+                       pImpl->Invalidate(true);
+               }
+       }
+
+       _Window* pRootWindow = pImpl->GetCore().GetRootWindow();
+       if (pRootWindow)
+       {
+               pEcoreEvas->UpdateWindowBounds(*pRootWindow);
+               
+               Rectangle bounds = pRootWindow->GetBounds();
+               SysLog(NID_UI, "[Window-based Rotation][Window : 0x%x, %d, %d, %d, %d] Update evas objects to %d degree.", 
+                       pRootWindow->GetNativeHandle(), bounds.x, bounds.y, bounds.width, bounds.height, rotation);
+       }
 }
+#endif
 
 void
 _OrientationAgent::RequestOrientationEvent(void)
@@ -326,6 +505,7 @@ _OrientationAgent::FireEvent(OrientationStatus status)
        pImplManager->SetOrientationStatus(status);
        pImpl->GetCore().ChangeLayout(coreOrientation);
 
+#if !defined(WINDOW_BASE_ROTATE)
        // Ownee
        int owneeCount = pImpl->GetCore().GetOwneeCount();
        for (int i = 0; i < owneeCount; i++)
@@ -337,6 +517,7 @@ _OrientationAgent::FireEvent(OrientationStatus status)
                        pOwnee->ChangeLayout(coreOrientation);
                }
        }
+#endif
 
        // Public
        if (__firePublicEvent && __statusChanged)
@@ -348,4 +529,102 @@ _OrientationAgent::FireEvent(OrientationStatus status)
        }
 }
 
+#if defined(WINDOW_BASE_ROTATE)
+void
+_OrientationAgent::SetRotation(const _Window& window, Orientation orientation)
+{
+       _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+       if (!pEcoreEvas)
+       {
+               return;
+       }
+
+       int deviceOrientation = app_get_device_orientation();
+       int windowRotation = pEcoreEvas->GetWindowRotation(window);
+
+       bool callback = true;
+
+       // Decide updating orientation forcibly.
+       switch (orientation)
+       {
+       case ORIENTATION_PORTRAIT:
+               pEcoreEvas->SetWindowPreferredRotation(window, 0);
+               
+               if ((deviceOrientation == 0) || (windowRotation == 0))
+               {
+                       callback = false;
+               }
+               
+               break;
+       case ORIENTATION_LANDSCAPE:
+               pEcoreEvas->SetWindowPreferredRotation(window, 270);
+               
+               if ((deviceOrientation == 270) || (windowRotation == 270))
+               {
+                       callback = false;
+               }
+               
+               break;
+       case ORIENTATION_PORTRAIT_REVERSE:
+               pEcoreEvas->SetWindowPreferredRotation(window, 180);
+               
+               if ((deviceOrientation == 180) || (windowRotation == 180))
+               {
+                       callback = false;
+               }
+               
+               break;
+       case ORIENTATION_LANDSCAPE_REVERSE:
+               pEcoreEvas->SetWindowPreferredRotation(window, 90);
+               
+               if ((deviceOrientation == 90) || (windowRotation == 90))
+               {
+                       callback = false;
+               }
+               
+               break;
+       case ORIENTATION_AUTOMATIC:
+               {
+                       pEcoreEvas->SetWindowPreferredRotation(window, -1);
+
+                       int autoRotation[3] = {0, 90, 270};
+                       pEcoreEvas->SetWindowAvailabledRotation(window, autoRotation, 3);
+
+                       if (deviceOrientation == windowRotation)
+                       {
+                               callback = false;
+                       }
+                       else
+                       {
+                               if (deviceOrientation == 180)
+                               {
+                                       callback = false;
+                               }
+                       }
+               }
+               break;
+       case ORIENTATION_AUTOMATIC_FOUR_DIRECTION:
+               {
+                       pEcoreEvas->SetWindowPreferredRotation(window, -1);
+
+                       int autoFourRotation[4] = {0, 90, 180, 270};
+                       pEcoreEvas->SetWindowAvailabledRotation(window, autoFourRotation, 4);
+
+                       if (deviceOrientation == windowRotation)
+                       {
+                               callback = false;
+                       }
+               }
+               break;
+       default:
+               break;
+       }
+
+       if (callback == false)
+       {
+               UpdateOrientation();
+       }
+}
+#endif
+
 }} // Tizen::Ui
index d5ab49b..e858eec 100644 (file)
@@ -33,6 +33,10 @@ namespace Tizen { namespace Ui
 
 class _PublicOrientationEvent;
 
+#if defined(WINDOW_BASE_ROTATE)
+class _Window;
+#endif
+
 class _OrientationAgent
 {
 public:
@@ -45,13 +49,20 @@ public:
        Orientation GetMode(void) const;
        OrientationStatus GetStatus(void) const;
        void SetMode(Orientation orientation);
+
        void Update(bool draw = false);
+#if defined(WINDOW_BASE_ROTATE)
+       void UpdateOrientation(void);
+#endif
 
        void RequestOrientationEvent(void);
        void FireOrientationEvent(void);
 
 private:
        void FireEvent(OrientationStatus status);
+#if defined(WINDOW_BASE_ROTATE)
+       void SetRotation(const _Window& window, Orientation orientation);
+#endif
 
        _OrientationAgent(Control& publicControl);
 
@@ -66,6 +77,9 @@ private:
        bool __firePublicEvent;
        bool __statusChanged;
        bool __updateStatus;
+#if defined(WINDOW_BASE_ROTATE)
+       bool __draw;
+#endif
 }; // _OrientationAgent
 
 }} // Tizen::Ui
index 0443548..41f711a 100644 (file)
 #include "FUi_EcoreEvas.h"
 #include "FUiAnim_DisplayManager.h"
 #include "FUiAnim_EflLayer.h"
+#include "FUiCtrl_Form.h"
+#include "FUiCtrl_FormImpl.h"
+#include "FUiCtrl_FrameImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui::Animations;
+using namespace Tizen::Ui::Controls;
 
 namespace Tizen { namespace Ui
 {
@@ -255,7 +259,12 @@ _Window::CreateRootVisualElement(void)
 
        _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
        SysAssert(pEcoreEvas);
+#if !defined(WINDOW_BASE_ROTATE)
        pEcoreEvas->SetWindowOrientationEnabled(*this, false);
+#else
+       __rotation = pEcoreEvas->GetWindowRotation(*this);
+       pEcoreEvas->RegisterWindowStateCallback(*this);
+#endif
 
        // Get visual element.
        _VisualElement* pVisualElement = GetVisualElement();
@@ -293,9 +302,6 @@ _Window::CreateLayer(void)
 
        __pRootVisualElement->SetName(L"Root");
 
-       //Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
-       //SysLog(NID_UI, "[Multi_Window] create x window(0x%x)", win);
-
        return E_SUCCESS;
 }
 
@@ -329,6 +335,7 @@ _Window::IsActivationEnabled(void)
        return enable;
 }
 
+#if !defined(WINDOW_BASE_ROTATE)
 void
 _Window::SetOrientationEnabled(bool enable)
 {
@@ -340,6 +347,7 @@ _Window::IsOrientationEnabled(void)
 {
        return __orientationEnabled;
 }
+#endif
 
 _RootVisualElement*
 _Window::GetRootVisualElement(void) const
@@ -503,6 +511,66 @@ _Window::OnDetachingFromMainTree(void)
        return E_SUCCESS;
 }
 
+#if defined(WINDOW_BASE_ROTATE)
+void
+_Window::OnWindowStateChanged(void)
+{
+       _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+       if (!pEcoreEvas)
+       {
+               return;
+       }
+
+       int rotation = pEcoreEvas->GetWindowRotation(*this);
+
+       Rectangle bounds = GetBounds();
+       SysLog(NID_UI, "[Window-based Rotation][Window : 0x%x, %d, %d, %d, %d] OnWindowStateChanged is called with prev rotation(__rotation) and cur rotation(rotation)", 
+               GetNativeHandle(), bounds.x, bounds.y, bounds.width, bounds.height, __rotation, rotation);
+
+       if (__rotation != rotation)
+       {
+               __rotation = rotation;
+
+               int childCount = GetChildCount();
+               for (int i = childCount; i > 0; i--)
+               {
+                       _Control* pChild = GetChild(i - 1);
+                       
+                       _Form* pForm = dynamic_cast<_Form*>(pChild);
+                       if (pForm)
+                       {
+                               if (pForm->IsVisible())
+                               {
+                                       // Current Form
+                                       _FormImpl* pFormImpl = static_cast<_FormImpl*>(pForm->GetUserData());
+                                       if (pFormImpl)
+                                       {
+                                               pFormImpl->UpdateOrientation();
+                                       }
+
+                                       return;
+                               }
+                       }
+               }
+
+               if (IsOrientationRoot())
+               {
+                       _FrameImpl* pFrameImpl = static_cast<_FrameImpl*>(GetUserData());
+                       if (pFrameImpl)
+                       {
+                               pFrameImpl->UpdateOrientation();
+                       }
+               }
+               else
+               {
+                       _ControlOrientation controlOrientation = (rotation == 0 || rotation == 180) ? _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE;
+                       ChangeLayout(controlOrientation);
+                       pEcoreEvas->UpdateWindowBounds(*this);
+               }
+       }
+}
+#endif
+
 bool
 _Window::IsLayoutChangable(void) const
 {
@@ -577,8 +645,12 @@ _Window::_Window()
        , __isOpened(false)
        , __isInitialized(false)
        , __pFocusedControl(null)
-       , __orientationEnabled(false)
        , __transient(true)
+#if !defined(WINDOW_BASE_ROTATE)
+       , __orientationEnabled(false)
+#else
+       , __rotation(0)
+#endif
 {
        SetControlDelegate(*this);
        SetWindowDelegate(*this);
index a4e8553..095e044 100644 (file)
@@ -908,6 +908,14 @@ _FormImpl::UpdateOrientationStatus(bool draw)
        __pOriAgent->Update(draw);
 }
 
+#if defined(WINDOW_BASE_ROTATE)
+void
+_FormImpl::UpdateOrientation(void)
+{
+       __pOriAgent->UpdateOrientation();
+}
+#endif
+
 bool
 _FormImpl::HasOptionkey(void) const
 {
index 85eb087..3ac4e83 100644 (file)
@@ -528,6 +528,14 @@ _FrameImpl::UpdateOrientationStatus(void)
        __pOrientationAgent->Update();
 }
 
+#if defined(WINDOW_BASE_ROTATE)
+void
+_FrameImpl::UpdateOrientation(void)
+{
+       __pOrientationAgent->UpdateOrientation();
+}
+#endif
+
 bool
 _FrameImpl::IsOpaque(void) const
 {
index a4988ec..e8ff97c 100644 (file)
@@ -120,6 +120,9 @@ public:
        Tizen::Ui::Orientation GetOrientation(void) const;
        Tizen::Ui::OrientationStatus GetOrientationStatus(void) const;
        void UpdateOrientationStatus(bool draw = false);
+#if defined(WINDOW_BASE_ROTATE)
+       void UpdateOrientation(void);
+#endif
 
        // Invoked by operations
        virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
index 2e858c3..b484034 100644 (file)
@@ -68,6 +68,9 @@ public:
        Tizen::Ui::OrientationStatus GetOrientationStatus(void) const;
        void SetOrientation(Tizen::Ui::Orientation orientation);
        void UpdateOrientationStatus(void);
+#if defined(WINDOW_BASE_ROTATE)
+       void UpdateOrientation(void);
+#endif
 
 // Callback
        virtual void OnDraw(void);
index cb1948f..3cd4036 100644 (file)
@@ -106,9 +106,18 @@ public:
 
        void ActivateWindow(const _Window& window);
        void MinimizeWindow(_Window& window);
+
        void RotateWindow(const _Window& window, int orientation);
-       void SetWindowOrientationEnabled(const _Window& window, bool enable);
        int GetWindowRotation(const _Window& window);
+#if defined(WINDOW_BASE_ROTATE)
+       void UpdateWindowBounds(const _Window& window);
+       void SetWindowPreferredRotation(const _Window& window, int rotation);
+       void SetWindowAvailabledRotation(const _Window& window, int* rotations, unsigned int count);
+       void RegisterWindowStateCallback(const _Window& window);
+#else
+       void SetWindowOrientationEnabled(const _Window& window, bool enable);
+#endif
+
        result SetFloatingMode(const _Window& window, bool enable);
        bool GetFloatingMode(const _Window& window) const;
        void SetWindowActivationEnabled(const _Window& window, bool enable);
index 671ce4e..0c2e2af 100644 (file)
@@ -24,6 +24,7 @@
 #include <FBase_ObjectManagerT.h>
 
 #define MULTI_WINDOW
+//#define WINDOW_BASE_ROTATE
 
 namespace Tizen { namespace Ui
 {
index aaf9101..31b0ff3 100644 (file)
@@ -87,13 +87,16 @@ public:
        virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds);
        virtual result OnAttachingToMainTree(const _Control* pParent);
        virtual result OnDetachingFromMainTree(void);
+#if defined(WINDOW_BASE_ROTATE)
+       void OnWindowStateChanged(void);
+#else
+       void SetOrientationEnabled(bool enable);
+       bool IsOrientationEnabled(void);
+#endif
 
        void SetActivationEnabled(bool enable);
        bool IsActivationEnabled(void);
 
-       void SetOrientationEnabled(bool enable);
-       bool IsOrientationEnabled(void);
-
        Tizen::Ui::Animations::_RootVisualElement* GetRootVisualElement(void) const;
        NativeWindowHandle GetNativeHandle(void) const;
 
@@ -137,8 +140,12 @@ private:
        bool __isOpened;
        bool __isInitialized;
        _Control* __pFocusedControl;
-       bool __orientationEnabled;
        bool __transient;
+#if !defined(WINDOW_BASE_ROTATE)
+       bool __orientationEnabled;
+#else
+       int __rotation;
+#endif
 
        friend class _ControlManager;
 }; // _Window