Fix Ime Rotation
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_FormImpl.cpp
index 41a1aba..30b77d3 100644 (file)
@@ -33,6 +33,7 @@
 #include "FUi_EcoreEvas.h"
 #include "FUi_ControlImplManager.h"
 #include "FUi_OrientationAgent.h"
+#include "FUi_ImeOrientationAgent.h"
 #include "FUi_UiBuilder.h"
 #include "FUi_CoordinateSystemUtils.h"
 #include "FUi_DataBindingContextImpl.h"
@@ -44,6 +45,7 @@
 #include "FUiCtrl_FooterImpl.h"
 #include "FUiCtrl_Form.h"
 #include "FUiCtrl_Frame.h"
+#include "FUiCtrl_FrameImpl.h"
 #include "FUiCtrl_TabImpl.h"
 #include "FUiCtrl_Indicator.h"
 
@@ -99,20 +101,39 @@ _FormImpl::_FormImpl(Form* pPublic, _Form* pCore, Layout* pPublicPortraitLayout,
        , __pForm(null)
        , __pFormBackEventListener(null)
        , __pOriAgent(null)
+       , __pImeOriAgent(null)
        , __pLeftSoftkeyActionEvent(null)
        , __pRightSoftkeyActionEvent(null)
        , __pOptionMenuActionEvent(null)
 {
        __pForm = pCore;
 
-       __pOriAgent = _OrientationAgent::CreateInstanceN(*pPublic);
-       SysTryReturnVoidResult(NID_UI_CTRL, __pOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       int appType = _AppInfo::GetAppType();
+       if (appType & _APP_TYPE_IME_APP)
+       {
+               __pImeOriAgent = _ImeOrientationAgent::CreateInstanceN(*pPublic);
+               SysTryReturnVoidResult(NID_UI_CTRL, __pImeOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
+       else
+       {
+               __pOriAgent = _OrientationAgent::CreateInstanceN(*pPublic);
+               SysTryReturnVoidResult(NID_UI_CTRL, __pOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       }
 }
 
 _FormImpl::~_FormImpl(void)
 {
-       delete __pOriAgent;
-       __pOriAgent = null;
+       if (__pImeOriAgent)
+       {
+               delete __pImeOriAgent;
+               __pImeOriAgent = null;
+       }
+
+       if (__pOriAgent)
+       {
+               delete __pOriAgent;
+               __pOriAgent = null;
+       }
 
        if (__pLeftSoftkeyActionEvent)
        {
@@ -257,6 +278,12 @@ _FormImpl::SetFormStyle(unsigned long formStyle)
                }
        }
 
+       if ((formStyle & FORM_STYLE_INDICATOR) && (formStyle & FORM_STYLE_INDICATOR_AUTO_HIDE))
+       {
+               SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid form style. FORM_STYLE_INDICATOR and FORM_STYLE_INDICATOR_AUTO_HIDE can't use each other.");
+               return;
+       }
+
        // check formstyle
        if (((formStyle & FORM_STYLE_TITLE) || (formStyle & FORM_STYLE_TEXT_TAB) || (formStyle & FORM_STYLE_ICON_TAB)) && (formStyle & FORM_STYLE_HEADER))
        {
@@ -323,6 +350,21 @@ _FormImpl::SetFormStyle(unsigned long formStyle)
                        GetCore().SetHeader(&pHeader->GetCore());
                        GetCore().AdjustClientBounds();
 
+                       if (GetCore().IsIndicatorTranslucent())
+                       {
+                               if (!GetCore().IsHeaderTranslucent())
+                               {
+                                       indicatorBounds.height = 0.0f;
+                               }
+                               else
+                               {
+                                       if (GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
+                                       {
+                                               indicatorBounds.height = 0.0f;
+                                       }
+                               }
+                       }
+
                        FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
                        GetCore().SetHeaderBounds(bounds);
 
@@ -360,13 +402,6 @@ _FormImpl::SetFormStyle(unsigned long formStyle)
                }
        }
 
-       _Indicator* pIndicator = GetCore().GetIndicator();
-       if (!pIndicator && !pIndicator->IsAttachedToMainTree())
-       {
-               r = GetCore().AttachSystemChild(*pIndicator);
-               SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
-       }
-
        if (formStyle & FORM_STYLE_TEXT_TAB)
        {
                float titleHeight = 0.0f;
@@ -670,7 +705,10 @@ _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regio
 void
 _FormImpl::OnDraw(void)
 {
-       __pOriAgent->FireOrientationEvent();
+       if (__pOriAgent)
+       {
+               __pOriAgent->FireOrientationEvent();
+       }
 
        _ContainerImpl::OnDraw();
 }
@@ -807,7 +845,14 @@ _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEvent
 void
 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
 {
-       __pOriAgent->AddListener(listener);
+       if (__pOriAgent)
+       {
+               __pOriAgent->AddListener(listener);
+       }
+       else if (__pImeOriAgent)
+       {
+               __pImeOriAgent->AddListener(listener);
+       }
 }
 
 void
@@ -860,7 +905,14 @@ _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener&
 void
 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
 {
-       __pOriAgent->RemoveListener(listener);
+       if (__pOriAgent)
+       {
+               __pOriAgent->RemoveListener(listener);
+       }
+       else if (__pImeOriAgent)
+       {
+               __pImeOriAgent->RemoveListener(listener);
+       }
 }
 
 void
@@ -906,35 +958,65 @@ _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListen
 void
 _FormImpl::SetOrientation(Orientation orientation)
 {
-       __pOriAgent->SetMode(orientation);
+       if (__pOriAgent)
+       {
+               __pOriAgent->SetMode(orientation);
+       }
 }
 
 Orientation
 _FormImpl::GetOrientation(void) const
 {
-       return __pOriAgent->GetMode();
+       if (__pOriAgent)
+       {
+               return __pOriAgent->GetMode();
+       }
+
+       return ORIENTATION_NONE;
 }
 
 OrientationStatus
 _FormImpl::GetOrientationStatus(void) const
 {
-       return __pOriAgent->GetStatus();
+       if (__pOriAgent)
+       {
+               return __pOriAgent->GetStatus();
+       }
+
+       return ORIENTATION_STATUS_NONE;
 }
 
 void
 _FormImpl::UpdateOrientationStatus(bool draw)
 {
-       __pOriAgent->Update(draw);
+       if (__pOriAgent)
+       {
+               __pOriAgent->Update(draw);
+       }
 }
 
 #if defined(WINDOW_BASE_ROTATE)
 void
 _FormImpl::UpdateOrientation(void)
 {
-       __pOriAgent->UpdateOrientation();
+       if (__pOriAgent)
+       {
+               __pOriAgent->UpdateOrientation();
+       }
 }
 #endif
 
+void
+_FormImpl::UpdateOrientation(int angle)
+{
+       SysLog(NID_UI_CTRL, "[Ime Rotation]");
+
+       if (__pImeOriAgent)
+       {
+               __pImeOriAgent->UpdateOrientation(angle);
+       }
+}
+
 bool
 _FormImpl::HasOptionkey(void) const
 {
@@ -1038,6 +1120,37 @@ _FormImpl::OnChangeLayout(_ControlOrientation orientation)
        const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
        const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
 
+       // Adjust the position of the partial Frame.
+       _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
+       if (pFrameImpl)
+       {
+               FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
+
+               if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
+               {
+                       bool movable = pFrameImpl->GetCore().IsMovable();
+                       pFrameImpl->GetCore().SetMovable(true);
+               
+                       FloatPoint prevPoint = pFrameImpl->GetPositionF();
+                       FloatPoint curPoint(0.0f, 0.0f);
+               
+                       if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+                       {
+                               curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
+                               curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
+                       }
+                       else
+                       {
+                               curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
+                               curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
+                       }
+               
+                       pFrameImpl->SetPosition(curPoint);
+               
+                       pFrameImpl->GetCore().SetMovable(movable);
+               }
+       }
+
        // Change layout.
        _ContainerImpl::OnChangeLayout(orientation);
        SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
@@ -1081,6 +1194,20 @@ _FormImpl::OnChangeLayout(_ControlOrientation orientation)
                if (GetCore().IsIndicatorVisible())
                {
                        indicatorBounds = GetCore().GetIndicatorBoundsF();
+                       if (GetCore().IsIndicatorTranslucent())
+                       {
+                               if (!GetCore().IsHeaderTranslucent())
+                               {
+                                       indicatorBounds.height = 0.0f;
+                               }
+                               else
+                               {
+                                       if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
+                                       {
+                                               indicatorBounds.height = 0.0f;
+                                       }
+                               }
+                       }
                }
 
                FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
@@ -1318,6 +1445,20 @@ _FormImpl::OnAttachedToMainTree(void)
 
        if (pHeader)
        {
+               if (GetCore().IsIndicatorTranslucent())
+               {
+                       if (!GetCore().IsHeaderTranslucent())
+                       {
+                               indicatorBounds.height = 0.0f;
+                       }
+                       else
+                       {
+                               if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
+                               {
+                                       indicatorBounds.height = 0.0f;
+                               }
+                       }
+               }
                FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
                GetCore().SetHeaderBounds(bounds);
        }
@@ -1360,7 +1501,10 @@ _FormImpl::OnAttachedToMainTree(void)
 
        UpdateOrientationStatus();
 
-       __pOriAgent->RequestOrientationEvent();
+       if (__pOriAgent)
+       {
+               __pOriAgent->RequestOrientationEvent();
+       }
 
        return r;
 }
@@ -1383,7 +1527,10 @@ _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
        {
                if (*pString == _REQUEST_ORIENTATION_EVENT)
                {
-                       __pOriAgent->FireOrientationEvent();
+                       if (__pOriAgent)
+                       {
+                               __pOriAgent->FireOrientationEvent();
+                       }
 
                        pArgs->RemoveAll(true);
                        delete pArgs;
@@ -1535,7 +1682,14 @@ protected:
                }
                if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
                {
-                       style |= FORM_STYLE_INDICATOR;
+                       if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
+                       {
+                               style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
+                       }
+                       else
+                       {
+                               style |= FORM_STYLE_INDICATOR;
+                       }
                }
                if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
                {