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_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 <stdint.h> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/basictypes.h" | |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "geometry/public/interfaces/geometry.mojom.h" | 12 #include "geometry/public/interfaces/geometry.mojom.h" |
13 #include "mojo/public/cpp/bindings/array.h" | 13 #include "mojo/public/cpp/bindings/array.h" |
| 14 #include "mojo/public/cpp/system/macros.h" |
14 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 15 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
15 #include "surfaces/public/interfaces/surface_id.mojom.h" | 16 #include "surfaces/public/interfaces/surface_id.mojom.h" |
16 #include "view_manager/public/cpp/types.h" | 17 #include "view_manager/public/cpp/types.h" |
17 #include "view_manager/public/interfaces/view_manager.mojom.h" | 18 #include "view_manager/public/interfaces/view_manager.mojom.h" |
18 #include "view_manager/public/interfaces/view_manager_constants.mojom.h" | 19 #include "view_manager/public/interfaces/view_manager_constants.mojom.h" |
19 | 20 |
20 namespace mojo { | 21 namespace mojo { |
21 | 22 |
22 class ServiceProviderImpl; | 23 class ServiceProviderImpl; |
23 class View; | 24 class View; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 81 |
81 // Sets the |property| to its default value. Useful for avoiding a cast when | 82 // Sets the |property| to its default value. Useful for avoiding a cast when |
82 // setting to NULL. | 83 // setting to NULL. |
83 // | 84 // |
84 // These properties are only visible in the current process and are not | 85 // These properties are only visible in the current process and are not |
85 // shared with other mojo services. | 86 // shared with other mojo services. |
86 template <typename T> | 87 template <typename T> |
87 void ClearLocalProperty(const ViewProperty<T>* property); | 88 void ClearLocalProperty(const ViewProperty<T>* property); |
88 | 89 |
89 // Type of a function to delete a property that this view owns. | 90 // Type of a function to delete a property that this view owns. |
90 typedef void (*PropertyDeallocator)(int64 value); | 91 typedef void (*PropertyDeallocator)(int64_t value); |
91 | 92 |
92 // A View is drawn if the View and all its ancestors are visible and the | 93 // A View is drawn if the View and all its ancestors are visible and the |
93 // View is attached to the root. | 94 // View is attached to the root. |
94 bool IsDrawn() const; | 95 bool IsDrawn() const; |
95 | 96 |
96 // Observation. | 97 // Observation. |
97 void AddObserver(ViewObserver* observer); | 98 void AddObserver(ViewObserver* observer); |
98 void RemoveObserver(ViewObserver* observer); | 99 void RemoveObserver(ViewObserver* observer); |
99 | 100 |
100 // Tree. | 101 // Tree. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 View(); | 135 View(); |
135 ~View(); | 136 ~View(); |
136 | 137 |
137 private: | 138 private: |
138 friend class ViewPrivate; | 139 friend class ViewPrivate; |
139 friend class ViewManagerClientImpl; | 140 friend class ViewManagerClientImpl; |
140 | 141 |
141 View(ViewManager* manager, Id id); | 142 View(ViewManager* manager, Id id); |
142 | 143 |
143 // Called by the public {Set,Get,Clear}Property functions. | 144 // Called by the public {Set,Get,Clear}Property functions. |
144 int64 SetLocalPropertyInternal(const void* key, | 145 int64_t SetLocalPropertyInternal(const void* key, |
145 const char* name, | 146 const char* name, |
146 PropertyDeallocator deallocator, | 147 PropertyDeallocator deallocator, |
147 int64 value, | 148 int64_t value, |
148 int64 default_value); | 149 int64_t default_value); |
149 int64 GetLocalPropertyInternal(const void* key, int64 default_value) const; | 150 int64_t GetLocalPropertyInternal(const void* key, |
| 151 int64_t default_value) const; |
150 | 152 |
151 void LocalDestroy(); | 153 void LocalDestroy(); |
152 void LocalAddChild(View* child); | 154 void LocalAddChild(View* child); |
153 void LocalRemoveChild(View* child); | 155 void LocalRemoveChild(View* child); |
154 // Returns true if the order actually changed. | 156 // Returns true if the order actually changed. |
155 bool LocalReorder(View* relative, OrderDirection direction); | 157 bool LocalReorder(View* relative, OrderDirection direction); |
156 void LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds); | 158 void LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds); |
157 void LocalSetViewportMetrics(const ViewportMetrics& old_metrics, | 159 void LocalSetViewportMetrics(const ViewportMetrics& old_metrics, |
158 const ViewportMetrics& new_metrics); | 160 const ViewportMetrics& new_metrics); |
159 void LocalSetDrawn(bool drawn); | 161 void LocalSetDrawn(bool drawn); |
| 162 void LocalSetVisible(bool visible); |
160 | 163 |
161 // Methods implementing visibility change notifications. See ViewObserver | 164 // Methods implementing visibility change notifications. See ViewObserver |
162 // for more details. | 165 // for more details. |
163 void NotifyViewVisibilityChanged(View* target); | 166 void NotifyViewVisibilityChanged(View* target); |
164 // Notifies this view's observers. Returns false if |this| was deleted during | 167 // Notifies this view's observers. Returns false if |this| was deleted during |
165 // the call (by an observer), otherwise true. | 168 // the call (by an observer), otherwise true. |
166 bool NotifyViewVisibilityChangedAtReceiver(View* target); | 169 bool NotifyViewVisibilityChangedAtReceiver(View* target); |
167 // Notifies this view and its child hierarchy. Returns false if |this| was | 170 // Notifies this view and its child hierarchy. Returns false if |this| was |
168 // deleted during the call (by an observer), otherwise true. | 171 // deleted during the call (by an observer), otherwise true. |
169 bool NotifyViewVisibilityChangedDown(View* target); | 172 bool NotifyViewVisibilityChangedDown(View* target); |
(...skipping 16 matching lines...) Expand all Loading... |
186 | 189 |
187 // Drawn state is derived from the visible state and the parent's visible | 190 // Drawn state is derived from the visible state and the parent's visible |
188 // state. This field is only used if the view has no parent (eg it's a root). | 191 // state. This field is only used if the view has no parent (eg it's a root). |
189 bool drawn_; | 192 bool drawn_; |
190 | 193 |
191 // Value struct to keep the name and deallocator for this property. | 194 // Value struct to keep the name and deallocator for this property. |
192 // Key cannot be used for this purpose because it can be char* or | 195 // Key cannot be used for this purpose because it can be char* or |
193 // WindowProperty<>. | 196 // WindowProperty<>. |
194 struct Value { | 197 struct Value { |
195 const char* name; | 198 const char* name; |
196 int64 value; | 199 int64_t value; |
197 PropertyDeallocator deallocator; | 200 PropertyDeallocator deallocator; |
198 }; | 201 }; |
199 | 202 |
200 std::map<const void*, Value> prop_map_; | 203 std::map<const void*, Value> prop_map_; |
201 | 204 |
202 DISALLOW_COPY_AND_ASSIGN(View); | 205 MOJO_DISALLOW_COPY_AND_ASSIGN(View); |
203 }; | 206 }; |
204 | 207 |
205 } // namespace mojo | 208 } // namespace mojo |
206 | 209 |
207 #endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ | 210 #endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ |
OLD | NEW |