Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / views / view_targeter.h
blob3e460ca0fb43d67af26d446a0f289572adf52f8c
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"
12 namespace gfx {
13 class Rect;
14 } // namespace gfx
16 namespace ui {
17 class GestureEvent;
18 class KeyEvent;
19 class ScrollEvent;
20 } // namespace ui
22 namespace views {
24 namespace internal {
25 class RootView;
26 } // namespace internal
28 class View;
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 {
34 public:
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;
44 protected:
45 // ui::EventTargeter:
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;
51 private:
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);
68 } // namespace views
70 #endif // UI_VIEWS_VIEW_TARGETER_H_