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

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

Issue 10824295: Rid the world of the last of views::Event types: TouchEvent, GestureEvent, MouseWheelEvent, ScrollE… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/ime/mock_input_method.cc ('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 <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "ui/base/event.h"
19 #include "ui/base/accelerators/accelerator.h" 20 #include "ui/base/accelerators/accelerator.h"
20 #include "ui/base/dragdrop/os_exchange_data.h" 21 #include "ui/base/dragdrop/os_exchange_data.h"
21 #include "ui/compositor/layer_delegate.h" 22 #include "ui/compositor/layer_delegate.h"
22 #include "ui/compositor/layer_owner.h" 23 #include "ui/compositor/layer_owner.h"
23 #include "ui/gfx/native_widget_types.h" 24 #include "ui/gfx/native_widget_types.h"
24 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
25 #include "ui/views/background.h" 26 #include "ui/views/background.h"
26 #include "ui/views/border.h" 27 #include "ui/views/border.h"
27 #include "ui/views/events/event.h"
28 28
29 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30 #include "base/win/scoped_comptr.h" 30 #include "base/win/scoped_comptr.h"
31 #endif 31 #endif
32 32
33 using ui::OSExchangeData; 33 using ui::OSExchangeData;
34 34
35 namespace gfx { 35 namespace gfx {
36 class Canvas; 36 class Canvas;
37 class Insets; 37 class Insets;
38 class Path; 38 class Path;
39 } 39 }
40 40
41 namespace ui { 41 namespace ui {
42 struct AccessibleViewState; 42 struct AccessibleViewState;
43 class Compositor; 43 class Compositor;
44 class KeyEvent;
45 class Layer; 44 class Layer;
46 class TextInputClient; 45 class TextInputClient;
47 class Texture; 46 class Texture;
48 class ThemeProvider; 47 class ThemeProvider;
49 class Transform; 48 class Transform;
50 } 49 }
51 50
52 #if defined(OS_WIN) 51 #if defined(OS_WIN)
53 class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) 52 class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
54 NativeViewAccessibilityWin; 53 NativeViewAccessibilityWin;
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // Default implementation does nothing. Override as needed. 568 // Default implementation does nothing. Override as needed.
570 virtual void OnMouseEntered(const ui::MouseEvent& event); 569 virtual void OnMouseEntered(const ui::MouseEvent& event);
571 570
572 // This method is invoked when the mouse exits this control 571 // This method is invoked when the mouse exits this control
573 // The provided event location is always (0, 0) 572 // The provided event location is always (0, 0)
574 // Default implementation does nothing. Override as needed. 573 // Default implementation does nothing. Override as needed.
575 virtual void OnMouseExited(const ui::MouseEvent& event); 574 virtual void OnMouseExited(const ui::MouseEvent& event);
576 575
577 // This method is invoked for each touch event. Default implementation 576 // This method is invoked for each touch event. Default implementation
578 // does nothing. Override as needed. 577 // does nothing. Override as needed.
579 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event); 578 virtual ui::TouchStatus OnTouchEvent(const ui::TouchEvent& event);
580 579
581 // This method is invoked for each GestureEvent created by GestureRecognizer. 580 // This method is invoked for each GestureEvent created by GestureRecognizer.
582 // Default implementation does nothing. Override as needed. 581 // Default implementation does nothing. Override as needed.
583 // If a View returns ui::GESTURE_STATUS_CONSUMED from OnGestureEvent, then 582 // If a View returns ui::GESTURE_STATUS_CONSUMED from OnGestureEvent, then
584 // subsequent gestures will be dispatched to the same View, until the gesture 583 // subsequent gestures will be dispatched to the same View, until the gesture
585 // ends (i.e. all touch-points are released). 584 // ends (i.e. all touch-points are released).
586 // Scroll gesture events are handled slightly differently: if a View starts 585 // Scroll gesture events are handled slightly differently: if a View starts
587 // processing gesture events, but does not process an ET_GESTURE_SCROLL_BEGIN 586 // processing gesture events, but does not process an ET_GESTURE_SCROLL_BEGIN
588 // gesture, then the scroll-gesture event will bubble up (i.e. will be sent to 587 // gesture, then the scroll-gesture event will bubble up (i.e. will be sent to
589 // the parent view for processing). If a View then returns 588 // the parent view for processing). If a View then returns
590 // GESTURE_STATUS_CONSUMED from OnGestureEvent, then the subsequent 589 // GESTURE_STATUS_CONSUMED from OnGestureEvent, then the subsequent
591 // scroll-gesture events will be sent to this View. However all the other 590 // scroll-gesture events will be sent to this View. However all the other
592 // gesture-events (e.g. ET_GESTURE_END, ET_GESTURE_PINCH_BEGIN etc.) will 591 // gesture-events (e.g. ET_GESTURE_END, ET_GESTURE_PINCH_BEGIN etc.) will
593 // continue to be dispatched to the first View. 592 // continue to be dispatched to the first View.
594 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event); 593 virtual ui::GestureStatus OnGestureEvent(const ui::GestureEvent& event);
595 594
596 // Set the MouseHandler for a drag session. 595 // Set the MouseHandler for a drag session.
597 // 596 //
598 // A drag session is a stream of mouse events starting 597 // A drag session is a stream of mouse events starting
599 // with a MousePressed event, followed by several MouseDragged 598 // with a MousePressed event, followed by several MouseDragged
600 // events and finishing with a MouseReleased event. 599 // events and finishing with a MouseReleased event.
601 // 600 //
602 // This method should be only invoked while processing a 601 // This method should be only invoked while processing a
603 // MouseDragged or MousePressed event. 602 // MouseDragged or MousePressed event.
604 // 603 //
(...skipping 13 matching lines...) Expand all
618 // Subclasser should return true if the event has been processed and false 617 // Subclasser should return true if the event has been processed and false
619 // otherwise. If the event has not been processed, the parent will be given a 618 // otherwise. If the event has not been processed, the parent will be given a
620 // chance. 619 // chance.
621 virtual bool OnKeyPressed(const ui::KeyEvent& event); 620 virtual bool OnKeyPressed(const ui::KeyEvent& event);
622 virtual bool OnKeyReleased(const ui::KeyEvent& event); 621 virtual bool OnKeyReleased(const ui::KeyEvent& event);
623 622
624 // Invoked when the user uses the mousewheel. Implementors should return true 623 // Invoked when the user uses the mousewheel. Implementors should return true
625 // if the event has been processed and false otherwise. This message is sent 624 // if the event has been processed and false otherwise. This message is sent
626 // if the view is focused. If the event has not been processed, the parent 625 // if the view is focused. If the event has not been processed, the parent
627 // will be given a chance. 626 // will be given a chance.
628 virtual bool OnMouseWheel(const MouseWheelEvent& event); 627 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event);
629 628
630 // Invoked when user scrolls (e.g. using two-finger scroll on touch pad). 629 // Invoked when user scrolls (e.g. using two-finger scroll on touch pad).
631 // Returns true if the event has been processed and false otherwise. The event 630 // Returns true if the event has been processed and false otherwise. The event
632 // is sent to the view where the event happens first. If it has not been 631 // is sent to the view where the event happens first. If it has not been
633 // processed, the parent will be given a chance. 632 // processed, the parent will be given a chance.
634 virtual bool OnScrollEvent(const ScrollEvent& event); 633 virtual bool OnScrollEvent(const ui::ScrollEvent& event);
635 634
636 // See field for description. 635 // See field for description.
637 void set_notify_enter_exit_on_child(bool notify) { 636 void set_notify_enter_exit_on_child(bool notify) {
638 notify_enter_exit_on_child_ = notify; 637 notify_enter_exit_on_child_ = notify;
639 } 638 }
640 bool notify_enter_exit_on_child() const { 639 bool notify_enter_exit_on_child() const {
641 return notify_enter_exit_on_child_; 640 return notify_enter_exit_on_child_;
642 } 641 }
643 642
644 // Returns the View's TextInputClient instance or NULL if the View doesn't 643 // Returns the View's TextInputClient instance or NULL if the View doesn't
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 virtual bool AreDropTypesRequired(); 823 virtual bool AreDropTypesRequired();
825 824
826 // A view that supports drag and drop must override this and return true if 825 // A view that supports drag and drop must override this and return true if
827 // data contains a type that may be dropped on this view. 826 // data contains a type that may be dropped on this view.
828 virtual bool CanDrop(const OSExchangeData& data); 827 virtual bool CanDrop(const OSExchangeData& data);
829 828
830 // OnDragEntered is invoked when the mouse enters this view during a drag and 829 // OnDragEntered is invoked when the mouse enters this view during a drag and
831 // drop session and CanDrop returns true. This is immediately 830 // drop session and CanDrop returns true. This is immediately
832 // followed by an invocation of OnDragUpdated, and eventually one of 831 // followed by an invocation of OnDragUpdated, and eventually one of
833 // OnDragExited or OnPerformDrop. 832 // OnDragExited or OnPerformDrop.
834 virtual void OnDragEntered(const DropTargetEvent& event); 833 virtual void OnDragEntered(const ui::DropTargetEvent& event);
835 834
836 // Invoked during a drag and drop session while the mouse is over the view. 835 // Invoked during a drag and drop session while the mouse is over the view.
837 // This should return a bitmask of the DragDropTypes::DragOperation supported 836 // This should return a bitmask of the DragDropTypes::DragOperation supported
838 // based on the location of the event. Return 0 to indicate the drop should 837 // based on the location of the event. Return 0 to indicate the drop should
839 // not be accepted. 838 // not be accepted.
840 virtual int OnDragUpdated(const DropTargetEvent& event); 839 virtual int OnDragUpdated(const ui::DropTargetEvent& event);
841 840
842 // Invoked during a drag and drop session when the mouse exits the views, or 841 // Invoked during a drag and drop session when the mouse exits the views, or
843 // when the drag session was canceled and the mouse was over the view. 842 // when the drag session was canceled and the mouse was over the view.
844 virtual void OnDragExited(); 843 virtual void OnDragExited();
845 844
846 // Invoked during a drag and drop session when OnDragUpdated returns a valid 845 // Invoked during a drag and drop session when OnDragUpdated returns a valid
847 // operation and the user release the mouse. 846 // operation and the user release the mouse.
848 virtual int OnPerformDrop(const DropTargetEvent& event); 847 virtual int OnPerformDrop(const ui::DropTargetEvent& event);
849 848
850 // Invoked from DoDrag after the drag completes. This implementation does 849 // Invoked from DoDrag after the drag completes. This implementation does
851 // nothing, and is intended for subclasses to do cleanup. 850 // nothing, and is intended for subclasses to do cleanup.
852 virtual void OnDragDone(); 851 virtual void OnDragDone();
853 852
854 // Returns true if the mouse was dragged enough to start a drag operation. 853 // Returns true if the mouse was dragged enough to start a drag operation.
855 // delta_x and y are the distance the mouse was dragged. 854 // delta_x and y are the distance the mouse was dragged.
856 static bool ExceededDragThreshold(int delta_x, int delta_y); 855 static bool ExceededDragThreshold(int delta_x, int delta_y);
857 856
858 // Accessibility ------------------------------------------------------------- 857 // Accessibility -------------------------------------------------------------
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 // Input --------------------------------------------------------------------- 1275 // Input ---------------------------------------------------------------------
1277 1276
1278 // RootView invokes these. These in turn invoke the appropriate OnMouseXXX 1277 // RootView invokes these. These in turn invoke the appropriate OnMouseXXX
1279 // method. If a drag is detected, DoDrag is invoked. 1278 // method. If a drag is detected, DoDrag is invoked.
1280 bool ProcessMousePressed(const ui::MouseEvent& event, DragInfo* drop_info); 1279 bool ProcessMousePressed(const ui::MouseEvent& event, DragInfo* drop_info);
1281 bool ProcessMouseDragged(const ui::MouseEvent& event, DragInfo* drop_info); 1280 bool ProcessMouseDragged(const ui::MouseEvent& event, DragInfo* drop_info);
1282 void ProcessMouseReleased(const ui::MouseEvent& event); 1281 void ProcessMouseReleased(const ui::MouseEvent& event);
1283 1282
1284 // RootView will invoke this with incoming TouchEvents. Returns the result 1283 // RootView will invoke this with incoming TouchEvents. Returns the result
1285 // of OnTouchEvent. 1284 // of OnTouchEvent.
1286 ui::TouchStatus ProcessTouchEvent(const TouchEvent& event); 1285 ui::TouchStatus ProcessTouchEvent(const ui::TouchEvent& event);
1287 1286
1288 // RootView will invoke this with incoming GestureEvents. This will invoke 1287 // RootView will invoke this with incoming GestureEvents. This will invoke
1289 // OnGestureEvent and return the result. 1288 // OnGestureEvent and return the result.
1290 ui::GestureStatus ProcessGestureEvent(const GestureEvent& event); 1289 ui::GestureStatus ProcessGestureEvent(const ui::GestureEvent& event);
1291 1290
1292 // Accelerators -------------------------------------------------------------- 1291 // Accelerators --------------------------------------------------------------
1293 1292
1294 // Registers this view's keyboard accelerators that are not registered to 1293 // Registers this view's keyboard accelerators that are not registered to
1295 // FocusManager yet, if possible. 1294 // FocusManager yet, if possible.
1296 void RegisterPendingAccelerators(); 1295 void RegisterPendingAccelerators();
1297 1296
1298 // Unregisters all the keyboard accelerators associated with this view. 1297 // Unregisters all the keyboard accelerators associated with this view.
1299 // |leave_data_intact| if true does not remove data from accelerators_ array, 1298 // |leave_data_intact| if true does not remove data from accelerators_ array,
1300 // so it could be re-registered with other focus manager 1299 // so it could be re-registered with other focus manager
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 base::win::ScopedComPtr<NativeViewAccessibilityWin> 1472 base::win::ScopedComPtr<NativeViewAccessibilityWin>
1474 native_view_accessibility_win_; 1473 native_view_accessibility_win_;
1475 #endif 1474 #endif
1476 1475
1477 DISALLOW_COPY_AND_ASSIGN(View); 1476 DISALLOW_COPY_AND_ASSIGN(View);
1478 }; 1477 };
1479 1478
1480 } // namespace views 1479 } // namespace views
1481 1480
1482 #endif // UI_VIEWS_VIEW_H_ 1481 #endif // UI_VIEWS_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/ime/mock_input_method.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698