Home | History | Annotate | Download | only in events
      1 // Copyright 2014 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 "ui/events/gesture_event_details.h"
      6 
      7 namespace ui {
      8 
      9 GestureEventDetails::GestureEventDetails()
     10     : type_(ET_UNKNOWN), touch_points_(0), oldest_touch_id_(-1) {
     11 }
     12 
     13 GestureEventDetails::GestureEventDetails(ui::EventType type)
     14     : type_(type), touch_points_(1), oldest_touch_id_(-1) {
     15   DCHECK_GE(type, ET_GESTURE_TYPE_START);
     16   DCHECK_LE(type, ET_GESTURE_TYPE_END);
     17 }
     18 
     19 GestureEventDetails::GestureEventDetails(ui::EventType type,
     20                                          float delta_x,
     21                                          float delta_y)
     22     : type_(type), touch_points_(1), oldest_touch_id_(-1) {
     23   DCHECK_GE(type, ET_GESTURE_TYPE_START);
     24   DCHECK_LE(type, ET_GESTURE_TYPE_END);
     25   switch (type_) {
     26     case ui::ET_GESTURE_SCROLL_BEGIN:
     27       data.scroll_begin.x_hint = delta_x;
     28       data.scroll_begin.y_hint = delta_y;
     29       break;
     30 
     31     case ui::ET_GESTURE_SCROLL_UPDATE:
     32       data.scroll_update.x = delta_x;
     33       data.scroll_update.y = delta_y;
     34       break;
     35 
     36     case ui::ET_SCROLL_FLING_START:
     37       data.fling_velocity.x = delta_x;
     38       data.fling_velocity.y = delta_y;
     39       break;
     40 
     41     case ui::ET_GESTURE_TWO_FINGER_TAP:
     42       data.first_finger_enclosing_rectangle.width = delta_x;
     43       data.first_finger_enclosing_rectangle.height = delta_y;
     44       break;
     45 
     46     case ui::ET_GESTURE_SWIPE:
     47       data.swipe.left = delta_x < 0;
     48       data.swipe.right = delta_x > 0;
     49       data.swipe.up = delta_y < 0;
     50       data.swipe.down = delta_y > 0;
     51       break;
     52 
     53     default:
     54       NOTREACHED() << "Invalid event type for constructor: " << type;
     55   }
     56 }
     57 
     58 GestureEventDetails::Details::Details() {
     59   memset(this, 0, sizeof(Details));
     60 }
     61 
     62 }  // namespace ui
     63