FocusUi SplitPanel Changes - tizen2.1
authorSreedeep Moulik <sreedeep.m@samsung.com>
Tue, 28 May 2013 08:36:40 +0000 (14:06 +0530)
committerSreedeep Moulik <sreedeep.m@samsung.com>
Tue, 4 Jun 2013 05:20:36 +0000 (10:50 +0530)
Change-Id: Ie44053d6bcd53995d3b4848cffad5462e413885a
Signed-off-by: Sreedeep Moulik <sreedeep.m@samsung.com>
src/ui/controls/FUiCtrl_SplitPanel.cpp
src/ui/controls/FUiCtrl_SplitPanelPresenter.cpp
src/ui/inc/FUiCtrl_SplitPanel.h

index 5164f56..9a0dea2 100644 (file)
@@ -24,6 +24,7 @@
 #include <FBaseString.h>
 #include <FBaseSysLog.h>
 #include <FGrp_BitmapImpl.h>
+#include <FGrp_CoordinateSystemUtils.h>
 #include "FUi_ResourceManager.h"
 #include "FUi_UiTouchEvent.h"
 #include "FUi_TouchTapGestureDetector.h"
@@ -31,7 +32,6 @@
 #include "FUi_AccessibilityElement.h"
 #include "FUiCtrl_SplitPanel.h"
 #include "FUiCtrl_SplitPanelPresenter.h"
-#include "FGrp_CoordinateSystemUtils.h"
 
 using namespace Tizen::Ui;
 using namespace Tizen::Graphics;
@@ -52,6 +52,7 @@ _SplitPanel::_SplitPanel()
        , __splitPanelDividerDirection(SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
        , __pSplitPanelEvent(null)
        , __dividerTapCount(0)
+       , __isFocusModeEnabled(false)
        , __pAccessibilityElement(null)
        , __pDividerVisualElement(null)
 {
@@ -403,18 +404,29 @@ _SplitPanel::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
 bool
 _SplitPanel::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
 {
+       if (__isFocusModeEnabled == false)
+       {
+               return false;
+       }
+
        return __pSplitPanelPresenter->OnKeyPressed(source, keyInfo);
 }
 
 bool
 _SplitPanel::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
 {
+       if (__isFocusModeEnabled == false)
+       {
+               return false;
+       }
+
        return __pSplitPanelPresenter->OnKeyReleased(source, keyInfo);
 }
 
 void
 _SplitPanel::OnDrawFocus(void)
 {
+       __isFocusModeEnabled = true;
        __pSplitPanelPresenter->DrawFocus();
        return;
 }
@@ -429,12 +441,21 @@ bool
 _SplitPanel::OnFocusLost(const _Control& source)
 {
        result r = __pSplitPanelPresenter->ReleaseFocus();
-       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
 
        _Control::OnFocusLost(source);
        return true;
 }
 
+void
+_SplitPanel::OnFocusModeStateChanged(void)
+{
+       __isFocusModeEnabled = false;
+       __pSplitPanelPresenter->ReleaseFocus();
+
+       return;
+}
+
 result
 _SplitPanel::SetPane(_Control* pControl, SplitPanelPaneOrder paneOrder)
 {
index b6329f3..048bb5a 100644 (file)
 #include <FUiCtrlSplitPanelTypes.h>
 #include <FBaseSysLog.h>
 #include <FGrp_BitmapImpl.h>
+#include <FGrp_CoordinateSystemUtils.h>
 #include "FUi_ResourceManager.h"
 #include "FUi_UiTouchEvent.h"
 #include "FUiCtrl_SplitPanelPresenter.h"
 #include "FUiCtrl_SplitPanel.h"
 #include "FUiCtrl_SplitPanelImpl.h"
-#include "FGrp_CoordinateSystemUtils.h"
 
 using namespace Tizen::Ui;
 using namespace Tizen::Graphics;
@@ -159,8 +159,6 @@ _SplitPanelPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& t
 {
        FloatPoint point(0.0f, 0.0f);
 
-       ReleaseFocus();
-
        point = touchinfo.GetCurrentPosition();
 
        if (CheckDividerTouchRegion(point.x, point.y) == true)
@@ -176,8 +174,6 @@ _SplitPanelPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& t
 bool
 _SplitPanelPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
 {
-       ReleaseFocus();
-
        if (__splitPanelDividerPressed == true)
        {
                PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
@@ -201,8 +197,6 @@ _SplitPanelPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& tou
        FloatPoint point(0.0f, 0.0f);
        Bitmap* pThumbBitmap = null;
 
-       ReleaseFocus();
-
        if (__pSplitPanel != &source || __splitPanelDividerPressed == false )
        {
                return false;
@@ -317,6 +311,10 @@ _SplitPanelPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyIn
                         DrawFocus(__currentFocusedPane);
                 }
         }
+        else if (keyCode == _KEY_TAB && !__pSplitPanel->IsFocused())
+        {
+                __pSplitPanel->SetFocused(true);
+        }
         else
         {
                 return false;
@@ -342,7 +340,7 @@ result
 _SplitPanelPresenter::DrawFocus(SplitPanelPaneOrder focusedPane)
 {
        result r = E_SUCCESS;
-       Canvas* pSplitPanelCanvas = null;
+       Canvas* pCanvas = null;
        FloatRectangle  currentFocusBounds(0.0f, 0.0f, 0.0f, 0.0f);
 
        _Control* pControl = null;
@@ -362,33 +360,48 @@ _SplitPanelPresenter::DrawFocus(SplitPanelPaneOrder focusedPane)
 
        if (pControl != null)
        {
-               pControl->SetFocused();
-               pControl->DrawFocus();
-       }
-       else
-       {
-               pSplitPanelCanvas = __pSplitPanel->GetCanvasN();
-               SysTryReturnResult(NID_UI_CTRL, (pSplitPanelCanvas != null), E_SYSTEM, "A system error has occurred. Failed to get the canvas of SplitPanel.");
-
-               //give focus
-               if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pFocusBitmap))
+               if (pControl->IsFocusable())
                {
-                       r = pSplitPanelCanvas->DrawNinePatchedBitmap(currentFocusBounds, *__pFocusBitmap);
-                       SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+                       pControl->SetFocused(true);
+                       pControl->DrawFocus();
+
+                       return r;
                }
                else
                {
-                       r = pSplitPanelCanvas->DrawBitmap(currentFocusBounds, *__pFocusBitmap);
-                       SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+                       __pSplitPanel->SetFocused(true);
+                       currentFocusBounds = pControl->GetBoundsF();
+
+                       pCanvas = pControl->GetCanvasN();
+                       SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_SYSTEM, "A system error has occurred. Failed to get the canvas of Control.");
                }
+       }
+       else
+       {
+               __pSplitPanel->SetFocused(true);
+
+               pCanvas = __pSplitPanel->GetCanvasN();
+               SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_SYSTEM, "A system error has occurred. Failed to get the canvas of SplitPanel.");
+       }
 
-               delete pSplitPanelCanvas;
+       //give focus
+       if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pFocusBitmap))
+       {
+               r = pCanvas->DrawNinePatchedBitmap(currentFocusBounds, *__pFocusBitmap);
+               SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else
+       {
+               r = pCanvas->DrawBitmap(currentFocusBounds, *__pFocusBitmap);
+               SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
+       delete pCanvas;
+
        return r;
 
 CATCH:
-       delete pSplitPanelCanvas;
+       delete pCanvas;
        return r;
 }
 
@@ -411,7 +424,30 @@ _SplitPanelPresenter::ReleaseFocus(void)
        }
        else
        {
-               return r;
+               _Control* pFocusedControl = __pSplitPanel->GetPane(__currentFocusedPane);
+               if (pFocusedControl != null)
+               {
+                       if (!pFocusedControl->IsFocusable())
+                       {
+                               Canvas* pPaneCanvas = pFocusedControl->GetCanvasN();
+                               SysTryReturnResult(NID_UI_CTRL, (pPaneCanvas != null), E_SYSTEM, "A system error has occurred. Failed to get the canvas of SplitPanel.");
+
+                               panebounds = pFocusedControl->GetBoundsF();
+
+                               pPaneCanvas->SetBackgroundColor(pFocusedControl->GetBackgroundColor());
+                               pPaneCanvas->Clear(panebounds);
+
+                               delete pPaneCanvas;
+                       }
+
+                       if(!__pSplitPanel->IsFocused())
+                       {
+                               pFocusedControl->SetFocused(false);
+                               __pSplitPanel->SetFocused(true);
+                       }
+
+                       return r;
+               }
        }
 
        pSplitPanelCanvas = __pSplitPanel->GetCanvasN();
index 24285f9..32bb59f 100644 (file)
@@ -111,6 +111,7 @@ public:
        virtual void OnDrawFocus(void);
        bool OnFocusGained(const _Control& source);
        bool OnFocusLost(const _Control& source);
+       void OnFocusModeStateChanged(void);
 
 public:
        result AddSplitPanelEventListener(const _ISplitPanelEventListener& listener);
@@ -180,6 +181,7 @@ private:
        _SplitPanelEvent* __pSplitPanelEvent;
 
        int __dividerTapCount;
+       bool __isFocusModeEnabled;
 
        Tizen::Ui::_AccessibilityElement* __pAccessibilityElement;