OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 #ifndef SERVICES_PREDICTION_KEY_SET_H_ | |
6 #define SERVICES_PREDICTION_KEY_SET_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "mojo/services/prediction/public/interfaces/prediction.mojom.h" | |
10 | |
11 // qwerty keyboard key sets | |
12 | |
13 namespace prediction { | |
14 | |
15 // NOTE: This struct has been modified from the Android Open | |
16 // Source Project. Specifically from the following file: | |
17 // https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/ | |
18 // android-5.1.1_r8/java/src/com/android/inputmethod/keyboard/Key.java | |
19 struct Key { | |
20 int kcode; | |
21 // Width of the key, not including the gap | |
22 int kwidth; | |
23 // Height of the key, not including the gap | |
24 int kheight; | |
25 // X coordinate of the key in the keyboard layout | |
26 int kx; | |
27 // Y coordinate of the key in the keyboard layout | |
28 int ky; | |
29 // Hit bounding box of the key | |
30 int khit_box_left; | |
31 int khit_box_top; | |
32 int khit_box_right; | |
33 int khit_box_bottom; | |
34 | |
35 Key(const int code, | |
36 const int x, | |
37 const int y, | |
38 const int width, | |
39 const int height, | |
40 const int horizontal_gap, | |
41 const int vertical_gap) { | |
42 kheight = height - vertical_gap; | |
43 kwidth = width - horizontal_gap; | |
44 kcode = code; | |
45 kx = x + horizontal_gap / 2; | |
46 ky = y; | |
47 khit_box_left = x; | |
48 khit_box_top = y; | |
49 khit_box_right = x + width + 1; | |
50 khit_box_bottom = y + height; | |
51 } | |
52 }; | |
53 | |
54 class KeySet { | |
APW
2015/07/23 20:11:28
There doesn't seem to be a purpose to this class a
riajiang
2015/07/31 02:13:05
Changed it to use namespace
| |
55 public: | |
56 static const Key key_set[]; | |
57 static const int key_count; | |
58 | |
59 static int SquaredDistanceToEdge(int x, int y, Key k); | |
60 | |
61 private: | |
62 static const Key A; | |
63 static const Key B; | |
64 static const Key C; | |
65 static const Key D; | |
66 static const Key E; | |
67 static const Key F; | |
68 static const Key G; | |
69 static const Key H; | |
70 static const Key I; | |
71 static const Key J; | |
72 static const Key K; | |
73 static const Key L; | |
74 static const Key M; | |
75 static const Key N; | |
76 static const Key O; | |
77 static const Key P; | |
78 static const Key Q; | |
79 static const Key R; | |
80 static const Key S; | |
81 static const Key T; | |
82 static const Key U; | |
83 static const Key V; | |
84 static const Key W; | |
85 static const Key X; | |
86 static const Key Y; | |
87 static const Key Z; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(KeySet); | |
90 }; // class KeySet | |
91 | |
92 } // namespace prediction | |
93 | |
94 #endif // SERVICES_PREDICTION_KEY_SET_H_ | |
OLD | NEW |