Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / ash / wm / window_resizer.h
blobc669886e9579cb1320632cd7747c9e36036c9849
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.
5 #ifndef ASH_WM_WINDOW_RESIZER_H_
6 #define ASH_WM_WINDOW_RESIZER_H_
8 #include "ash/ash_export.h"
9 #include "ash/wm/drag_details.h"
10 #include "ash/wm/window_state.h"
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/wm/public/window_move_client.h"
16 namespace aura {
17 class Window;
20 namespace ash {
22 // WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving
23 // or resizing a window. All coordinates passed to this are in the parent
24 // windows coordinates.
25 class ASH_EXPORT WindowResizer {
26 public:
27 // Constants to identify the type of resize.
28 static const int kBoundsChange_None;
29 static const int kBoundsChange_Repositions;
30 static const int kBoundsChange_Resizes;
32 // Used to indicate which direction the resize occurs in.
33 static const int kBoundsChangeDirection_None;
34 static const int kBoundsChangeDirection_Horizontal;
35 static const int kBoundsChangeDirection_Vertical;
37 WindowResizer(wm::WindowState* window_state);
38 virtual ~WindowResizer();
40 // Returns a bitmask of the kBoundsChange_ values.
41 static int GetBoundsChangeForWindowComponent(int component);
43 // Returns a bitmask of the kBoundsChange_ values.
44 static int GetPositionChangeDirectionForWindowComponent(int window_component);
46 // Invoked to drag/move/resize the window. |location| is in the coordinates
47 // of the window supplied to the constructor. |event_flags| is the event
48 // flags from the event.
49 virtual void Drag(const gfx::Point& location, int event_flags) = 0;
51 // Invoked to complete the drag.
52 virtual void CompleteDrag() = 0;
54 // Reverts the drag.
55 virtual void RevertDrag() = 0;
57 // Returns the target window the resizer was created for.
58 aura::Window* GetTarget() const {
59 return window_state_ ? window_state_->window() : NULL;
62 // See comment for |DragDetails::initial_location_in_parent|.
63 const gfx::Point& GetInitialLocation() const {
64 return window_state_->drag_details()->initial_location_in_parent;
67 // Drag parameters established when drag starts.
68 const DragDetails& details() const { return *window_state_->drag_details(); }
70 protected:
71 gfx::Rect CalculateBoundsForDrag(const gfx::Point& location);
73 static bool IsBottomEdge(int component);
75 // WindowState of the drag target.
76 wm::WindowState* window_state_;
78 private:
79 // In case of touch resizing, adjusts deltas so that the border is positioned
80 // just under the touch point.
81 void AdjustDeltaForTouchResize(int* delta_x, int* delta_y);
83 // Returns the new origin of the window. The arguments are the difference
84 // between the current location and the initial location.
85 gfx::Point GetOriginForDrag(int delta_x, int delta_y);
87 // Returns the size of the window for the drag.
88 gfx::Size GetSizeForDrag(int* delta_x, int* delta_y);
90 // Returns the width of the window.
91 int GetWidthForDrag(int min_width, int* delta_x);
93 // Returns the height of the drag.
94 int GetHeightForDrag(int min_height, int* delta_y);
96 DISALLOW_COPY_AND_ASSIGN(WindowResizer);
99 // Creates a WindowResizer for |window|. This can return a scoped_ptr
100 // initialized with NULL if |window| should not be resized nor dragged.
101 ASH_EXPORT scoped_ptr<WindowResizer> CreateWindowResizer(
102 aura::Window* window,
103 const gfx::Point& point_in_parent,
104 int window_component,
105 aura::client::WindowMoveSource source);
107 } // namespace ash
109 #endif // ASH_WM_WINDOW_RESIZER_H_