• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef UI_VIEWS_VIEW_TARGETER_H_
6 #define UI_VIEWS_VIEW_TARGETER_H_
7 
8 #include "ui/events/event_targeter.h"
9 #include "ui/views/views_export.h"
10 
11 namespace views {
12 
13 class View;
14 
15 // Contains the logic used to determine the View to which an
16 // event should be dispatched. A ViewTargeter (or one of its
17 // derived classes) is installed on a View to specify the
18 // targeting behaviour to be used for the subtree rooted at
19 // that View.
20 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter {
21  public:
22   ViewTargeter();
23   virtual ~ViewTargeter();
24 
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 
31   // ui::EventTargeter:
32   virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
33                                               ui::Event* event) OVERRIDE;
34   virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target,
35                                               ui::Event* event) OVERRIDE;
36   virtual bool SubtreeCanAcceptEvent(
37       ui::EventTarget* target,
38       const ui::LocatedEvent& event) const OVERRIDE;
39   virtual bool EventLocationInsideBounds(
40       ui::EventTarget* target,
41       const ui::LocatedEvent& event) const OVERRIDE;
42 
43  private:
44   View* FindTargetForKeyEvent(View* view, const ui::KeyEvent& key);
45 
46   DISALLOW_COPY_AND_ASSIGN(ViewTargeter);
47 };
48 
49 }  // namespace views
50 
51 #endif  // UI_VIEWS_VIEW_TARGETER_H_
52