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

Side by Side Diff: mojo/services/public/cpp/view_manager/view.h

Issue 658923003: Remove dependency on ui from view_manager. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase Created 6 years, 1 month 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_ 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_
6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_ 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "mojo/public/cpp/bindings/array.h" 12 #include "mojo/public/cpp/bindings/array.h"
13 #include "mojo/public/interfaces/application/service_provider.mojom.h" 13 #include "mojo/public/interfaces/application/service_provider.mojom.h"
14 #include "mojo/services/public/cpp/view_manager/types.h" 14 #include "mojo/services/public/cpp/view_manager/types.h"
15 #include "mojo/services/public/interfaces/geometry/geometry.mojom.h"
15 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" 16 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h"
16 #include "mojo/services/public/interfaces/view_manager/view_manager_constants.mo jom.h" 17 #include "mojo/services/public/interfaces/view_manager/view_manager_constants.mo jom.h"
17 #include "ui/gfx/geometry/rect.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 20
21 class ServiceProviderImpl; 21 class ServiceProviderImpl;
22 class View; 22 class View;
23 class ViewManager; 23 class ViewManager;
24 class ViewObserver; 24 class ViewObserver;
25 25
26 // Views are owned by the ViewManager. 26 // Views are owned by the ViewManager.
27 // TODO(beng): Right now, you'll have to implement a ViewObserver to track 27 // TODO(beng): Right now, you'll have to implement a ViewObserver to track
28 // destruction and NULL any pointers you have. 28 // destruction and NULL any pointers you have.
29 // Investigate some kind of smart pointer or weak pointer for these. 29 // Investigate some kind of smart pointer or weak pointer for these.
30 class View { 30 class View {
31 public: 31 public:
32 typedef std::vector<View*> Children; 32 typedef std::vector<View*> Children;
33 33
34 static View* Create(ViewManager* view_manager); 34 static View* Create(ViewManager* view_manager);
35 35
36 // Destroys this view and all its children. 36 // Destroys this view and all its children.
37 void Destroy(); 37 void Destroy();
38 38
39 ViewManager* view_manager() { return manager_; } 39 ViewManager* view_manager() { return manager_; }
40 40
41 // Configuration. 41 // Configuration.
42 Id id() const { return id_; } 42 Id id() const { return id_; }
43 43
44 // Geometric disposition. 44 // Geometric disposition.
45 const gfx::Rect& bounds() const { return bounds_; } 45 const Rect& bounds() const { return bounds_; }
46 void SetBounds(const gfx::Rect& bounds); 46 void SetBounds(const Rect& bounds);
47 47
48 // Visibility (also see IsDrawn()). 48 // Visibility (also see IsDrawn()).
49 bool visible() const { return visible_; } 49 bool visible() const { return visible_; }
50 void SetVisible(bool value); 50 void SetVisible(bool value);
51 51
52 // A View is drawn if the View and all its ancestors are visible and the 52 // A View is drawn if the View and all its ancestors are visible and the
53 // View is attached to the root. 53 // View is attached to the root.
54 bool IsDrawn() const; 54 bool IsDrawn() const;
55 55
56 // Observation. 56 // Observation.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 friend class ViewPrivate; 93 friend class ViewPrivate;
94 friend class ViewManagerClientImpl; 94 friend class ViewManagerClientImpl;
95 95
96 explicit View(ViewManager* manager); 96 explicit View(ViewManager* manager);
97 97
98 void LocalDestroy(); 98 void LocalDestroy();
99 void LocalAddChild(View* child); 99 void LocalAddChild(View* child);
100 void LocalRemoveChild(View* child); 100 void LocalRemoveChild(View* child);
101 // Returns true if the order actually changed. 101 // Returns true if the order actually changed.
102 bool LocalReorder(View* relative, OrderDirection direction); 102 bool LocalReorder(View* relative, OrderDirection direction);
103 void LocalSetBounds(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds); 103 void LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds);
104 void LocalSetDrawn(bool drawn); 104 void LocalSetDrawn(bool drawn);
105 105
106 ViewManager* manager_; 106 ViewManager* manager_;
107 Id id_; 107 Id id_;
108 View* parent_; 108 View* parent_;
109 Children children_; 109 Children children_;
110 110
111 ObserverList<ViewObserver> observers_; 111 ObserverList<ViewObserver> observers_;
112 112
113 gfx::Rect bounds_; 113 Rect bounds_;
114 114
115 bool visible_; 115 bool visible_;
116 116
117 // Drawn state is derived from the visible state and the parent's visible 117 // Drawn state is derived from the visible state and the parent's visible
118 // state. This field is only used if the view has no parent (eg it's a root). 118 // state. This field is only used if the view has no parent (eg it's a root).
119 bool drawn_; 119 bool drawn_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(View); 121 DISALLOW_COPY_AND_ASSIGN(View);
122 }; 122 };
123 123
124 } // namespace mojo 124 } // namespace mojo
125 125
126 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_ 126 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698