Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef UI_VIEWS_VIEW_H_ |
| 6 #define UI_VIEWS_VIEW_H_ | 6 #define UI_VIEWS_VIEW_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 // When a view is removed, it is invoked for all children and grand | 1094 // When a view is removed, it is invoked for all children and grand |
| 1095 // children. For each of these views, a notification is sent to the | 1095 // children. For each of these views, a notification is sent to the |
| 1096 // view and all parents. | 1096 // view and all parents. |
| 1097 // | 1097 // |
| 1098 // When a view is added, a notification is sent to the view, all its | 1098 // When a view is added, a notification is sent to the view, all its |
| 1099 // parents, and all its children (and grand children) | 1099 // parents, and all its children (and grand children) |
| 1100 // | 1100 // |
| 1101 // Default implementation does nothing. Override to perform operations | 1101 // Default implementation does nothing. Override to perform operations |
| 1102 // required when a view is added or removed from a view hierarchy | 1102 // required when a view is added or removed from a view hierarchy |
| 1103 // | 1103 // |
| 1104 // Refer to comments in struct |ViewHierarchyChangedDetails| for |details|. | 1104 // Refer to comments in struct |ViewHierarchyChangedDetails| for |details|. |
|
sky
2017/03/01 20:26:51
Add a comment here to see AddedToWidget/RemovedFro
msimonides
2017/03/02 07:48:56
Done.
| |
| 1105 virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details); | 1105 virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details); |
| 1106 | 1106 |
| 1107 // When SetVisible() changes the visibility of a view, this method is | 1107 // When SetVisible() changes the visibility of a view, this method is |
| 1108 // invoked for that view as well as all the children recursively. | 1108 // invoked for that view as well as all the children recursively. |
| 1109 virtual void VisibilityChanged(View* starting_from, bool is_visible); | 1109 virtual void VisibilityChanged(View* starting_from, bool is_visible); |
| 1110 | 1110 |
| 1111 // This method is invoked when the parent NativeView of the widget that the | 1111 // This method is invoked when the parent NativeView of the widget that the |
| 1112 // view is attached to has changed and the view hierarchy has not changed. | 1112 // view is attached to has changed and the view hierarchy has not changed. |
| 1113 // ViewHierarchyChanged() is called when the parent NativeView of the widget | 1113 // ViewHierarchyChanged() is called when the parent NativeView of the widget |
| 1114 // that the view is attached to is changed as a result of changing the view | 1114 // that the view is attached to is changed as a result of changing the view |
| 1115 // hierarchy. Overriding this method is useful for tracking which | 1115 // hierarchy. Overriding this method is useful for tracking which |
| 1116 // FocusManager manages this view. | 1116 // FocusManager manages this view. |
| 1117 virtual void NativeViewHierarchyChanged(); | 1117 virtual void NativeViewHierarchyChanged(); |
| 1118 | 1118 |
| 1119 // This method is invoked for a view when it is attached to a hierarchy with | |
| 1120 // a widget, i.e. GetWidget() starts returning a non-null result. | |
| 1121 virtual void AddedToWidget(); | |
| 1122 | |
| 1123 // This method is invoked for a view when it is removed from a hierarchy with | |
| 1124 // a widget. | |
|
sky
2017/03/01 20:26:51
Clarify this is also invoked if a view is moved to
msimonides
2017/03/02 07:48:56
Done.
| |
| 1125 virtual void RemovedFromWidget(); | |
| 1126 | |
| 1119 // Painting ------------------------------------------------------------------ | 1127 // Painting ------------------------------------------------------------------ |
| 1120 | 1128 |
| 1121 // Responsible for calling Paint() on child Views. Override to control the | 1129 // Responsible for calling Paint() on child Views. Override to control the |
| 1122 // order child Views are painted. | 1130 // order child Views are painted. |
| 1123 virtual void PaintChildren(const ui::PaintContext& context); | 1131 virtual void PaintChildren(const ui::PaintContext& context); |
| 1124 | 1132 |
| 1125 // Override to provide rendering in any part of the View's bounds. Typically | 1133 // Override to provide rendering in any part of the View's bounds. Typically |
| 1126 // this is the "contents" of the view. If you override this method you will | 1134 // this is the "contents" of the view. If you override this method you will |
| 1127 // have to call the subsequent OnPaint*() methods manually. | 1135 // have to call the subsequent OnPaint*() methods manually. |
| 1128 virtual void OnPaint(gfx::Canvas* canvas); | 1136 virtual void OnPaint(gfx::Canvas* canvas); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 void DoRemoveChildView(View* view, | 1299 void DoRemoveChildView(View* view, |
| 1292 bool update_focus_cycle, | 1300 bool update_focus_cycle, |
| 1293 bool update_tool_tip, | 1301 bool update_tool_tip, |
| 1294 bool delete_removed_view, | 1302 bool delete_removed_view, |
| 1295 View* new_parent); | 1303 View* new_parent); |
| 1296 | 1304 |
| 1297 // Call ViewHierarchyChanged() for all child views and all parents. | 1305 // Call ViewHierarchyChanged() for all child views and all parents. |
| 1298 // |old_parent| is the original parent of the View that was removed. | 1306 // |old_parent| is the original parent of the View that was removed. |
| 1299 // If |new_parent| is not NULL, the View that was removed will be reparented | 1307 // If |new_parent| is not NULL, the View that was removed will be reparented |
| 1300 // to |new_parent| after the remove operation. | 1308 // to |new_parent| after the remove operation. |
| 1301 void PropagateRemoveNotifications(View* old_parent, View* new_parent); | 1309 // If is_removed_from_widget is true, calls RemovedFromWidget for all |
| 1310 // children. | |
| 1311 void PropagateRemoveNotifications(View* old_parent, | |
| 1312 View* new_parent, | |
| 1313 bool is_removed_from_widget); | |
| 1302 | 1314 |
| 1303 // Call ViewHierarchyChanged() for all children. | 1315 // Call ViewHierarchyChanged() for all children. |
| 1304 void PropagateAddNotifications(const ViewHierarchyChangedDetails& details); | 1316 // If is_added_to_widget is true, calls AddedToWidget for all children. |
| 1317 void PropagateAddNotifications(const ViewHierarchyChangedDetails& details, | |
| 1318 bool is_added_to_widget); | |
| 1305 | 1319 |
| 1306 // Propagates NativeViewHierarchyChanged() notification through all the | 1320 // Propagates NativeViewHierarchyChanged() notification through all the |
| 1307 // children. | 1321 // children. |
| 1308 void PropagateNativeViewHierarchyChanged(); | 1322 void PropagateNativeViewHierarchyChanged(); |
| 1309 | 1323 |
| 1310 // Takes care of registering/unregistering accelerators if | 1324 // Takes care of registering/unregistering accelerators if |
| 1311 // |register_accelerators| true and calls ViewHierarchyChanged(). | 1325 // |register_accelerators| true and calls ViewHierarchyChanged(). |
| 1312 void ViewHierarchyChangedImpl(bool register_accelerators, | 1326 void ViewHierarchyChangedImpl(bool register_accelerators, |
| 1313 const ViewHierarchyChangedDetails& details); | 1327 const ViewHierarchyChangedDetails& details); |
| 1314 | 1328 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1623 // Observers ------------------------------------------------------------- | 1637 // Observers ------------------------------------------------------------- |
| 1624 | 1638 |
| 1625 base::ObserverList<ViewObserver> observers_; | 1639 base::ObserverList<ViewObserver> observers_; |
| 1626 | 1640 |
| 1627 DISALLOW_COPY_AND_ASSIGN(View); | 1641 DISALLOW_COPY_AND_ASSIGN(View); |
| 1628 }; | 1642 }; |
| 1629 | 1643 |
| 1630 } // namespace views | 1644 } // namespace views |
| 1631 | 1645 |
| 1632 #endif // UI_VIEWS_VIEW_H_ | 1646 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |