Adjust for new clipboard focus policy and repair layout logic for command button
authorTaejun <tj.twt.park@samsung.com>
Thu, 28 Mar 2013 07:10:03 +0000 (16:10 +0900)
committerTaejun <tj.twt.park@samsung.com>
Thu, 28 Mar 2013 07:10:03 +0000 (16:10 +0900)
Change-Id: I6d39f1f43f925da22698b4fb311325e19730517e

src/ui/controls/FUiCtrl_EditPresenter.cpp
src/ui/controls/FUiCtrl_Keypad.cpp
src/ui/inc/FUiCtrl_EditPresenter.h
src/ui/inc/FUiCtrl_Keypad.h

index 0df25c1..07a3d0b 100755 (executable)
@@ -102,6 +102,7 @@ bool _EditPresenter::__isClipboardExist = false;
 float _EditPresenter::__initialParentHeight = 0.0f;
 float _EditPresenter::__clipboardHeight = 0.0f;
 bool _EditPresenter::__isPanelBoundsChanging = false;
+_EditFooterVisibleStatus _EditPresenter::__initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
 
 _EditAnimationProvider::_EditAnimationProvider(void)
 {
@@ -177,7 +178,6 @@ _EditPresenter::_EditPresenter(void)
        , __isTextBlocked(false)
        , __isGuideTextColorChanged(false)
        , __isKeypadCommandButtonVisible(false)
-       , __isKeypadHiding(false)
        , __isTextComposing(false)
        , __isCopyPasteManagerExist(false)
        , __isCursorChanged(false)
@@ -207,7 +207,6 @@ _EditPresenter::_EditPresenter(void)
        , __rotated(false)
        , __isCutLinkParserEnabled(false)
        , __echoChar('*')
-       , __footerVisibleStatus(EDIT_FOOTER_VISIBLE_STATUS_NONE)
        , __ContentTextStatus(EDIT_TEXT_STATUS_COMPOSE_NON)
        , __pEditVEDelegator(null)
        , __isAutoShrinkEnabled(false)
@@ -232,7 +231,7 @@ _EditPresenter::_EditPresenter(void)
 void
 _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
  {
-       if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. bounded 2.bounded&rotate
+       if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. keypad show 2.usb on&predictive window show
        {
                __isKeypadShowing = false;
                __isKeypadExist = true;
@@ -241,7 +240,7 @@ _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source,
 
                if (__isInputConnectionBound)
                {
-                       if (__isKeypadCommandButtonVisible  && !__isUSBKeyboardConnected)
+                       if (__isKeypadCommandButtonVisible)
                        {
                                SetFooterVisible(false);
                        }
@@ -259,13 +258,15 @@ _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source,
                        }
                }
 
-               if (__isUSBKeyboardConnected && !__isKeypadCommandButtonVisible)
+               if (__isUSBKeyboardConnected)
                {
-                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
+                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
+               }
+               else
+               {
+                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
+                       __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
                }
-
-               __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
-               __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
 
                if (!__pEdit->IsFullScreenKeypadEdit())
                {
@@ -292,10 +293,8 @@ _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source,
                        __isTextBlocked = false;
                }
 
-               if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on)
+               if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on), focus remaining
                {
-                       AdjustParentPanelHeight(true);
-
                        if (!__pEdit->IsFullScreenKeypadEdit())
                        {
                                if (__pParentForm)
@@ -303,6 +302,9 @@ _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source,
                                        __pParentForm->SetKeypadShowState(false);
                                }
                        }
+
+                       ChangeLayoutInternal(__pEdit->GetOrientation());
+                       AdjustParentPanelHeight(true);
                }
                else
                {
@@ -314,40 +316,46 @@ _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source,
                                        __isTextComposing = false;
                                        __composingTextLength = 0;
                                }
+
+                               ChangeLayoutInternal(__pEdit->GetOrientation());
+                               AdjustParentPanelHeight(true);
                        }
                        else// called by focus move or HideKeypad() api call
                        {
                                SetKeypadClosedEventSkipped(true);//it will adjust only fullscreen keypad edit.
-                       }
-
-                       AdjustParentPanelHeight(true);
 
-                       __isInputConnectionBound = false;
+                               if (__pCommandButton && __isKeypadCommandButtonVisible)
+                               {
+                                       SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
+                                       __pCommandButton->SetVisibleState(false);
+                                       __pCommandButton->Invalidate();
+                               }
 
-                       __pEdit->DetachScrollPanelEvent();
-               }
+                               __pEdit->DetachScrollPanelEvent();
+                               __isInputConnectionBound = false;
 
-               if (__pCommandButton && __pCommandButton->GetVisibleState() == true)
-               {
-                       SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
-                       __pCommandButton->SetVisibleState(false);
-                       __pCommandButton->Invalidate();
-               }
+                               AdjustParentPanelHeight(true);
 
-               if (__pParentForm)
-               {
-                       __pParentForm->DeflateClientRectHeight(0.0f);
+                               if (__pParentForm)
+                               {
+                                       __pParentForm->DeflateClientRectHeight(0.0f);
+                               }
+                       }
                }
 
-               __isKeypadHiding = false;
-
-               SetKeypadBounds(FloatRectangle());
-
                if (!__isKeypadClosedEventSkipped)
                {
-                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
-                       __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
+                       if (__isUSBKeyboardConnected)
+                       {
+                               __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
+                       }
+                       else
+                       {
+                               __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
+                               __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
+                       }
                }
+
                __isKeypadClosedEventSkipped = false;
 
                if (!__pEdit->IsFullScreenKeypadEdit())
@@ -786,6 +794,8 @@ _EditPresenter::OnClipboardPopupOpened(Tizen::Graphics::Dimension& clipboardPopu
                }
                else
                {
+                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
+
                        ChangeLayoutInternal(__pEdit->GetOrientation());
                        AdjustParentPanelHeight(false);
 
@@ -796,7 +806,6 @@ _EditPresenter::OnClipboardPopupOpened(Tizen::Graphics::Dimension& clipboardPopu
                                __pParentForm->Draw();
                        }
 
-                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
                        __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
                }
        }
@@ -860,6 +869,11 @@ _EditPresenter::OnClipboardPopupClosed(void)
 
        if (__clipboardConnected)
        {
+               if (__pClipboard)
+               {
+                       __pClipboard->HidePopup();
+               }
+
                __isClipboardExist = false;
                FloatRectangle absKeypadBounds;
                GetKeypadBounds(absKeypadBounds);
@@ -5418,6 +5432,14 @@ _EditPresenter::OnFocusLost(void)
 
        ReplaceTextIntoPasswordHyphenString();
 
+       if (__isClipboardExist)
+       {
+               if (__pClipboard)
+               {
+                       __pClipboard->HidePopup();
+               }
+       }
+
        if (__isInputConnectionBound)
        {
 
@@ -5431,14 +5453,6 @@ _EditPresenter::OnFocusLost(void)
                __isTouchReleaseSkipped = false;
                __isUSBKeyboardConnected = false;
 
-               if (__isClipboardExist)
-               {
-                       if (__pClipboard)
-                       {
-                               __pClipboard->HidePopup();
-                       }
-               }
-
                HideKeypad();
        }
 
@@ -5906,7 +5920,7 @@ CATCH:
 }
 
 void
-_EditPresenter::CheckFooterVisible(void)
+_EditPresenter::CheckInitialFooterVisibleState(void)
 {
        if (__pParentForm == null)
        {
@@ -5918,16 +5932,16 @@ _EditPresenter::CheckFooterVisible(void)
        {
                if (pFooter->GetVisibleState() == false)
                {
-                       __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE;
+                       __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE;
                }
                else
                {
-                       __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW;
+                       __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW;
                }
        }
        else
        {
-               __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
+               __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
        }
 
        return;
@@ -5942,13 +5956,18 @@ _EditPresenter::SetFooterVisible(bool isVisible)
        }
 
        _Toolbar* pFooter = __pParentForm->GetFooter();
-       if (pFooter && __footerVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW)
+       if (pFooter && __initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW)
        {
                if ((isVisible == true && pFooter->GetVisibleState() == false) ||
                        (isVisible == false && pFooter->GetVisibleState() == true))
                {
                        pFooter->SetVisibleState(isVisible);
                        pFooter->Invalidate();
+
+                       if (isVisible)
+                       {
+                               __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
+                       }
                }
        }
 
@@ -6074,8 +6093,6 @@ _EditPresenter::GetKeypadBounds(FloatRectangle& bounds) const
 result
 _EditPresenter::ShowKeypad(bool focus)
 {
-       //SysTryReturnResult(NID_UI_CTRL, IsKeypadEnabled() == true, E_INVALID_STATE, "[EDIT] Keypad is not enabled.");
-
        if (focus)
        {
                __pEdit->SetFocused();
@@ -6128,31 +6145,58 @@ _EditPresenter::ShowKeypad(bool focus)
                SetCurrentLanguage(initialKeypadLanguage);
        }
 
-       if (!__isUSBKeyboardConnected && IsKeypadEnabled())
+       //layout rearrange
+       if (IsKeypadEnabled())
        {
-               __pInputConnection->ShowInputPanel();
-
-               if (!__isKeypadExist)
+               if (__isUSBKeyboardConnected)
                {
-                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
-               }
+                       if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
+                       {
+                               CheckInitialFooterVisibleState();
+                       }
+
+                       if (__isKeypadCommandButtonVisible)
+                       {
+                               __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
+                               __pEdit->AttachScrollPanelEvent();
+                               __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
 
-               CheckFooterVisible();
+                               SetFooterVisible(false);
+                               ChangeLayoutInternal(__pEdit->GetOrientation());
+                               AdjustParentPanelHeight(false);
 
-               if (__isKeypadCommandButtonVisible)
-               {
-                       SetFooterVisible(false);
+                               __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
+                               __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
+                       }
                }
-
-               if (__isKeypadExist)
+               else
                {
-                       ChangeLayoutInternal(__pEdit->GetOrientation());
-                       AdjustParentPanelHeight(false);
+                       __pInputConnection->ShowInputPanel();
+
+                       if (!__isKeypadExist)
+                       {
+                               __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
+                               __pEdit->AttachScrollPanelEvent();
+                               __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
+
+                               CheckInitialFooterVisibleState();
+                       }
+
+                       if (__isKeypadCommandButtonVisible)
+                       {
+                               SetFooterVisible(false);
+                       }
+
+                       if (__isKeypadExist)
+                       {
+                               ChangeLayoutInternal(__pEdit->GetOrientation(), false);
+                               //AdjustParentPanelHeight(false);
+                       }
                }
        }
 
-       __pEdit->AttachScrollPanelEvent();
-       __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
+       ScrollPanelToExposedRegion(true);
+       ScrollPanelToCursorPosition();
 
        return E_SUCCESS;
 }
@@ -6189,6 +6233,15 @@ _EditPresenter::ChangeLayout(_ControlOrientation orientation)
                        ChangeLayoutInternal(orientation);
                        AdjustParentPanelHeight(false);
                }
+               else
+               {
+                       if (__isKeypadCommandButtonVisible)
+                       {
+                               __initialParentHeight = 0.0f;
+                               ChangeLayoutInternal(orientation);
+                               AdjustParentPanelHeight(false);
+                       }
+               }
        }
 
        if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false)
@@ -6202,7 +6255,7 @@ _EditPresenter::ChangeLayout(_ControlOrientation orientation)
 }
 
 result
-_EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation)
+_EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation, bool deflateForm)
 {
        result r = E_SUCCESS;
 
@@ -6257,7 +6310,7 @@ _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation)
                        }
                }
 
-               if (__isKeypadCommandButtonVisible && !__isUSBKeyboardConnected)
+               if (__isKeypadCommandButtonVisible)
                {
                        if (__isClipboardExist)
                        {
@@ -6321,7 +6374,7 @@ _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation)
                }
        }
 
-       if (__pParentForm)
+       if (__pParentForm && deflateForm)
        {
                SysLog(NID_UI_CTRL, "ChangeLayoutInternal: formDeflateHeight:%f, KeypadExist(%d), ClipboardExist(%d), CommandButtonVisible(%d)",
                        formDeflateHeight, __isKeypadExist, __isClipboardExist, __isKeypadCommandButtonVisible);
@@ -6334,18 +6387,6 @@ _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation)
 void
 _EditPresenter::OnScrollPanelBoundsChanged(void)
 {
-       /*
-       if (__pParentPanel && __isPanelBoundsChanging == false)
-       {
-               __initialParentHeight = __pParentPanel->GetBounds().height;
-               if (__pParentPanel->GetOrientation() == __pEdit->GetOrientation())
-               {
-                       AdjustParentPanelHeight(false);
-                       ScrollPanelToExposedRegion(false);
-                       ScrollPanelToCursorPosition();
-               }
-       }*/
-
        return;
 }
 
@@ -6513,32 +6554,45 @@ _EditPresenter::HideKeypad(bool focus)
                return E_SUCCESS;
        }
 
-       if (__isInputConnectionBound)
+       if (__isUSBKeyboardConnected)
        {
-               __pInputConnection->FinishTextComposition();
-               __pInputConnection->HideInputPanel();
-               __pInputConnection->UnbindInputMethod();
-               __isKeypadHiding = true;
-               __isTextComposing = false;
-               __composingTextLength = 0;
-       }
+               SetFooterVisible(true);
+               if (__pCommandButton && __isKeypadCommandButtonVisible)
+               {
+                       __pCommandButton->SetVisibleState(false);
 
-       if (__pCommandButton && __pCommandButton->GetVisibleState() == true)
-       {
-               SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights
-               __pCommandButton->SetVisibleState(false);
-       }
+                       if (__pParentForm)
+                       {
+                               __pParentForm->DeflateClientRectHeight(0.0f);
+                       }
 
-       if (__isKeypadExist)
+                       AdjustParentPanelHeight(true);
+
+                       __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
+               }
+       }
+       else
        {
-               if (__pParentForm)
+               if (__pCommandButton && __pCommandButton->GetVisibleState() == true)
                {
-                       __pParentForm->DeflateClientRectHeight(0.0f);
+                       if (!__isKeypadExist)
+                       {
+                               SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights
+                               if (__pParentForm)
+                               {
+                                       __pParentForm->DeflateClientRectHeight(0.0f);
+                               }
+                       }
+                       __pCommandButton->SetVisibleState(false);
                }
-
-               AdjustParentPanelHeight(true);
        }
 
+       __pInputConnection->FinishTextComposition();
+       __pInputConnection->HideInputPanel();
+       __pInputConnection->UnbindInputMethod();
+       __isTextComposing = false;
+       __composingTextLength = 0;
+
        __isInputConnectionBound = false;
 
        if (focus && IsInternalFocused())
index 400ceca..30dd05f 100644 (file)
@@ -54,7 +54,6 @@ IMPLEMENT_PROPERTY(_Keypad);
 _Keypad::_Keypad(void)
        : __isInitialized(false)
        , __isSingleLineEnabled(false)
-       , __pOwner(null)
        , __pCallerEdit(null)
        , __pChildEdit(null)
        , __pFooter(null)
@@ -118,18 +117,12 @@ _Keypad::Initialize(int editStyle, _KeypadStyleInfo keypadStyleInfo, int limitLe
                if (pForm)
                {
                        SetOwner(pForm);
-                       __pOwner = pForm;
                }
                else
                {
                        SetOwner(pFrame);
-                       __pOwner = pFrame;
                }
        }
-       else
-       {
-               __pOwner = GetOwner();
-       }
 
        __pFooter = CreateFooter();
 
@@ -537,6 +530,8 @@ _Keypad::OnAttachedToMainTree(void)
 {
        result r = E_SUCCESS;
 
+       GetEcoreEvasMgr()->GetEcoreEvas()->SetOwner(*this, *GetOwner());//set owner to EcoreEvas for orientation set.
+
        r = __pChildEdit->SetText(__text);
        SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -733,7 +728,7 @@ _Keypad::OnActionPerformed(const _Control& source, int actionId)
        }
        else
        {
-               __pOwner->Invalidate(true);
+               GetOwner()->Invalidate(true);
                if (__pTextEvent)
                {
                        IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(textEventStatus);
index ae22665..fe5dd6f 100644 (file)
@@ -425,10 +425,10 @@ private:
        result OnTitleSlidingTimerExpired(void);
        result OnFlickTimerExpired(void);
        bool IsDelimiter(wchar_t character) const;
-       void AdjustParentPanelHeight(bool restore, bool panelResizeByPrediction=false);
-       result ChangeLayoutInternal(_ControlOrientation orientation);
+       void AdjustParentPanelHeight(bool restore, bool panelResizeByPrediction = false);
+       result ChangeLayoutInternal(_ControlOrientation orientation, bool deflateForm = true);
        _Button* CreateCommandButtonItemN(int actionId, const Tizen::Base::String& text);
-       void CheckFooterVisible(void);
+       void CheckInitialFooterVisibleState(void);
        void SetFooterVisible(bool isVisible);
        result ShowFullscreenKeypad(void);
        InputPanelAction ConvertKeypadAction(CoreKeypadAction keypadAction);
@@ -508,7 +508,6 @@ private:
        bool __isTextBlocked;
        bool __isGuideTextColorChanged;
        bool __isKeypadCommandButtonVisible;
-       bool __isKeypadHiding;
        bool __isTextComposing;
        bool __isCopyPasteManagerExist;
        bool __isCursorChanged;
@@ -546,10 +545,10 @@ private:
        static float __initialParentHeight;
        static float __clipboardHeight;
        static bool __isPanelBoundsChanging;
+       static _EditFooterVisibleStatus __initialFooterVisibleStatus;
 
        wchar_t __echoChar;
 
-       _EditFooterVisibleStatus __footerVisibleStatus;
        _EditTextStatus __ContentTextStatus;
 
        _EditAnimationProvider* __pEditVEDelegator;
index 52d57d1..6cb8157 100644 (file)
@@ -107,7 +107,6 @@ private:
 private:
        bool __isInitialized;
        bool __isSingleLineEnabled;
-       _Control* __pOwner;
        _Edit* __pCallerEdit;
        _Edit* __pChildEdit;
        _Toolbar* __pFooter;