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

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

Issue 12313118: Refactor: Shelf Widget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
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/panel_layout_manager.h" 5 #include "ash/wm/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/shelf_widget.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
13 #include "ash/wm/frame_painter.h" 14 #include "ash/wm/frame_painter.h"
14 #include "ash/wm/property_util.h" 15 #include "ash/wm/property_util.h"
15 #include "ash/wm/window_animations.h" 16 #include "ash/wm/window_animations.h"
16 #include "ash/wm/window_util.h" 17 #include "ash/wm/window_util.h"
17 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
18 #include "base/bind.h" 19 #include "base/bind.h"
19 #include "base/bind_helpers.h" 20 #include "base/bind_helpers.h"
20 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
21 #include "third_party/skia/include/core/SkPaint.h" 22 #include "third_party/skia/include/core/SkPaint.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 //////////////////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////////////////
124 // PanelLayoutManager public implementation: 125 // PanelLayoutManager public implementation:
125 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) 126 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container)
126 : panel_container_(panel_container), 127 : panel_container_(panel_container),
127 in_layout_(false), 128 in_layout_(false),
128 dragged_panel_(NULL), 129 dragged_panel_(NULL),
129 launcher_(NULL), 130 launcher_(NULL),
130 last_active_panel_(NULL), 131 last_active_panel_(NULL),
131 weak_factory_(this) { 132 weak_factory_(this) {
132 DCHECK(panel_container); 133 DCHECK(panel_container);
133 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 134 aura::client::GetActivationClient(panel_container_->GetRootWindow())->
James Cook 2013/03/05 20:30:38 Is this part of the same patch? It looks OK but I'
Harry McCleave 2013/03/06 01:59:49 Done.
134 AddObserver(this); 135 AddObserver(this);
135 } 136 }
136 137
137 PanelLayoutManager::~PanelLayoutManager() { 138 PanelLayoutManager::~PanelLayoutManager() {
138 Shutdown(); 139 Shutdown();
139 if (launcher_)
140 launcher_->RemoveIconObserver(this);
141 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 140 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
142 RemoveObserver(this); 141 RemoveObserver(this);
143 } 142 }
144 143
145 void PanelLayoutManager::Shutdown() { 144 void PanelLayoutManager::Shutdown() {
146 for (PanelList::iterator iter = panel_windows_.begin(); 145 for (PanelList::iterator iter = panel_windows_.begin();
147 iter != panel_windows_.end(); ++iter) { 146 iter != panel_windows_.end(); ++iter) {
148 delete iter->callout_widget; 147 delete iter->callout_widget;
149 } 148 }
150 panel_windows_.clear(); 149 panel_windows_.clear();
150 if (launcher_)
151 launcher_->RemoveIconObserver(this);
152 launcher_ = NULL;
151 } 153 }
152 154
153 void PanelLayoutManager::StartDragging(aura::Window* panel) { 155 void PanelLayoutManager::StartDragging(aura::Window* panel) {
154 DCHECK(!dragged_panel_); 156 DCHECK(!dragged_panel_);
155 DCHECK(panel->parent() == panel_container_); 157 DCHECK(panel->parent() == panel_container_);
156 dragged_panel_ = panel; 158 dragged_panel_ = panel;
157 Relayout(); 159 Relayout();
158 } 160 }
159 161
160 void PanelLayoutManager::FinishDragging() { 162 void PanelLayoutManager::FinishDragging() {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 wm::DeactivateWindow(panel); 317 wm::DeactivateWindow(panel);
316 Relayout(); 318 Relayout();
317 } 319 }
318 320
319 void PanelLayoutManager::RestorePanel(aura::Window* panel) { 321 void PanelLayoutManager::RestorePanel(aura::Window* panel) {
320 panel->Show(); 322 panel->Show();
321 Relayout(); 323 Relayout();
322 } 324 }
323 325
324 void PanelLayoutManager::Relayout() { 326 void PanelLayoutManager::Relayout() {
325 if (!launcher_ || !launcher_->widget()) 327 if (!launcher_ || !launcher_->shelf_widget())
326 return; 328 return;
327 329
328 if (in_layout_) 330 if (in_layout_)
329 return; 331 return;
330 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 332 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
331 333
332 int launcher_top = launcher_->widget()->GetWindowBoundsInScreen().y(); 334 int launcher_top = launcher_->shelf_widget()->GetWindowBoundsInScreen().y();
333 int panel_left_bounds = kPanelIdealSpacing; 335 int panel_left_bounds = kPanelIdealSpacing;
334 int panel_right_bounds = 336 int panel_right_bounds =
335 panel_container_->bounds().width() - kPanelIdealSpacing; 337 panel_container_->bounds().width() - kPanelIdealSpacing;
336 aura::Window* active_panel = NULL; 338 aura::Window* active_panel = NULL;
337 std::vector<VisiblePanelPositionInfo> visible_panels; 339 std::vector<VisiblePanelPositionInfo> visible_panels;
338 for (PanelList::iterator iter = panel_windows_.begin(); 340 for (PanelList::iterator iter = panel_windows_.begin();
339 iter != panel_windows_.end(); ++iter) { 341 iter != panel_windows_.end(); ++iter) {
340 aura::Window* panel = iter->window; 342 aura::Window* panel = iter->window;
341 if (!panel->IsVisible() || panel == dragged_panel_) 343 if (!panel->IsVisible() || panel == dragged_panel_)
342 continue; 344 continue;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 DCHECK_EQ(callout_widget->GetNativeView()->GetRootWindow(), 498 DCHECK_EQ(callout_widget->GetNativeView()->GetRootWindow(),
497 panel_container_->GetRootWindow()); 499 panel_container_->GetRootWindow());
498 views::View* content_view = new views::View; 500 views::View* content_view = new views::View;
499 content_view->set_background(new CalloutWidgetBackground); 501 content_view->set_background(new CalloutWidgetBackground);
500 callout_widget->SetContentsView(content_view); 502 callout_widget->SetContentsView(content_view);
501 return callout_widget; 503 return callout_widget;
502 } 504 }
503 505
504 } // namespace internal 506 } // namespace internal
505 } // namespace ash 507 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698