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 COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_ |
6 #define COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "components/mus/public/cpp/view.h" | 10 #include "components/mus/public/cpp/view.h" |
11 #include "ui/mojo/events/input_events.mojom.h" | 11 #include "ui/mojo/events/input_events.mojom.h" |
12 | 12 |
13 namespace mus { | 13 namespace mojo { |
14 | 14 |
15 class View; | 15 class View; |
16 | 16 |
17 // A note on -ing and -ed suffixes: | 17 // A note on -ing and -ed suffixes: |
18 // | 18 // |
19 // -ing methods are called before changes are applied to the local view model. | 19 // -ing methods are called before changes are applied to the local view model. |
20 // -ed methods are called after changes are applied to the local view model. | 20 // -ed methods are called after changes are applied to the local view model. |
21 // | 21 // |
22 // If the change originated from another connection to the view manager, it's | 22 // If the change originated from another connection to the view manager, it's |
23 // possible that the change has already been applied to the service-side model | 23 // possible that the change has already been applied to the service-side model |
24 // prior to being called, so for example in the case of OnViewDestroying(), it's | 24 // prior to being called, so for example in the case of OnViewDestroying(), it's |
25 // possible the view has already been destroyed on the service side. | 25 // possible the view has already been destroyed on the service side. |
26 | 26 |
27 class ViewObserver { | 27 class ViewObserver { |
28 public: | 28 public: |
29 struct TreeChangeParams { | 29 struct TreeChangeParams { |
30 TreeChangeParams(); | 30 TreeChangeParams(); |
31 View* target; | 31 View* target; |
32 View* old_parent; | 32 View* old_parent; |
33 View* new_parent; | 33 View* new_parent; |
34 View* receiver; | 34 View* receiver; |
35 }; | 35 }; |
36 | 36 |
37 virtual void OnTreeChanging(const TreeChangeParams& params) {} | 37 virtual void OnTreeChanging(const TreeChangeParams& params) {} |
38 virtual void OnTreeChanged(const TreeChangeParams& params) {} | 38 virtual void OnTreeChanged(const TreeChangeParams& params) {} |
39 | 39 |
40 virtual void OnViewReordering(View* view, | 40 virtual void OnViewReordering(View* view, |
41 View* relative_view, | 41 View* relative_view, |
42 mojo::OrderDirection direction) {} | 42 OrderDirection direction) {} |
43 virtual void OnViewReordered(View* view, | 43 virtual void OnViewReordered(View* view, |
44 View* relative_view, | 44 View* relative_view, |
45 mojo::OrderDirection direction) {} | 45 OrderDirection direction) {} |
46 | 46 |
47 virtual void OnViewDestroying(View* view) {} | 47 virtual void OnViewDestroying(View* view) {} |
48 virtual void OnViewDestroyed(View* view) {} | 48 virtual void OnViewDestroyed(View* view) {} |
49 | 49 |
50 virtual void OnViewBoundsChanging(View* view, | 50 virtual void OnViewBoundsChanging(View* view, |
51 const mojo::Rect& old_bounds, | 51 const Rect& old_bounds, |
52 const mojo::Rect& new_bounds) {} | 52 const Rect& new_bounds) {} |
53 virtual void OnViewBoundsChanged(View* view, | 53 virtual void OnViewBoundsChanged(View* view, |
54 const mojo::Rect& old_bounds, | 54 const Rect& old_bounds, |
55 const mojo::Rect& new_bounds) {} | 55 const Rect& new_bounds) {} |
56 | 56 |
57 virtual void OnViewViewportMetricsChanged( | 57 virtual void OnViewViewportMetricsChanged( |
58 View* view, | 58 View* view, |
59 const mojo::ViewportMetrics& old_metrics, | 59 const ViewportMetrics& old_metrics, |
60 const mojo::ViewportMetrics& new_metrics) {} | 60 const ViewportMetrics& new_metrics) {} |
61 | 61 |
62 virtual void OnViewFocusChanged(View* gained_focus, View* lost_focus) {} | 62 virtual void OnViewFocusChanged(View* gained_focus, View* lost_focus) {} |
63 | 63 |
64 virtual void OnViewInputEvent(View* view, const mojo::EventPtr& event) {} | 64 virtual void OnViewInputEvent(View* view, const EventPtr& event) {} |
65 | 65 |
66 virtual void OnViewVisibilityChanging(View* view) {} | 66 virtual void OnViewVisibilityChanging(View* view) {} |
67 virtual void OnViewVisibilityChanged(View* view) {} | 67 virtual void OnViewVisibilityChanged(View* view) {} |
68 | 68 |
69 // Invoked when this View's shared properties have changed. This can either | 69 // Invoked when this View's shared properties have changed. This can either |
70 // be caused by SetSharedProperty() being called locally, or by us receiving | 70 // be caused by SetSharedProperty() being called locally, or by us receiving |
71 // a mojo message that this property has changed. If this property has been | 71 // a mojo message that this property has changed. If this property has been |
72 // added, |old_data| is null. If this property was removed, |new_data| is | 72 // added, |old_data| is null. If this property was removed, |new_data| is |
73 // null. | 73 // null. |
74 virtual void OnViewSharedPropertyChanged( | 74 virtual void OnViewSharedPropertyChanged( |
(...skipping 15 matching lines...) Expand all Loading... |
90 | 90 |
91 // Sent when the drawn state changes. This is only sent for the root nodes | 91 // Sent when the drawn state changes. This is only sent for the root nodes |
92 // when embedded. | 92 // when embedded. |
93 virtual void OnViewDrawnChanging(View* view) {} | 93 virtual void OnViewDrawnChanging(View* view) {} |
94 virtual void OnViewDrawnChanged(View* view) {} | 94 virtual void OnViewDrawnChanged(View* view) {} |
95 | 95 |
96 protected: | 96 protected: |
97 virtual ~ViewObserver() {} | 97 virtual ~ViewObserver() {} |
98 }; | 98 }; |
99 | 99 |
100 } // namespace mus | 100 } // namespace mojo |
101 | 101 |
102 #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_ | 102 #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_ |
OLD | NEW |