Fixed to decide the position of the mini App
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_FormImpl.cpp
index 1def572..ae4e508 100644 (file)
@@ -328,22 +328,48 @@ _FormImpl::SetFormStyle(unsigned long formStyle)
        {
                GetCore().SetIndicatorShowState(true);
                indicatorBounds = GetCore().GetIndicatorBoundsF();
-               GetCore().SetIndicatorAutoHide(false);
+
+               if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
+               {
+                       GetCore().SetIndicatorAutoHide(false, true);
+               }
+               else
+               {
+                       GetCore().SetIndicatorAutoHide(false, false);
+               }
                r = GetLastResult();
                SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        }
-       else if(FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
-       {
-               r = GetCore().SetIndicatorShowState(true);
-               r = GetCore().SetIndicatorAutoHide(true);
-               SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
        else
        {
-               r = GetCore().SetIndicatorShowState(false);
-               r = GetCore().SetIndicatorAutoHide(false);
-               SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               if ((FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle) && (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle))
+               {
+                       r = GetCore().SetIndicatorShowState(true);
+                       GetCore().SetIndicatorAutoHide(true, true);
+                       SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else
+               {
+                       if (FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
+                       {
+                               r = GetCore().SetIndicatorShowState(true);
+                               GetCore().SetIndicatorAutoHide(true, false);
+                               SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       else if(FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
+                       {
+                               r = GetCore().SetIndicatorShowState(true);
+                               GetCore().SetIndicatorAutoHide(false, true);
+                               SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+                       else
+                       {
+                               r = GetCore().SetIndicatorShowState(false);
+                               GetCore().SetIndicatorAutoHide(false, false);
+                               SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+                       }
+               }
        }
 
        if (formStyle & FORM_STYLE_HEADER)
@@ -376,6 +402,8 @@ _FormImpl::SetFormStyle(unsigned long formStyle)
 
                        r = GetCore().AttachSystemChild(pHeader->GetCore());
                        SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       GetCore().SetFormBackEventListener(this);
                }
        }
        else if (formStyle & FORM_STYLE_TITLE)
@@ -493,6 +521,9 @@ _FormImpl::SetFormStyle(unsigned long formStyle)
 
                        r = GetCore().AttachSystemChild(pFooter->GetCore());
                        SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       GetCore().SetFormBackEventListener(this);
+                       GetCore().SetFormMenuEventListener(this);
                }
        }
        else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
@@ -539,9 +570,6 @@ _FormImpl::SetFormStyle(unsigned long formStyle)
                }
        }
 
-       GetCore().SetFormBackEventListener(this);
-       GetCore().SetFormMenuEventListener(this);
-
        GetCore().AdjustClientBounds();
 
        SetLastResult(E_SUCCESS);
@@ -840,15 +868,6 @@ _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) con
 void
 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
 {
-       bool isBackButton = false;
-
-       Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isBackButton);
-
-       if(!isBackButton)
-       {
-               SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
-       }
-
        __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
        GetCore().SetFormBackEventListener(this);
        result r = GetLastResult();
@@ -858,14 +877,6 @@ _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEvent
 void
 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
 {
-       bool isMenuButton = false;
-
-       Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.menu", isMenuButton);
-
-       if(!isMenuButton)
-       {
-               SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
-       }
        __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
        GetCore().SetFormMenuEventListener(this);
        result r = GetLastResult();
@@ -1152,7 +1163,6 @@ _FormImpl::OnChangeLayout(_ControlOrientation orientation)
        FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
        FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
 
-       // Adjust the position of the partial Frame.
        _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
        if (pFrameImpl)
        {
@@ -1164,56 +1174,38 @@ _FormImpl::OnChangeLayout(_ControlOrientation orientation)
                        pFrameImpl->GetCore().SetMovable(true);
 
                        FloatPoint prevPoint = pFrameImpl->GetPositionF();
-
-                       FloatPoint curPoint(0.0f, 0.0f);
-
+                       FloatPoint curPoint(prevPoint.x, prevPoint.y);
+                       float ratio = portraitSize.width / portraitSize.height;
                        if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
                        {
-                               if (prevPoint.x < 0.0f)
+                               if (prevPoint.x > 0.0f)
                                {
-                                       curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;                                    
-                               }
-                               else
-                               {
-                                       curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
+                                       curPoint.x = prevPoint.x * ratio;
                                }
 
-                               if (prevPoint.y < 0.0f)
-                               {
-                                       curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
-                               }
-                               else
+                               if (prevPoint.y > 0.0f)
                                {
-                                       curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
+                                       curPoint.y = prevPoint.y / ratio;
                                }
                        }
                        else
                        {
-                               if (prevPoint.x < 0.0f)
-                               {
-                                       curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
-                               }
-                               else
+                               if (prevPoint.x > 0.0f)
                                {
-                                       curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
+                                       curPoint.x = prevPoint.x / ratio;
                                }
 
-                               if (prevPoint.y < 0.0f)
+                               if (prevPoint.y > 0.0f)
                                {
-                                       curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
-                               }
-                               else
-                               {
-                                       curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
+                                       curPoint.y = prevPoint.y * ratio;
                                }
                        }
 
                        pFrameImpl->SetPosition(curPoint);
-
                        portraitSize = pFrameImpl->GetSizeF();
                        landscapeSize = portraitSize;
-
                        pFrameImpl->GetCore().SetMovable(movable);
+                       pFrameImpl->GetCore().SetFloatingOrientation(orientation);
                }
        }
 
@@ -1241,15 +1233,29 @@ _FormImpl::OnChangeLayout(_ControlOrientation orientation)
                        if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
                        {
                                pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
+                               if ((FORM_STYLE_INDICATOR & GetFormStyle()) || (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle()))
+                               {
+                                       GetCore().SetIndicatorShowState(true);
+                               }
+                               else
+                               {
+                                       GetCore().SetIndicatorShowState(false);
+                               }
                        }
                        else
                        {
-                               GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetCore().GetOrientation(), indicatorheight);
-                               pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
+                               if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & GetFormStyle())
+                               {
+                                       GetCore().SetIndicatorShowState(true);
+                               }
                        }
                }
                GetCore().AdjustClientBounds();
        }
+       else
+       {
+               GetCore().SetIndicatorShowState(false);
+       }
        if (pIndicator)
        {
                pIndicator->OnChangeLayout(orientation);
@@ -1276,6 +1282,13 @@ _FormImpl::OnChangeLayout(_ControlOrientation orientation)
                                        {
                                                indicatorBounds.height = 0.0f;
                                        }
+                                       else
+                                       {
+                                               if (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle())
+                                               {
+                                                       adjHeight = 0.0f;
+                                               }
+                                       }
                                }
                        }
                }
@@ -1808,6 +1821,21 @@ protected:
                                style |= FORM_STYLE_INDICATOR;
                        }
                }
+               if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR"))
+               {
+                       if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE"))
+                       {
+                               style |= FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE;
+                       }
+                       else
+                       {
+                               style |= FORM_STYLE_PORTRAIT_INDICATOR;
+                       }
+               }
+               if (styleString.Contains(L"FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE"))
+               {
+                       style |= FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE;
+               }
                if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
                {
                        style |= FORM_STYLE_TEXT_TAB;