OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 UI_VIEWS_VIEW_OBSERVER_H_ | 5 #ifndef UI_VIEWS_VIEW_OBSERVER_H_ |
6 #define UI_VIEWS_VIEW_OBSERVER_H_ | 6 #define UI_VIEWS_VIEW_OBSERVER_H_ |
7 | 7 |
8 #include "ui/views/views_export.h" | 8 #include "ui/views/views_export.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
12 class View; | 12 class View; |
13 | 13 |
14 // Observer can listen to various events on the Views. | 14 // ViewObserver is used to observe changes to a View. The first argument to all |
| 15 // ViewObserver functions is the View the observer was added to. |
15 class VIEWS_EXPORT ViewObserver { | 16 class VIEWS_EXPORT ViewObserver { |
16 public: | 17 public: |
17 // Called when |child| is added to its parent. Invoked on the parent which has | 18 // Called when |child| is added as a child to |observed_view|. |
18 // the |child| added to it. | 19 virtual void OnChildViewAdded(View* observed_view, View* child) {} |
19 virtual void OnChildViewAdded(View* child) {} | |
20 | 20 |
21 // Called when |child| is removed from its |parent|. | 21 // Called when |child| is removed as a child of |observed_view|. |
22 virtual void OnChildViewRemoved(View* child, View* parent) {} | 22 virtual void OnChildViewRemoved(View* observed_view, View* child) {} |
23 | 23 |
24 // Called when View::SetVisible() is called with a new value. | 24 // Called when View::SetVisible() is called with a new value. See |
25 // The |view| may still be hidden at this point. | 25 // View::IsDrawn() for details on how visibility and drawn differ. |
26 virtual void OnViewVisibilityChanged(View* view) {} | 26 virtual void OnViewVisibilityChanged(View* observed_view) {} |
27 | 27 |
28 virtual void OnViewEnabledChanged(View* view) {} | 28 // Called when View::SetEnabled() is called with a new value. |
| 29 virtual void OnViewEnabledChanged(View* observed_view) {} |
29 | 30 |
30 virtual void OnViewBoundsChanged(View* view) {} | 31 // Called when the bounds of |observed_view| change. |
| 32 virtual void OnViewBoundsChanged(View* observed_view) {} |
31 | 33 |
32 // Invoked whenever a child is moved to another index. This is called on the | 34 // Called when a child is reordered among its siblings, specifically |
33 // parent view. |view| is the child view being moved. | 35 // View::ReorderChildView() is called on |observed_view|. |
34 virtual void OnChildViewReordered(View* view) {} | 36 virtual void OnChildViewReordered(View* observed_view, View* child) {} |
35 | 37 |
36 // Called from ~View. | 38 // Called from ~View. |
37 virtual void OnViewIsDeleting(View* observed_view) {} | 39 virtual void OnViewIsDeleting(View* observed_view) {} |
38 | 40 |
39 protected: | 41 protected: |
40 virtual ~ViewObserver() {} | 42 virtual ~ViewObserver() {} |
41 }; | 43 }; |
42 | 44 |
43 } // namespace views | 45 } // namespace views |
44 | 46 |
45 #endif // UI_VIEWS_VIEW_OBSERVER_H_ | 47 #endif // UI_VIEWS_VIEW_OBSERVER_H_ |
OLD | NEW |