fix for p130925 - 00132
authorvipul <vipul.kumar@samsung.com>
Wed, 25 Sep 2013 09:50:04 +0000 (15:20 +0530)
committervipul <vipul.kumar@samsung.com>
Fri, 27 Sep 2013 06:43:08 +0000 (12:13 +0530)
Signed-off-by: vipul <vipul.kumar@samsung.com>
Change-Id: I84eff6a0db80232a252f2eb342cb36c5a4206f6d

src/ui/controls/FUiCtrl_OptionMenu.cpp
src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp
src/ui/inc/FUiCtrl_OptionMenu.h
src/ui/inc/FUiCtrl_OptionMenuPresenter.h
src/ui/inc/FUi_ResourceOptionMenuConfig.h
src/ui/resource/FUi_ResourceOptionMenuConfig.cpp

index 14cac9a..b10f1a3 100644 (file)
@@ -28,6 +28,7 @@
 #include "FUi_ControlImplManager.h"
 #include "FUi_EcoreEvasMgr.h"
 #include "FUi_ResourceManager.h"
+#include "FUi_TouchManager.h"
 #include "FUiAnim_VisualElement.h"
 #include "FUiAnim_AnimationManager.h"
 #include "FUi_AccessibilityContainer.h"
@@ -39,7 +40,6 @@
 #include "FUiCtrl_Scroll.h"
 #include "FUiCtrl_ContextMenu.h"
 #include "FUiCtrl_OptionMenuItem.h"
-#include "FUi_TouchManager.h"
 
 using namespace Tizen::Graphics;
 using namespace Tizen::Base;
@@ -64,6 +64,9 @@ _OptionMenu::_OptionMenu(void)
        , __isMaxVisibleCountSet(false)
        , __isFocused(false)
        , __currentFocusedIndex(-1)
+       , __selectedActionID(-1)
+       , __pBoundsTimingFunction(null)
+       , __pOpacityTimingFunction(null)
        , __windowRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
        , __bodyRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
        , __itemRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
@@ -124,6 +127,12 @@ _OptionMenu::~_OptionMenu(void)
        delete __pActionEvent;
        __pActionEvent = null;
 
+       delete __pBoundsTimingFunction;
+       __pBoundsTimingFunction = null;
+
+       delete __pOpacityTimingFunction;
+       __pOpacityTimingFunction= null;
+
        __actionId.RemoveAll();
 
        RemoveAllAccessibilityElement();
@@ -325,7 +334,7 @@ _OptionMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
                __isFocused = false;
                __pOptionMenuPresenter->ClearFocus();
 
-               SetVisibleState(false);
+               CloseAnimation(-1);
                return true;
        }
 
@@ -333,7 +342,7 @@ _OptionMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
        {
                if (__isAttachedToMainTree)
                {
-                       SetVisibleState(false);
+                       CloseAnimation(-1);
                }
                else
                {
@@ -346,6 +355,21 @@ _OptionMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
        return false;
 }
 
+void
+_OptionMenu::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
+{
+       if (keyName == L"ClosingOpacityAnimation")
+       {
+               SetVisibleState(false);
+
+               if (__selectedActionID != -1)
+               {
+                       FireActionEvent(__selectedActionID);
+                       __selectedActionID = -1;
+               }
+       }
+}
+
 result
 _OptionMenu::Install(void)
 {
@@ -494,24 +518,7 @@ _OptionMenu::OnAttachedToMainTree(void)
 
        SetAllAccessibilityElement();
 
-       _VisualElement* pVisualElement = GetVisualElement();
-       FloatRectangle pBounds = pVisualElement->GetBounds();
-       float oldBoundsX = pBounds.x;
-       float oldBoundsY = pBounds.y;
-
-       pVisualElement->SetBounds(pBounds);
-       pVisualElement->SetOpacity(0.0f);
-
-       bool enable = pVisualElement->IsImplicitAnimationEnabled();
-
-       pVisualElement->SetImplicitAnimationEnabled(true);
-
-       pBounds.x = oldBoundsX;
-       pBounds.y = oldBoundsY;
-       pVisualElement->SetBounds(pBounds);
-       pVisualElement->SetOpacity(1.0f);
-
-       pVisualElement->SetImplicitAnimationEnabled(enable);
+       OpenAnimation();
 
        return _Window::OnAttachedToMainTree();
 }
@@ -1359,6 +1366,179 @@ _OptionMenu::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& tou
        return __pOptionMenuPresenter->OnPreviewTouchPressed(source, touchinfo);
 }
 
+void
+_OptionMenu::OpenAnimation()
+{
+       result r = E_SUCCESS;
+
+       VisualElementPropertyAnimation* pBoundsAnimation;
+       VisualElementPropertyAnimation* pOpacityAnimation;
+
+       _VisualElement* pVisualElement = GetVisualElement();
+       FloatRectangle pEndBounds = pVisualElement->GetBounds();
+       FloatRectangle pStartBounds(0.0f, 0.0f, 0.0f, 0.0f);
+       pStartBounds = pEndBounds;
+
+       float animationDistance = 0.0f;
+
+       GET_SHAPE_CONFIG(OPTIONMENU::ANIMATION_DISTANCE_Y, _CONTROL_ORIENTATION_PORTRAIT, animationDistance);
+
+       pStartBounds.y += animationDistance;
+
+       pBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
+       SysTryReturnVoidResult(NID_UI_CTRL, pBoundsAnimation != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation();
+       SysTryCatch(NID_UI_CTRL, pOpacityAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (__pBoundsTimingFunction != null)
+       {
+               delete __pBoundsTimingFunction;
+               __pBoundsTimingFunction = null;
+       }
+
+       __pBoundsTimingFunction = new (std::nothrow) SineThirtyThreeTimingFunction();
+       SysTryCatch(NID_UI_CTRL, __pBoundsTimingFunction != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pBoundsAnimation->SetPropertyName(L"bounds");
+       pBoundsAnimation->SetStartValue(Variant(pStartBounds));
+       pBoundsAnimation->SetEndValue(Variant(pEndBounds));
+       pBoundsAnimation->SetTimingFunction(__pBoundsTimingFunction);
+       pBoundsAnimation->SetDuration(ANIMATION_DURATION);
+
+       pBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
+
+       pVisualElement->AddAnimation(L"OpeningBoundsAnimation", *pBoundsAnimation);
+
+       if (__pOpacityTimingFunction != null)
+       {
+               delete __pOpacityTimingFunction;
+               __pOpacityTimingFunction = null;
+       }
+
+       __pOpacityTimingFunction = new (std::nothrow) SineSixtyTimingFunction();
+       SysTryCatch(NID_UI_CTRL, __pOpacityTimingFunction != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pOpacityAnimation->SetPropertyName(L"opacity");
+       pOpacityAnimation->SetStartValue(Variant(0.0f));
+       pOpacityAnimation->SetEndValue(Variant(1.0f));
+       pBoundsAnimation->SetTimingFunction(__pOpacityTimingFunction);
+       pOpacityAnimation->SetDuration(ANIMATION_DURATION);
+
+       pOpacityAnimation->SetVisualElementAnimationStatusEventListener(this);
+
+       pVisualElement->AddAnimation(L"OpeningOpacityAnimation", *pOpacityAnimation);
+
+       delete pBoundsAnimation;
+       pBoundsAnimation = null;
+
+       delete pOpacityAnimation;
+       pOpacityAnimation = null;
+
+       return;
+
+CATCH:
+       delete pBoundsAnimation;
+
+       delete pOpacityAnimation;
+
+       delete __pBoundsTimingFunction;
+       __pBoundsTimingFunction = null;
+
+       delete __pOpacityTimingFunction;
+       __pOpacityTimingFunction = null;
+
+       return;
+}
+
+void
+_OptionMenu::CloseAnimation(int actionId)
+{
+       result r = E_SUCCESS;
+       __selectedActionID = actionId;
+
+       VisualElementPropertyAnimation* pBoundsAnimation ;
+       VisualElementPropertyAnimation* pOpacityAnimation;
+
+       _VisualElement* pVisualElement = GetVisualElement();
+
+       FloatRectangle pStartBounds = pVisualElement->GetBounds();
+       FloatRectangle pEndBounds(0.0f, 0.0f, 0.0f, 0.0f);
+       pEndBounds = pStartBounds;
+
+       float animationDistance = 0.0f;
+
+       GET_SHAPE_CONFIG(OPTIONMENU::ANIMATION_DISTANCE_Y, _CONTROL_ORIENTATION_PORTRAIT, animationDistance);
+
+       pEndBounds.y += animationDistance;
+
+       pBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
+       SysTryReturnVoidResult(NID_UI_CTRL, pBoundsAnimation != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation();
+       SysTryCatch(NID_UI_CTRL, pOpacityAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       if (__pBoundsTimingFunction != null)
+       {
+               delete __pBoundsTimingFunction;
+               __pBoundsTimingFunction = null;
+       }
+
+       __pBoundsTimingFunction = new (std::nothrow) SineThirtyThreeTimingFunction();
+       SysTryCatch(NID_UI_CTRL, __pBoundsTimingFunction != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pBoundsAnimation->SetPropertyName(L"bounds");
+       pBoundsAnimation->SetStartValue(Variant(pStartBounds));
+       pBoundsAnimation->SetEndValue(Variant(pEndBounds));
+       pBoundsAnimation->SetTimingFunction(__pBoundsTimingFunction);
+       pBoundsAnimation->SetEndValueApplied(false);
+       pBoundsAnimation->SetDuration(ANIMATION_DURATION);
+
+       pBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
+
+       if (__pOpacityTimingFunction != null)
+       {
+               delete __pOpacityTimingFunction;
+               __pOpacityTimingFunction = null;
+       }
+
+       __pOpacityTimingFunction = new (std::nothrow) SineSixtyTimingFunction();
+       SysTryCatch(NID_UI_CTRL, __pOpacityTimingFunction != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pOpacityAnimation->SetPropertyName(L"opacity");
+       pOpacityAnimation->SetStartValue(Variant(1.0f));
+       pOpacityAnimation->SetEndValue(Variant(0.0f));
+       pBoundsAnimation->SetEndValueApplied(false);
+       pBoundsAnimation->SetTimingFunction(__pOpacityTimingFunction);
+       pOpacityAnimation->SetDuration(ANIMATION_DURATION);
+
+       pOpacityAnimation->SetVisualElementAnimationStatusEventListener(this);
+
+       pVisualElement->AddAnimation(L"ClosingBoundsAnimation", *pBoundsAnimation);
+       pVisualElement->AddAnimation(L"ClosingOpacityAnimation", *pOpacityAnimation);
+
+       delete pBoundsAnimation;
+       pBoundsAnimation = null;
+
+       delete pOpacityAnimation;
+       pOpacityAnimation = null;
+
+       return;
+
+CATCH:
+       delete pBoundsAnimation;
+
+       delete pOpacityAnimation;
+
+       delete __pBoundsTimingFunction;
+       __pBoundsTimingFunction = null;
+
+       delete __pOpacityTimingFunction;
+       __pOpacityTimingFunction = null;
+
+       return;
+}
+
 bool
 _OptionMenu::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
 {
@@ -1528,7 +1708,7 @@ _OptionMenu::OnAccessibilityFocusOut(const _AccessibilityContainer& control, con
 bool
 _OptionMenu::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
 {
-       SetVisibleState(false);
+       CloseAnimation(-1);
 
        return true;
 }
index 7bc11ee..e578c11 100755 (executable)
@@ -30,6 +30,7 @@
 #include "FUi_CoordinateSystemUtils.h"
 #include "FUi_Math.h"
 #include "FUi_ResourceManager.h"
+#include "FUiAnim_MatrixUtil.h"
 #include "FUiCtrl_ActionEvent.h"
 #include "FUiCtrl_IActionEventListener.h"
 
@@ -40,6 +41,7 @@ using namespace Tizen::Ui;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Runtime;
 using namespace Tizen::Graphics::_Text;
+using namespace Tizen::Ui::Animations;
 
 namespace {
 static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
@@ -50,6 +52,58 @@ static const int OPTION_MENU_LIST_ELEMENT_BITMAP = 1;
 namespace Tizen { namespace Ui { namespace Controls
 {
 
+float
+SineThirtyThreeTimingFunction::CalculateProgress(float timeProgress) const
+{
+       const float segments[2][3] = {{0.0f, 0.050f, 0.495f}, {0.495f, 0.940f, 1.0f}};
+
+       float loc_5 = timeProgress;
+       int loc_6 = 2;  //Length of the segments array
+       int loc_9 = (int)floor(loc_6 * loc_5);
+
+       if (loc_9 >= loc_6)
+       {
+               loc_9 = loc_6 - 1;
+       }
+
+       float loc_7 = (loc_5 - loc_9 * (1.0f / loc_6)) * loc_6;
+
+       float loc_8[3];
+
+       for (int i = 0; i < 3; i++)
+       {
+               loc_8[i] = segments[loc_9][i];
+       }
+
+       float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0])));
+       return ret;
+}
+
+float
+SineSixtyTimingFunction::CalculateProgress(float timeProgress) const
+{
+       const float segments[3][3] = {{0.0f, 0.01f, 0.37f}, {0.37f, 0.72f, 0.888f}, {0.888f, 0.9999f, 1.0f}};
+       float loc_5 = timeProgress;
+       int loc_6 = 3;  //Length of the segments array
+       int loc_9 = (int)floor(loc_6 * loc_5);
+
+       if (loc_9 >= loc_6)
+       {
+               loc_9 = loc_6 - 1;
+       }
+       float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6;
+       float loc_8[3];
+
+       for (int i = 0; i < 3; i++)
+       {
+               loc_8[i] = segments[loc_9][i];
+       }
+
+       float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0])));
+
+       return ret;
+}
+
 _OptionMenuPresenter::_OptionMenuPresenter(_OptionMenu* pOptionMenu)
        : __pOptionMenu(pOptionMenu)
        , __pModel(null)
@@ -832,8 +886,7 @@ _OptionMenuPresenter::OnEnterKeyReleased(int selectedIndex)
                }
                else
                {
-                       __pOptionMenu->Close();
-                       __pOptionMenu->FireActionEvent(pItem->GetActionId());
+                       __pOptionMenu->CloseAnimation(pItem->GetActionId());
                }
        }
        return;
@@ -920,8 +973,7 @@ _OptionMenuPresenter::OnTouchReleased(const _Control& source, const _TouchInfo&
                if (!itemRect.Contains(touchPosition))
                {
                        __selectedIndex = -1;
-                       __pOptionMenu->SetVisibleState(false);
-
+                       __pOptionMenu->CloseAnimation(-1);
                        return true;
                }
        }
@@ -946,9 +998,8 @@ _OptionMenuPresenter::OnTouchReleased(const _Control& source, const _TouchInfo&
                        else
                        {
                                // Fire Action Event
-                               __pOptionMenu->SetVisibleState(false);
+                               __pOptionMenu->CloseAnimation(pItem->GetActionId());
                                PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pOptionMenu);
-                               __pOptionMenu->FireActionEvent(pItem->GetActionId());
                        }
                }
 
@@ -993,8 +1044,7 @@ _OptionMenuPresenter::OnActionPerformed(const _Control& source, int actionId)
 {
        // for SubMenu Events
        __pOptionMenu->DestroySubMenu();
-       __pOptionMenu->SetVisibleState(false);
-       __pOptionMenu->FireActionEvent(actionId);
+       __pOptionMenu->CloseAnimation(actionId);
 }
 
 void
index 7dc760b..0cd85e0 100644 (file)
 
 #include <FBaseString.h>
 #include <FGrpColor.h>
+#include <FUiAnimIVisualElementAnimationStatusEventListener.h>
 #include "FUi_Window.h"
 #include "FUiCtrl_OptionMenuPresenter.h"
 #include "FUiCtrl_ActionEvent.h"
 #include "FUiCtrl_IActionEventListener.h"
 #include "FUiCtrl_IFrameEventListener.h"
-
 #include "FUiCtrl_ScrollPanel.h"
 
 namespace Tizen { namespace Ui {
@@ -72,6 +72,7 @@ class _OSP_EXPORT_ _OptionMenu
        , virtual public _IUiEventPreviewer
        , public _IAccessibilityListener
        , virtual public _IFrameEventListener
+       , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
 {
        DECLARE_CLASS_BEGIN(_OptionMenu, _Control);
        DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor);
@@ -114,6 +115,9 @@ public:
        static _OptionMenu* CreateOptionMenuN(void);
 
 public:
+        void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
+        void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount){};
+        void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target){};
        result Install(void);
        result Initialize(void);
        result AddItem(const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
@@ -174,6 +178,8 @@ public:
        virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
        virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
        virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
+       void CloseAnimation(int actionID);
+       void OpenAnimation();
 
        virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
        virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
@@ -235,6 +241,12 @@ private:
        bool __isMaxVisibleCountSet;
        bool __isFocused;
        int __currentFocusedIndex;
+       int __selectedActionID;
+
+       static const int ANIMATION_DURATION = 333;
+
+       Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* __pBoundsTimingFunction;
+       Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* __pOpacityTimingFunction;
 
        // attribute for position fo the window
        Tizen::Graphics::FloatRectangle __windowRect;   // OptionMenu window in the whole screen area
index cae21ba..436f9ef 100644 (file)
 #include <FBaseString.h>
 #include <FGrpColor.h>
 #include <FGrpBitmap.h>
+#include <FGrpFloatMatrix4.h>
+#include <FUiAnimIVisualElementAnimationTimingFunction.h>
 #include <FUiCtrlListView.h>
 #include <FUiCtrlCustomItem.h>
 
+
 #include "FUi_Control.h"
+#include "FUiAnim_VisualElement.h"
 #include "FUiCtrl_OptionMenu.h"
 #include "FUiCtrl_OptionMenuModel.h"
-#include "FUiAnim_VisualElement.h"
 
 namespace Tizen { namespace Ui { namespace Controls
 {
@@ -43,6 +46,20 @@ class _OptionMenuModel;
 class _OptionMenuItem;
 class _ListItem;
 
+class SineThirtyThreeTimingFunction
+               : public Tizen::Ui::Animations::IVisualElementAnimationTimingFunction
+{
+public:
+       float CalculateProgress(float timeProgress) const;
+}; // SineTimingFunction
+
+class SineSixtyTimingFunction
+               : public Tizen::Ui::Animations::IVisualElementAnimationTimingFunction
+{
+public:
+       float CalculateProgress(float timeProgress) const;
+}; // SineTimingFunction
+
 struct _OptionMenuItemInfo
 {
        bool bListItem;
index 9214e04..614e2bd 100644 (file)
@@ -72,6 +72,7 @@ DECLARE_UI_CONFIG(OPTIONMENU);
        DECLARE_SHAPE_CONFIG(ITEM_BG_PRESSED_LEFT_RIGHT_MARGIN, 25);
        DECLARE_SHAPE_CONFIG(ITEM_BG_PRESSED_TOP_BOTTOM_MARGIN, 26);
        DECLARE_SHAPE_CONFIG(SCROLL_PANEL_MARGIN, 27);
+       DECLARE_SHAPE_CONFIG(ANIMATION_DISTANCE_Y, 28);
 
 DECLARE_END_UI_CONFIG(OPTIONMENU);
 
index 1a92f09..9ef6b35 100644 (file)
@@ -84,6 +84,7 @@ START_UI_CONFIG(OPTIONMENU);
                ADD_SHAPE_CONFIG(ITEM_BG_PRESSED_LEFT_RIGHT_MARGIN, 4);
                ADD_SHAPE_CONFIG(ITEM_BG_PRESSED_TOP_BOTTOM_MARGIN, 3);
                ADD_SHAPE_CONFIG(SCROLL_PANEL_MARGIN, 3);
+               ADD_SHAPE_CONFIG(ANIMATION_DISTANCE_Y, 40);
        }
        END_UI_CONFIG_MODE(720x1280);