| OLD | NEW |
| 1 /* | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 * | 3 // found in the LICENSE file. |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * * Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * * Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | 4 |
| 26 #ifndef SKY_ENGINE_CORE_EVENTS_GESTUREEVENT_H_ | 5 #ifndef SKY_ENGINE_CORE_EVENTS_GESTUREEVENT_H_ |
| 27 #define SKY_ENGINE_CORE_EVENTS_GESTUREEVENT_H_ | 6 #define SKY_ENGINE_CORE_EVENTS_GESTUREEVENT_H_ |
| 28 | 7 |
| 29 #include "sky/engine/core/events/EventDispatcher.h" | 8 #include "sky/engine/core/events/Event.h" |
| 30 #include "sky/engine/core/events/MouseRelatedEvent.h" | 9 #include "sky/engine/public/platform/WebInputEvent.h" |
| 31 #include "sky/engine/platform/PlatformGestureEvent.h" | |
| 32 | 10 |
| 33 namespace blink { | 11 namespace blink { |
| 34 | 12 |
| 35 struct GestureEventInit : public UIEventInit { | 13 struct GestureEventInit : public EventInit { |
| 36 int screenX = 0; | 14 double x = 0; |
| 37 int screenY = 0; | 15 double y = 0; |
| 38 int clientX = 0; | 16 double dx = 0; |
| 39 int clientY = 0; | 17 double dy = 0; |
| 40 bool ctrlKey = false; | |
| 41 bool altKey = false; | |
| 42 bool shiftKey = false; | |
| 43 bool metaKey = false;; | |
| 44 double deltaX = 0; | |
| 45 double deltaY = 0; | |
| 46 double velocityX = 0; | 18 double velocityX = 0; |
| 47 double velocityY = 0; | 19 double velocityY = 0; |
| 48 }; | 20 }; |
| 49 | 21 |
| 50 class GestureEvent final : public MouseRelatedEvent { | 22 class GestureEvent : public Event { |
| 51 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
| 52 public: | 24 public: |
| 53 virtual ~GestureEvent() { } | 25 static PassRefPtr<GestureEvent> create() |
| 26 { |
| 27 return adoptRef(new GestureEvent); |
| 28 } |
| 29 static PassRefPtr<GestureEvent> create(const WebGestureEvent& event) |
| 30 { |
| 31 return adoptRef(new GestureEvent(event)); |
| 32 } |
| 33 static PassRefPtr<GestureEvent> create(const AtomicString& type, const Gestu
reEventInit& initializer) |
| 34 { |
| 35 return adoptRef(new GestureEvent(type, initializer)); |
| 36 } |
| 54 | 37 |
| 55 static PassRefPtr<GestureEvent> create() { return adoptRef(new GestureEvent)
; } | 38 ~GestureEvent() override; |
| 56 static PassRefPtr<GestureEvent> create(PassRefPtr<AbstractView>, const Platf
ormGestureEvent&); | |
| 57 static PassRefPtr<GestureEvent> create(const AtomicString& type, const Gestu
reEventInit&); | |
| 58 | |
| 59 bool isGestureEvent() const override; | |
| 60 | |
| 61 const AtomicString& interfaceName() const override; | 39 const AtomicString& interfaceName() const override; |
| 62 | 40 |
| 63 float deltaX() const { return m_deltaX; } | 41 float x() const { return m_x; } |
| 64 float deltaY() const { return m_deltaY; } | 42 float y() const { return m_y; } |
| 65 | 43 float dx() const { return m_dx; } |
| 44 float dy() const { return m_dy; } |
| 66 float velocityX() const { return m_velocityX; } | 45 float velocityX() const { return m_velocityX; } |
| 67 float velocityY() const { return m_velocityY; } | 46 float velocityY() const { return m_velocityY; } |
| 68 | 47 |
| 69 private: | 48 private: |
| 70 GestureEvent(); | 49 GestureEvent(); |
| 50 explicit GestureEvent(const WebGestureEvent&); |
| 71 GestureEvent(const AtomicString& type, const GestureEventInit&); | 51 GestureEvent(const AtomicString& type, const GestureEventInit&); |
| 72 GestureEvent(const AtomicString& type, PassRefPtr<AbstractView>, int screenX
, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKe
y, bool metaKey, float deltaX, float deltaY, float velocityX, float velocityY); | |
| 73 | 52 |
| 74 float m_deltaX; | 53 float m_x; |
| 75 float m_deltaY; | 54 float m_y; |
| 76 | 55 float m_dx; |
| 56 float m_dy; |
| 77 float m_velocityX; | 57 float m_velocityX; |
| 78 float m_velocityY; | 58 float m_velocityY; |
| 79 }; | 59 }; |
| 80 | 60 |
| 81 class GestureEventDispatchMediator final : public EventDispatchMediator { | |
| 82 public: | |
| 83 static PassRefPtr<GestureEventDispatchMediator> create(PassRefPtr<GestureEve
nt> gestureEvent) | |
| 84 { | |
| 85 return adoptRef(new GestureEventDispatchMediator(gestureEvent)); | |
| 86 } | |
| 87 | |
| 88 private: | |
| 89 explicit GestureEventDispatchMediator(PassRefPtr<GestureEvent>); | |
| 90 | |
| 91 GestureEvent* event() const; | |
| 92 | |
| 93 virtual bool dispatchEvent(EventDispatcher*) const override; | |
| 94 }; | |
| 95 | |
| 96 DEFINE_EVENT_TYPE_CASTS(GestureEvent); | |
| 97 | |
| 98 } // namespace blink | 61 } // namespace blink |
| 99 | 62 |
| 100 #endif // SKY_ENGINE_CORE_EVENTS_GESTUREEVENT_H_ | 63 #endif // SKY_ENGINE_CORE_EVENTS_GESTUREEVENT_H_ |
| OLD | NEW |