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

Side by Side Diff: ash/launcher/launcher_view.cc

Issue 9808026: Layout panels on top of their launcher icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback Created 8 years, 8 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 #include "ash/launcher/launcher_view.h" 5 #include "ash/launcher/launcher_view.h"
6 6
7 #include "ash/launcher/launcher_button.h" 7 #include "ash/launcher/launcher_button.h"
8 #include "ash/launcher/launcher_delegate.h" 8 #include "ash/launcher/launcher_delegate.h"
9 #include "ash/launcher/launcher_icon_observer.h"
9 #include "ash/launcher/launcher_model.h" 10 #include "ash/launcher/launcher_model.h"
10 #include "ash/launcher/tabbed_launcher_button.h" 11 #include "ash/launcher/tabbed_launcher_button.h"
11 #include "ash/launcher/view_model.h" 12 #include "ash/launcher/view_model.h"
12 #include "ash/launcher/view_model_utils.h" 13 #include "ash/launcher/view_model_utils.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/shell_delegate.h" 15 #include "ash/shell_delegate.h"
15 #include "base/auto_reset.h" 16 #include "base/auto_reset.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
18 #include "grit/ui_resources.h" 19 #include "grit/ui_resources.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 launcher_menu_runner_->IsRunning()); 285 launcher_menu_runner_->IsRunning());
285 #endif 286 #endif
286 return false; 287 return false;
287 } 288 }
288 289
289 void LauncherView::LayoutToIdealBounds() { 290 void LauncherView::LayoutToIdealBounds() {
290 IdealBounds ideal_bounds; 291 IdealBounds ideal_bounds;
291 CalculateIdealBounds(&ideal_bounds); 292 CalculateIdealBounds(&ideal_bounds);
292 ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_); 293 ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_);
293 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); 294 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
295 FOR_EACH_OBSERVER(LauncherIconObserver, observers_,
296 OnLauncherIconPositionsChanged());
294 } 297 }
295 298
296 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { 299 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) {
297 int available_width = width(); 300 int available_width = width();
298 if (!available_width) 301 if (!available_width)
299 return; 302 return;
300 303
301 int x = kLeadingInset; 304 int x = kLeadingInset;
302 for (int i = 0; i < view_model_->view_size(); ++i) { 305 for (int i = 0; i < view_model_->view_size(); ++i) {
303 gfx::Size pref(kButtonWidth, kButtonHeight); 306 gfx::Size pref(kButtonWidth, kButtonHeight);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 344 }
342 } 345 }
343 346
344 int LauncherView::DetermineLastVisibleIndex(int max_x) { 347 int LauncherView::DetermineLastVisibleIndex(int max_x) {
345 int index = view_model_->view_size() - 1; 348 int index = view_model_->view_size() - 1;
346 while (index >= 0 && view_model_->ideal_bounds(index).right() > max_x) 349 while (index >= 0 && view_model_->ideal_bounds(index).right() > max_x)
347 index--; 350 index--;
348 return index; 351 return index;
349 } 352 }
350 353
354 void LauncherView::AddIconObserver(LauncherIconObserver* observer) {
355 observers_.AddObserver(observer);
356 }
357
358 void LauncherView::RemoveIconObserver(LauncherIconObserver* observer) {
359 observers_.RemoveObserver(observer);
360 }
361
351 void LauncherView::AnimateToIdealBounds() { 362 void LauncherView::AnimateToIdealBounds() {
352 IdealBounds ideal_bounds; 363 IdealBounds ideal_bounds;
353 CalculateIdealBounds(&ideal_bounds); 364 CalculateIdealBounds(&ideal_bounds);
354 for (int i = 0; i < view_model_->view_size(); ++i) { 365 for (int i = 0; i < view_model_->view_size(); ++i) {
355 bounds_animator_->AnimateViewTo(view_model_->view_at(i), 366 bounds_animator_->AnimateViewTo(view_model_->view_at(i),
356 view_model_->ideal_bounds(i)); 367 view_model_->ideal_bounds(i));
357 } 368 }
358 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); 369 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
370 FOR_EACH_OBSERVER(LauncherIconObserver, observers_,
371 OnLauncherIconPositionsChanged());
359 } 372 }
360 373
361 views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { 374 views::View* LauncherView::CreateViewForItem(const LauncherItem& item) {
362 views::View* view = NULL; 375 views::View* view = NULL;
363 switch (item.type) { 376 switch (item.type) {
364 case TYPE_TABBED: { 377 case TYPE_TABBED: {
365 TabbedLauncherButton* button = 378 TabbedLauncherButton* button =
366 TabbedLauncherButton::Create( 379 TabbedLauncherButton::Create(
367 this, 380 this,
368 this, 381 this,
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), 839 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
827 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) 840 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED)
828 return; 841 return;
829 842
830 Shell::GetInstance()->UpdateShelfVisibility(); 843 Shell::GetInstance()->UpdateShelfVisibility();
831 #endif 844 #endif
832 } 845 }
833 846
834 } // namespace internal 847 } // namespace internal
835 } // namespace ash 848 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698