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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
// Copyright (c) 2011 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.
#ifndef UI_AURA_EVENT_H_
#define UI_AURA_EVENT_H_
#pragma once
#include "base/basictypes.h"
#include "base/event_types.h"
#include "base/time.h"
#include "ui/aura/aura_export.h"
#include "ui/base/events.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/gfx/point.h"
namespace aura {
class Window;
class AURA_EXPORT Event {
public:
const base::NativeEvent& native_event() const { return native_event_; }
ui::EventType type() const { return type_; }
const base::Time& time_stamp() const { return time_stamp_; }
int flags() const { return flags_; }
protected:
Event(ui::EventType type, int flags);
Event(const base::NativeEvent& native_event, ui::EventType type, int flags);
Event(const Event& copy);
void set_type(ui::EventType type) { type_ = type; }
private:
void operator=(const Event&);
// Safely initializes the native event members of this class.
void Init();
void InitWithNativeEvent(const base::NativeEvent& native_event);
base::NativeEvent native_event_;
ui::EventType type_;
base::Time time_stamp_;
int flags_;
};
class AURA_EXPORT LocatedEvent : public Event {
public:
int x() const { return location_.x(); }
int y() const { return location_.y(); }
gfx::Point location() const { return location_; }
protected:
explicit LocatedEvent(const base::NativeEvent& native_event);
// Create a new LocatedEvent which is identical to the provided model.
// If source / target windows are provided, the model location will be
// converted from |source| coordinate system to |target| coordinate system.
LocatedEvent(const LocatedEvent& model, Window* source, Window* target);
// Used for synthetic events in testing.
LocatedEvent(ui::EventType type, const gfx::Point& location, int flags);
gfx::Point location_;
private:
DISALLOW_COPY_AND_ASSIGN(LocatedEvent);
};
class AURA_EXPORT MouseEvent : public LocatedEvent {
public:
explicit MouseEvent(const base::NativeEvent& native_event);
// Create a new MouseEvent which is identical to the provided model.
// If source / target windows are provided, the model location will be
// converted from |source| coordinate system to |target| coordinate system.
MouseEvent(const MouseEvent& model, Window* source, Window* target);
MouseEvent(const MouseEvent& model,
Window* source,
Window* target,
ui::EventType type);
// Used for synthetic events in testing.
MouseEvent(ui::EventType type, const gfx::Point& location, int flags);
private:
DISALLOW_COPY_AND_ASSIGN(MouseEvent);
};
class AURA_EXPORT TouchEvent : public LocatedEvent {
public:
explicit TouchEvent(const base::NativeEvent& native_event);
// Create a new TouchEvent which is identical to the provided model.
// If source / target windows are provided, the model location will be
// converted from |source| coordinate system to |target| coordinate system.
TouchEvent(const TouchEvent& model, Window* source, Window* target);
// Used for synthetic events in testing.
TouchEvent(ui::EventType type, const gfx::Point& location, int touch_id);
int touch_id() const { return touch_id_; }
float radius_x() const { return radius_x_; }
float radius_y() const { return radius_y_; }
float rotation_angle() const { return rotation_angle_; }
float force() const { return force_; }
private:
// The identity (typically finger) of the touch starting at 0 and incrementing
// for each separable additional touch that the hardware can detect.
const int touch_id_;
// Radius of the X (major) axis of the touch ellipse. 1.0 if unknown.
const float radius_x_;
// Radius of the Y (minor) axis of the touch ellipse. 1.0 if unknown.
const float radius_y_;
// Angle of the major axis away from the X axis. Default 0.0.
const float rotation_angle_;
// Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
const float force_;
DISALLOW_COPY_AND_ASSIGN(TouchEvent);
};
class AURA_EXPORT KeyEvent : public Event {
public:
explicit KeyEvent(const base::NativeEvent& native_event);
// Used for synthetic events in testing.
KeyEvent(ui::EventType type,
ui::KeyboardCode key_code,
int flags);
ui::KeyboardCode key_code() const { return key_code_; }
private:
ui::KeyboardCode key_code_;
};
} // namespace aura
#endif // UI_AURA_EVENT_H_
|