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

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

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

Powered by Google App Engine
This is Rietveld 408576698