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

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

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests added Created 7 years, 1 month 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 | Annotate | Revision Log
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 <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 flip_canvas_on_paint_for_rtl_ui_ = enable; 552 flip_canvas_on_paint_for_rtl_ui_ = enable;
553 } 553 }
554 554
555 // Accelerated painting ------------------------------------------------------ 555 // Accelerated painting ------------------------------------------------------
556 556
557 // Enable/Disable accelerated compositing. 557 // Enable/Disable accelerated compositing.
558 static void set_use_acceleration_when_possible(bool use); 558 static void set_use_acceleration_when_possible(bool use);
559 static bool get_use_acceleration_when_possible(); 559 static bool get_use_acceleration_when_possible();
560 560
561 // Input --------------------------------------------------------------------- 561 // Input ---------------------------------------------------------------------
562 // The points (and mouse locations) in the following functions are in the 562 // The points, rects, mouse locations, and touch locations in the following
563 // view's coordinates, except for a RootView. 563 // functions are in the view's coordinates, except for a RootView.
564 564
565 // Returns the deepest visible descendant that contains the specified point 565 // Convenience functions which calls into GetEventHandler() with
566 // and supports event handling. 566 // a 1x1 rect centered at |point|.
567 virtual View* GetEventHandlerForPoint(const gfx::Point& point); 567 View* GetEventHandlerForPoint(const gfx::Point& point);
568
569 // If point-based targeting should be used, return the deepest visible
570 // descendant that contains the center point of |rect|.
571 // If rect-based targeting (i.e., fuzzing) should be used, return the
572 // closest visible descendant having at least kRectTargetOverlap of
573 // its area covered by |rect|. If no such descendant exists, return the
574 // deepest visible descendant that contains the center point of |rect|.
575 virtual View* GetEventHandlerForRect(const gfx::Rect& rect);
568 576
569 // Returns the deepest visible descendant that contains the specified point 577 // Returns the deepest visible descendant that contains the specified point
570 // and supports tooltips. If the view does not contain the point, returns 578 // and supports tooltips. If the view does not contain the point, returns
571 // NULL. 579 // NULL.
572 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point); 580 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point);
573 581
574 // Return the cursor that should be used for this view or the default cursor. 582 // Return the cursor that should be used for this view or the default cursor.
575 // The event location is in the receiver's coordinate system. The caller is 583 // The event location is in the receiver's coordinate system. The caller is
576 // responsible for managing the lifetime of the returned object, though that 584 // responsible for managing the lifetime of the returned object, though that
577 // lifetime may vary from platform to platform. On Windows and Aura, 585 // lifetime may vary from platform to platform. On Windows and Aura,
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // This reorders the immediate children of |*parent_layer| to match the 1119 // This reorders the immediate children of |*parent_layer| to match the
1112 // order of the view tree. Child layers which are owned by a view are 1120 // order of the view tree. Child layers which are owned by a view are
1113 // reordered so that they are below any child layers not owned by a view. 1121 // reordered so that they are below any child layers not owned by a view.
1114 // Widget::ReorderNativeViews() should be called to reorder any child layers 1122 // Widget::ReorderNativeViews() should be called to reorder any child layers
1115 // with an associated view. Widget::ReorderNativeViews() may reorder layers 1123 // with an associated view. Widget::ReorderNativeViews() may reorder layers
1116 // below layers owned by a view. 1124 // below layers owned by a view.
1117 virtual void ReorderChildLayers(ui::Layer* parent_layer); 1125 virtual void ReorderChildLayers(ui::Layer* parent_layer);
1118 1126
1119 // Input --------------------------------------------------------------------- 1127 // Input ---------------------------------------------------------------------
1120 1128
1129 // Specifies the source of the region used in a hit test.
1130 // HIT_TEST_SOURCE_MOUSE indicates the hit test is being performed with a
1131 // single point and HIT_TEST_SOURCE_TOUCH indicates the hit test is being
1132 // performed with a rect larger than a single point. This value can be used,
1133 // for example, to add extra padding or change the shape of the hit test mask.
1134 enum HitTestSource {
1135 HIT_TEST_SOURCE_MOUSE,
1136 HIT_TEST_SOURCE_TOUCH
1137 };
1138
1121 // Called by HitTestRect() to see if this View has a custom hit test mask. If 1139 // Called by HitTestRect() to see if this View has a custom hit test mask. If
1122 // the return value is true, GetHitTestMask() will be called to obtain the 1140 // the return value is true, GetHitTestMask() will be called to obtain the
1123 // mask. Default value is false, in which case the View will hit-test against 1141 // mask. Default value is false, in which case the View will hit-test against
1124 // its bounds. 1142 // its bounds.
1125 virtual bool HasHitTestMask() const; 1143 virtual bool HasHitTestMask() const;
1126 1144
1127 // Called by HitTestRect() to retrieve a mask for hit-testing against. 1145 // Called by HitTestRect() to retrieve a mask for hit-testing against.
1128 // Subclasses override to provide custom shaped hit test regions. 1146 // Subclasses override to provide custom shaped hit test regions.
1129 virtual void GetHitTestMask(gfx::Path* mask) const; 1147 virtual void GetHitTestMask(gfx::Path* mask,
1148 HitTestSource source = HIT_TEST_SOURCE_MOUSE) const;
1130 1149
1131 virtual DragInfo* GetDragInfo(); 1150 virtual DragInfo* GetDragInfo();
1132 1151
1133 // Focus --------------------------------------------------------------------- 1152 // Focus ---------------------------------------------------------------------
1134 1153
1135 // Override to be notified when focus has changed either to or from this View. 1154 // Override to be notified when focus has changed either to or from this View.
1136 virtual void OnFocus(); 1155 virtual void OnFocus();
1137 virtual void OnBlur(); 1156 virtual void OnBlur();
1138 1157
1139 // Handle view focus/blur events for this view. 1158 // Handle view focus/blur events for this view.
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 // Belongs to this view, but it's reference-counted on some platforms 1571 // Belongs to this view, but it's reference-counted on some platforms
1553 // so we can't use a scoped_ptr. It's dereferenced in the destructor. 1572 // so we can't use a scoped_ptr. It's dereferenced in the destructor.
1554 NativeViewAccessibility* native_view_accessibility_; 1573 NativeViewAccessibility* native_view_accessibility_;
1555 1574
1556 DISALLOW_COPY_AND_ASSIGN(View); 1575 DISALLOW_COPY_AND_ASSIGN(View);
1557 }; 1576 };
1558 1577
1559 } // namespace views 1578 } // namespace views
1560 1579
1561 #endif // UI_VIEWS_VIEW_H_ 1580 #endif // UI_VIEWS_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698