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

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

Issue 818583002: Moves Create() off of View and onto ViewManager (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: merge 2 trunk Created 6 years 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_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ 6 #define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 18 matching lines...) Expand all
29 29
30 // Views are owned by the ViewManager. 30 // Views are owned by the ViewManager.
31 // TODO(beng): Right now, you'll have to implement a ViewObserver to track 31 // TODO(beng): Right now, you'll have to implement a ViewObserver to track
32 // destruction and NULL any pointers you have. 32 // destruction and NULL any pointers you have.
33 // Investigate some kind of smart pointer or weak pointer for these. 33 // Investigate some kind of smart pointer or weak pointer for these.
34 class View { 34 class View {
35 public: 35 public:
36 using Children = std::vector<View*>; 36 using Children = std::vector<View*>;
37 using SharedProperties = std::map<std::string, std::vector<uint8_t>>; 37 using SharedProperties = std::map<std::string, std::vector<uint8_t>>;
38 38
39 // Creates and returns a new View (which is owned by the ViewManager). Views
40 // are initially hidden, use SetVisible(true) to show.
41 static View* Create(ViewManager* view_manager);
42
43 // Destroys this view and all its children. 39 // Destroys this view and all its children.
44 void Destroy(); 40 void Destroy();
45 41
46 ViewManager* view_manager() { return manager_; } 42 ViewManager* view_manager() { return manager_; }
47 43
48 // Configuration. 44 // Configuration.
49 Id id() const { return id_; } 45 Id id() const { return id_; }
50 46
51 // Geometric disposition. 47 // Geometric disposition.
52 const Rect& bounds() const { return bounds_; } 48 const Rect& bounds() const { return bounds_; }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 127
132 protected: 128 protected:
133 // This class is subclassed only by test classes that provide a public ctor. 129 // This class is subclassed only by test classes that provide a public ctor.
134 View(); 130 View();
135 ~View(); 131 ~View();
136 132
137 private: 133 private:
138 friend class ViewPrivate; 134 friend class ViewPrivate;
139 friend class ViewManagerClientImpl; 135 friend class ViewManagerClientImpl;
140 136
141 explicit View(ViewManager* manager); 137 View(ViewManager* manager, Id id);
142 138
143 // Called by the public {Set,Get,Clear}Property functions. 139 // Called by the public {Set,Get,Clear}Property functions.
144 int64 SetLocalPropertyInternal(const void* key, 140 int64 SetLocalPropertyInternal(const void* key,
145 const char* name, 141 const char* name,
146 PropertyDeallocator deallocator, 142 PropertyDeallocator deallocator,
147 int64 value, 143 int64 value,
148 int64 default_value); 144 int64 default_value);
149 int64 GetLocalPropertyInternal(const void* key, int64 default_value) const; 145 int64 GetLocalPropertyInternal(const void* key, int64 default_value) const;
150 146
151 void LocalDestroy(); 147 void LocalDestroy();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 }; 191 };
196 192
197 std::map<const void*, Value> prop_map_; 193 std::map<const void*, Value> prop_map_;
198 194
199 DISALLOW_COPY_AND_ASSIGN(View); 195 DISALLOW_COPY_AND_ASSIGN(View);
200 }; 196 };
201 197
202 } // namespace mojo 198 } // namespace mojo
203 199
204 #endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ 200 #endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698