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_PANELS_PANEL_WINDOW_RESIZER_H_
6 #define ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_
8 #include "ash/wm/window_resizer.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
19 // PanelWindowResizer is used by ToplevelWindowEventFilter to handle dragging,
20 // moving or resizing panel window. These can be attached and detached from the
22 class ASH_EXPORT PanelWindowResizer
: public WindowResizer
{
24 ~PanelWindowResizer() override
;
26 // Creates a new PanelWindowResizer. The caller takes ownership of the
27 // returned object. The ownership of |next_window_resizer| is taken by the
28 // returned object. Returns NULL if not resizable.
29 static PanelWindowResizer
* Create(WindowResizer
* next_window_resizer
,
30 wm::WindowState
* window_state
);
33 void Drag(const gfx::Point
& location
, int event_flags
) override
;
34 void CompleteDrag() override
;
35 void RevertDrag() override
;
38 // Creates PanelWindowResizer that adds the ability to attach / detach panel
39 // windows as well as reparenting them to the panel layer while dragging to
40 // |next_window_resizer|. This object takes ownership of
41 // |next_window_resizer|.
42 PanelWindowResizer(WindowResizer
* next_window_resizer
,
43 wm::WindowState
* window_state
);
45 // Checks if the provided window bounds should attach to the launcher. If true
46 // the offset gives the necessary adjustment to snap to the launcher.
47 bool AttachToLauncher(const gfx::Rect
& bounds
, gfx::Point
* offset
);
49 // Tracks the panel's initial position and attachment at the start of a drag
50 // and informs the PanelLayoutManager that a drag has started if necessary.
51 void StartedDragging();
53 // Informs the PanelLayoutManager that the drag is complete if it was informed
55 void FinishDragging();
57 // Updates the dragged panel's index in the launcher.
58 void UpdateLauncherPosition();
60 // Last pointer location in screen coordinates.
61 gfx::Point last_location_
;
63 // Wraps a window resizer and adds panel detaching / reattaching and snapping
64 // to launcher behavior during drags.
65 scoped_ptr
<WindowResizer
> next_window_resizer_
;
67 // Panel container window.
68 aura::Window
* panel_container_
;
69 aura::Window
* initial_panel_container_
;
71 // Set to true once Drag() is invoked and the bounds of the window change.
72 bool did_move_or_resize_
;
74 // True if the window started attached to the launcher.
75 const bool was_attached_
;
77 base::WeakPtrFactory
<PanelWindowResizer
> weak_ptr_factory_
;
79 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer
);
84 #endif // ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_