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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « mojo/ui/gl_view.cc ('k') | mojo/ui/input_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_UI_INPUT_HANDLER_H_
6 #define MOJO_UI_INPUT_HANDLER_H_
7
8 #include "mojo/public/cpp/bindings/binding.h"
9 #include "mojo/public/cpp/system/macros.h"
10 #include "mojo/public/interfaces/application/service_provider.mojom.h"
11 #include "mojo/services/ui/input/interfaces/input_connection.mojom.h"
12
13 namespace mojo {
14 namespace ui {
15
16 // Holds an |InputConnection| and sets its |InputListener|.
17 //
18 // This class is intended to be included as a member of a View that wants to
19 // receive input using the following pattern.
20 //
21 // class MyView : public mojo::ui::BaseView, public mojo::ui::InputListener {
22 // public:
23 // MyView(mojo::ApplicationImpl* app_impl,
24 // const mojo::ui::ViewProvider::CreateViewCallback&
25 // create_view_callback)
26 // : BaseView(app_impl, "MyView", create_view_callback),
27 // input_handler_(view_service_provider(), this) {}
28 // ~MyView() override {}
29 //
30 // private:
31 // // |InputListener|:
32 // void OnEvent(mojo::EventPtr event,
33 // const OnEventCallback& callback) override;
34 //
35 // mojo::ui::InputHandler input_handler_;
36 //
37 // MOJO_DISALLOW_COPY_AND_ASSIGN(MyView);
38 // };
39 class InputHandler {
40 public:
41 // Creates an input connection associated with the specified view host.
42 InputHandler(mojo::ServiceProvider* service_provider,
43 mojo::ui::InputListener* listener);
44 ~InputHandler();
45
46 // Gets the input connection.
47 mojo::ui::InputConnection* connection() { return connection_.get(); }
48
49 private:
50 mojo::Binding<mojo::ui::InputListener> listener_binding_;
51 mojo::ui::InputConnectionPtr connection_;
52
53 MOJO_DISALLOW_COPY_AND_ASSIGN(InputHandler);
54 };
55
56 } // namespace ui
57 } // namespace mojo
58
59 #endif // MOJO_UI_INPUT_HANDLER_H_
OLDNEW
« 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