| 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. |
| 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 |
| 37 protected: |
| 38 // ui::EventTargeter: |
| 35 virtual bool SubtreeCanAcceptEvent( | 39 virtual bool SubtreeCanAcceptEvent( |
| 36 ui::EventTarget* target, | 40 ui::EventTarget* target, |
| 37 const ui::LocatedEvent& event) const OVERRIDE; | 41 const ui::LocatedEvent& event) const OVERRIDE; |
| 38 virtual bool EventLocationInsideBounds( | 42 virtual bool EventLocationInsideBounds( |
| 39 ui::EventTarget* target, | 43 ui::EventTarget* target, |
| 40 const ui::LocatedEvent& event) const OVERRIDE; | 44 const ui::LocatedEvent& event) const OVERRIDE; |
| 41 | 45 |
| 42 private: | 46 private: |
| 43 View* FindTargetForKeyEvent(View* root, const ui::KeyEvent& key); | 47 View* FindTargetForKeyEvent(View* root, const ui::KeyEvent& key); |
| 44 View* FindTargetForScrollEvent(View* root, const ui::ScrollEvent& scroll); | 48 View* FindTargetForScrollEvent(View* root, const ui::ScrollEvent& scroll); |
| 49 View* FindTargetForGestureEvent(View* root, const ui::GestureEvent& gesture); |
| 45 | 50 |
| 46 // ViewTargeter does not own the |delegate_|, but |delegate_| must | 51 // ViewTargeter does not own the |delegate_|, but |delegate_| must |
| 47 // outlive the targeter. | 52 // outlive the targeter. |
| 48 ViewTargeterDelegate* delegate_; | 53 ViewTargeterDelegate* delegate_; |
| 49 | 54 |
| 50 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); | 55 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 } // namespace views | 58 } // namespace views |
| 54 | 59 |
| 55 #endif // UI_VIEWS_VIEW_TARGETER_H_ | 60 #endif // UI_VIEWS_VIEW_TARGETER_H_ |
| OLD | NEW |