Init Tizen 2.2.1
[framework/osp/web.git] / src / controls / FWebCtrl_WebNotification.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 6ca49c9..98f3fad
  * @file               FWebCtrl_WebNotification.cpp
  * @brief              The file contains the definition of _WebNotification class.
  */
-
 #include <FBaseRtTimer.h>
 #include <FBaseSysLog.h>
+#include <FSysVibrator.h>
+#include <FSys_VibratorImpl.h>
 #include <FUiAnimControlAnimator.h>
 #include <FUiAnimPointAnimation.h>
 #include <FUiAnimFloatAnimation.h>
 #include <FUiAnimAnimationTransaction.h>
+#include <FUiAnimVisualElementPropertyAnimation.h>
 #include <FUiCtrlButton.h>
+#include "FWebCtrl_WebImpl.h"
 #include "FWebCtrl_WebNotificationHandler.h"
 #include "FWebCtrl_WebNotification.h"
 
@@ -38,14 +41,17 @@ using namespace Tizen::Ui;
 using namespace Tizen::Ui::Animations;
 using namespace Tizen::Ui::Controls;
 
+
 namespace Tizen { namespace Web { namespace Controls
 {
 
+
 _WebNotification::_WebNotification(void)
                                : __pNotificationHandler(null)
                                , __pContext(null)
                                , __notificationId(0)
                                , __pTimer(null)
+                               , __pWebImpl(null)
 {
 }
 
@@ -54,13 +60,10 @@ _WebNotification::~_WebNotification(void)
 {
 }
 
+
 result
-_WebNotification::Construct(Ewk_Context *pContext, uint64_t notificationId)
+_WebNotification::Construct(Ewk_Context *pContext, uint64_t notificationId, Tizen::Web::Controls::_WebImpl* pImpl)
 {
-
-//     _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
-//     Dimension screenRect = _ControlManager::GetInstance()->GetScreenSize();
-
        Rectangle rect(NOTIFCATION_RECT_AREA);
        result r = E_SUCCESS;
 
@@ -71,6 +74,7 @@ _WebNotification::Construct(Ewk_Context *pContext, uint64_t notificationId)
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
        SetBounds(rect);
 
+       Window::SetOwner(&pImpl->GetPublic());
        __pNotificationHandler = std::unique_ptr<_WebNotificationHandler>(new (std::nothrow) _WebNotificationHandler());
        SysTryReturnResult(NID_WEB_CTRL, __pNotificationHandler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
 
@@ -84,6 +88,8 @@ _WebNotification::Construct(Ewk_Context *pContext, uint64_t notificationId)
        r = __pTimer->Construct(*this);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
 
+       __pWebImpl = pImpl;
+
        return r;
 }
 
@@ -94,6 +100,7 @@ _WebNotification::SetText(const String& text)
        __pNotificationHandler->SetText(text);
 }
 
+
 String
 _WebNotification::GetText(void) const
 {
@@ -123,6 +130,16 @@ _WebNotification::OnClicked()
        ewk_notification_clicked(__pContext,__notificationId);
 }
 
+
+void
+_WebNotification::OnChangeLayout(void)
+{
+       SetShowState(false);
+       SetShowState(true);
+       Window::Show();
+}
+
+
 result
 _WebNotification::LaunchNotification()
 {
@@ -133,29 +150,30 @@ _WebNotification::LaunchNotification()
        r = pButton->Construct(Rectangle(NOTIFCATION_BUTTON_AREA));
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
 
-       pButton->SetText(L"x"); //Need to add bit map
+       pButton->SetText(L"x"); //Need to add bitmap
        pButton->AddActionEventListener(*this);
 
        r = AddControl(pButton.get());
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
        pButton.release();
 
        SetShowState(true);
        r = Window::Show();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
 
-       Point start(0,-200),end;
-       PointAnimation pointAnimation(Point(0, 0), Point(0, 0), 0, ANIMATION_INTERPOLATOR_LINEAR);
+       FloatRectangle rect(static_cast< float >(NOTIFCATION_RECT_AREA.x),static_cast< float >(NOTIFCATION_RECT_AREA.y),static_cast< float >(NOTIFCATION_RECT_AREA.width),static_cast< float >(NOTIFCATION_RECT_AREA.height));
 
-       end = Point(0,0);
+       FloatRectangle __endRect = rect;
+       FloatRectangle __startRect = FloatRectangle(rect.x, rect.height - 200, rect.width, rect.height);
 
-       pointAnimation.SetStartValue(start);
-       pointAnimation.SetEndValue(end);
-       pointAnimation.SetDuration(2000);
-       pointAnimation.SetAutoReverseEnabled(false);
+       std::unique_ptr<VisualElementPropertyAnimation> pAnimation(new (std::nothrow) VisualElementPropertyAnimation());
+       SysTryReturnResult(NID_WEB_CTRL, pAnimation.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-       ControlAnimator *pAnimator = this->GetControlAnimator();
-       r = pAnimator->StartUserAnimation(ANIMATION_TARGET_POSITION, pointAnimation);
-       SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error Propagated.", GetErrorMessage(r));
+       pAnimation->SetPropertyName(L"bounds");
+       pAnimation->SetStartValue(Variant(__startRect));
+       pAnimation->SetEndValue(Variant(__endRect));
+       pAnimation->SetDuration(2000);
+       this->GetVisualElement()->AddAnimation(L"bounds", *pAnimation);
 
        __pTimer->Start(15000);
        return E_SUCCESS;
@@ -165,32 +183,29 @@ _WebNotification::LaunchNotification()
 void
 _WebNotification::OnTimerExpired(Timer& timer)
 {
-
-       int transactionId = 0;
-       int duration = 1000;
        float start = 1.0f;
        float end = 0.0f;
 
-       ParallelAnimationGroup showAnim;
-       FloatAnimation floatAnim(start, end, duration, ANIMATION_INTERPOLATOR_LINEAR);
-       showAnim.AddAnimation(ANIMATION_TARGET_ALPHA, floatAnim);
+       std::unique_ptr<VisualElementPropertyAnimation> pAnimation(new (std::nothrow) VisualElementPropertyAnimation());
+       SysTryReturnVoidResult(NID_WEB_CTRL, pAnimation.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-       AnimationTransaction::Begin(transactionId);
-
-       ControlAnimator *pAnimator = this->GetControlAnimator();
-       pAnimator->SetAnimation(ANIMATION_TRIGGER_SHOW_STATE_CHANGE, &showAnim);
-       pAnimator->SetShowState(static_cast< int >(start));
-
-       AnimationTransaction::Commit();
-       delete this;
+       pAnimation->SetPropertyName(L"opacity");
+       pAnimation->SetStartValue(Variant(start));
+       pAnimation->SetEndValue(Variant(end));
+       pAnimation->SetDuration(2000);
+       this->GetVisualElement()->AddAnimation(L"opacity", *pAnimation);
 }
 
+
 void
 _WebNotification::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
 {
        SetShowState(false);
 
+       __pWebImpl->ClearWebNotification(this);
+
        delete this;
 }
 
+
 }}}