Fixed to decide the position of the mini App
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Frame.cpp
index 6cc5b56..e318c02 100644 (file)
@@ -61,6 +61,7 @@ _Frame::_Frame(void)
        : __pFramePresenter(null)
        , __pFrameEvent(null)
        , __floatingBounds(0.0f, 0.0f, 0.0f, 0.0f)
+       , __floatingOrientation(_CONTROL_ORIENTATION_PORTRAIT)
        , __showMode(FRAME_SHOW_MODE_FULL_SCREEN)
        , __restore(false)
        , __minimized(false)
@@ -448,6 +449,15 @@ _Frame::SetFloatingBounds(const Rectangle& rect)
        __floatingBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
 }
 
+void
+_Frame::SetFloatingOrientation(_ControlOrientation orientation)
+{
+       if ((__showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (__showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
+       {
+               __floatingOrientation = orientation;
+       }
+}
+
 result
 _Frame::SetShowMode(FrameShowMode showMode)
 {
@@ -494,6 +504,67 @@ _Frame::SetShowMode(FrameShowMode showMode)
        int oldShowMode = __showMode;
        __showMode = showMode;
 
+       if ((__showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (__showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
+       {
+               _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
+               _Form* pCurForm = GetCurrentForm();
+               if (pCurForm)
+               {
+                       orientation = pCurForm->GetOrientation();
+               }
+               else
+               {
+                       orientation = GetOrientation();
+               }
+
+               if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+               {
+                       if (__floatingOrientation == _CONTROL_ORIENTATION_LANDSCAPE)
+                       {
+                               FloatDimension screenSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
+                               FloatPoint prevPoint(__floatingBounds.x, __floatingBounds.y);
+                               FloatPoint curPoint(prevPoint.x, prevPoint.y);
+                               float ratio = screenSize.width / screenSize.height;
+
+                               if (prevPoint.x > 0.0f)
+                               {
+                                       curPoint.x = prevPoint.x * ratio;
+                               }
+                       
+                               if (prevPoint.y > 0.0f)
+                               {
+                                       curPoint.y = prevPoint.y / ratio;
+                               }
+
+                               __floatingBounds.x = curPoint.x;
+                               __floatingBounds.y = curPoint.y;
+                       }
+               }
+               else
+               {
+                       if (__floatingOrientation == _CONTROL_ORIENTATION_PORTRAIT)
+                       {
+                               FloatDimension screenSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
+                               FloatPoint prevPoint(__floatingBounds.x, __floatingBounds.y);
+                               FloatPoint curPoint(prevPoint.x, prevPoint.y);
+                               float ratio = screenSize.width / screenSize.height;
+
+                               if (prevPoint.x > 0.0f)
+                               {
+                                       curPoint.x = prevPoint.x / ratio;
+                               }
+                       
+                               if (prevPoint.y > 0.0f)
+                               {
+                                       curPoint.y = prevPoint.y * ratio;
+                               }
+                       
+                               __floatingBounds.x = curPoint.x;
+                               __floatingBounds.y = curPoint.y;
+                       }
+               }
+       }
+
        result r = E_SUCCESS;
 
        switch (__showMode)
@@ -558,6 +629,19 @@ _Frame::SetShowMode(FrameShowMode showMode)
                break;
        }
 
+       if ((__showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (__showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
+       {
+               _Form* pCurForm = GetCurrentForm();
+               if (pCurForm)
+               {
+                       __floatingOrientation = pCurForm->GetOrientation();
+               }
+               else
+               {
+                       __floatingOrientation = GetOrientation();
+               }
+       }
+
        return E_SUCCESS;
 }