| 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); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 186 | 188 |
| 187 // Drawn state is derived from the visible state and the parent's visible | 189 // 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). | 190 // state. This field is only used if the view has no parent (eg it's a root). |
| 189 bool drawn_; | 191 bool drawn_; |
| 190 | 192 |
| 191 // Value struct to keep the name and deallocator for this property. | 193 // 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 | 194 // Key cannot be used for this purpose because it can be char* or |
| 193 // WindowProperty<>. | 195 // WindowProperty<>. |
| 194 struct Value { | 196 struct Value { |
| 195 const char* name; | 197 const char* name; |
| 196 int64 value; | 198 int64_t value; |
| 197 PropertyDeallocator deallocator; | 199 PropertyDeallocator deallocator; |
| 198 }; | 200 }; |
| 199 | 201 |
| 200 std::map<const void*, Value> prop_map_; | 202 std::map<const void*, Value> prop_map_; |
| 201 | 203 |
| 202 DISALLOW_COPY_AND_ASSIGN(View); | 204 MOJO_DISALLOW_COPY_AND_ASSIGN(View); |
| 203 }; | 205 }; |
| 204 | 206 |
| 205 } // namespace mojo | 207 } // namespace mojo |
| 206 | 208 |
| 207 #endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ | 209 #endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ |
| OLD | NEW |