File: touch_point.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (66 lines) | stat: -rw-r--r-- 2,386 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PPAPI_CPP_TOUCH_POINT_H_
#define PPAPI_CPP_TOUCH_POINT_H_

#include <stdint.h>

#include "ppapi/c/ppb_input_event.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/point.h"

namespace pp {

/// Wrapper class for PP_TouchPoint.
class TouchPoint {
 public:
  TouchPoint() : touch_point_(PP_MakeTouchPoint()) {}

  TouchPoint(const PP_TouchPoint& point)
      : touch_point_(point), tilt_(PP_MakeFloatPoint(0, 0)) {}

  TouchPoint(const PP_TouchPoint& point, const PP_FloatPoint& tilt)
      : touch_point_(point), tilt_(tilt) {}

  /// @return The identifier for this TouchPoint. This corresponds to the order
  /// in which the points were pressed. For example, the first point to be
  /// pressed has an id of 0, the second has an id of 1, and so on. An id can be
  /// reused when a touch point is released.  For example, if two fingers are
  /// down, with id 0 and 1, and finger 0 releases, the next finger to be
  /// pressed can be assigned to id 0.
  uint32_t id() const { return touch_point_.id; }

  /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space.
  FloatPoint position() const {
    return pp::FloatPoint(touch_point_.position);
  }

  /// @return The elliptical radii, in screen pixels, in the x and y direction
  /// of this TouchPoint.
  FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); }

  /// @return The angle of rotation of the elliptical model of this TouchPoint
  /// from the y-axis.
  float rotation_angle() const { return touch_point_.rotation_angle; }

  /// @return The pressure applied to this TouchPoint.  This is typically a
  /// value between 0 and 1, with 0 indicating no pressure and 1 indicating
  /// some maximum pressure, but scaling differs depending on the hardware and
  /// the value is not guaranteed to stay within that range.
  float pressure() const { return touch_point_.pressure; }

  /// @return The tilt of this touchpoint. This is a float point. Values of x
  /// and y are between 0 and 90, with 0 indicating 0 degrees and 90 indicating
  //  90 degrees.
  PP_FloatPoint tilt() const { return tilt_; }

 private:
  PP_TouchPoint touch_point_;
  PP_FloatPoint tilt_;
};

}  // namespace pp

#endif  // PPAPI_CPP_TOUCH_POINT_H_