Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: services/window_manager/view_target.h

Issue 788453002: Put code in //services/window_manager in namespace window_manager (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ 5 #ifndef SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_
6 #define SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ 6 #define 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 class View;
22 }
23
24 namespace window_manager {
21 25
22 class TestView; 26 class TestView;
23 class View;
24 class ViewTargeter; 27 class ViewTargeter;
25 class WindowManagerApp; 28 class WindowManagerApp;
26 29
27 // A wrapper class around mojo::View; we can't subclass View to implement the 30 // 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 31 // event targeting interfaces, so we create a separate object which observes
29 // the View and ties its lifetime to it. 32 // the View and ties its lifetime to it.
30 // 33 //
31 // We set ourselves as a property of the view passed in, and we are owned by 34 // We set ourselves as a property of the view passed in, and we are owned by
32 // said View. 35 // said View.
33 class ViewTarget : public ui::EventTarget { 36 class ViewTarget : public ui::EventTarget {
34 public: 37 public:
35 ~ViewTarget() override; 38 ~ViewTarget() override;
36 39
37 // Returns the ViewTarget for a View. ViewTargets are owned by the |view| 40 // Returns the ViewTarget for a View. ViewTargets are owned by the |view|
38 // passed in, and are created on demand. 41 // passed in, and are created on demand.
39 static ViewTarget* TargetFromView(View* view); 42 static ViewTarget* TargetFromView(mojo::View* view);
40 43
41 // Converts |point| from |source|'s coordinates to |target|'s. If |source| is 44 // Converts |point| from |source|'s coordinates to |target|'s. If |source| is
42 // NULL, the function returns without modifying |point|. |target| cannot be 45 // NULL, the function returns without modifying |point|. |target| cannot be
43 // NULL. 46 // NULL.
44 static void ConvertPointToTarget(const ViewTarget* source, 47 static void ConvertPointToTarget(const ViewTarget* source,
45 const ViewTarget* target, 48 const ViewTarget* target,
46 gfx::Point* point); 49 gfx::Point* point);
47 50
48 View* view() { return view_; } 51 mojo::View* view() { return view_; }
49 52
50 // TODO(erg): Make this const once we've removed aura from the tree and it's 53 // 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 54 // feasible to change all callers of the EventTargeter interface to pass and
52 // accept const objects. (When that gets done, re-const the 55 // accept const objects. (When that gets done, re-const the
53 // EventTargetIterator::GetNextTarget and EventTarget::GetChildIterator 56 // EventTargetIterator::GetNextTarget and EventTarget::GetChildIterator
54 // interfaces.) 57 // interfaces.)
55 std::vector<ViewTarget*> GetChildren(); 58 std::vector<ViewTarget*> GetChildren();
56 59
57 const ViewTarget* GetParent() const; 60 const ViewTarget* GetParent() const;
58 gfx::Rect GetBounds() const; 61 gfx::Rect GetBounds() const;
59 bool HasParent() const; 62 bool HasParent() const;
60 bool IsVisible() const; 63 bool IsVisible() const;
61 64
62 const ViewTarget* GetRoot() const; 65 const ViewTarget* GetRoot() const;
63 66
64 // Sets a new ViewTargeter for the view, and returns the previous 67 // Sets a new ViewTargeter for the view, and returns the previous
65 // ViewTargeter. 68 // ViewTargeter.
66 scoped_ptr<ViewTargeter> SetEventTargeter(scoped_ptr<ViewTargeter> targeter); 69 scoped_ptr<ViewTargeter> SetEventTargeter(scoped_ptr<ViewTargeter> targeter);
67 70
68 // Overridden from ui::EventTarget: 71 // Overridden from ui::EventTarget:
69 bool CanAcceptEvent(const ui::Event& event) override; 72 bool CanAcceptEvent(const ui::Event& event) override;
70 EventTarget* GetParentTarget() override; 73 EventTarget* GetParentTarget() override;
71 scoped_ptr<ui::EventTargetIterator> GetChildIterator() override; 74 scoped_ptr<ui::EventTargetIterator> GetChildIterator() override;
72 ui::EventTargeter* GetEventTargeter() override; 75 ui::EventTargeter* GetEventTargeter() override;
73 void ConvertEventToTarget(ui::EventTarget* target, 76 void ConvertEventToTarget(ui::EventTarget* target,
74 ui::LocatedEvent* event) override; 77 ui::LocatedEvent* event) override;
75 78
76 private: 79 private:
77 friend class TestView; 80 friend class TestView;
78 explicit ViewTarget(View* view_to_wrap); 81 explicit ViewTarget(mojo::View* view_to_wrap);
79 82
80 bool ConvertPointForAncestor(const ViewTarget* ancestor, 83 bool ConvertPointForAncestor(const ViewTarget* ancestor,
81 gfx::Point* point) const; 84 gfx::Point* point) const;
82 bool ConvertPointFromAncestor(const ViewTarget* ancestor, 85 bool ConvertPointFromAncestor(const ViewTarget* ancestor,
83 gfx::Point* point) const; 86 gfx::Point* point) const;
84 bool GetTargetOffsetRelativeTo(const ViewTarget* ancestor, 87 bool GetTargetOffsetRelativeTo(const ViewTarget* ancestor,
85 gfx::Vector2d* offset) const; 88 gfx::Vector2d* offset) const;
86 89
87 // The mojo::View that we dispatch to. 90 // The mojo::View that we dispatch to.
88 View* view_; 91 mojo::View* view_;
89 92
90 scoped_ptr<ViewTargeter> targeter_; 93 scoped_ptr<ViewTargeter> targeter_;
91 94
92 DISALLOW_COPY_AND_ASSIGN(ViewTarget); 95 DISALLOW_COPY_AND_ASSIGN(ViewTarget);
93 }; 96 };
94 97
95 } // namespace mojo 98 } // namespace window_manager
96 99
97 #endif // SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_ 100 #endif // SERVICES_WINDOW_MANAGER_VIEW_TARGET_H_
OLDNEW
« no previous file with comments | « services/window_manager/view_event_dispatcher.cc ('k') | services/window_manager/view_target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698