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

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

Issue 1921353002: Moves handful of files to ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shell_ids
Patch Set: merge to trunk Created 4 years, 7 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
« no previous file with comments | « ash/wm/window_properties.cc ('k') | ash/wm/window_resizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_WINDOW_RESIZER_H_
6 #define ASH_WM_WINDOW_RESIZER_H_
7
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "ash/wm/drag_details.h"
12 #include "ash/wm/window_state.h"
13 #include "base/macros.h"
14 #include "ui/wm/public/window_move_client.h"
15
16 namespace gfx {
17 class Rect;
18 }
19
20 namespace ash {
21 namespace wm {
22 class WmWindow;
23 }
24
25 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving
26 // or resizing a window. All coordinates passed to this are in the parent
27 // windows coordinates.
28 class ASH_EXPORT WindowResizer {
29 public:
30 // Constants to identify the type of resize.
31 static const int kBoundsChange_None;
32 static const int kBoundsChange_Repositions;
33 static const int kBoundsChange_Resizes;
34
35 // Used to indicate which direction the resize occurs in.
36 static const int kBoundsChangeDirection_None;
37 static const int kBoundsChangeDirection_Horizontal;
38 static const int kBoundsChangeDirection_Vertical;
39
40 explicit WindowResizer(wm::WindowState* window_state);
41 virtual ~WindowResizer();
42
43 // Returns a bitmask of the kBoundsChange_ values.
44 static int GetBoundsChangeForWindowComponent(int component);
45
46 // Returns a bitmask of the kBoundsChange_ values.
47 static int GetPositionChangeDirectionForWindowComponent(int window_component);
48
49 // Invoked to drag/move/resize the window. |location| is in the coordinates
50 // of the window supplied to the constructor. |event_flags| is the event
51 // flags from the event.
52 virtual void Drag(const gfx::Point& location, int event_flags) = 0;
53
54 // Invoked to complete the drag.
55 virtual void CompleteDrag() = 0;
56
57 // Reverts the drag.
58 virtual void RevertDrag() = 0;
59
60 // Returns the target window the resizer was created for.
61 wm::WmWindow* GetTarget() const {
62 return window_state_ ? window_state_->window() : nullptr;
63 }
64 // See comment for |DragDetails::initial_location_in_parent|.
65 const gfx::Point& GetInitialLocation() const {
66 return window_state_->drag_details()->initial_location_in_parent;
67 }
68
69 // Drag parameters established when drag starts.
70 const DragDetails& details() const { return *window_state_->drag_details(); }
71
72 protected:
73 gfx::Rect CalculateBoundsForDrag(const gfx::Point& location);
74
75 static bool IsBottomEdge(int component);
76
77 // WindowState of the drag target.
78 wm::WindowState* window_state_;
79
80 private:
81 // In case of touch resizing, adjusts deltas so that the border is positioned
82 // just under the touch point.
83 void AdjustDeltaForTouchResize(int* delta_x, int* delta_y);
84
85 // Returns the new origin of the window. The arguments are the difference
86 // between the current location and the initial location.
87 gfx::Point GetOriginForDrag(int delta_x, int delta_y);
88
89 // Returns the size of the window for the drag.
90 gfx::Size GetSizeForDrag(int* delta_x, int* delta_y);
91
92 // Returns the width of the window.
93 int GetWidthForDrag(int min_width, int* delta_x);
94
95 // Returns the height of the drag.
96 int GetHeightForDrag(int min_height, int* delta_y);
97
98 DISALLOW_COPY_AND_ASSIGN(WindowResizer);
99 };
100
101 // Creates a WindowResizer for |window|. Returns a unique_ptr with null if
102 // |window| should not be resized nor dragged.
103 ASH_EXPORT std::unique_ptr<WindowResizer> CreateWindowResizer(
104 wm::WmWindow* window,
105 const gfx::Point& point_in_parent,
106 int window_component,
107 aura::client::WindowMoveSource source);
108
109 } // namespace ash
110
111 #endif // ASH_WM_WINDOW_RESIZER_H_
OLDNEW
« no previous file with comments | « ash/wm/window_properties.cc ('k') | ash/wm/window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698