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

Side by Side Diff: ash/wm/panels/panel_layout_manager.cc

Issue 12313118: Refactor: Shelf Widget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: safer shutdown (status_area_widget_) 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
« no previous file with comments | « ash/wm/maximize_bubble_controller.cc ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ash/wm/panels/panel_layout_manager.h" 5 #include "ash/wm/panels/panel_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "ash/launcher/launcher.h" 10 #include "ash/launcher/launcher.h"
11 #include "ash/screen_ash.h" 11 #include "ash/screen_ash.h"
12 #include "ash/shelf_types.h" 12 #include "ash/shelf/shelf_types.h"
13 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/wm/frame_painter.h" 15 #include "ash/wm/frame_painter.h"
15 #include "ash/wm/property_util.h" 16 #include "ash/wm/property_util.h"
16 #include "ash/wm/window_animations.h" 17 #include "ash/wm/window_animations.h"
17 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
18 #include "base/auto_reset.h" 19 #include "base/auto_reset.h"
19 #include "base/bind.h" 20 #include "base/bind.h"
20 #include "base/bind_helpers.h" 21 #include "base/bind_helpers.h"
21 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
22 #include "third_party/skia/include/core/SkPaint.h" 23 #include "third_party/skia/include/core/SkPaint.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 last_active_panel_(NULL), 212 last_active_panel_(NULL),
212 weak_factory_(this) { 213 weak_factory_(this) {
213 DCHECK(panel_container); 214 DCHECK(panel_container);
214 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 215 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
215 AddObserver(this); 216 AddObserver(this);
216 Shell::GetInstance()->AddShellObserver(this); 217 Shell::GetInstance()->AddShellObserver(this);
217 } 218 }
218 219
219 PanelLayoutManager::~PanelLayoutManager() { 220 PanelLayoutManager::~PanelLayoutManager() {
220 Shutdown(); 221 Shutdown();
221 if (launcher_)
222 launcher_->RemoveIconObserver(this);
223 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 222 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
224 RemoveObserver(this); 223 RemoveObserver(this);
225 Shell::GetInstance()->RemoveShellObserver(this); 224 Shell::GetInstance()->RemoveShellObserver(this);
226 } 225 }
227 226
228 void PanelLayoutManager::Shutdown() { 227 void PanelLayoutManager::Shutdown() {
229 for (PanelList::iterator iter = panel_windows_.begin(); 228 for (PanelList::iterator iter = panel_windows_.begin();
230 iter != panel_windows_.end(); ++iter) { 229 iter != panel_windows_.end(); ++iter) {
231 delete iter->callout_widget; 230 delete iter->callout_widget;
232 } 231 }
233 panel_windows_.clear(); 232 panel_windows_.clear();
233 if (launcher_)
234 launcher_->RemoveIconObserver(this);
235 launcher_ = NULL;
234 } 236 }
235 237
236 void PanelLayoutManager::StartDragging(aura::Window* panel) { 238 void PanelLayoutManager::StartDragging(aura::Window* panel) {
237 DCHECK(!dragged_panel_); 239 DCHECK(!dragged_panel_);
238 DCHECK(panel->parent() == panel_container_); 240 DCHECK(panel->parent() == panel_container_);
239 dragged_panel_ = panel; 241 dragged_panel_ = panel;
240 Relayout(); 242 Relayout();
241 } 243 }
242 244
243 void PanelLayoutManager::FinishDragging() { 245 void PanelLayoutManager::FinishDragging() {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 wm::DeactivateWindow(panel); 409 wm::DeactivateWindow(panel);
408 Relayout(); 410 Relayout();
409 } 411 }
410 412
411 void PanelLayoutManager::RestorePanel(aura::Window* panel) { 413 void PanelLayoutManager::RestorePanel(aura::Window* panel) {
412 panel->Show(); 414 panel->Show();
413 Relayout(); 415 Relayout();
414 } 416 }
415 417
416 void PanelLayoutManager::Relayout() { 418 void PanelLayoutManager::Relayout() {
417 if (!launcher_ || !launcher_->widget()) 419 if (!launcher_ || !launcher_->shelf_widget())
418 return; 420 return;
419 421
420 if (in_layout_) 422 if (in_layout_)
421 return; 423 return;
422 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 424 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
423 425
424 ShelfAlignment alignment = launcher_->alignment(); 426 ShelfAlignment alignment = launcher_->shelf_widget()->GetAlignment();
425 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || 427 bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
426 alignment == SHELF_ALIGNMENT_BOTTOM; 428 alignment == SHELF_ALIGNMENT_BOTTOM;
427 gfx::Rect launcher_bounds = launcher_->widget()->GetWindowBoundsInScreen(); 429 gfx::Rect launcher_bounds = launcher_->shelf_widget()->
430 GetWindowBoundsInScreen();
428 int panel_start_bounds = kPanelIdealSpacing; 431 int panel_start_bounds = kPanelIdealSpacing;
429 int panel_end_bounds = horizontal ? 432 int panel_end_bounds = horizontal ?
430 panel_container_->bounds().width() - kPanelIdealSpacing : 433 panel_container_->bounds().width() - kPanelIdealSpacing :
431 panel_container_->bounds().height() - kPanelIdealSpacing; 434 panel_container_->bounds().height() - kPanelIdealSpacing;
432 aura::Window* active_panel = NULL; 435 aura::Window* active_panel = NULL;
433 std::vector<VisiblePanelPositionInfo> visible_panels; 436 std::vector<VisiblePanelPositionInfo> visible_panels;
434 for (PanelList::iterator iter = panel_windows_.begin(); 437 for (PanelList::iterator iter = panel_windows_.begin();
435 iter != panel_windows_.end(); ++iter) { 438 iter != panel_windows_.end(); ++iter) {
436 aura::Window* panel = iter->window; 439 aura::Window* panel = iter->window;
437 iter->callout_widget->SetAlignment(alignment); 440 iter->callout_widget->SetAlignment(alignment);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 620
618 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds); 621 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds);
619 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(), 622 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(),
620 panel); 623 panel);
621 callout_widget->Show(); 624 callout_widget->Show();
622 } 625 }
623 } 626 }
624 627
625 } // namespace internal 628 } // namespace internal
626 } // namespace ash 629 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_bubble_controller.cc ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698