Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: ui/views/view.h

Issue 2713643002: Add View::AddedToWidget and RemovedFromWidget. (Closed)
Patch Set: Review fixes. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.h
diff --git a/ui/views/view.h b/ui/views/view.h
index fcbee85c1bf2155eef7639c5b96e75c6980c1b4f..2d2389090993985b564d06991f01c5b0ccf962f7 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -1102,6 +1102,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// required when a view is added or removed from a view hierarchy
//
// Refer to comments in struct |ViewHierarchyChangedDetails| for |details|.
+ //
+ // See also AddedToWidget() and RemovedFromWidget() for detecting when the
+ // view is added to/removed from a widget.
virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details);
// When SetVisible() changes the visibility of a view, this method is
@@ -1116,6 +1119,15 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// FocusManager manages this view.
virtual void NativeViewHierarchyChanged();
+ // This method is invoked for a view when it is attached to a hierarchy with
+ // a widget, i.e. GetWidget() starts returning a non-null result.
+ // It is also called when the view is moved to a different widget.
+ virtual void AddedToWidget();
+
+ // This method is invoked for a view when it is removed from a hierarchy with
+ // a widget or moved to a different widget.
+ virtual void RemovedFromWidget();
+
// Painting ------------------------------------------------------------------
// Responsible for calling Paint() on child Views. Override to control the
@@ -1298,10 +1310,16 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// |old_parent| is the original parent of the View that was removed.
// If |new_parent| is not NULL, the View that was removed will be reparented
// to |new_parent| after the remove operation.
- void PropagateRemoveNotifications(View* old_parent, View* new_parent);
+ // If is_removed_from_widget is true, calls RemovedFromWidget for all
+ // children.
+ void PropagateRemoveNotifications(View* old_parent,
+ View* new_parent,
+ bool is_removed_from_widget);
// Call ViewHierarchyChanged() for all children.
- void PropagateAddNotifications(const ViewHierarchyChangedDetails& details);
+ // If is_added_to_widget is true, calls AddedToWidget for all children.
+ void PropagateAddNotifications(const ViewHierarchyChangedDetails& details,
+ bool is_added_to_widget);
// Propagates NativeViewHierarchyChanged() notification through all the
// children.
« no previous file with comments | « no previous file | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698