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

Unified 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: Fix .gitignore and other issues Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: services/keyboard_native/key_layout.h
diff --git a/services/keyboard_native/key_layout.h b/services/keyboard_native/key_layout.h
index d55e50f44c27b769ffcfa2d01f61c4f0c6f8107c..683efc757c0b9bc226343e40a84fbc9bed81bc95 100644
--- a/services/keyboard_native/key_layout.h
+++ b/services/keyboard_native/key_layout.h
@@ -12,7 +12,10 @@
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/services/geometry/public/interfaces/geometry.mojom.h"
+#include "mojo/tools/embed/data.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkImageDecoder.h"
viettrungluu 2015/06/02 22:29:35 I don't think you need these includes in the .h, o
APW 2015/06/02 23:16:55 Done.
+#include "third_party/skia/include/core/SkStream.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
@@ -69,6 +72,8 @@ class KeyLayout {
TextKey(const char* text,
base::Callback<void(const TextKey&)> touch_up_callback);
~TextKey() override;
+
+ // Key implementation.
void Draw(SkCanvas* canvas, SkPaint paint, const gfx::RectF& rect) override;
const char* ToText() const override;
void OnTouchUp() override;
@@ -80,6 +85,27 @@ class KeyLayout {
DISALLOW_COPY_AND_ASSIGN(TextKey);
};
+ // An implementation of Key that draws itself as an image.
+ class ImageKey : public Key {
+ public:
+ ImageKey(const char* text,
+ base::Callback<void(const TextKey&)> touch_up_callback,
+ const mojo::embed::Data& data);
viettrungluu 2015/06/02 22:29:35 Probably you can just forward declare mojo::embed:
APW 2015/06/02 23:16:55 Done.
+ ~ImageKey() override;
+
+ // Key implementation.
+ void Draw(SkCanvas* canvas, SkPaint paint, const gfx::RectF& rect) override;
+ const char* ToText() const override;
+ void OnTouchUp() override;
+
+ private:
+ TextKey text_key_;
+ bool bitmap_valid_;
+ SkBitmap bitmap_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImageKey);
+ };
+
// initializes the *_layout_ vectors.
void InitLayouts();

Powered by Google App Engine
This is Rietveld 408576698