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

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

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
Patch Set: 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
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_BASE_VIEW_H_
6 #define MOJO_UI_BASE_VIEW_H_
7
8 #include <string>
9
10 #include "mojo/public/cpp/application/application_impl.h"
11 #include "mojo/public/cpp/bindings/strong_binding.h"
12 #include "mojo/public/cpp/system/macros.h"
13 #include "mojo/public/interfaces/application/service_provider.mojom.h"
14 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h"
15 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h"
16 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h"
17 #include "mojo/services/ui/views/interfaces/views.mojom.h"
18
19 namespace mojo {
20 namespace ui {
21
22 // Abstract base implementation of the View interface for simple applications.
23 // Subclasses must handle layout and provide content for the scene.
viettrungluu 2016/01/05 21:35:17 It'd be nice to have a comment (maybe in the class
jeffbrown 2016/01/26 07:25:15 The View mojom is going to change shortly so for n
24 //
25 // It is not necessary to use this class to implement all Views.
26 // This class is merely intended to make the simple apps easier to write.
27 class BaseView : public mojo::ui::View {
28 public:
29 // TODO(jeffbrown): Consider switching this over to an ApplicationConnector
30 // but having ApplicationImpl is handy for simple examples.
31 BaseView(
32 mojo::ApplicationImpl* app_impl,
33 const std::string& label,
34 const mojo::ui::ViewProvider::CreateViewCallback& create_view_callback);
35
36 ~BaseView() override;
37
38 // Gets the application implementation object provided at creation time.
39 mojo::ApplicationImpl* app_impl() { return app_impl_; }
40
41 // Gets the view manager.
42 mojo::ui::ViewManager* view_manager() { return view_manager_.get(); }
43
44 // Gets the view host for the view.
45 mojo::ui::ViewHost* view_host() { return view_host_.get(); }
46
47 // Gets the service provider for the view.
48 mojo::ServiceProvider* view_service_provider() {
49 return view_service_provider_.get();
50 }
51
52 // Gets the scene for the view.
53 // Returns nullptr if the |TakeScene| was called.
54 mojo::gfx::composition::Scene* scene() { return scene_.get(); }
55
56 // Takes the scene from the view.
57 // This is useful if the scene will be rendered by a separate component.
58 mojo::gfx::composition::ScenePtr TakeScene() { return scene_.Pass(); }
59
60 // |View|:
61 void OnChildUnavailable(uint32_t child_key,
62 const OnChildUnavailableCallback& callback) override;
63
64 private:
65 mojo::ApplicationImpl* app_impl_;
66
67 mojo::StrongBinding<mojo::ui::View> view_binding_;
68 mojo::ui::ViewManagerPtr view_manager_;
69 mojo::ui::ViewHostPtr view_host_;
70 mojo::ServiceProviderPtr view_service_provider_;
71 mojo::gfx::composition::ScenePtr scene_;
72
73 MOJO_DISALLOW_COPY_AND_ASSIGN(BaseView);
74 };
75
76 } // namespace ui
77 } // namespace mojo
78
79 #endif // MOJO_UI_BASE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698