| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_ | 5 #ifndef SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_ |
| 6 #define SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_ | 6 #define SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "mojo/public/cpp/bindings/callback.h" | 13 #include "mojo/public/cpp/bindings/callback.h" |
| 14 #include "mojo/services/geometry/public/interfaces/geometry.mojom.h" | 14 #include "mojo/services/geometry/public/interfaces/geometry.mojom.h" |
| 15 #include "mojo/tools/embed/data.h" |
| 15 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "third_party/skia/include/core/SkImageDecoder.h" |
| 18 #include "third_party/skia/include/core/SkStream.h" |
| 16 #include "ui/gfx/geometry/point.h" | 19 #include "ui/gfx/geometry/point.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 18 | 21 |
| 19 namespace keyboard { | 22 namespace keyboard { |
| 20 | 23 |
| 21 // Represents a drawable keyboard. | 24 // Represents a drawable keyboard. |
| 22 class KeyLayout { | 25 class KeyLayout { |
| 23 public: | 26 public: |
| 24 // All keys represented by this KeyBoard layout will implement the Key | 27 // All keys represented by this KeyBoard layout will implement the Key |
| 25 // interface. | 28 // interface. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 const char* ToText() const override; | 73 const char* ToText() const override; |
| 71 void OnTouchUp() override; | 74 void OnTouchUp() override; |
| 72 | 75 |
| 73 private: | 76 private: |
| 74 const char* text_; | 77 const char* text_; |
| 75 base::Callback<void(const TextKey&)> touch_up_callback_; | 78 base::Callback<void(const TextKey&)> touch_up_callback_; |
| 76 | 79 |
| 77 DISALLOW_COPY_AND_ASSIGN(TextKey); | 80 DISALLOW_COPY_AND_ASSIGN(TextKey); |
| 78 }; | 81 }; |
| 79 | 82 |
| 83 // An implementation of Key that draws itself as an image. |
| 84 class ImageKey : public TextKey { |
| 85 public: |
| 86 ImageKey(const char* text, |
| 87 base::Callback<void(const TextKey&)> touch_up_callback, |
| 88 const mojo::embed::Data& data); |
| 89 ~ImageKey() override; |
| 90 void Draw(SkCanvas* canvas, SkPaint paint, const gfx::RectF& rect) override; |
| 91 |
| 92 private: |
| 93 SkBitmap bitmap_; |
| 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(ImageKey); |
| 96 }; |
| 97 |
| 80 // initializes the *_layout_ vectors. | 98 // initializes the *_layout_ vectors. |
| 81 void InitLayouts(); | 99 void InitLayouts(); |
| 82 | 100 |
| 83 // initializes the *_key_map_ vectors. | 101 // initializes the *_key_map_ vectors. |
| 84 void InitKeyMaps(); | 102 void InitKeyMaps(); |
| 85 | 103 |
| 86 // A TextKey callback that does nothing. | 104 // A TextKey callback that does nothing. |
| 87 void OnKeyDoNothing(const TextKey& key); | 105 void OnKeyDoNothing(const TextKey& key); |
| 88 | 106 |
| 89 // A TextKey callback that calls on_text_callback_ with the text of the | 107 // A TextKey callback that calls on_text_callback_ with the text of the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 109 std::vector<std::vector<Key*>> upper_case_key_map_; | 127 std::vector<std::vector<Key*>> upper_case_key_map_; |
| 110 std::vector<std::vector<Key*>> symbols_key_map_; | 128 std::vector<std::vector<Key*>> symbols_key_map_; |
| 111 base::WeakPtrFactory<KeyLayout> weak_factory_; | 129 base::WeakPtrFactory<KeyLayout> weak_factory_; |
| 112 | 130 |
| 113 DISALLOW_COPY_AND_ASSIGN(KeyLayout); | 131 DISALLOW_COPY_AND_ASSIGN(KeyLayout); |
| 114 }; | 132 }; |
| 115 | 133 |
| 116 } // namespace keyboard | 134 } // namespace keyboard |
| 117 | 135 |
| 118 #endif // SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_ | 136 #endif // SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_ |
| OLD | NEW |