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 <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // accessed from the main thread. | 103 // accessed from the main thread. |
104 // | 104 // |
105 ///////////////////////////////////////////////////////////////////////////// | 105 ///////////////////////////////////////////////////////////////////////////// |
106 class VIEWS_EXPORT View : public ui::LayerDelegate, | 106 class VIEWS_EXPORT View : public ui::LayerDelegate, |
107 public ui::LayerOwner, | 107 public ui::LayerOwner, |
108 public ui::AcceleratorTarget, | 108 public ui::AcceleratorTarget, |
109 public ui::EventTarget { | 109 public ui::EventTarget { |
110 public: | 110 public: |
111 typedef std::vector<View*> Views; | 111 typedef std::vector<View*> Views; |
112 | 112 |
113 // TODO(tdanderson): Becomes obsolete with the refactoring of the event | |
114 // targeting logic for views and windows. See | |
115 // crbug.com/355425. | |
116 // Specifies the source of the region used in a hit test. | |
117 // HIT_TEST_SOURCE_MOUSE indicates the hit test is being performed with a | |
118 // single point and HIT_TEST_SOURCE_TOUCH indicates the hit test is being | |
119 // performed with a rect larger than a single point. This value can be used, | |
120 // for example, to add extra padding or change the shape of the hit test mask. | |
121 enum HitTestSource { | |
122 HIT_TEST_SOURCE_MOUSE, | |
123 HIT_TEST_SOURCE_TOUCH | |
124 }; | |
125 | |
126 struct ViewHierarchyChangedDetails { | 113 struct ViewHierarchyChangedDetails { |
127 ViewHierarchyChangedDetails() | 114 ViewHierarchyChangedDetails() |
128 : is_add(false), | 115 : is_add(false), |
129 parent(NULL), | 116 parent(NULL), |
130 child(NULL), | 117 child(NULL), |
131 move_view(NULL) {} | 118 move_view(NULL) {} |
132 | 119 |
133 ViewHierarchyChangedDetails(bool is_add, | 120 ViewHierarchyChangedDetails(bool is_add, |
134 View* parent, | 121 View* parent, |
135 View* child, | 122 View* child, |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 549 |
563 // TODO(tdanderson): GetEventHandlerForPoint() and GetEventHandlerForRect() | 550 // TODO(tdanderson): GetEventHandlerForPoint() and GetEventHandlerForRect() |
564 // will be removed once their logic is moved into | 551 // will be removed once their logic is moved into |
565 // ViewTargeter and its derived classes. See | 552 // ViewTargeter and its derived classes. See |
566 // crbug.com/355425. | 553 // crbug.com/355425. |
567 | 554 |
568 // Convenience functions which calls into GetEventHandler() with | 555 // Convenience functions which calls into GetEventHandler() with |
569 // a 1x1 rect centered at |point|. | 556 // a 1x1 rect centered at |point|. |
570 View* GetEventHandlerForPoint(const gfx::Point& point); | 557 View* GetEventHandlerForPoint(const gfx::Point& point); |
571 | 558 |
| 559 // Terry - update doc |
| 560 |
572 // If point-based targeting should be used, return the deepest visible | 561 // If point-based targeting should be used, return the deepest visible |
573 // descendant that contains the center point of |rect|. | 562 // descendant that contains the center point of |rect|. |
574 // If rect-based targeting (i.e., fuzzing) should be used, return the | 563 // If rect-based targeting (i.e., fuzzing) should be used, return the |
575 // closest visible descendant having at least kRectTargetOverlap of | 564 // closest visible descendant having at least kRectTargetOverlap of |
576 // its area covered by |rect|. If no such descendant exists, return the | 565 // its area covered by |rect|. If no such descendant exists, return the |
577 // deepest visible descendant that contains the center point of |rect|. | 566 // deepest visible descendant that contains the center point of |rect|. |
578 // See http://goo.gl/3Jp2BD for more information about rect-based targeting. | 567 // See http://goo.gl/3Jp2BD for more information about rect-based targeting. |
579 virtual View* GetEventHandlerForRect(const gfx::Rect& rect); | 568 View* GetEventHandlerForRect(const gfx::Rect& rect); |
580 | 569 |
581 // Returns the deepest visible descendant that contains the specified point | 570 // Returns the deepest visible descendant that contains the specified point |
582 // and supports tooltips. If the view does not contain the point, returns | 571 // and supports tooltips. If the view does not contain the point, returns |
583 // NULL. | 572 // NULL. |
584 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point); | 573 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point); |
585 | 574 |
586 // Return the cursor that should be used for this view or the default cursor. | 575 // Return the cursor that should be used for this view or the default cursor. |
587 // The event location is in the receiver's coordinate system. The caller is | 576 // The event location is in the receiver's coordinate system. The caller is |
588 // responsible for managing the lifetime of the returned object, though that | 577 // responsible for managing the lifetime of the returned object, though that |
589 // lifetime may vary from platform to platform. On Windows and Aura, | 578 // lifetime may vary from platform to platform. On Windows and Aura, |
590 // the cursor is a shared resource. | 579 // the cursor is a shared resource. |
591 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event); | 580 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event); |
592 | 581 |
593 // TODO(tdanderson): HitTestPoint() and HitTestRect() will be removed once | |
594 // their logic is moved into ViewTargeter and its | |
595 // derived classes. See crbug.com/355425. | |
596 | |
597 // A convenience function which calls HitTestRect() with a rect of size | 582 // A convenience function which calls HitTestRect() with a rect of size |
598 // 1x1 and an origin of |point|. | 583 // 1x1 and an origin of |point|. |
599 bool HitTestPoint(const gfx::Point& point) const; | 584 bool HitTestPoint(const gfx::Point& point) const; |
600 | 585 |
601 // Tests whether |rect| intersects this view's bounds. | 586 // Tests whether |rect| intersects this view's bounds using the ViewTargeter |
602 virtual bool HitTestRect(const gfx::Rect& rect) const; | 587 // installed on |this|. If there is no ViewTargeter installed on |this|, the |
| 588 // ViewTargeter installed on the root view is used instead. |
| 589 bool HitTestRect(const gfx::Rect& rect) const; |
603 | 590 |
604 // Returns true if this view or any of its descendants are permitted to | 591 // Returns true if this view or any of its descendants are permitted to |
605 // be the target of an event. | 592 // be the target of an event. |
606 virtual bool CanProcessEventsWithinSubtree() const; | 593 virtual bool CanProcessEventsWithinSubtree() const; |
607 | 594 |
608 // Returns true if the mouse cursor is over |view| and mouse events are | 595 // Returns true if the mouse cursor is over |view| and mouse events are |
609 // enabled. | 596 // enabled. |
610 bool IsMouseHovered(); | 597 bool IsMouseHovered(); |
611 | 598 |
612 // This method is invoked when the user clicks on this view. | 599 // This method is invoked when the user clicks on this view. |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 // This reorders the immediate children of |*parent_layer| to match the | 1126 // This reorders the immediate children of |*parent_layer| to match the |
1140 // order of the view tree. Child layers which are owned by a view are | 1127 // order of the view tree. Child layers which are owned by a view are |
1141 // reordered so that they are below any child layers not owned by a view. | 1128 // reordered so that they are below any child layers not owned by a view. |
1142 // Widget::ReorderNativeViews() should be called to reorder any child layers | 1129 // Widget::ReorderNativeViews() should be called to reorder any child layers |
1143 // with an associated view. Widget::ReorderNativeViews() may reorder layers | 1130 // with an associated view. Widget::ReorderNativeViews() may reorder layers |
1144 // below layers owned by a view. | 1131 // below layers owned by a view. |
1145 virtual void ReorderChildLayers(ui::Layer* parent_layer); | 1132 virtual void ReorderChildLayers(ui::Layer* parent_layer); |
1146 | 1133 |
1147 // Input --------------------------------------------------------------------- | 1134 // Input --------------------------------------------------------------------- |
1148 | 1135 |
1149 // Called by HitTestRect() to see if this View has a custom hit test mask. If | |
1150 // the return value is true, GetHitTestMask() will be called to obtain the | |
1151 // mask. Default value is false, in which case the View will hit-test against | |
1152 // its bounds. | |
1153 virtual bool HasHitTestMask() const; | |
1154 | |
1155 // Called by HitTestRect() to retrieve a mask for hit-testing against. | |
1156 // Subclasses override to provide custom shaped hit test regions. | |
1157 // TODO(tdanderson): Remove this method once Tab, TabCloseButton, | |
1158 // NewTabButton, and MicButton all implement | |
1159 // MaskedViewTargeter. | |
1160 virtual void GetHitTestMaskDeprecated(HitTestSource source, | |
1161 gfx::Path* mask) const; | |
1162 | |
1163 virtual DragInfo* GetDragInfo(); | 1136 virtual DragInfo* GetDragInfo(); |
1164 | 1137 |
1165 // Focus --------------------------------------------------------------------- | 1138 // Focus --------------------------------------------------------------------- |
1166 | 1139 |
1167 // Returns last value passed to SetFocusable(). Use IsFocusable() to determine | 1140 // Returns last value passed to SetFocusable(). Use IsFocusable() to determine |
1168 // if a view can take focus right now. | 1141 // if a view can take focus right now. |
1169 bool focusable() const { return focusable_; } | 1142 bool focusable() const { return focusable_; } |
1170 | 1143 |
1171 // Override to be notified when focus has changed either to or from this View. | 1144 // Override to be notified when focus has changed either to or from this View. |
1172 virtual void OnFocus(); | 1145 virtual void OnFocus(); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 // Belongs to this view, but it's reference-counted on some platforms | 1589 // Belongs to this view, but it's reference-counted on some platforms |
1617 // so we can't use a scoped_ptr. It's dereferenced in the destructor. | 1590 // so we can't use a scoped_ptr. It's dereferenced in the destructor. |
1618 NativeViewAccessibility* native_view_accessibility_; | 1591 NativeViewAccessibility* native_view_accessibility_; |
1619 | 1592 |
1620 DISALLOW_COPY_AND_ASSIGN(View); | 1593 DISALLOW_COPY_AND_ASSIGN(View); |
1621 }; | 1594 }; |
1622 | 1595 |
1623 } // namespace views | 1596 } // namespace views |
1624 | 1597 |
1625 #endif // UI_VIEWS_VIEW_H_ | 1598 #endif // UI_VIEWS_VIEW_H_ |
OLD | NEW |