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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_VIEW_TARGETER_H_
6 #define UI_VIEWS_VIEW_TARGETER_H_
8 #include "base/macros.h"
9 #include "ui/events/event_targeter.h"
10 #include "ui/views/views_export.h"
26 } // namespace internal
29 class ViewTargeterDelegate
;
31 // A ViewTargeter is installed on a View that wishes to use the custom
32 // hit-testing or event-targeting behaviour defined by |delegate|.
33 class VIEWS_EXPORT ViewTargeter
: public ui::EventTargeter
{
35 explicit ViewTargeter(ViewTargeterDelegate
* delegate
);
36 ~ViewTargeter() override
;
38 // A call-through to DoesIntersectRect() on |delegate_|.
39 bool DoesIntersectRect(const View
* target
, const gfx::Rect
& rect
) const;
41 // A call-through to TargetForRect() on |delegate_|.
42 View
* TargetForRect(View
* root
, const gfx::Rect
& rect
) const;
46 ui::EventTarget
* FindTargetForEvent(ui::EventTarget
* root
,
47 ui::Event
* event
) override
;
48 ui::EventTarget
* FindNextBestTarget(ui::EventTarget
* previous_target
,
49 ui::Event
* event
) override
;
52 View
* FindTargetForKeyEvent(View
* root
, const ui::KeyEvent
& key
);
53 View
* FindTargetForScrollEvent(View
* root
, const ui::ScrollEvent
& scroll
);
55 virtual View
* FindTargetForGestureEvent(View
* root
,
56 const ui::GestureEvent
& gesture
);
57 virtual ui::EventTarget
* FindNextBestTargetForGestureEvent(
58 ui::EventTarget
* previous_target
,
59 const ui::GestureEvent
& gesture
);
61 // ViewTargeter does not own the |delegate_|, but |delegate_| must
62 // outlive the targeter.
63 ViewTargeterDelegate
* delegate_
;
65 DISALLOW_COPY_AND_ASSIGN(ViewTargeter
);
70 #endif // UI_VIEWS_VIEW_TARGETER_H_