OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "views/touchui/gesture_manager.h" |
| 6 #ifndef NDEBUG |
| 7 #include <iostream> |
| 8 #endif |
| 9 |
| 10 #include "base/logging.h" |
| 11 #include "views/event.h" |
| 12 #include "views/view.h" |
| 13 |
| 14 namespace views { |
| 15 |
| 16 GestureManager::~GestureManager() { |
| 17 } |
| 18 |
| 19 GestureManager* GestureManager::Get() { |
| 20 return Singleton<GestureManager>::get(); |
| 21 } |
| 22 |
| 23 bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event, |
| 24 View* source, |
| 25 bool previouslyHandled) { |
| 26 // TODO(rjkroege): A realistic version of the GestureManager will |
| 27 // appear in a subsequent CL. This interim version permits verifying that the |
| 28 // event distirbution code works by turning all touch inputs into |
| 29 // mouse approximations. |
| 30 bool handled = false; |
| 31 if (event.GetType() == Event::ET_TOUCH_PRESSED) { |
| 32 DLOG(INFO) << "GestureManager::ProcessTouchEventForGesture: " << |
| 33 "TouchPressed\n"; |
| 34 MouseEvent mouse_event(Event::ET_MOUSE_PRESSED, event.x(), event.y(), |
| 35 event.GetFlags()); |
| 36 source->OnMousePressed(mouse_event); |
| 37 handled = true; |
| 38 } else if (event.GetType() == Event::ET_TOUCH_RELEASED) { |
| 39 DLOG(INFO) << "GestureManager::ProcessTouchEventForGesture: " << |
| 40 "TouchReleased\n"; |
| 41 MouseEvent mouse_event(Event::ET_MOUSE_RELEASED, event.x(), event.y(), |
| 42 event.GetFlags()); |
| 43 source->OnMouseReleased(mouse_event, false); |
| 44 handled = true; |
| 45 } else if (event.GetType() == Event::ET_TOUCH_MOVED) { |
| 46 DLOG(INFO) << "GestureManager::ProcessTouchEventForGesture: " << |
| 47 "TouchMotion\n"; |
| 48 MouseEvent mouse_event(Event::ET_MOUSE_DRAGGED, event.x(), event.y(), |
| 49 event.GetFlags()); |
| 50 source->OnMouseDragged(mouse_event); |
| 51 handled = true; |
| 52 } else { |
| 53 DLOG(INFO) << "GestureManager::ProcessTouchEventForGesture: " << |
| 54 "unhandled event\n"; |
| 55 } |
| 56 return handled; |
| 57 } |
| 58 |
| 59 GestureManager::GestureManager() { |
| 60 } |
| 61 |
| 62 } // namespace views |
OLD | NEW |