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

Unified Diff: mojo/ui/input_handler.h

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
Patch Set: address feedback Created 4 years, 11 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
« no previous file with comments | « mojo/ui/gl_view.cc ('k') | mojo/ui/input_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/ui/input_handler.h
diff --git a/mojo/ui/input_handler.h b/mojo/ui/input_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..50735848f24971844b3c35287a7028cc03694a41
--- /dev/null
+++ b/mojo/ui/input_handler.h
@@ -0,0 +1,59 @@
+// 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 MOJO_UI_INPUT_HANDLER_H_
+#define MOJO_UI_INPUT_HANDLER_H_
+
+#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/system/macros.h"
+#include "mojo/public/interfaces/application/service_provider.mojom.h"
+#include "mojo/services/ui/input/interfaces/input_connection.mojom.h"
+
+namespace mojo {
+namespace ui {
+
+// Holds an |InputConnection| and sets its |InputListener|.
+//
+// This class is intended to be included as a member of a View that wants to
+// receive input using the following pattern.
+//
+// class MyView : public mojo::ui::BaseView, public mojo::ui::InputListener {
+// public:
+// MyView(mojo::ApplicationImpl* app_impl,
+// const mojo::ui::ViewProvider::CreateViewCallback&
+// create_view_callback)
+// : BaseView(app_impl, "MyView", create_view_callback),
+// input_handler_(view_service_provider(), this) {}
+// ~MyView() override {}
+//
+// private:
+// // |InputListener|:
+// void OnEvent(mojo::EventPtr event,
+// const OnEventCallback& callback) override;
+//
+// mojo::ui::InputHandler input_handler_;
+//
+// MOJO_DISALLOW_COPY_AND_ASSIGN(MyView);
+// };
+class InputHandler {
+ public:
+ // Creates an input connection associated with the specified view host.
+ InputHandler(mojo::ServiceProvider* service_provider,
+ mojo::ui::InputListener* listener);
+ ~InputHandler();
+
+ // Gets the input connection.
+ mojo::ui::InputConnection* connection() { return connection_.get(); }
+
+ private:
+ mojo::Binding<mojo::ui::InputListener> listener_binding_;
+ mojo::ui::InputConnectionPtr connection_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(InputHandler);
+};
+
+} // namespace ui
+} // namespace mojo
+
+#endif // MOJO_UI_INPUT_HANDLER_H_
« no previous file with comments | « mojo/ui/gl_view.cc ('k') | mojo/ui/input_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698