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 | 14 |
15 // Contains the logic used to determine the View to which an | 15 // Contains the logic used to determine the View to which an |
16 // event should be dispatched. A ViewTargeter (or one of its | 16 // event should be dispatched. A ViewTargeter (or one of its |
17 // derived classes) is installed on a View to specify the | 17 // derived classes) is installed on a View to specify the |
18 // targeting behaviour to be used for the subtree rooted at | 18 // targeting behaviour to be used for the subtree rooted at |
19 // that View. | 19 // that View. |
20 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { | 20 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { |
21 public: | 21 public: |
22 ViewTargeter(); | 22 ViewTargeter(); |
23 virtual ~ViewTargeter(); | 23 virtual ~ViewTargeter(); |
24 | 24 |
25 protected: | 25 protected: |
| 26 // Returns the location of |event| represented as a rect. If |event| is |
| 27 // a gesture event, its bounding box is returned. Otherwise, a 1x1 rect |
| 28 // having its origin at the location of |event| is returned. |
| 29 gfx::RectF BoundsForEvent(const ui::LocatedEvent& event) const; |
| 30 |
26 // ui::EventTargeter: | 31 // ui::EventTargeter: |
27 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, | 32 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, |
28 ui::Event* event) OVERRIDE; | 33 ui::Event* event) OVERRIDE; |
29 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, | 34 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, |
30 ui::Event* event) OVERRIDE; | 35 ui::Event* event) OVERRIDE; |
31 virtual bool SubtreeCanAcceptEvent( | 36 virtual bool SubtreeCanAcceptEvent( |
32 ui::EventTarget* target, | 37 ui::EventTarget* target, |
33 const ui::LocatedEvent& event) const OVERRIDE; | 38 const ui::LocatedEvent& event) const OVERRIDE; |
34 virtual bool EventLocationInsideBounds( | 39 virtual bool EventLocationInsideBounds( |
35 ui::EventTarget* target, | 40 ui::EventTarget* target, |
36 const ui::LocatedEvent& event) const OVERRIDE; | 41 const ui::LocatedEvent& event) const OVERRIDE; |
37 | 42 |
38 private: | 43 private: |
39 View* FindTargetForKeyEvent(View* view, const ui::KeyEvent& key); | 44 View* FindTargetForKeyEvent(View* view, const ui::KeyEvent& key); |
40 | 45 |
41 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); | 46 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); |
42 }; | 47 }; |
43 | 48 |
44 } // namespace views | 49 } // namespace views |
45 | 50 |
46 #endif // UI_VIEWS_VIEW_TARGETER_H_ | 51 #endif // UI_VIEWS_VIEW_TARGETER_H_ |
OLD | NEW |