Merging SplitPanel changes from RSA-master to RSA-tizen2.1 branch
authorSreedeep Moulik <sreedeep.m@samsung.com>
Tue, 21 May 2013 03:39:50 +0000 (09:09 +0530)
committerSreedeep Moulik <sreedeep.m@samsung.com>
Tue, 21 May 2013 14:06:14 +0000 (19:36 +0530)
Change-Id: I35c511e0a980ebd4e985a62a9399d6c015b8b77f
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
src/ui/inc/FUiCtrl_SplitPanelPresenter.h

index a1e8503..c1a62e2 100644 (file)
@@ -114,7 +114,10 @@ _SplitPanel::CreateSplitPanelN(const FloatRectangle& rect, SplitPanelDividerStyl
 
        pSplitPanel->SetBackgroundColor(Color(0,0,0,0));
 
-       pSplitPanel->GetAccessibilityContainer()->Activate(true);
+       if (pSplitPanel->GetAccessibilityContainer())
+       {
+               pSplitPanel->GetAccessibilityContainer()->Activate(true);
+       }
 
        return pSplitPanel;
 
@@ -387,6 +390,41 @@ _SplitPanel::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
        return __pSplitPanelPresenter->OnTapGestureCanceled(gesture);
 }
 
+bool
+_SplitPanel::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+{
+       return __pSplitPanelPresenter->OnKeyPressed(source, keyInfo);
+}
+
+bool
+_SplitPanel::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+{
+       return __pSplitPanelPresenter->OnKeyReleased(source, keyInfo);
+}
+
+void
+_SplitPanel::OnDrawFocus(void)
+{
+       __pSplitPanelPresenter->DrawFocus();
+       return;
+}
+
+bool
+_SplitPanel::OnFocusGained(const _Control& source)
+{
+       return _Control::OnFocusGained(source);
+}
+
+bool
+_SplitPanel::OnFocusLost(const _Control& source)
+{
+       result r = __pSplitPanelPresenter->ReleaseFocus();
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       _Control::OnFocusLost(source);
+       return true;
+}
+
 result
 _SplitPanel::SetPane(_Control* pControl, SplitPanelPaneOrder paneOrder)
 {
@@ -830,23 +868,22 @@ _SplitPanel::OnAttachedToMainTree(void)
        {
                if (__pDividerVisualElement)
                {
-                       __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
-                       SysTryReturn(NID_UI_CTRL, __pAccessibilityElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
                        dividerRect = __pSplitPanelPresenter->GetDividerRectangle();
 
                        if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED)
                        {
-                               hintText = String(L"double tap to open/close the split area");
-                               __pAccessibilityElement->SetTrait(L"Split view button");
+                               hintText = String(L"Drag scroll Fixed");
                        }
                        else
                        {
-                               hintText = String(L"double tap and move to adjust split area");
-                               __pAccessibilityElement->SetTrait(L"Drag scroll");
+                               hintText = String(L"Drag scroll, double tap and move to adjust split area");
                        }
 
-                       __pAccessibilityElement->SetBounds(dividerRect);
+                       __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
+                       SysTryReturn(NID_UI_CTRL, __pAccessibilityElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       __pAccessibilityElement->SetBounds(_CoordinateSystemUtils::ConvertToInteger(dividerRect));
+                       __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
                        __pAccessibilityElement->SetHint(hintText);
                        __pAccessibilityElement->SetLabel(L"");
                        __pAccessibilityElement->SetName(L"SplitPanelDivider");
index 535fce5..b6329f3 100644 (file)
@@ -56,8 +56,10 @@ _SplitPanelPresenter::_SplitPanelPresenter(void)
        , __pDividerBackgroundBitmap(null)
        , __pDividerBackgroundEffectBitmap(null)
        , __pDividerThumbBitmap(null)
+       , __pFocusBitmap(null)
        , __transactionIdMaximize(0)
        , __transactionIdRestore(0)
+       , __currentFocusedPane(SPLIT_PANEL_PANE_ORDER_FIRST)
        , __controlAnimatorInterpolator(ANIMATION_INTERPOLATOR_LINEAR)
        , __visualElementInterpolator(L"Linear")
 {
@@ -81,6 +83,9 @@ _SplitPanelPresenter::~_SplitPanelPresenter(void)
 
        delete __pDividerBackgroundEffectBitmap;
        __pDividerBackgroundEffectBitmap = null;
+
+       delete __pFocusBitmap;
+       __pFocusBitmap = null;
 }
 
 result
@@ -154,34 +159,40 @@ _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)
        {
                __splitPanelDividerPressed = true;
+               Draw();
+               return true;
        }
 
-       Draw();
-
-       return E_SUCCESS;
+       return false;
 }
 
 bool
 _SplitPanelPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
 {
+       ReleaseFocus();
+
        if (__splitPanelDividerPressed == true)
        {
                PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
                __splitPanelDividerPressed = false;
                Draw();
+               return true;
        }
-
-       if (__isChangeBounds == true)
+       else
        {
-               __isChangeBounds = false;
+               if (__isChangeBounds == true)
+               {
+                       __isChangeBounds = false;
+               }
+               return false;
        }
-
-       return E_SUCCESS;
 }
 
 bool
@@ -190,6 +201,8 @@ _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;
@@ -281,6 +294,138 @@ _SplitPanelPresenter::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
        return false;
 }
 
+bool
+_SplitPanelPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+{
+        _KeyCode keyCode = keyInfo.GetKeyCode();
+
+        if (keyCode == _KEY_RIGHT)
+        {
+                if (__currentFocusedPane == SPLIT_PANEL_PANE_ORDER_FIRST)
+                {
+                        ReleaseFocus();
+                        __currentFocusedPane = SPLIT_PANEL_PANE_ORDER_SECOND;
+                        DrawFocus(__currentFocusedPane);
+                }
+        }
+        else if (keyCode == _KEY_LEFT)
+        {
+                if (__currentFocusedPane == SPLIT_PANEL_PANE_ORDER_SECOND)
+                {
+                        ReleaseFocus();
+                        __currentFocusedPane = SPLIT_PANEL_PANE_ORDER_FIRST;
+                        DrawFocus(__currentFocusedPane);
+                }
+        }
+        else
+        {
+                return false;
+        }
+
+        return true;
+}
+
+bool
+_SplitPanelPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+{
+        _KeyCode keyCode = keyInfo.GetKeyCode();
+
+       if (keyCode == _KEY_RIGHT || keyCode == _KEY_LEFT)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+result
+_SplitPanelPresenter::DrawFocus(SplitPanelPaneOrder focusedPane)
+{
+       result r = E_SUCCESS;
+       Canvas* pSplitPanelCanvas = null;
+       FloatRectangle  currentFocusBounds(0.0f, 0.0f, 0.0f, 0.0f);
+
+       _Control* pControl = null;
+
+       if (focusedPane == SPLIT_PANEL_PANE_ORDER_FIRST)
+       {
+               pControl = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_FIRST);
+               __currentFocusedPane = SPLIT_PANEL_PANE_ORDER_FIRST;
+               currentFocusBounds = GetPaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST);
+       }
+       else
+       {
+               pControl = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_SECOND);
+               __currentFocusedPane = SPLIT_PANEL_PANE_ORDER_SECOND;
+               currentFocusBounds = GetPaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND);
+       }
+
+       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))
+               {
+                       r = pSplitPanelCanvas->DrawNinePatchedBitmap(currentFocusBounds, *__pFocusBitmap);
+                       SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else
+               {
+                       r = pSplitPanelCanvas->DrawBitmap(currentFocusBounds, *__pFocusBitmap);
+                       SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               delete pSplitPanelCanvas;
+       }
+
+       return r;
+
+CATCH:
+       delete pSplitPanelCanvas;
+       return r;
+}
+
+result
+_SplitPanelPresenter::ReleaseFocus(void)
+{
+       result r = E_SUCCESS;
+       Canvas* pSplitPanelCanvas = null;
+       FloatRectangle panebounds(0.0f, 0.0f, 0.0f, 0.0f);
+
+       if (__currentFocusedPane == SPLIT_PANEL_PANE_ORDER_FIRST &&
+                       __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_FIRST) == null)
+       {
+               panebounds = GetPaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST);
+       }
+       else if (__currentFocusedPane == SPLIT_PANEL_PANE_ORDER_SECOND &&
+                       __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_SECOND) == null)
+       {
+               panebounds = GetPaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND);
+       }
+       else
+       {
+               return r;
+       }
+
+       pSplitPanelCanvas = __pSplitPanel->GetCanvasN();
+       SysTryReturnResult(NID_UI_CTRL, (pSplitPanelCanvas != null), E_SYSTEM, "A system error has occurred. Failed to get the canvas of SplitPanel.");
+
+       //reset
+       pSplitPanelCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
+       pSplitPanelCanvas->Clear(panebounds);
+
+       delete pSplitPanelCanvas;
+
+       return r;
+}
+
 result
 _SplitPanelPresenter::SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle)
 {
@@ -549,6 +694,9 @@ _SplitPanelPresenter::LoadBitmap(SplitPanelDividerDirection splitPanelDividerDir
        __pDividerBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDividerBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __dividerBackgroundColor);
        SysTryCatch(NID_UI_CTRL, (__pDividerBackgroundBitmap != null), , r, "[%s] Failed to get replacement color bitmap.", GetErrorMessage(GetLastResult()));
 
+       r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, __pFocusBitmap);
+       SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+
        delete pDividerBackgroundBitmap;
 
        return r;
@@ -611,6 +759,7 @@ _SplitPanelPresenter::SetPaneBounds(void)
        FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
        FloatRectangle firstPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
        FloatRectangle secondPaneBounds(0.0f, 0.0f, 0.0f, 0.0f);
+       FloatRectangle dividerBounds(0.0f, 0.0f, 0.0f, 0.0f);
        FloatPoint panePostion(0.0f, 0.0f);
        _Control* pFirstPane = null;
        _Control* pSecondPane = null;
@@ -639,6 +788,11 @@ _SplitPanelPresenter::SetPaneBounds(void)
                {
                        secondPaneBounds = FloatRectangle(0.0f, clientBounds.height + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height);
                }
+
+               dividerBounds = __dividerRectangle;
+               dividerBounds.x = clientBounds.width;
+
+               __pSplitPanel->SetDividerVisualElementBounds(dividerBounds);
        }
        else if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_SECOND))
        {
@@ -652,6 +806,11 @@ _SplitPanelPresenter::SetPaneBounds(void)
                {
                        firstPaneBounds = FloatRectangle(0.0f, clientBounds.y -__dividerRectangle.y - __dividerRectangle.height, clientBounds.width, __dividerRectangle.y);
                }
+
+               dividerBounds = __dividerRectangle;
+               dividerBounds.x = -__dividerRectangle.width;
+
+               __pSplitPanel->SetDividerVisualElementBounds(dividerBounds);
        }
        else
        {
@@ -684,7 +843,11 @@ _SplitPanelPresenter::SetPaneBounds(void)
        {
                if (pFirstPane->IsResizable())
                {
-                       pFirstPane->SetBounds(firstPaneBounds);
+                       r = pFirstPane->SetBounds(firstPaneBounds);
+                       if (IsFailed(r))
+                       {
+                               SysLog(NID_UI_CTRL, "[%s] SetBounds failed.", GetErrorMessage(r));
+                       }
                }
 
                r = pFirstPane->SetPosition(Point(0.0f, 0.0f));
@@ -695,7 +858,11 @@ _SplitPanelPresenter::SetPaneBounds(void)
        {
                if (pSecondPane->IsResizable())
                {
-                       pSecondPane->SetBounds(secondPaneBounds);
+                       r = pSecondPane->SetBounds(secondPaneBounds);
+                       if (IsFailed(r))
+                       {
+                               SysLog(NID_UI_CTRL, "[%s] SetBounds failed.", GetErrorMessage(r));
+                       }
                }
 
                r = pSecondPane->SetPosition(Point(0.0f, 0.0f));
@@ -724,7 +891,6 @@ _SplitPanelPresenter::AdjustDividerRectangle(void)
        float width = 0.0f;
        float height = 0.0f;
        FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
-       FloatRectangle dividerBounds(0.0f, 0.0f, 0.0f, 0.0f);
        _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
        Bitmap* pThumbBitmap = null;
 
@@ -754,17 +920,6 @@ _SplitPanelPresenter::AdjustDividerRectangle(void)
                {
                        __dividerRectangle = FloatRectangle(dividerPosition, 0.0f, width, height);
                        __dividerThumbRectangle = FloatRectangle(dividerPosition, ((height - pThumbBitmap->GetHeightF()) / 2.0f), pThumbBitmap->GetWidthF(), pThumbBitmap->GetHeightF());
-
-                       dividerBounds = __dividerRectangle;
-
-                       if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_FIRST))
-                       {
-                               dividerBounds.x = clientBounds.width;
-                       }
-                       else if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_SECOND))
-                       {
-                               dividerBounds.x = -__dividerRectangle.width;
-                       }
                }
        }
        else
@@ -775,21 +930,10 @@ _SplitPanelPresenter::AdjustDividerRectangle(void)
                {
                        __dividerRectangle = FloatRectangle(0.0f, dividerPosition, width, height);
                        __dividerThumbRectangle = FloatRectangle(((width - pThumbBitmap->GetWidth()) / 2.0f), dividerPosition, pThumbBitmap->GetWidthF(), pThumbBitmap->GetHeightF());
-
-                       dividerBounds = __dividerRectangle;
-
-                       if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_FIRST))
-                       {
-                               dividerBounds.y = clientBounds.height;
-                       }
-                       else if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_SECOND))
-                       {
-                               dividerBounds.y = -__dividerRectangle.height;
-                       }
                }
        }
 
-       __pSplitPanel->SetDividerVisualElementBounds(dividerBounds);
+       __pSplitPanel->SetDividerVisualElementBounds(__dividerRectangle);
 }
 
 result
@@ -1354,6 +1498,33 @@ _SplitPanelPresenter::GetRestorePaneBounds(SplitPanelPaneOrder paneOrder)
        return secondPaneBounds;
 }
 
+FloatRectangle
+_SplitPanelPresenter::GetPaneBounds(SplitPanelPaneOrder paneOrder)
+{
+       FloatRectangle firstPaneBounds;
+       FloatRectangle secondPaneBounds;
+
+       FloatRectangle clientBounds = __pSplitPanel->GetBoundsF();
+
+       if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
+       {
+               firstPaneBounds = FloatRectangle(0.0f, 0.0f, __dividerRectangle.x, clientBounds.height);
+               secondPaneBounds = FloatRectangle(__dividerRectangle.x + __dividerRectangle.width, 0.0f, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width, clientBounds.height);
+       }
+       else
+       {
+               firstPaneBounds  = FloatRectangle(0.0f, 0.0f, clientBounds.width, __dividerRectangle.y);
+               secondPaneBounds = FloatRectangle(0.0f, __dividerRectangle.y + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height);
+       }
+
+       if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
+       {
+               return firstPaneBounds;
+       }
+
+       return secondPaneBounds;
+}
+
 VisualElementPropertyAnimation*
 _SplitPanelPresenter::GetVisualElementAnimation(Tizen::Base::String propertyName)
 {
index 7b801ff..24285f9 100644 (file)
@@ -105,6 +105,13 @@ public:
        virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element);
        virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element);
 
+       //key listners
+       virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+       virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
+       virtual void OnDrawFocus(void);
+       bool OnFocusGained(const _Control& source);
+       bool OnFocusLost(const _Control& source);
+
 public:
        result AddSplitPanelEventListener(const _ISplitPanelEventListener& listener);
        result RemoveSplitPanelEventListener(const _ISplitPanelEventListener& listener);
index f05098c..8b19189 100644 (file)
@@ -71,6 +71,11 @@ public:
        virtual bool OnTapGestureDetected(_TouchTapGestureDetector& gesture);
        virtual bool OnTapGestureCanceled(_TouchTapGestureDetector& gesture);
 
+       virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+       virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
+       result DrawFocus(SplitPanelPaneOrder focusedPane = SPLIT_PANEL_PANE_ORDER_FIRST);
+       result ReleaseFocus(void);
+
        result SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle);
        SplitPanelDividerStyle GetDividerStyle(void) const;
 
@@ -105,6 +110,7 @@ private:
        Tizen::Ui::Control* GetPaneControl(SplitPanelPaneOrder paneOrder);
        Tizen::Ui::Animations::AnimationTransactionStatus GetTransactionStatus(void);
        Tizen::Graphics::FloatRectangle GetRestorePaneBounds(SplitPanelPaneOrder paneOrder);
+       Tizen::Graphics::FloatRectangle GetPaneBounds(SplitPanelPaneOrder paneOrder);
        Tizen::Ui::Animations::VisualElementPropertyAnimation* GetVisualElementAnimation(Tizen::Base::String propertyName);
 
 private:
@@ -127,6 +133,7 @@ private:
        Tizen::Graphics::Bitmap* __pDividerBackgroundBitmap;
        Tizen::Graphics::Bitmap* __pDividerBackgroundEffectBitmap;
        Tizen::Graphics::Bitmap* __pDividerThumbBitmap;
+       Tizen::Graphics::Bitmap* __pFocusBitmap;
        Tizen::Graphics::Color __dividerBackgroundColor;
        Tizen::Graphics::Color __dividerPressedBackgroundColor;
 
@@ -134,6 +141,9 @@ private:
        int __transactionIdMaximize;
        int __transactionIdRestore;
 
+       //Focus UI
+       SplitPanelPaneOrder __currentFocusedPane;
+
        Tizen::Ui::Animations::AnimationInterpolatorType __controlAnimatorInterpolator;
        Tizen::Base::String __visualElementInterpolator;