OLD | NEW |
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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 struct ViewProperty; | 28 struct ViewProperty; |
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 | 37 |
| 38 // Creates and returns a new View (which is owned by the ViewManager). Views |
| 39 // are initially hidden, use SetVisible(true) to show. |
38 static View* Create(ViewManager* view_manager); | 40 static View* Create(ViewManager* view_manager); |
39 | 41 |
40 // Destroys this view and all its children. | 42 // Destroys this view and all its children. |
41 void Destroy(); | 43 void Destroy(); |
42 | 44 |
43 ViewManager* view_manager() { return manager_; } | 45 ViewManager* view_manager() { return manager_; } |
44 | 46 |
45 // Configuration. | 47 // Configuration. |
46 Id id() const { return id_; } | 48 Id id() const { return id_; } |
47 | 49 |
48 // Geometric disposition. | 50 // Geometric disposition. |
49 const Rect& bounds() const { return bounds_; } | 51 const Rect& bounds() const { return bounds_; } |
50 void SetBounds(const Rect& bounds); | 52 void SetBounds(const Rect& bounds); |
51 | 53 |
52 // Visibility (also see IsDrawn()). | 54 // Visibility (also see IsDrawn()). When created views are hidden. |
53 bool visible() const { return visible_; } | 55 bool visible() const { return visible_; } |
54 void SetVisible(bool value); | 56 void SetVisible(bool value); |
55 | 57 |
56 // Returns the set of string to bag of byte properties. These properties are | 58 // Returns the set of string to bag of byte properties. These properties are |
57 // shared with the view manager. | 59 // shared with the view manager. |
58 const std::map<std::string, std::vector<uint8_t>>& shared_properties() const { | 60 const std::map<std::string, std::vector<uint8_t>>& shared_properties() const { |
59 return properties_; | 61 return properties_; |
60 } | 62 } |
61 // Sets a property. If |data| is null, this property is deleted. | 63 // Sets a property. If |data| is null, this property is deleted. |
62 void SetSharedProperty(const std::string& name, | 64 void SetSharedProperty(const std::string& name, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 }; | 181 }; |
180 | 182 |
181 std::map<const void*, Value> prop_map_; | 183 std::map<const void*, Value> prop_map_; |
182 | 184 |
183 DISALLOW_COPY_AND_ASSIGN(View); | 185 DISALLOW_COPY_AND_ASSIGN(View); |
184 }; | 186 }; |
185 | 187 |
186 } // namespace mojo | 188 } // namespace mojo |
187 | 189 |
188 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_ | 190 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_H_ |
OLD | NEW |