Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: services/keyboard_native/key_layout.h

Issue 1149293002: Add the ability for keys to be drawn as an image. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Switch back to embedding with files downloading via gclient sync Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const char* ToText() const override; 76 const char* ToText() const override;
74 void OnTouchUp() override; 77 void OnTouchUp() override;
75 78
76 private: 79 private:
77 const char* text_; 80 const char* text_;
78 base::Callback<void(const TextKey&)> touch_up_callback_; 81 base::Callback<void(const TextKey&)> touch_up_callback_;
79 82
80 DISALLOW_COPY_AND_ASSIGN(TextKey); 83 DISALLOW_COPY_AND_ASSIGN(TextKey);
81 }; 84 };
82 85
86 // An implementation of Key that draws itself as an image.
87 class ImageKey : public TextKey {
jamesr 2015/05/27 23:30:31 why does this inherit from TextKey? inheriting fro
APW 2015/05/28 17:54:25 Done.
88 public:
89 ImageKey(const char* text,
90 base::Callback<void(const TextKey&)> touch_up_callback,
91 const mojo::embed::Data& data);
92 ~ImageKey() override;
93 void Draw(SkCanvas* canvas, SkPaint paint, const gfx::RectF& rect) override;
94
95 private:
96 SkBitmap bitmap_;
97
98 DISALLOW_COPY_AND_ASSIGN(ImageKey);
99 };
100
83 // initializes the *_layout_ vectors. 101 // initializes the *_layout_ vectors.
84 void InitLayouts(); 102 void InitLayouts();
85 103
86 // initializes the *_key_map_ vectors. 104 // initializes the *_key_map_ vectors.
87 void InitKeyMaps(); 105 void InitKeyMaps();
88 106
89 // A TextKey callback that does nothing. 107 // A TextKey callback that does nothing.
90 void OnKeyDoNothing(const TextKey& key); 108 void OnKeyDoNothing(const TextKey& key);
91 109
92 // A TextKey callback that calls on_text_callback_ with the text of the 110 // A TextKey callback that calls on_text_callback_ with the text of the
(...skipping 23 matching lines...) Expand all
116 std::vector<std::vector<Key*>> upper_case_key_map_; 134 std::vector<std::vector<Key*>> upper_case_key_map_;
117 std::vector<std::vector<Key*>> symbols_key_map_; 135 std::vector<std::vector<Key*>> symbols_key_map_;
118 base::WeakPtrFactory<KeyLayout> weak_factory_; 136 base::WeakPtrFactory<KeyLayout> weak_factory_;
119 137
120 DISALLOW_COPY_AND_ASSIGN(KeyLayout); 138 DISALLOW_COPY_AND_ASSIGN(KeyLayout);
121 }; 139 };
122 140
123 } // namespace keyboard 141 } // namespace keyboard
124 142
125 #endif // SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_ 143 #endif // SERVICES_KEYBOARD_NATIVE_KEY_LAYOUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698