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

Side by Side Diff: ui/views/view.h

Issue 2500623002: Add ViewObserver to View for view updates (Closed)
Patch Set: Change OnViewParentChanged to OnChildViewAdded/Removed Created 4 years 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 unified diff | Download patch
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 class Background; 68 class Background;
69 class Border; 69 class Border;
70 class ContextMenuController; 70 class ContextMenuController;
71 class DragController; 71 class DragController;
72 class FocusManager; 72 class FocusManager;
73 class FocusTraversable; 73 class FocusTraversable;
74 class LayoutManager; 74 class LayoutManager;
75 class NativeViewAccessibility; 75 class NativeViewAccessibility;
76 class ScrollView; 76 class ScrollView;
77 class ViewObserver;
77 class Widget; 78 class Widget;
78 class WordLookupClient; 79 class WordLookupClient;
79 80
80 namespace internal { 81 namespace internal {
81 class PreEventDispatchHandler; 82 class PreEventDispatchHandler;
82 class PostEventDispatchHandler; 83 class PostEventDispatchHandler;
83 class RootView; 84 class RootView;
84 } 85 }
85 86
86 ///////////////////////////////////////////////////////////////////////////// 87 /////////////////////////////////////////////////////////////////////////////
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 // to scroll. ScrollView interprets a return value of 0 (or negative) 994 // to scroll. ScrollView interprets a return value of 0 (or negative)
994 // to scroll by a default amount. 995 // to scroll by a default amount.
995 // 996 //
996 // See VariableRowHeightScrollHelper and FixedRowHeightScrollHelper for 997 // See VariableRowHeightScrollHelper and FixedRowHeightScrollHelper for
997 // implementations of common cases. 998 // implementations of common cases.
998 virtual int GetPageScrollIncrement(ScrollView* scroll_view, 999 virtual int GetPageScrollIncrement(ScrollView* scroll_view,
999 bool is_horizontal, bool is_positive); 1000 bool is_horizontal, bool is_positive);
1000 virtual int GetLineScrollIncrement(ScrollView* scroll_view, 1001 virtual int GetLineScrollIncrement(ScrollView* scroll_view,
1001 bool is_horizontal, bool is_positive); 1002 bool is_horizontal, bool is_positive);
1002 1003
1004 void AddObserver(ViewObserver* observer);
1005 void RemoveObserver(ViewObserver* observer);
1006 bool HasObserver(const ViewObserver* observer) const;
1007
1003 protected: 1008 protected:
1004 // Used to track a drag. RootView passes this into 1009 // Used to track a drag. RootView passes this into
1005 // ProcessMousePressed/Dragged. 1010 // ProcessMousePressed/Dragged.
1006 struct DragInfo { 1011 struct DragInfo {
1007 // Sets possible_drag to false and start_x/y to 0. This is invoked by 1012 // Sets possible_drag to false and start_x/y to 0. This is invoked by
1008 // RootView prior to invoke ProcessMousePressed. 1013 // RootView prior to invoke ProcessMousePressed.
1009 void Reset(); 1014 void Reset();
1010 1015
1011 // Sets possible_drag to true and start_pt to the specified point. 1016 // Sets possible_drag to true and start_pt to the specified point.
1012 // This is invoked by the target view if it detects the press may generate 1017 // This is invoked by the target view if it detects the press may generate
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 1433
1429 // Starts a drag and drop operation originating from this view. This invokes 1434 // Starts a drag and drop operation originating from this view. This invokes
1430 // WriteDragData to write the data and GetDragOperations to determine the 1435 // WriteDragData to write the data and GetDragOperations to determine the
1431 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is 1436 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is
1432 // in the view's coordinate system. 1437 // in the view's coordinate system.
1433 // Returns true if a drag was started. 1438 // Returns true if a drag was started.
1434 bool DoDrag(const ui::LocatedEvent& event, 1439 bool DoDrag(const ui::LocatedEvent& event,
1435 const gfx::Point& press_pt, 1440 const gfx::Point& press_pt,
1436 ui::DragDropTypes::DragEventSource source); 1441 ui::DragDropTypes::DragEventSource source);
1437 1442
1443 // Called after the |child| has been added to its parent. Called on observers
1444 // listening to |child|'s parent.
1445 void NotifyChildViewAdded(View* child);
sky 2016/11/22 04:40:48 You only call these functions from one place, inli
Sarmad Hashmi 2016/11/22 04:47:00 Moved the implementations to where they were calle
1446 // Called after the |child| has been removed from its |parent|. Called on
1447 // observers listening to |parent|.
1448 void NotifyChildViewRemoved(View* child);
1449
1438 ////////////////////////////////////////////////////////////////////////////// 1450 //////////////////////////////////////////////////////////////////////////////
1439 1451
1440 // Creation and lifetime ----------------------------------------------------- 1452 // Creation and lifetime -----------------------------------------------------
1441 1453
1442 // False if this View is owned by its parent - i.e. it will be deleted by its 1454 // False if this View is owned by its parent - i.e. it will be deleted by its
1443 // parent during its parents destruction. False is the default. 1455 // parent during its parents destruction. False is the default.
1444 bool owned_by_client_; 1456 bool owned_by_client_;
1445 1457
1446 // Attributes ---------------------------------------------------------------- 1458 // Attributes ----------------------------------------------------------------
1447 1459
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 // Input -------------------------------------------------------------------- 1580 // Input --------------------------------------------------------------------
1569 1581
1570 std::unique_ptr<ViewTargeter> targeter_; 1582 std::unique_ptr<ViewTargeter> targeter_;
1571 1583
1572 // Accessibility ------------------------------------------------------------- 1584 // Accessibility -------------------------------------------------------------
1573 1585
1574 // Belongs to this view, but it's reference-counted on some platforms 1586 // Belongs to this view, but it's reference-counted on some platforms
1575 // so we can't use a scoped_ptr. It's dereferenced in the destructor. 1587 // so we can't use a scoped_ptr. It's dereferenced in the destructor.
1576 NativeViewAccessibility* native_view_accessibility_; 1588 NativeViewAccessibility* native_view_accessibility_;
1577 1589
1590 // Observers -------------------------------------------------------------
1591
1592 base::ObserverList<ViewObserver> observers_;
1593
1578 DISALLOW_COPY_AND_ASSIGN(View); 1594 DISALLOW_COPY_AND_ASSIGN(View);
1579 }; 1595 };
1580 1596
1581 } // namespace views 1597 } // namespace views
1582 1598
1583 #endif // UI_VIEWS_VIEW_H_ 1599 #endif // UI_VIEWS_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698