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