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

Side by Side Diff: ash/wm/workspace/snap_sizer.h

Issue 23431009: Windows docking should get triggered by pressing against the screen edge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows docking should get triggered by pressing against the screen edge (warn) Created 7 years, 3 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 ASH_WM_WORKSPACE_SNAP_SIZER_H_ 5 #ifndef ASH_WM_WORKSPACE_SNAP_SIZER_H_
6 #define ASH_WM_WORKSPACE_SNAP_SIZER_H_ 6 #define ASH_WM_WORKSPACE_SNAP_SIZER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 14
15 namespace aura { 15 namespace aura {
16 class Window; 16 class Window;
17 } 17 }
18 18
19 namespace ash { 19 namespace ash {
20 namespace internal { 20 namespace internal {
21 21
22 class DockedWindowLayoutManager;
23
22 // SnapSizer is responsible for determining the resulting bounds of a window 24 // SnapSizer is responsible for determining the resulting bounds of a window
23 // that is being snapped to the left or right side of the screen. 25 // that is being snapped to the left or right side of the screen.
24 // The bounds used in this class are in the container's coordinates. 26 // The bounds used in this class are in the container's coordinates.
25 class ASH_EXPORT SnapSizer { 27 class ASH_EXPORT SnapSizer {
26 public: 28 public:
27 enum Edge { 29 enum Edge {
28 LEFT_EDGE, 30 LEFT_EDGE,
29 RIGHT_EDGE 31 RIGHT_EDGE
30 }; 32 };
31 33
32 enum InputType { 34 enum InputType {
33 TOUCH_MAXIMIZE_BUTTON_INPUT, 35 TOUCH_MAXIMIZE_BUTTON_INPUT,
36 WORKSPACE_DRAG_INPUT,
34 OTHER_INPUT 37 OTHER_INPUT
35 }; 38 };
36 39
37 // Set |input_type| to |TOUCH_MAXIMIZE_BUTTON_INPUT| when called by a touch 40 // Set |input_type| to |TOUCH_MAXIMIZE_BUTTON_INPUT| when called by a touch
38 // operation by the maximize button. This will allow the user to snap resize 41 // operation by the maximize button. This will allow the user to snap resize
39 // the window beginning close to the border. 42 // the window beginning close to the border.
40 SnapSizer(aura::Window* window, 43 SnapSizer(aura::Window* window,
41 const gfx::Point& start, 44 const gfx::Point& start,
42 Edge edge, 45 Edge edge,
43 InputType input_type); 46 InputType input_type);
(...skipping 12 matching lines...) Expand all
56 // then it returns the next snap-bounds). 59 // then it returns the next snap-bounds).
57 gfx::Rect GetSnapBounds(const gfx::Rect& bounds); 60 gfx::Rect GetSnapBounds(const gfx::Rect& bounds);
58 61
59 // Set the snap sizer to the button press default size and prevent resizing. 62 // Set the snap sizer to the button press default size and prevent resizing.
60 void SelectDefaultSizeAndDisableResize(); 63 void SelectDefaultSizeAndDisableResize();
61 64
62 // Returns the target bounds based on the edge and the provided |size_index|. 65 // Returns the target bounds based on the edge and the provided |size_index|.
63 // For unit test purposes this function is not private. 66 // For unit test purposes this function is not private.
64 gfx::Rect GetTargetBoundsForSize(size_t size_index) const; 67 gfx::Rect GetTargetBoundsForSize(size_t size_index) const;
65 68
69 // Returns true when snapping sequence is at its last (docking) step.
sky 2013/09/11 19:38:40 Why do we need snapsizer to know about docked wind
varkha 2013/09/11 20:02:10 We moved to the model where docking is the last st
varkha 2013/09/12 19:49:23 Done.
70 bool ShouldDockWindow() const;
71
72 // Returns true when a window can be docked. Windows cannot be docked at the
73 // edge used by the launcher shelf or the edge opposite from existing dock.
74 static bool CanDockWindow(aura::Window* window, SnapSizer::Edge edge);
75
66 private: 76 private:
67 // Calculates the amount to increment by. This returns one of -1, 0 or 1 and 77 // Calculates the amount to increment by. This returns one of -1, 0 or 1 and
68 // is intended to by applied to |size_index_|. |x| is the current 78 // is intended to by applied to |size_index_|. |x| is the current
69 // x-coordinate, and |reference_x| is used to determine whether to increase 79 // x-coordinate, and |reference_x| is used to determine whether to increase
70 // or decrease the position. It's one of |last_adjust_x_| or |last_update_x_|. 80 // or decrease the position. It's one of |last_adjust_x_| or |last_update_x_|.
71 int CalculateIncrement(int x, int reference_x) const; 81 int CalculateIncrement(int x, int reference_x) const;
72 82
73 // Changes the bounds. |x| is the current x-coordinate and |delta| the amount 83 // Changes the bounds. |x| is the current x-coordinate and |delta| the amount
74 // to increase by. |delta| comes from CalculateIncrement() and is applied 84 // to increase by. |delta| comes from CalculateIncrement() and is applied
75 // to |size_index_|. 85 // to |size_index_|.
76 void ChangeBounds(int x, int delta); 86 void ChangeBounds(int x, int delta);
77 87
78 // Returns the target bounds based on the edge and |size_index_|. 88 // Returns the target bounds based on the edge and |size_index_|.
79 gfx::Rect GetTargetBounds() const; 89 gfx::Rect GetTargetBounds() const;
80 90
81 // Returns true if the specified point is along the edge of the screen. 91 // Returns true if the specified point is along the edge of the screen.
82 bool AlongEdge(int x) const; 92 bool AlongEdge(int x) const;
83 93
94 // Dock when a window is at its last step in snapping sequence, undock
95 // otherwise.
96 void UpdateDockedState();
97
84 // Window being snapped. 98 // Window being snapped.
85 aura::Window* window_; 99 aura::Window* window_;
86 100
87 const Edge edge_; 101 const Edge edge_;
88 102
89 // Current target bounds for the snap. 103 // Current target bounds for the snap.
90 gfx::Rect target_bounds_; 104 gfx::Rect target_bounds_;
91 105
92 // Time Update() was last invoked. 106 // Time Update() was last invoked.
93 base::TimeTicks time_last_update_; 107 base::TimeTicks time_last_update_;
(...skipping 17 matching lines...) Expand all
111 125
112 // Initial x-coordinate. 126 // Initial x-coordinate.
113 const int start_x_; 127 const int start_x_;
114 128
115 // |TOUCH_MAXIMIZE_BUTTON_INPUT| if the snap sizer was created through a 129 // |TOUCH_MAXIMIZE_BUTTON_INPUT| if the snap sizer was created through a
116 // touch & drag operation of the maximizer button. It changes the behavior of 130 // touch & drag operation of the maximizer button. It changes the behavior of
117 // the drag / resize behavior when the dragging starts close to the border. 131 // the drag / resize behavior when the dragging starts close to the border.
118 const InputType input_type_; 132 const InputType input_type_;
119 133
120 // A list of usable window widths for size. This gets created when the 134 // A list of usable window widths for size. This gets created when the
121 // sizer gets created. 135 // sizer gets created. Possible last 0 entry indicates that computing bounds
122 const std::vector<int> usable_width_; 136 // needs to be delegated to DockedWindowLayoutManager.
137 std::vector<int> usable_width_;
138
139 // Dock container window layout manager.
140 DockedWindowLayoutManager* dock_layout_;
123 141
124 DISALLOW_COPY_AND_ASSIGN(SnapSizer); 142 DISALLOW_COPY_AND_ASSIGN(SnapSizer);
125 }; 143 };
126 144
127 } // namespace internal 145 } // namespace internal
128 } // namespace ash 146 } // namespace ash
129 147
130 #endif // ASH_WM_WORKSPACE_SNAP_SIZER_H_ 148 #endif // ASH_WM_WORKSPACE_SNAP_SIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698