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

Side by Side Diff: ash/wm/window_resizer.h

Issue 15008002: Make touch-resizing windows to screen edge possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move border immediately under the finger + change snapping distance back to 16 Created 7 years, 6 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 | Annotate | Revision Log
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_WINDOW_RESIZER_H_ 5 #ifndef ASH_WM_WINDOW_RESIZER_H_
6 #define ASH_WM_WINDOW_RESIZER_H_ 6 #define ASH_WM_WINDOW_RESIZER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "ui/aura/client/window_move_client.h"
11 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
12 13
13 namespace aura { 14 namespace aura {
14 class Window; 15 class Window;
15 } 16 }
16 17
17 namespace ash { 18 namespace ash {
18 19
19 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving 20 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving
20 // or resizing a window. All coordinates passed to this are in the parent 21 // or resizing a window. All coordinates passed to this are in the parent
(...skipping 28 matching lines...) Expand all
49 virtual void RevertDrag() = 0; 50 virtual void RevertDrag() = 0;
50 51
51 // Returns the target window the resizer was created for. 52 // Returns the target window the resizer was created for.
52 virtual aura::Window* GetTarget() = 0; 53 virtual aura::Window* GetTarget() = 0;
53 54
54 protected: 55 protected:
55 struct Details { 56 struct Details {
56 Details(); 57 Details();
57 Details(aura::Window* window, 58 Details(aura::Window* window,
58 const gfx::Point& location, 59 const gfx::Point& location,
59 int window_component); 60 int window_component,
61 aura::client::WindowMoveSource source);
60 ~Details(); 62 ~Details();
61 63
62 // The window we're resizing. 64 // The window we're resizing.
63 aura::Window* window; 65 aura::Window* window;
64 66
65 // Initial bounds of the window in parent coordinates. 67 // Initial bounds of the window in parent coordinates.
66 gfx::Rect initial_bounds_in_parent; 68 gfx::Rect initial_bounds_in_parent;
67 69
68 // Restore bounds (in screen coordinates) of the window before the drag 70 // Restore bounds (in screen coordinates) of the window before the drag
69 // started. Only set if the window is normal and is being dragged. 71 // started. Only set if the window is normal and is being dragged.
(...skipping 12 matching lines...) Expand all
82 int bounds_change; 84 int bounds_change;
83 85
84 // Bitmask of the |kBoundsChangeDirection_| constants. 86 // Bitmask of the |kBoundsChangeDirection_| constants.
85 int position_change_direction; 87 int position_change_direction;
86 88
87 // Bitmask of the |kBoundsChangeDirection_| constants. 89 // Bitmask of the |kBoundsChangeDirection_| constants.
88 int size_change_direction; 90 int size_change_direction;
89 91
90 // Will the drag actually modify the window? 92 // Will the drag actually modify the window?
91 bool is_resizable; 93 bool is_resizable;
94
95 // Source of the event initiating the drag.
96 aura::client::WindowMoveSource source;
92 }; 97 };
93 98
94 static gfx::Rect CalculateBoundsForDrag(const Details& details, 99 static gfx::Rect CalculateBoundsForDrag(const Details& details,
95 const gfx::Point& location); 100 const gfx::Point& location);
96 101
97 static gfx::Rect AdjustBoundsToGrid(const gfx::Rect& bounds, 102 static gfx::Rect AdjustBoundsToGrid(const gfx::Rect& bounds,
98 int grid_size); 103 int grid_size);
99 104
105 // In case of touch resizing, adjusts deltas so that the border is positioned
106 // just under the touch point.
107 static void AdjustDeltaForTouchResize(const Details& details, int* delta_x,
sky 2013/06/14 15:57:27 nit: when you wrap put each param on its own line.
sky 2013/06/14 15:57:27 Can this be private?
sky 2013/06/14 15:57:27 Can this be private?
mohsen 2013/06/14 16:21:48 Yes. It should be. Done.
mohsen 2013/06/14 16:21:48 Done. I thought that only if no parameter fits in
108 int* delta_y);
109
100 static bool IsBottomEdge(int component); 110 static bool IsBottomEdge(int component);
101 111
102 private: 112 private:
103 // Returns the new origin of the window. The arguments are the difference 113 // Returns the new origin of the window. The arguments are the difference
104 // between the current location and the initial location. 114 // between the current location and the initial location.
105 static gfx::Point GetOriginForDrag(const Details& details, 115 static gfx::Point GetOriginForDrag(const Details& details,
106 int delta_x, 116 int delta_x,
107 int delta_y); 117 int delta_y);
108 118
109 // Returns the size of the window for the drag. 119 // Returns the size of the window for the drag.
(...skipping 10 matching lines...) Expand all
120 static int GetHeightForDrag(const Details& details, 130 static int GetHeightForDrag(const Details& details,
121 int min_height, 131 int min_height,
122 int* delta_y); 132 int* delta_y);
123 }; 133 };
124 134
125 // Creates a WindowResizer for |window|. This can return a scoped_ptr 135 // Creates a WindowResizer for |window|. This can return a scoped_ptr
126 // initialized with NULL if |window| should not be resized nor dragged. 136 // initialized with NULL if |window| should not be resized nor dragged.
127 ASH_EXPORT scoped_ptr<WindowResizer> CreateWindowResizer( 137 ASH_EXPORT scoped_ptr<WindowResizer> CreateWindowResizer(
128 aura::Window* window, 138 aura::Window* window,
129 const gfx::Point& point_in_parent, 139 const gfx::Point& point_in_parent,
130 int window_component); 140 int window_component,
141 aura::client::WindowMoveSource source);
131 142
132 } // namespace aura 143 } // namespace aura
133 144
134 #endif // ASH_WM_WINDOW_RESIZER_H_ 145 #endif // ASH_WM_WINDOW_RESIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698