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 MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ | 5 #ifndef MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ |
6 #define MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ | 6 #define MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ |
7 | 7 |
8 #include "ui/events/event_target.h" | 8 #include "ui/events/event_target.h" |
9 | 9 |
10 namespace gfx { | 10 namespace gfx { |
11 class Point; | 11 class Point; |
12 class Rect; | 12 class Rect; |
13 class Vector2d; | 13 class Vector2d; |
14 } | 14 } |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 class EventTargeter; | 17 class EventTargeter; |
18 } | 18 } |
19 | 19 |
20 namespace mojo { | 20 namespace mojo { |
21 | 21 |
22 class FocusController; | |
22 class TestView; | 23 class TestView; |
23 class View; | 24 class View; |
24 class ViewTargeter; | 25 class ViewTargeter; |
25 class WindowManagerApp; | 26 class WindowManagerApp; |
26 | 27 |
27 // A wrapper class around mojo::View; we can't subclass View to implement the | 28 // A wrapper class around mojo::View; we can't subclass View to implement the |
28 // event targeting interfaces, so we create a separate object which observes | 29 // event targeting interfaces, so we create a separate object which observes |
29 // the View and ties its lifetime to it. | 30 // the View and ties its lifetime to it. |
30 // | 31 // |
31 // We set ourselves as a property of the view passed in, and we are owned by | 32 // We set ourselves as a property of the view passed in, and we are owned by |
32 // said View. | 33 // said View. |
33 class ViewTarget : public ui::EventTarget { | 34 class ViewTarget : public ui::EventTarget { |
34 public: | 35 public: |
35 ~ViewTarget() override; | 36 ~ViewTarget() override; |
36 | 37 |
37 // Returns the ViewTarget for a View. ViewTargets are owned by the |view| | 38 // Returns the ViewTarget for a View. ViewTargets are owned by the |view| |
38 // passed in, and are created on demand. | 39 // passed in, and are created on demand. |
39 static ViewTarget* TargetFromView(View* view); | 40 static ViewTarget* TargetFromView(View* view); |
40 | 41 |
41 // Converts |point| from |source|'s coordinates to |target|'s. If |source| is | 42 // Converts |point| from |source|'s coordinates to |target|'s. If |source| is |
42 // NULL, the function returns without modifying |point|. |target| cannot be | 43 // NULL, the function returns without modifying |point|. |target| cannot be |
43 // NULL. | 44 // NULL. |
44 static void ConvertPointToTarget(const ViewTarget* source, | 45 static void ConvertPointToTarget(const ViewTarget* source, |
45 const ViewTarget* target, | 46 const ViewTarget* target, |
46 gfx::Point* point); | 47 gfx::Point* point); |
47 | 48 |
48 View* view() { return view_; } | 49 View* view() { return view_; } |
49 | 50 |
51 FocusController* focus_controller() { return focus_controller_; } | |
52 void set_focus_controller(FocusController* focus_controller) { | |
sky
2014/11/18 22:36:38
Document ownership.
Elliot Glaysher
2014/11/18 23:52:30
Was unhappy with this. Instead of hanging it here,
| |
53 focus_controller_ = focus_controller; | |
54 } | |
55 | |
50 // TODO(erg): Make this const once we've removed aura from the tree and it's | 56 // TODO(erg): Make this const once we've removed aura from the tree and it's |
51 // feasible to change all callers of the EventTargeter interface to pass and | 57 // feasible to change all callers of the EventTargeter interface to pass and |
52 // accept const objects. (When that gets done, re-const the | 58 // accept const objects. (When that gets done, re-const the |
53 // EventTargetIterator::GetNextTarget and EventTarget::GetChildIterator | 59 // EventTargetIterator::GetNextTarget and EventTarget::GetChildIterator |
54 // interfaces.) | 60 // interfaces.) |
55 std::vector<ViewTarget*> GetChildren(); | 61 std::vector<ViewTarget*> GetChildren(); |
56 | 62 |
57 const ViewTarget* GetParent() const; | 63 const ViewTarget* GetParent() const; |
58 gfx::Rect GetBounds() const; | 64 gfx::Rect GetBounds() const; |
59 bool HasParent() const; | 65 bool HasParent() const; |
(...skipping 20 matching lines...) Expand all Loading... | |
80 bool ConvertPointForAncestor(const ViewTarget* ancestor, | 86 bool ConvertPointForAncestor(const ViewTarget* ancestor, |
81 gfx::Point* point) const; | 87 gfx::Point* point) const; |
82 bool ConvertPointFromAncestor(const ViewTarget* ancestor, | 88 bool ConvertPointFromAncestor(const ViewTarget* ancestor, |
83 gfx::Point* point) const; | 89 gfx::Point* point) const; |
84 bool GetTargetOffsetRelativeTo(const ViewTarget* ancestor, | 90 bool GetTargetOffsetRelativeTo(const ViewTarget* ancestor, |
85 gfx::Vector2d* offset) const; | 91 gfx::Vector2d* offset) const; |
86 | 92 |
87 // The mojo::View that we dispatch to. | 93 // The mojo::View that we dispatch to. |
88 View* view_; | 94 View* view_; |
89 | 95 |
96 FocusController* focus_controller_; | |
97 | |
90 scoped_ptr<ViewTargeter> targeter_; | 98 scoped_ptr<ViewTargeter> targeter_; |
91 | 99 |
92 DISALLOW_COPY_AND_ASSIGN(ViewTarget); | 100 DISALLOW_COPY_AND_ASSIGN(ViewTarget); |
93 }; | 101 }; |
94 | 102 |
95 } // namespace mojo | 103 } // namespace mojo |
96 | 104 |
97 #endif // MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ | 105 #endif // MOJO_SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ |
OLD | NEW |