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

Side by Side Diff: ash/wm/panels/panel_window_resizer.h

Issue 12441010: Attach panel while dragging to bring it in front of other panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments, etc. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ 5 #ifndef ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_
6 #define ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ 6 #define ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_
7 7
8 #include "ash/wm/window_resizer.h" 8 #include "ash/wm/window_resizer.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 class Rect; 12 class Rect;
13 } 13 }
14 14
15 namespace ash { 15 namespace ash {
16 16
17 class WindowResizerOwner;
18
17 namespace internal { 19 namespace internal {
18 class PanelLayoutManager; 20 class PanelLayoutManager;
19 } 21 }
20 22
21 // PanelWindowResizer is used by ToplevelWindowEventFilter to handle dragging, 23 // PanelWindowResizer is used by ToplevelWindowEventFilter to handle dragging,
22 // moving or resizing panel window. These can be attached and detached from the 24 // moving or resizing panel window. These can be attached and detached from the
23 // launcher. 25 // launcher.
24 class ASH_EXPORT PanelWindowResizer : public WindowResizer { 26 class ASH_EXPORT PanelWindowResizer : public WindowResizer {
25 public: 27 public:
26 virtual ~PanelWindowResizer(); 28 virtual ~PanelWindowResizer();
27 29
28 // Creates a new PanelWindowResizer. The caller takes ownership of the 30 // Creates a new PanelWindowResizer. The caller takes ownership of the
29 // returned object. Returns NULL if not resizable. 31 // returned object. Returns NULL if not resizable.
30 static PanelWindowResizer* Create(aura::Window* window, 32 static PanelWindowResizer* Create(WindowResizerOwner* owner,
33 aura::Window* window,
31 const gfx::Point& location, 34 const gfx::Point& location,
32 int window_component); 35 int window_component);
33 36
34 // Returns true if the drag will result in changing the window in anyway. 37 // Returns true if the drag will result in changing the window in anyway.
35 bool is_resizable() const { return details_.is_resizable; } 38 bool is_resizable() const { return details_.is_resizable; }
36 39
37 bool changed_size() const { 40 bool changed_size() const {
38 return !(details_.bounds_change & kBoundsChange_Repositions); 41 return !(details_.bounds_change & kBoundsChange_Repositions);
39 } 42 }
40 43
41 // WindowResizer overides: 44 // WindowResizer overides:
42 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE; 45 virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE;
43 virtual void CompleteDrag(int event_flags) OVERRIDE; 46 virtual void CompleteDrag(int event_flags) OVERRIDE;
44 virtual void RevertDrag() OVERRIDE; 47 virtual void RevertDrag() OVERRIDE;
45 virtual aura::Window* GetTarget() OVERRIDE; 48 virtual aura::Window* GetTarget() OVERRIDE;
46 49
47 const gfx::Point& GetInitialLocationInParentForTest() const { 50 const gfx::Point& GetInitialLocationInParentForTest() const {
48 return details_.initial_location_in_parent; 51 return details_.initial_location_in_parent;
49 } 52 }
50 53
51 private: 54 private:
52 explicit PanelWindowResizer(const Details& details); 55 explicit PanelWindowResizer(WindowResizerOwner* owner,
56 const Details& details);
53 57
54 // Checks if the provided window bounds should attach to the launcher. If true 58 // Checks if the provided window bounds should attach to the launcher. If true
55 // the bounds are modified to snap the window to the launcher. 59 // the bounds are modified to snap the window to the launcher.
56 bool AttachToLauncher(gfx::Rect* bounds); 60 bool AttachToLauncher(gfx::Rect* bounds);
57 61
58 // Tracks the panel's initial position and attachment at the start of a drag 62 // Tracks the panel's initial position and attachment at the start of a drag
59 // and informs the PanelLayoutManager that a drag has started if necessary. 63 // and informs the PanelLayoutManager that a drag has started if necessary.
60 void StartedDragging(); 64 void StartedDragging();
61 65
62 // Informs the PanelLayoutManager that the drag is complete if it was informed 66 // Informs the PanelLayoutManager that the drag is complete if it was informed
63 // of the drag start. 67 // of the drag start.
64 void FinishDragging(); 68 void FinishDragging();
65 69
70 // The owner of this resizer.
71 WindowResizerOwner* owner_;
72
66 const Details details_; 73 const Details details_;
67 74
68 // Panel container window. 75 // Panel container window.
69 aura::Window* panel_container_; 76 aura::Window* panel_container_;
70 77
71 // Weak pointer, owned by panel container. 78 // Weak pointer, owned by panel container.
72 internal::PanelLayoutManager* panel_layout_manager_; 79 internal::PanelLayoutManager* panel_layout_manager_;
73 80
74 // Set to true once Drag() is invoked and the bounds of the window change. 81 // Set to true once Drag() is invoked and the bounds of the window change.
75 bool did_move_or_resize_; 82 bool did_move_or_resize_;
76 83
77 // True if the window started attached to the launcher. 84 // True if the window started attached to the launcher.
78 const bool was_attached_; 85 const bool was_attached_;
79 86
80 // True if the window should attach to the launcher after releasing. 87 // True if the window should attach to the launcher after releasing.
81 bool should_attach_; 88 bool should_attach_;
82 89
83 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer); 90 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer);
84 }; 91 };
85 92
86 } // namespace aura 93 } // namespace aura
87 94
88 #endif // ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_ 95 #endif // ASH_WM_PANELS_PANEL_WINDOW_RESIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698