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

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: Pre-patch with tests 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/shell.h" 12 #include "ash/shell.h"
12 #include "ash/shell_delegate.h" 13 #include "ash/shell_delegate.h"
13 #include "base/auto_reset.h" 14 #include "base/auto_reset.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
15 #include "grit/ash_strings.h" 16 #include "grit/ash_strings.h"
16 #include "grit/ui_resources.h" 17 #include "grit/ui_resources.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/base/animation/animation.h" 19 #include "ui/base/animation/animation.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 341
341 View* LauncherView::GetFocusTraversableParentView() { 342 View* LauncherView::GetFocusTraversableParentView() {
342 return this; 343 return this;
343 } 344 }
344 345
345 void LauncherView::LayoutToIdealBounds() { 346 void LauncherView::LayoutToIdealBounds() {
346 IdealBounds ideal_bounds; 347 IdealBounds ideal_bounds;
347 CalculateIdealBounds(&ideal_bounds); 348 CalculateIdealBounds(&ideal_bounds);
348 views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_); 349 views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_);
349 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); 350 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
351 FOR_EACH_OBSERVER(LauncherIconObserver, observers_,
352 OnLauncherIconPositionsChanged());
350 } 353 }
351 354
352 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { 355 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) {
353 int available_width = width(); 356 int available_width = width();
354 if (!available_width) 357 if (!available_width)
355 return; 358 return;
356 359
357 int x = kLeadingInset; 360 int x = kLeadingInset;
358 for (int i = 0; i < view_model_->view_size(); ++i) { 361 for (int i = 0; i < view_model_->view_size(); ++i) {
359 gfx::Size pref(kButtonWidth, kButtonHeight); 362 gfx::Size pref(kButtonWidth, kButtonHeight);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 400 }
398 } 401 }
399 402
400 int LauncherView::DetermineLastVisibleIndex(int max_x) { 403 int LauncherView::DetermineLastVisibleIndex(int max_x) {
401 int index = view_model_->view_size() - 1; 404 int index = view_model_->view_size() - 1;
402 while (index >= 0 && view_model_->ideal_bounds(index).right() > max_x) 405 while (index >= 0 && view_model_->ideal_bounds(index).right() > max_x)
403 index--; 406 index--;
404 return index; 407 return index;
405 } 408 }
406 409
410 void LauncherView::AddIconObserver(LauncherIconObserver* observer) {
411 observers_.AddObserver(observer);
412 }
413
414 void LauncherView::RemoveIconObserver(LauncherIconObserver* observer) {
415 observers_.RemoveObserver(observer);
416 }
417
407 void LauncherView::AnimateToIdealBounds() { 418 void LauncherView::AnimateToIdealBounds() {
408 IdealBounds ideal_bounds; 419 IdealBounds ideal_bounds;
409 CalculateIdealBounds(&ideal_bounds); 420 CalculateIdealBounds(&ideal_bounds);
410 for (int i = 0; i < view_model_->view_size(); ++i) { 421 for (int i = 0; i < view_model_->view_size(); ++i) {
411 bounds_animator_->AnimateViewTo(view_model_->view_at(i), 422 bounds_animator_->AnimateViewTo(view_model_->view_at(i),
412 view_model_->ideal_bounds(i)); 423 view_model_->ideal_bounds(i));
413 } 424 }
414 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); 425 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
426 FOR_EACH_OBSERVER(LauncherIconObserver, observers_,
427 OnLauncherIconPositionsChanged());
415 } 428 }
416 429
417 views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { 430 views::View* LauncherView::CreateViewForItem(const LauncherItem& item) {
418 views::View* view = NULL; 431 views::View* view = NULL;
419 switch (item.type) { 432 switch (item.type) {
420 case TYPE_TABBED: { 433 case TYPE_TABBED: {
421 TabbedLauncherButton* button = 434 TabbedLauncherButton* button =
422 TabbedLauncherButton::Create( 435 TabbedLauncherButton::Create(
423 this, 436 this,
424 this, 437 this,
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), 901 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
889 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) 902 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED)
890 return; 903 return;
891 904
892 Shell::GetInstance()->UpdateShelfVisibility(); 905 Shell::GetInstance()->UpdateShelfVisibility();
893 #endif 906 #endif
894 } 907 }
895 908
896 } // namespace internal 909 } // namespace internal
897 } // namespace ash 910 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698