| 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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1089 |
| 1090 // Tree operations ----------------------------------------------------------- | 1090 // Tree operations ----------------------------------------------------------- |
| 1091 | 1091 |
| 1092 // This method is invoked when the tree changes. | 1092 // This method is invoked when the tree changes. |
| 1093 // | 1093 // |
| 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 calls AddedToWidget and RemovedFromWidget. |
| 1102 // required when a view is added or removed from a view hierarchy | 1102 // Override to perform operations required when a view is added or |
| 1103 // removed from a view hierarchy. |
| 1103 // | 1104 // |
| 1104 // Refer to comments in struct |ViewHierarchyChangedDetails| for |details|. | 1105 // Refer to comments in struct |ViewHierarchyChangedDetails| for |details|. |
| 1105 virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details); | 1106 virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details); |
| 1106 | 1107 |
| 1107 // When SetVisible() changes the visibility of a view, this method is | 1108 // When SetVisible() changes the visibility of a view, this method is |
| 1108 // invoked for that view as well as all the children recursively. | 1109 // invoked for that view as well as all the children recursively. |
| 1109 virtual void VisibilityChanged(View* starting_from, bool is_visible); | 1110 virtual void VisibilityChanged(View* starting_from, bool is_visible); |
| 1110 | 1111 |
| 1111 // This method is invoked when the parent NativeView of the widget that the | 1112 // 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. | 1113 // view is attached to has changed and the view hierarchy has not changed. |
| 1113 // ViewHierarchyChanged() is called when the parent NativeView of the widget | 1114 // 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 | 1115 // 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 | 1116 // hierarchy. Overriding this method is useful for tracking which |
| 1116 // FocusManager manages this view. | 1117 // FocusManager manages this view. |
| 1117 virtual void NativeViewHierarchyChanged(); | 1118 virtual void NativeViewHierarchyChanged(); |
| 1118 | 1119 |
| 1120 // This method is invoked for a view when it is attached to a hierarchy with |
| 1121 // a widget, i.e. GetWidget() starts returning a non-null result. |
| 1122 virtual void AddedToWidget(); |
| 1123 |
| 1124 // This method is invoked for a view when it is removed from a hierarchy with |
| 1125 // a widget. |
| 1126 virtual void RemovedFromWidget(); |
| 1127 |
| 1119 // Painting ------------------------------------------------------------------ | 1128 // Painting ------------------------------------------------------------------ |
| 1120 | 1129 |
| 1121 // Responsible for calling Paint() on child Views. Override to control the | 1130 // Responsible for calling Paint() on child Views. Override to control the |
| 1122 // order child Views are painted. | 1131 // order child Views are painted. |
| 1123 virtual void PaintChildren(const ui::PaintContext& context); | 1132 virtual void PaintChildren(const ui::PaintContext& context); |
| 1124 | 1133 |
| 1125 // Override to provide rendering in any part of the View's bounds. Typically | 1134 // 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 | 1135 // this is the "contents" of the view. If you override this method you will |
| 1127 // have to call the subsequent OnPaint*() methods manually. | 1136 // have to call the subsequent OnPaint*() methods manually. |
| 1128 virtual void OnPaint(gfx::Canvas* canvas); | 1137 virtual void OnPaint(gfx::Canvas* canvas); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 int group_; | 1493 int group_; |
| 1485 | 1494 |
| 1486 // Tree operations ----------------------------------------------------------- | 1495 // Tree operations ----------------------------------------------------------- |
| 1487 | 1496 |
| 1488 // This view's parent. | 1497 // This view's parent. |
| 1489 View* parent_; | 1498 View* parent_; |
| 1490 | 1499 |
| 1491 // This view's children. | 1500 // This view's children. |
| 1492 Views children_; | 1501 Views children_; |
| 1493 | 1502 |
| 1503 // The widget this view is (possibily indirectly) attached to. |
| 1504 Widget* attached_widget_; |
| 1505 |
| 1494 #if DCHECK_IS_ON() | 1506 #if DCHECK_IS_ON() |
| 1495 // True while iterating over |children_|. Used to detect and DCHECK when | 1507 // True while iterating over |children_|. Used to detect and DCHECK when |
| 1496 // |children_| is mutated during iteration. | 1508 // |children_| is mutated during iteration. |
| 1497 mutable bool iterating_; | 1509 mutable bool iterating_; |
| 1498 #endif | 1510 #endif |
| 1499 | 1511 |
| 1500 bool can_process_events_within_subtree_; | 1512 bool can_process_events_within_subtree_; |
| 1501 | 1513 |
| 1502 // Size and disposition ------------------------------------------------------ | 1514 // Size and disposition ------------------------------------------------------ |
| 1503 | 1515 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 // Observers ------------------------------------------------------------- | 1635 // Observers ------------------------------------------------------------- |
| 1624 | 1636 |
| 1625 base::ObserverList<ViewObserver> observers_; | 1637 base::ObserverList<ViewObserver> observers_; |
| 1626 | 1638 |
| 1627 DISALLOW_COPY_AND_ASSIGN(View); | 1639 DISALLOW_COPY_AND_ASSIGN(View); |
| 1628 }; | 1640 }; |
| 1629 | 1641 |
| 1630 } // namespace views | 1642 } // namespace views |
| 1631 | 1643 |
| 1632 #endif // UI_VIEWS_VIEW_H_ | 1644 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |