OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_TARGETER_H_ | 5 #ifndef UI_VIEWS_VIEW_TARGETER_H_ |
6 #define UI_VIEWS_VIEW_TARGETER_H_ | 6 #define UI_VIEWS_VIEW_TARGETER_H_ |
7 | 7 |
8 #include "ui/events/event_targeter.h" | 8 #include "ui/events/event_targeter.h" |
9 #include "ui/views/views_export.h" | 9 #include "ui/views/views_export.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 | 12 |
13 class View; | 13 class View; |
14 class ViewTargeterDelegate; | 14 class ViewTargeterDelegate; |
15 | 15 |
16 // A ViewTargeter is installed on a View that wishes to use the custom | 16 // A ViewTargeter is installed on a View that wishes to use the custom |
17 // hit-testing or event-targeting behaviour defined by |delegate|. | 17 // hit-testing or event-targeting behaviour defined by |delegate|. |
18 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { | 18 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { |
19 public: | 19 public: |
20 explicit ViewTargeter(ViewTargeterDelegate* delegate); | 20 explicit ViewTargeter(ViewTargeterDelegate* delegate); |
21 virtual ~ViewTargeter(); | 21 virtual ~ViewTargeter(); |
22 | 22 |
23 // A call-through to DoesIntersectRect() on |delegate_|. | 23 // A call-through to DoesIntersectRect() on |delegate_|. |
24 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const; | 24 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const; |
25 | 25 |
26 // A call-through to TargetForRect() on |delegate_|. | 26 // A call-through to TargetForRect() on |delegate_|. |
27 View* TargetForRect(View* root, const gfx::Rect& rect) const; | 27 View* TargetForRect(View* root, const gfx::Rect& rect) const; |
28 | 28 |
29 protected: | |
30 // ui::EventTargeter: | 29 // ui::EventTargeter: |
30 // TODO(tdanderson): Make these private once RootView::DispatchGestureEvent() | |
31 // has been removed. | |
sadrul
2014/08/26 16:21:44
Maybe make RootView friend for the short-term inst
tdanderson
2014/08/26 20:21:14
Done.
| |
31 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, | 32 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, |
32 ui::Event* event) OVERRIDE; | 33 ui::Event* event) OVERRIDE; |
33 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, | 34 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, |
34 ui::Event* event) OVERRIDE; | 35 ui::Event* event) OVERRIDE; |
36 protected: | |
37 // ui::EventTargeter: | |
35 virtual bool SubtreeCanAcceptEvent( | 38 virtual bool SubtreeCanAcceptEvent( |
36 ui::EventTarget* target, | 39 ui::EventTarget* target, |
37 const ui::LocatedEvent& event) const OVERRIDE; | 40 const ui::LocatedEvent& event) const OVERRIDE; |
38 virtual bool EventLocationInsideBounds( | 41 virtual bool EventLocationInsideBounds( |
39 ui::EventTarget* target, | 42 ui::EventTarget* target, |
40 const ui::LocatedEvent& event) const OVERRIDE; | 43 const ui::LocatedEvent& event) const OVERRIDE; |
41 | 44 |
42 private: | 45 private: |
43 View* FindTargetForKeyEvent(View* root, const ui::KeyEvent& key); | 46 View* FindTargetForKeyEvent(View* root, const ui::KeyEvent& key); |
44 View* FindTargetForScrollEvent(View* root, const ui::ScrollEvent& scroll); | 47 View* FindTargetForScrollEvent(View* root, const ui::ScrollEvent& scroll); |
48 View* FindTargetForGestureEvent(View* root, const ui::GestureEvent& gesture); | |
45 | 49 |
46 // ViewTargeter does not own the |delegate_|, but |delegate_| must | 50 // ViewTargeter does not own the |delegate_|, but |delegate_| must |
47 // outlive the targeter. | 51 // outlive the targeter. |
48 ViewTargeterDelegate* delegate_; | 52 ViewTargeterDelegate* delegate_; |
49 | 53 |
50 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); | 54 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); |
51 }; | 55 }; |
52 | 56 |
53 } // namespace views | 57 } // namespace views |
54 | 58 |
55 #endif // UI_VIEWS_VIEW_TARGETER_H_ | 59 #endif // UI_VIEWS_VIEW_TARGETER_H_ |
OLD | NEW |