[Title] Implement Flick.
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] N/A
Change-Id: I4c66477b4c15017f418f8f5f5ca80dad7843d8af
UIProcess/API/efl/editor/TextSelectionHandle.cpp
UIProcess/API/efl/editor/TextSelectionMagnifier.cpp
+ UIProcess/API/efl/tizen/EasingUtilities.cpp
+ UIProcess/API/efl/tizen/Flick.cpp
UIProcess/API/efl/tizen/Zoom.cpp
UIProcess/API/efl/tizen/ewk_popup_picker.cpp
GestureClient::GestureClient(Evas_Object* viewWidget)
: m_viewWidget(viewWidget)
+ , m_pan(Pan::create(viewWidget))
+ , m_flick(Flick::create(viewWidget))
{
- m_pan = Pan::create(viewWidget);
}
GestureClient::~GestureClient()
void GestureClient::startFlick(const IntPoint& position, const IntPoint& velocity)
{
- notImplemented();
+ m_flick->start(velocity);
}
void GestureClient::endFlick(const IntPoint& position, const IntPoint& velocity)
{
- notImplemented();
+ m_flick->stop();
}
void GestureClient::startPinch(const IntPoint& position, double scale)
#ifndef GestureClient_h
#define GestureClient_h
+#include "Flick.h"
#include "Pan.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
private:
GestureClient(Evas_Object*);
- OwnPtr<Pan> m_pan;
Evas_Object* m_viewWidget;
+ OwnPtr<Pan> m_pan;
+ OwnPtr<Flick> m_flick;
};
} // namespace WebKit
--- /dev/null
+/*
+ * Copyright (C) 2001 Robert Penner All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Robert Penner's easing equations. http://www.robertpenner.com/easing/
+ * static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
+ * if ((t/=d/2) < 1) return c/2*t*t*t + b;
+ * return c/2*((t-=2)*t*t + 2) + b;
+ * }
+ */
+float easeInOutCubic(int duration, int index)
+{
+ // If index is bigger than duration, it is error.
+ if (index > duration)
+ return 0;
+
+ // Time is reversed value of index.
+ float time = duration - index;
+ const float constant = 1;
+ float value;
+
+ if ((time /= (duration / 2)) < 1) {
+ value = (constant / 2) * time * time * time;
+ } else {
+ time -= 2;
+ value = (constant / 2) * (time * time * time + 2);
+ }
+
+ return value;
+}
--- /dev/null
+/*
+ * Copyright (C) 2001 Robert Penner All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EasingUtilities_h
+#define EasingUtilities_h
+
+float easeInOutCubic(int duration, int index);
+
+#endif // EasingUtilities_h
--- /dev/null
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "Flick.h"
+
+#include "EasingUtilities.h"
+#include "PageClientImpl.h"
+#include "WKAPICast.h"
+#include "WKPageTizen.h"
+#include "ewk_view_private.h"
+
+using namespace WebCore;
+using namespace WebKit;
+
+#define FLICK_DISTANCE_FACTOR 3 // It's measurement value. The more it's large, the more the total distance is extended.
+
+Flick::Flick(Evas_Object* viewWidget)
+ : m_viewWidget(viewWidget)
+ , m_velocity()
+ , m_flickIndex(0)
+ , m_flickAnimator(0)
+{
+}
+
+Flick::~Flick()
+{
+ stop();
+}
+
+void Flick::start(IntPoint velocity)
+{
+ stop();
+
+ if (!velocity.x() && !velocity.y())
+ return;
+
+ m_velocity = velocity;
+ m_flickIndex = 0;
+ m_flickAnimator = ecore_animator_add(flickAnimatorCallback, this);
+}
+
+void Flick::stop()
+{
+ if (m_flickAnimator) {
+ ecore_animator_del(m_flickAnimator);
+ m_flickAnimator = 0;
+ }
+}
+
+Eina_Bool Flick::flickAnimatorCallback(void* data)
+{
+ return static_cast<Flick*>(data)->process();
+}
+
+bool Flick::process()
+{
+ double frametime = ecore_animator_frametime_get();
+ double valueOfEaseInOutCubic = easeInOutCubic(FLICK_DISTANCE_FACTOR / frametime, m_flickIndex);
+ Evas_Coord deltaX = -1 * m_velocity.x() * frametime * valueOfEaseInOutCubic;
+ Evas_Coord deltaY = -1 * m_velocity.y() * frametime * valueOfEaseInOutCubic;
+
+ m_flickIndex++;
+ PageClientImpl* pageClientImpl = ewkViewGetPageClient(m_viewWidget);
+
+ if (!deltaX && !deltaY) {
+ m_flickAnimator = 0;
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ pageClientImpl->updateTextSelectionHandlesAndContextMenu(true);
+#endif
+ return false;
+
+ } else {
+ ewkViewSendScrollEvent(m_viewWidget, deltaX, deltaY);
+ IntPoint scrollPosition = pageClientImpl->scrollPosition();
+ WKPageScrollBy(toAPI(pageClientImpl->page()), toAPI(IntSize(deltaX, deltaY)));
+ ewkViewSendEdgeEvent(m_viewWidget, scrollPosition, deltaX, deltaY);
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ pageClientImpl->updateTextSelectionHandlesAndContextMenu(false);
+#endif
+ return true;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef Flick_h
+#define Flick_h
+
+#include <Ecore.h>
+#include <Eina.h>
+#include <Evas.h>
+#include <WebCore/IntPoint.h>
+#include <wtf/PassOwnPtr.h>
+
+class Flick {
+public:
+ static PassOwnPtr<Flick> create(Evas_Object* viewWidget)
+ {
+ return adoptPtr(new Flick(viewWidget));
+ }
+ ~Flick();
+
+ void start(WebCore::IntPoint velocity);
+ void stop();
+
+private:
+ static Eina_Bool flickAnimatorCallback(void*);
+
+private:
+ Flick(Evas_Object*);
+ bool process();
+
+ Evas_Object* m_viewWidget;
+ WebCore::IntPoint m_velocity;
+ int m_flickIndex;
+ Ecore_Animator* m_flickAnimator;
+};
+
+#endif // Flick_h