Chromium Code Reviews| Index: services/prediction/key_set.h |
| diff --git a/services/prediction/key_set.h b/services/prediction/key_set.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d8d60301b9ccf099e9b047826f34473c3e3c48e8 |
| --- /dev/null |
| +++ b/services/prediction/key_set.h |
| @@ -0,0 +1,94 @@ |
| +// Copyright 2015 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 SERVICES_PREDICTION_KEY_SET_H_ |
| +#define SERVICES_PREDICTION_KEY_SET_H_ |
| + |
| +#include "base/macros.h" |
| +#include "mojo/services/prediction/public/interfaces/prediction.mojom.h" |
| + |
| +// qwerty keyboard key sets |
| + |
| +namespace prediction { |
| + |
| +// NOTE: This struct has been modified from the Android Open |
| +// Source Project. Specifically from the following file: |
| +// https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/ |
| +// android-5.1.1_r8/java/src/com/android/inputmethod/keyboard/Key.java |
| +struct Key { |
| + int kcode; |
| + // Width of the key, not including the gap |
| + int kwidth; |
| + // Height of the key, not including the gap |
| + int kheight; |
| + // X coordinate of the key in the keyboard layout |
| + int kx; |
| + // Y coordinate of the key in the keyboard layout |
| + int ky; |
| + // Hit bounding box of the key |
| + int khit_box_left; |
| + int khit_box_top; |
| + int khit_box_right; |
| + int khit_box_bottom; |
| + |
| + Key(const int code, |
| + const int x, |
| + const int y, |
| + const int width, |
| + const int height, |
| + const int horizontal_gap, |
| + const int vertical_gap) { |
| + kheight = height - vertical_gap; |
| + kwidth = width - horizontal_gap; |
| + kcode = code; |
| + kx = x + horizontal_gap / 2; |
| + ky = y; |
| + khit_box_left = x; |
| + khit_box_top = y; |
| + khit_box_right = x + width + 1; |
| + khit_box_bottom = y + height; |
| + } |
| +}; |
| + |
| +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
|
| + public: |
| + static const Key key_set[]; |
| + static const int key_count; |
| + |
| + static int SquaredDistanceToEdge(int x, int y, Key k); |
| + |
| + private: |
| + static const Key A; |
| + static const Key B; |
| + static const Key C; |
| + static const Key D; |
| + static const Key E; |
| + static const Key F; |
| + static const Key G; |
| + static const Key H; |
| + static const Key I; |
| + static const Key J; |
| + static const Key K; |
| + static const Key L; |
| + static const Key M; |
| + static const Key N; |
| + static const Key O; |
| + static const Key P; |
| + static const Key Q; |
| + static const Key R; |
| + static const Key S; |
| + static const Key T; |
| + static const Key U; |
| + static const Key V; |
| + static const Key W; |
| + static const Key X; |
| + static const Key Y; |
| + static const Key Z; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(KeySet); |
| +}; // class KeySet |
| + |
| +} // namespace prediction |
| + |
| +#endif // SERVICES_PREDICTION_KEY_SET_H_ |