mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
1) Factors InkWell out of Material so that components can use an ink well without needing the shadow/level machinery. 2) Makes the ink effect move at a different velocity once the tap has actually occurred, converging with the spec. We don't have the right speeds yet, but at least we're approaching the right shape. 3) To support (2), added a primaryPointer attribute to GestureEvents to let authors coorelate gesturetapdown events with later gesturetap events. 4) To support (2), modernized SplashAnimation to used AnimatedValue and friends. 5) Added more constants to view-configuration.dart that match Android. I've also removed the cancelling of the ink effect on scroll. The proper way to do that is to notice that someone in the event chain is listening for scrollstart and delay the beginning of the ink effect for some period of time. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1019023003
105 lines
3.6 KiB
C++
105 lines
3.6 KiB
C++
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
#include "sky/engine/core/dom/Element.h"
|
|
#include "sky/engine/core/events/GestureEvent.h"
|
|
#include "sky/engine/wtf/text/AtomicString.h"
|
|
|
|
namespace blink {
|
|
|
|
static AtomicString stringForType(WebInputEvent::Type type)
|
|
{
|
|
if (type == WebInputEvent::GestureScrollBegin)
|
|
return EventTypeNames::gesturescrollstart;
|
|
if (type == WebInputEvent::GestureScrollEnd)
|
|
return EventTypeNames::gesturescrollend;
|
|
if (type == WebInputEvent::GestureScrollUpdate)
|
|
return EventTypeNames::gesturescrollupdate;
|
|
if (type == WebInputEvent::GestureScrollUpdateWithoutPropagation)
|
|
return EventTypeNames::gesturescrollupdate;
|
|
if (type == WebInputEvent::GestureFlingStart)
|
|
return EventTypeNames::gestureflingstart;
|
|
if (type == WebInputEvent::GestureFlingCancel)
|
|
return EventTypeNames::gestureflingcancel;
|
|
if (type == WebInputEvent::GestureShowPress)
|
|
return EventTypeNames::gestureshowpress;
|
|
if (type == WebInputEvent::GestureTap)
|
|
return EventTypeNames::gesturetap;
|
|
if (type == WebInputEvent::GestureTapUnconfirmed)
|
|
return EventTypeNames::gesturetapunconfirmed;
|
|
if (type == WebInputEvent::GestureTapDown)
|
|
return EventTypeNames::gesturetapdown;
|
|
if (type == WebInputEvent::GestureTapCancel)
|
|
return EventTypeNames::gesturetapcancel;
|
|
if (type == WebInputEvent::GestureDoubleTap)
|
|
return EventTypeNames::gesturedoubletap;
|
|
if (type == WebInputEvent::GestureTwoFingerTap)
|
|
return EventTypeNames::gesturetwofingertap;
|
|
if (type == WebInputEvent::GestureLongPress)
|
|
return EventTypeNames::gesturelongpress;
|
|
if (type == WebInputEvent::GestureLongTap)
|
|
return EventTypeNames::gesturelongtap;
|
|
if (type == WebInputEvent::GesturePinchBegin)
|
|
return EventTypeNames::gesturepinchstart;
|
|
if (type == WebInputEvent::GesturePinchEnd)
|
|
return EventTypeNames::gesturepinchend;
|
|
if (type == WebInputEvent::GesturePinchUpdate)
|
|
return EventTypeNames::gesturepinchupdate;
|
|
ASSERT_NOT_REACHED();
|
|
return AtomicString();
|
|
}
|
|
|
|
GestureEvent::~GestureEvent()
|
|
{
|
|
}
|
|
|
|
const AtomicString& GestureEvent::interfaceName() const
|
|
{
|
|
return EventNames::GestureEvent;
|
|
}
|
|
|
|
GestureEvent::GestureEvent()
|
|
: GestureEvent(AtomicString(), GestureEventInit())
|
|
{
|
|
}
|
|
|
|
GestureEvent::GestureEvent(const WebGestureEvent& event)
|
|
: Event(stringForType(event.type), true, true)
|
|
, m_primaryPointer(event.primaryPointer)
|
|
, m_x(event.x)
|
|
, m_y(event.y)
|
|
, m_dx(0)
|
|
, m_dy(0)
|
|
, m_velocityX(0)
|
|
, m_velocityY(0)
|
|
{
|
|
m_timeStamp = event.timeStampMS;
|
|
|
|
if (event.type == WebInputEvent::GestureFlingStart) {
|
|
m_velocityX = event.data.flingStart.velocityX;
|
|
m_velocityY = event.data.flingStart.velocityY;
|
|
} else if (event.type == WebInputEvent::GestureScrollUpdate
|
|
|| event.type == WebInputEvent::GestureScrollUpdateWithoutPropagation) {
|
|
m_dx = event.data.scrollUpdate.deltaX;
|
|
m_dy = event.data.scrollUpdate.deltaY;
|
|
m_velocityX = event.data.scrollUpdate.velocityX;
|
|
m_velocityY = event.data.scrollUpdate.velocityY;
|
|
}
|
|
}
|
|
|
|
GestureEvent::GestureEvent(const AtomicString& type, const GestureEventInit& initializer)
|
|
: Event(type, initializer)
|
|
, m_primaryPointer(initializer.primaryPointer)
|
|
, m_x(initializer.x)
|
|
, m_y(initializer.y)
|
|
, m_dx(initializer.dx)
|
|
, m_dy(initializer.dy)
|
|
, m_velocityX(initializer.velocityX)
|
|
, m_velocityY(initializer.velocityY)
|
|
{
|
|
}
|
|
|
|
} // namespace blink
|