OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MASH_WM_FRAME_MOVE_LOOP_H_ | 5 #ifndef MASH_WM_FRAME_MOVE_LOOP_H_ |
6 #define MASH_WM_FRAME_MOVE_LOOP_H_ | 6 #define MASH_WM_FRAME_MOVE_LOOP_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "components/mus/public/cpp/window_observer.h" | 12 #include "components/mus/public/cpp/window_observer.h" |
13 #include "components/mus/public/interfaces/input_events.mojom.h" | 13 #include "components/mus/public/interfaces/input_events.mojom.h" |
14 #include "ui/gfx/geometry/point.h" | 14 #include "ui/gfx/geometry/point.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 | 16 |
| 17 namespace ui { |
| 18 class PointerEvent; |
| 19 } |
| 20 |
17 namespace mash { | 21 namespace mash { |
18 namespace wm { | 22 namespace wm { |
19 | 23 |
20 // MoveLoop is responsible for moving/resizing windows. | 24 // MoveLoop is responsible for moving/resizing windows. |
21 class MoveLoop : public mus::WindowObserver { | 25 class MoveLoop : public mus::WindowObserver { |
22 public: | 26 public: |
23 enum MoveResult { | 27 enum MoveResult { |
24 // The move is still ongoing. | 28 // The move is still ongoing. |
25 CONTINUE, | 29 CONTINUE, |
26 | 30 |
(...skipping 14 matching lines...) Expand all Loading... |
41 }; | 45 }; |
42 | 46 |
43 ~MoveLoop() override; | 47 ~MoveLoop() override; |
44 | 48 |
45 // If a move/resize loop should occur for the specified parameters creates | 49 // If a move/resize loop should occur for the specified parameters creates |
46 // and returns a new MoveLoop. All events should be funneled to the MoveLoop | 50 // and returns a new MoveLoop. All events should be funneled to the MoveLoop |
47 // until done (Move()). |ht_location| is one of the constants defined by | 51 // until done (Move()). |ht_location| is one of the constants defined by |
48 // HitTestCompat. | 52 // HitTestCompat. |
49 static scoped_ptr<MoveLoop> Create(mus::Window* target, | 53 static scoped_ptr<MoveLoop> Create(mus::Window* target, |
50 int ht_location, | 54 int ht_location, |
51 const mus::mojom::Event& event); | 55 const ui::PointerEvent& event); |
52 | 56 |
53 // Processes an event for a move/resize loop. | 57 // Processes an event for a move/resize loop. |
54 MoveResult Move(const mus::mojom::Event& event); | 58 MoveResult Move(const ui::PointerEvent& event); |
55 | 59 |
56 // If possible reverts any changes made during the move loop. | 60 // If possible reverts any changes made during the move loop. |
57 void Revert(); | 61 void Revert(); |
58 | 62 |
59 private: | 63 private: |
60 enum class Type { | 64 enum class Type { |
61 MOVE, | 65 MOVE, |
62 RESIZE, | 66 RESIZE, |
63 }; | 67 }; |
64 | 68 |
65 MoveLoop(mus::Window* target, | 69 MoveLoop(mus::Window* target, |
66 const mus::mojom::Event& event, | 70 const ui::PointerEvent& event, |
67 Type type, | 71 Type type, |
68 HorizontalLocation h_loc, | 72 HorizontalLocation h_loc, |
69 VerticalLocation v_loc); | 73 VerticalLocation v_loc); |
70 | 74 |
71 // Determines the type of move from the specified HitTestCompat value. | 75 // Determines the type of move from the specified HitTestCompat value. |
72 // Returns true if a move/resize should occur. | 76 // Returns true if a move/resize should occur. |
73 static bool DetermineType(int ht_location, | 77 static bool DetermineType(int ht_location, |
74 Type* type, | 78 Type* type, |
75 HorizontalLocation* h_loc, | 79 HorizontalLocation* h_loc, |
76 VerticalLocation* v_loc); | 80 VerticalLocation* v_loc); |
77 | 81 |
78 // Does the actual move/resize. | 82 // Does the actual move/resize. |
79 void MoveImpl(const mus::mojom::Event& event); | 83 void MoveImpl(const ui::PointerEvent& event); |
80 | 84 |
81 // Cancels the loop. This sets |target_| to null and removes the observer. | 85 // Cancels the loop. This sets |target_| to null and removes the observer. |
82 // After this the MoveLoop is still ongoing and won't stop until the | 86 // After this the MoveLoop is still ongoing and won't stop until the |
83 // appropriate event is received. | 87 // appropriate event is received. |
84 void Cancel(); | 88 void Cancel(); |
85 | 89 |
86 gfx::Rect DetermineBoundsFromDelta(const gfx::Vector2d& delta); | 90 gfx::Rect DetermineBoundsFromDelta(const gfx::Vector2d& delta); |
87 | 91 |
88 // mus::WindowObserver: | 92 // mus::WindowObserver: |
89 void OnTreeChanged(const TreeChangeParams& params) override; | 93 void OnTreeChanged(const TreeChangeParams& params) override; |
(...skipping 25 matching lines...) Expand all Loading... |
115 // canceled if the bounds change unexpectedly during the move. | 119 // canceled if the bounds change unexpectedly during the move. |
116 bool changing_bounds_; | 120 bool changing_bounds_; |
117 | 121 |
118 DISALLOW_COPY_AND_ASSIGN(MoveLoop); | 122 DISALLOW_COPY_AND_ASSIGN(MoveLoop); |
119 }; | 123 }; |
120 | 124 |
121 } // namespace wm | 125 } // namespace wm |
122 } // namespace mash | 126 } // namespace mash |
123 | 127 |
124 #endif // MASH_WM_FRAME_MOVE_LOOP_H_ | 128 #endif // MASH_WM_FRAME_MOVE_LOOP_H_ |
OLD | NEW |