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

Side by Side Diff: mojo/ui/base_view.h

Issue 1991853003: Make BaseView et al. take an ApplicationConnector instead of an ApplicationImpl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 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 unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/application/lib/connect.cc ('k') | mojo/ui/base_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 MOJO_UI_BASE_VIEW_H_ 5 #ifndef MOJO_UI_BASE_VIEW_H_
6 #define MOJO_UI_BASE_VIEW_H_ 6 #define MOJO_UI_BASE_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/public/cpp/application/application_impl.h"
11 #include "mojo/public/cpp/bindings/binding.h" 10 #include "mojo/public/cpp/bindings/binding.h"
11 #include "mojo/public/cpp/bindings/interface_handle.h"
12 #include "mojo/public/cpp/bindings/strong_binding.h" 12 #include "mojo/public/cpp/bindings/strong_binding.h"
13 #include "mojo/public/cpp/system/macros.h" 13 #include "mojo/public/cpp/system/macros.h"
14 #include "mojo/public/interfaces/application/application_connector.mojom.h"
14 #include "mojo/public/interfaces/application/service_provider.mojom.h" 15 #include "mojo/public/interfaces/application/service_provider.mojom.h"
15 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h" 16 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h"
16 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h" 17 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h"
17 #include "mojo/services/ui/views/interfaces/views.mojom.h" 18 #include "mojo/services/ui/views/interfaces/views.mojom.h"
18 19
19 namespace mojo { 20 namespace mojo {
20 namespace ui { 21 namespace ui {
21 22
22 // Abstract base implementation of a view for simple applications. 23 // Abstract base implementation of a view for simple applications.
23 // Subclasses must handle layout and provide content for the scene by 24 // Subclasses must handle layout and provide content for the scene by
24 // implementing the methods of the |ViewListener| mojom interface. 25 // implementing the methods of the |ViewListener| mojom interface.
25 // 26 //
26 // It is not necessary to use this class to implement all Views. 27 // It is not necessary to use this class to implement all Views.
27 // This class is merely intended to make the simple apps easier to write. 28 // This class is merely intended to make the simple apps easier to write.
28 class BaseView : public mojo::ui::ViewListener, 29 class BaseView : public ViewListener, public ViewContainerListener {
29 public mojo::ui::ViewContainerListener {
30 public: 30 public:
31 // TODO(jeffbrown): Consider switching this over to an ApplicationConnector 31 BaseView(InterfaceHandle<ApplicationConnector> app_connector,
32 // but having ApplicationImpl is handy for simple examples. 32 InterfaceRequest<ViewOwner> view_owner_request,
33 BaseView(mojo::ApplicationImpl* app_impl,
34 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request,
35 const std::string& label); 33 const std::string& label);
36 34
37 ~BaseView() override; 35 ~BaseView() override;
38 36
39 // Gets the application implementation object provided at creation time. 37 // Gets the application implementation object provided at creation time.
40 mojo::ApplicationImpl* app_impl() { return app_impl_; } 38 ApplicationConnector* app_connector() { return app_connector_.get(); }
41 39
42 // Gets the view manager. 40 // Gets the view manager.
43 mojo::ui::ViewManager* view_manager() { return view_manager_.get(); } 41 ViewManager* view_manager() { return view_manager_.get(); }
44 42
45 // Gets the underlying view interface. 43 // Gets the underlying view interface.
46 mojo::ui::View* view() { return view_.get(); } 44 View* view() { return view_.get(); }
47 45
48 // Gets the service provider for the view. 46 // Gets the service provider for the view.
49 mojo::ServiceProvider* GetViewServiceProvider(); 47 ServiceProvider* GetViewServiceProvider();
50 48
51 // Gets the underlying view container interface. 49 // Gets the underlying view container interface.
52 mojo::ui::ViewContainer* GetViewContainer(); 50 ViewContainer* GetViewContainer();
53 51
54 // Gets the scene for the view. 52 // Gets the scene for the view.
55 // Returns nullptr if the |TakeScene| was called. 53 // Returns nullptr if the |TakeScene| was called.
56 mojo::gfx::composition::Scene* scene() { return scene_.get(); } 54 gfx::composition::Scene* scene() { return scene_.get(); }
57 55
58 // Takes the scene from the view. 56 // Takes the scene from the view.
59 // This is useful if the scene will be rendered by a separate component. 57 // This is useful if the scene will be rendered by a separate component.
60 mojo::gfx::composition::ScenePtr TakeScene() { return scene_.Pass(); } 58 gfx::composition::ScenePtr TakeScene() { return scene_.Pass(); }
61 59
62 // Gets the currently requested scene version. 60 // Gets the currently requested scene version.
63 uint32_t scene_version() { return scene_version_; } 61 uint32_t scene_version() { return scene_version_; }
64 62
65 // Gets the current view properties. 63 // Gets the current view properties.
66 // Returns nullptr if none. 64 // Returns nullptr if none.
67 mojo::ui::ViewProperties* properties() { return properties_.get(); } 65 ViewProperties* properties() { return properties_.get(); }
68 66
69 // Called when properties changed. 67 // Called when properties changed.
70 // Use |scene_version()| and |properties()| to get the current values. 68 // Use |scene_version()| and |properties()| to get the current values.
71 virtual void OnPropertiesChanged(uint32_t old_scene_version, 69 virtual void OnPropertiesChanged(uint32_t old_scene_version,
72 mojo::ui::ViewPropertiesPtr old_properties); 70 ViewPropertiesPtr old_properties);
73 71
74 // Called when a child is attached. 72 // Called when a child is attached.
75 virtual void OnChildAttached(uint32_t child_key, 73 virtual void OnChildAttached(uint32_t child_key, ViewInfoPtr child_view_info);
76 mojo::ui::ViewInfoPtr child_view_info);
77 74
78 // Called when a child becomes unavailable. 75 // Called when a child becomes unavailable.
79 virtual void OnChildUnavailable(uint32_t child_key); 76 virtual void OnChildUnavailable(uint32_t child_key);
80 77
81 private: 78 private:
82 // |ViewListener|: 79 // |ViewListener|:
83 void OnPropertiesChanged( 80 void OnPropertiesChanged(
84 uint32_t scene_version, 81 uint32_t scene_version,
85 mojo::ui::ViewPropertiesPtr properties, 82 ViewPropertiesPtr properties,
86 const OnPropertiesChangedCallback& callback) override; 83 const OnPropertiesChangedCallback& callback) override;
87 84
88 // |ViewContainerListener|: 85 // |ViewContainerListener|:
89 void OnChildAttached(uint32_t child_key, 86 void OnChildAttached(uint32_t child_key,
90 mojo::ui::ViewInfoPtr child_view_info, 87 ViewInfoPtr child_view_info,
91 const OnChildAttachedCallback& callback) override; 88 const OnChildAttachedCallback& callback) override;
92 void OnChildUnavailable(uint32_t child_key, 89 void OnChildUnavailable(uint32_t child_key,
93 const OnChildUnavailableCallback& callback) override; 90 const OnChildUnavailableCallback& callback) override;
94 91
95 mojo::ApplicationImpl* app_impl_; 92 ApplicationConnectorPtr app_connector_;
96 93
97 mojo::StrongBinding<mojo::ui::ViewListener> view_listener_binding_; 94 StrongBinding<ViewListener> view_listener_binding_;
98 mojo::Binding<mojo::ui::ViewContainerListener> 95 Binding<ViewContainerListener> view_container_listener_binding_;
99 view_container_listener_binding_; 96 ViewManagerPtr view_manager_;
100 mojo::ui::ViewManagerPtr view_manager_; 97 ViewPtr view_;
101 mojo::ui::ViewPtr view_; 98 ServiceProviderPtr view_service_provider_;
102 mojo::ServiceProviderPtr view_service_provider_; 99 ViewContainerPtr view_container_;
103 mojo::ui::ViewContainerPtr view_container_; 100 gfx::composition::ScenePtr scene_;
104 mojo::gfx::composition::ScenePtr scene_; 101 uint32_t scene_version_ = gfx::composition::kSceneVersionNone;
105 uint32_t scene_version_ = mojo::gfx::composition::kSceneVersionNone; 102 ViewPropertiesPtr properties_;
106 mojo::ui::ViewPropertiesPtr properties_;
107 103
108 MOJO_DISALLOW_COPY_AND_ASSIGN(BaseView); 104 MOJO_DISALLOW_COPY_AND_ASSIGN(BaseView);
109 }; 105 };
110 106
111 } // namespace ui 107 } // namespace ui
112 } // namespace mojo 108 } // namespace mojo
113 109
114 #endif // MOJO_UI_BASE_VIEW_H_ 110 #endif // MOJO_UI_BASE_VIEW_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/lib/connect.cc ('k') | mojo/ui/base_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698