OLD | NEW |
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 #include "ash/wm/panels/panel_window_resizer.h" | 5 #include "ash/wm/panels/panel_window_resizer.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
10 #include "ash/shelf/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/base/hit_test.h" | 25 #include "ui/base/hit_test.h" |
26 #include "ui/base/ui_base_types.h" | 26 #include "ui/base/ui_base_types.h" |
27 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
29 | 29 |
30 namespace ash { | 30 namespace ash { |
31 | 31 |
32 namespace { | 32 namespace { |
33 const int kPanelSnapToLauncherDistance = 30; | 33 const int kPanelSnapToLauncherDistance = 30; |
34 | 34 |
35 internal::PanelLayoutManager* GetPanelLayoutManager( | 35 PanelLayoutManager* GetPanelLayoutManager(aura::Window* panel_container) { |
36 aura::Window* panel_container) { | 36 DCHECK(panel_container->id() == kShellWindowId_PanelContainer); |
37 DCHECK(panel_container->id() == internal::kShellWindowId_PanelContainer); | 37 return static_cast<PanelLayoutManager*>(panel_container->layout_manager()); |
38 return static_cast<internal::PanelLayoutManager*>( | |
39 panel_container->layout_manager()); | |
40 } | 38 } |
41 | 39 |
42 } // namespace | 40 } // namespace |
43 | 41 |
44 PanelWindowResizer::~PanelWindowResizer() { | 42 PanelWindowResizer::~PanelWindowResizer() { |
45 } | 43 } |
46 | 44 |
47 // static | 45 // static |
48 PanelWindowResizer* | 46 PanelWindowResizer* |
49 PanelWindowResizer::Create(WindowResizer* next_window_resizer, | 47 PanelWindowResizer::Create(WindowResizer* next_window_resizer, |
(...skipping 17 matching lines...) Expand all Loading... |
67 screen->GetDisplayNearestWindow(panel_container_->GetRootWindow()).id()) { | 65 screen->GetDisplayNearestWindow(panel_container_->GetRootWindow()).id()) { |
68 // The panel is being dragged to a new display. If the previous container is | 66 // The panel is being dragged to a new display. If the previous container is |
69 // the current parent of the panel it will be informed of the end of drag | 67 // the current parent of the panel it will be informed of the end of drag |
70 // when the panel is reparented, otherwise let the previous container know | 68 // when the panel is reparented, otherwise let the previous container know |
71 // the drag is complete. If we told the panel's parent that the drag was | 69 // the drag is complete. If we told the panel's parent that the drag was |
72 // complete it would begin positioning the panel. | 70 // complete it would begin positioning the panel. |
73 if (GetTarget()->parent() != panel_container_) | 71 if (GetTarget()->parent() != panel_container_) |
74 GetPanelLayoutManager(panel_container_)->FinishDragging(); | 72 GetPanelLayoutManager(panel_container_)->FinishDragging(); |
75 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> | 73 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> |
76 GetRootWindowForDisplayId(dst_display.id()); | 74 GetRootWindowForDisplayId(dst_display.id()); |
77 panel_container_ = Shell::GetContainer( | 75 panel_container_ = |
78 dst_root, internal::kShellWindowId_PanelContainer); | 76 Shell::GetContainer(dst_root, kShellWindowId_PanelContainer); |
79 | 77 |
80 // The panel's parent already knows that the drag is in progress for this | 78 // The panel's parent already knows that the drag is in progress for this |
81 // panel. | 79 // panel. |
82 if (panel_container_ && GetTarget()->parent() != panel_container_) | 80 if (panel_container_ && GetTarget()->parent() != panel_container_) |
83 GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget()); | 81 GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget()); |
84 } | 82 } |
85 gfx::Point offset; | 83 gfx::Point offset; |
86 gfx::Rect bounds(CalculateBoundsForDrag(location)); | 84 gfx::Rect bounds(CalculateBoundsForDrag(location)); |
87 if (!(details().bounds_change & WindowResizer::kBoundsChange_Resizes)) { | 85 if (!(details().bounds_change & WindowResizer::kBoundsChange_Resizes)) { |
88 window_state_->drag_details()->should_attach_to_shelf = | 86 window_state_->drag_details()->should_attach_to_shelf = |
(...skipping 28 matching lines...) Expand all Loading... |
117 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer, | 115 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer, |
118 wm::WindowState* window_state) | 116 wm::WindowState* window_state) |
119 : WindowResizer(window_state), | 117 : WindowResizer(window_state), |
120 next_window_resizer_(next_window_resizer), | 118 next_window_resizer_(next_window_resizer), |
121 panel_container_(NULL), | 119 panel_container_(NULL), |
122 initial_panel_container_(NULL), | 120 initial_panel_container_(NULL), |
123 did_move_or_resize_(false), | 121 did_move_or_resize_(false), |
124 was_attached_(window_state->panel_attached()), | 122 was_attached_(window_state->panel_attached()), |
125 weak_ptr_factory_(this) { | 123 weak_ptr_factory_(this) { |
126 DCHECK(details().is_resizable); | 124 DCHECK(details().is_resizable); |
127 panel_container_ = Shell::GetContainer( | 125 panel_container_ = Shell::GetContainer(GetTarget()->GetRootWindow(), |
128 GetTarget()->GetRootWindow(), | 126 kShellWindowId_PanelContainer); |
129 internal::kShellWindowId_PanelContainer); | |
130 initial_panel_container_ = panel_container_; | 127 initial_panel_container_ = panel_container_; |
131 } | 128 } |
132 | 129 |
133 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, | 130 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, |
134 gfx::Point* offset) { | 131 gfx::Point* offset) { |
135 bool should_attach = false; | 132 bool should_attach = false; |
136 if (panel_container_) { | 133 if (panel_container_) { |
137 internal::PanelLayoutManager* panel_layout_manager = | 134 PanelLayoutManager* panel_layout_manager = |
138 GetPanelLayoutManager(panel_container_); | 135 GetPanelLayoutManager(panel_container_); |
139 gfx::Rect launcher_bounds = ScreenUtil::ConvertRectFromScreen( | 136 gfx::Rect launcher_bounds = ScreenUtil::ConvertRectFromScreen( |
140 GetTarget()->parent(), | 137 GetTarget()->parent(), |
141 panel_layout_manager->shelf()-> | 138 panel_layout_manager->shelf()-> |
142 shelf_widget()->GetWindowBoundsInScreen()); | 139 shelf_widget()->GetWindowBoundsInScreen()); |
143 switch (panel_layout_manager->shelf()->alignment()) { | 140 switch (panel_layout_manager->shelf()->alignment()) { |
144 case SHELF_ALIGNMENT_BOTTOM: | 141 case SHELF_ALIGNMENT_BOTTOM: |
145 if (bounds.bottom() >= (launcher_bounds.y() - | 142 if (bounds.bottom() >= (launcher_bounds.y() - |
146 kPanelSnapToLauncherDistance)) { | 143 kPanelSnapToLauncherDistance)) { |
147 should_attach = true; | 144 should_attach = true; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 215 } |
219 | 216 |
220 void PanelWindowResizer::UpdateLauncherPosition() { | 217 void PanelWindowResizer::UpdateLauncherPosition() { |
221 if (panel_container_) { | 218 if (panel_container_) { |
222 GetPanelLayoutManager(panel_container_)->shelf()-> | 219 GetPanelLayoutManager(panel_container_)->shelf()-> |
223 UpdateIconPositionForWindow(GetTarget()); | 220 UpdateIconPositionForWindow(GetTarget()); |
224 } | 221 } |
225 } | 222 } |
226 | 223 |
227 } // namespace aura | 224 } // namespace aura |
OLD | NEW |