| 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void EnableCanvasFlippingForRTLUI(bool enable) { | 552 void EnableCanvasFlippingForRTLUI(bool enable) { |
| 553 flip_canvas_on_paint_for_rtl_ui_ = enable; | 553 flip_canvas_on_paint_for_rtl_ui_ = enable; |
| 554 } | 554 } |
| 555 | 555 |
| 556 // Input --------------------------------------------------------------------- | 556 // Input --------------------------------------------------------------------- |
| 557 // The points, rects, mouse locations, and touch locations in the following | 557 // The points, rects, mouse locations, and touch locations in the following |
| 558 // functions are in the view's coordinates, except for a RootView. | 558 // functions are in the view's coordinates, except for a RootView. |
| 559 | 559 |
| 560 // Convenience functions which calls into GetEventHandler() with | 560 // Convenience functions which calls into GetEventHandler() with |
| 561 // a 1x1 rect centered at |point|. | 561 // a 1x1 rect centered at |point|. |
| 562 View* GetEventHandlerForPoint(const gfx::Point& point); | 562 View* GetEventHandlerForPoint(const gfx::PointF& point); |
| 563 | 563 |
| 564 // If point-based targeting should be used, return the deepest visible | 564 // If point-based targeting should be used, return the deepest visible |
| 565 // descendant that contains the center point of |rect|. | 565 // descendant that contains the center point of |rect|. |
| 566 // If rect-based targeting (i.e., fuzzing) should be used, return the | 566 // If rect-based targeting (i.e., fuzzing) should be used, return the |
| 567 // closest visible descendant having at least kRectTargetOverlap of | 567 // closest visible descendant having at least kRectTargetOverlap of |
| 568 // its area covered by |rect|. If no such descendant exists, return the | 568 // its area covered by |rect|. If no such descendant exists, return the |
| 569 // deepest visible descendant that contains the center point of |rect|. | 569 // deepest visible descendant that contains the center point of |rect|. |
| 570 // See http://goo.gl/3Jp2BD for more information about rect-based targeting. | 570 // See http://goo.gl/3Jp2BD for more information about rect-based targeting. |
| 571 virtual View* GetEventHandlerForRect(const gfx::Rect& rect); | 571 virtual View* GetEventHandlerForRect(const gfx::RectF& rect); |
| 572 | 572 |
| 573 // Returns the deepest visible descendant that contains the specified point | 573 // Returns the deepest visible descendant that contains the specified point |
| 574 // and supports tooltips. If the view does not contain the point, returns | 574 // and supports tooltips. If the view does not contain the point, returns |
| 575 // NULL. | 575 // NULL. |
| 576 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point); | 576 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point); |
| 577 | 577 |
| 578 // Return the cursor that should be used for this view or the default cursor. | 578 // Return the cursor that should be used for this view or the default cursor. |
| 579 // The event location is in the receiver's coordinate system. The caller is | 579 // The event location is in the receiver's coordinate system. The caller is |
| 580 // responsible for managing the lifetime of the returned object, though that | 580 // responsible for managing the lifetime of the returned object, though that |
| 581 // lifetime may vary from platform to platform. On Windows and Aura, | 581 // lifetime may vary from platform to platform. On Windows and Aura, |
| 582 // the cursor is a shared resource. | 582 // the cursor is a shared resource. |
| 583 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event); | 583 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event); |
| 584 | 584 |
| 585 // A convenience function which calls HitTestRect() with a rect of size | 585 // A convenience function which calls HitTestRect() with a rect of size |
| 586 // 1x1 and an origin of |point|. | 586 // 1x1 and an origin of |point|. |
| 587 bool HitTestPoint(const gfx::Point& point) const; | 587 bool HitTestPoint(const gfx::PointF& point) const; |
| 588 | 588 |
| 589 // Tests whether |rect| intersects this view's bounds. | 589 // Tests whether |rect| intersects this view's bounds. |
| 590 virtual bool HitTestRect(const gfx::Rect& rect) const; | 590 virtual bool HitTestRect(const gfx::RectF& rect) const; |
| 591 | 591 |
| 592 // Returns true if the mouse cursor is over |view| and mouse events are | 592 // Returns true if the mouse cursor is over |view| and mouse events are |
| 593 // enabled. | 593 // enabled. |
| 594 bool IsMouseHovered(); | 594 bool IsMouseHovered(); |
| 595 | 595 |
| 596 // This method is invoked when the user clicks on this view. | 596 // This method is invoked when the user clicks on this view. |
| 597 // The provided event is in the receiver's coordinate system. | 597 // The provided event is in the receiver's coordinate system. |
| 598 // | 598 // |
| 599 // Return true if you processed the event and want to receive subsequent | 599 // Return true if you processed the event and want to receive subsequent |
| 600 // MouseDraggged and MouseReleased events. This also stops the event from | 600 // MouseDraggged and MouseReleased events. This also stops the event from |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 // Invoked during a drag and drop session when OnDragUpdated returns a valid | 917 // Invoked during a drag and drop session when OnDragUpdated returns a valid |
| 918 // operation and the user release the mouse. | 918 // operation and the user release the mouse. |
| 919 virtual int OnPerformDrop(const ui::DropTargetEvent& event); | 919 virtual int OnPerformDrop(const ui::DropTargetEvent& event); |
| 920 | 920 |
| 921 // Invoked from DoDrag after the drag completes. This implementation does | 921 // Invoked from DoDrag after the drag completes. This implementation does |
| 922 // nothing, and is intended for subclasses to do cleanup. | 922 // nothing, and is intended for subclasses to do cleanup. |
| 923 virtual void OnDragDone(); | 923 virtual void OnDragDone(); |
| 924 | 924 |
| 925 // Returns true if the mouse was dragged enough to start a drag operation. | 925 // Returns true if the mouse was dragged enough to start a drag operation. |
| 926 // delta_x and y are the distance the mouse was dragged. | 926 // delta_x and y are the distance the mouse was dragged. |
| 927 static bool ExceededDragThreshold(const gfx::Vector2d& delta); | 927 static bool ExceededDragThreshold(const gfx::Vector2dF& delta); |
| 928 | 928 |
| 929 // Accessibility ------------------------------------------------------------- | 929 // Accessibility ------------------------------------------------------------- |
| 930 | 930 |
| 931 // Modifies |state| to reflect the current accessible state of this view. | 931 // Modifies |state| to reflect the current accessible state of this view. |
| 932 virtual void GetAccessibleState(ui::AXViewState* state) { } | 932 virtual void GetAccessibleState(ui::AXViewState* state) { } |
| 933 | 933 |
| 934 // Returns an instance of the native accessibility interface for this view. | 934 // Returns an instance of the native accessibility interface for this view. |
| 935 virtual gfx::NativeViewAccessible GetNativeViewAccessible(); | 935 virtual gfx::NativeViewAccessible GetNativeViewAccessible(); |
| 936 | 936 |
| 937 // Notifies assistive technology that an accessibility event has | 937 // Notifies assistive technology that an accessibility event has |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 // Used to track a drag. RootView passes this into | 981 // Used to track a drag. RootView passes this into |
| 982 // ProcessMousePressed/Dragged. | 982 // ProcessMousePressed/Dragged. |
| 983 struct DragInfo { | 983 struct DragInfo { |
| 984 // Sets possible_drag to false and start_x/y to 0. This is invoked by | 984 // Sets possible_drag to false and start_x/y to 0. This is invoked by |
| 985 // RootView prior to invoke ProcessMousePressed. | 985 // RootView prior to invoke ProcessMousePressed. |
| 986 void Reset(); | 986 void Reset(); |
| 987 | 987 |
| 988 // Sets possible_drag to true and start_pt to the specified point. | 988 // Sets possible_drag to true and start_pt to the specified point. |
| 989 // This is invoked by the target view if it detects the press may generate | 989 // This is invoked by the target view if it detects the press may generate |
| 990 // a drag. | 990 // a drag. |
| 991 void PossibleDrag(const gfx::Point& p); | 991 void PossibleDrag(const gfx::PointF& p); |
| 992 | 992 |
| 993 // Whether the press may generate a drag. | 993 // Whether the press may generate a drag. |
| 994 bool possible_drag; | 994 bool possible_drag; |
| 995 | 995 |
| 996 // Coordinates of the mouse press. | 996 // Coordinates of the mouse press. |
| 997 gfx::Point start_pt; | 997 gfx::PointF start_pt; |
| 998 }; | 998 }; |
| 999 | 999 |
| 1000 // Size and disposition ------------------------------------------------------ | 1000 // Size and disposition ------------------------------------------------------ |
| 1001 | 1001 |
| 1002 // Override to be notified when the bounds of the view have changed. | 1002 // Override to be notified when the bounds of the view have changed. |
| 1003 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); | 1003 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); |
| 1004 | 1004 |
| 1005 // Called when the preferred size of a child view changed. This gives the | 1005 // Called when the preferred size of a child view changed. This gives the |
| 1006 // parent an opportunity to do a fresh layout if that makes sense. | 1006 // parent an opportunity to do a fresh layout if that makes sense. |
| 1007 virtual void ChildPreferredSizeChanged(View* child) {} | 1007 virtual void ChildPreferredSizeChanged(View* child) {} |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 // This method is invoked when the context menu is shown by way of the | 1175 // This method is invoked when the context menu is shown by way of the |
| 1176 // keyboard. | 1176 // keyboard. |
| 1177 virtual gfx::Point GetKeyboardContextMenuLocation(); | 1177 virtual gfx::Point GetKeyboardContextMenuLocation(); |
| 1178 | 1178 |
| 1179 // Drag and drop ------------------------------------------------------------- | 1179 // Drag and drop ------------------------------------------------------------- |
| 1180 | 1180 |
| 1181 // These are cover methods that invoke the method of the same name on | 1181 // These are cover methods that invoke the method of the same name on |
| 1182 // the DragController. Subclasses may wish to override rather than install | 1182 // the DragController. Subclasses may wish to override rather than install |
| 1183 // a DragController. | 1183 // a DragController. |
| 1184 // See DragController for a description of these methods. | 1184 // See DragController for a description of these methods. |
| 1185 virtual int GetDragOperations(const gfx::Point& press_pt); | 1185 virtual int GetDragOperations(const gfx::PointF& press_pt); |
| 1186 virtual void WriteDragData(const gfx::Point& press_pt, OSExchangeData* data); | 1186 virtual void WriteDragData(const gfx::PointF& press_pt, OSExchangeData* data); |
| 1187 | 1187 |
| 1188 // Returns whether we're in the middle of a drag session that was initiated | 1188 // Returns whether we're in the middle of a drag session that was initiated |
| 1189 // by us. | 1189 // by us. |
| 1190 bool InDrag(); | 1190 bool InDrag(); |
| 1191 | 1191 |
| 1192 // Returns how much the mouse needs to move in one direction to start a | 1192 // Returns how much the mouse needs to move in one direction to start a |
| 1193 // drag. These methods cache in a platform-appropriate way. These values are | 1193 // drag. These methods cache in a platform-appropriate way. These values are |
| 1194 // used by the public static method ExceededDragThreshold(). | 1194 // used by the public static method ExceededDragThreshold(). |
| 1195 static int GetHorizontalDragThreshold(); | 1195 static int GetHorizontalDragThreshold(); |
| 1196 static int GetVerticalDragThreshold(); | 1196 static int GetVerticalDragThreshold(); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 void UpdateTooltip(); | 1411 void UpdateTooltip(); |
| 1412 | 1412 |
| 1413 // Drag and drop ------------------------------------------------------------- | 1413 // Drag and drop ------------------------------------------------------------- |
| 1414 | 1414 |
| 1415 // Starts a drag and drop operation originating from this view. This invokes | 1415 // Starts a drag and drop operation originating from this view. This invokes |
| 1416 // WriteDragData to write the data and GetDragOperations to determine the | 1416 // WriteDragData to write the data and GetDragOperations to determine the |
| 1417 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is | 1417 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is |
| 1418 // in the view's coordinate system. | 1418 // in the view's coordinate system. |
| 1419 // Returns true if a drag was started. | 1419 // Returns true if a drag was started. |
| 1420 bool DoDrag(const ui::LocatedEvent& event, | 1420 bool DoDrag(const ui::LocatedEvent& event, |
| 1421 const gfx::Point& press_pt, | 1421 const gfx::PointF& press_pt, |
| 1422 ui::DragDropTypes::DragEventSource source); | 1422 ui::DragDropTypes::DragEventSource source); |
| 1423 | 1423 |
| 1424 ////////////////////////////////////////////////////////////////////////////// | 1424 ////////////////////////////////////////////////////////////////////////////// |
| 1425 | 1425 |
| 1426 // Creation and lifetime ----------------------------------------------------- | 1426 // Creation and lifetime ----------------------------------------------------- |
| 1427 | 1427 |
| 1428 // False if this View is owned by its parent - i.e. it will be deleted by its | 1428 // False if this View is owned by its parent - i.e. it will be deleted by its |
| 1429 // parent during its parents destruction. False is the default. | 1429 // parent during its parents destruction. False is the default. |
| 1430 bool owned_by_client_; | 1430 bool owned_by_client_; |
| 1431 | 1431 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 // Belongs to this view, but it's reference-counted on some platforms | 1559 // Belongs to this view, but it's reference-counted on some platforms |
| 1560 // so we can't use a scoped_ptr. It's dereferenced in the destructor. | 1560 // so we can't use a scoped_ptr. It's dereferenced in the destructor. |
| 1561 NativeViewAccessibility* native_view_accessibility_; | 1561 NativeViewAccessibility* native_view_accessibility_; |
| 1562 | 1562 |
| 1563 DISALLOW_COPY_AND_ASSIGN(View); | 1563 DISALLOW_COPY_AND_ASSIGN(View); |
| 1564 }; | 1564 }; |
| 1565 | 1565 |
| 1566 } // namespace views | 1566 } // namespace views |
| 1567 | 1567 |
| 1568 #endif // UI_VIEWS_VIEW_H_ | 1568 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |