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/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_icons_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 Loading... | |
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); |
294 } | 295 } |
sky
2012/04/03 20:39:37
I think you want to notify here too.
Dmitry Lomov (no reviews)
2012/04/03 20:50:07
Will do.
| |
295 | 296 |
296 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { | 297 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { |
297 int available_width = width(); | 298 int available_width = width(); |
298 if (!available_width) | 299 if (!available_width) |
299 return; | 300 return; |
300 | 301 |
301 int x = kLeadingInset; | 302 int x = kLeadingInset; |
302 for (int i = 0; i < view_model_->view_size(); ++i) { | 303 for (int i = 0; i < view_model_->view_size(); ++i) { |
303 gfx::Size pref(kButtonWidth, kButtonHeight); | 304 gfx::Size pref(kButtonWidth, kButtonHeight); |
304 view_model_->set_ideal_bounds(i, gfx::Rect( | 305 view_model_->set_ideal_bounds(i, gfx::Rect( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 } | 342 } |
342 } | 343 } |
343 | 344 |
344 int LauncherView::DetermineLastVisibleIndex(int max_x) { | 345 int LauncherView::DetermineLastVisibleIndex(int max_x) { |
345 int index = view_model_->view_size() - 1; | 346 int index = view_model_->view_size() - 1; |
346 while (index >= 0 && view_model_->ideal_bounds(index).right() > max_x) | 347 while (index >= 0 && view_model_->ideal_bounds(index).right() > max_x) |
347 index--; | 348 index--; |
348 return index; | 349 return index; |
349 } | 350 } |
350 | 351 |
352 void LauncherView::AddIconsObserver(LauncherIconsObserver* observer) { | |
353 observers_.AddObserver(observer); | |
354 } | |
355 | |
356 void LauncherView::RemoveIconsObserver(LauncherIconsObserver* observer) { | |
357 observers_.RemoveObserver(observer); | |
358 } | |
359 | |
351 void LauncherView::AnimateToIdealBounds() { | 360 void LauncherView::AnimateToIdealBounds() { |
352 IdealBounds ideal_bounds; | 361 IdealBounds ideal_bounds; |
353 CalculateIdealBounds(&ideal_bounds); | 362 CalculateIdealBounds(&ideal_bounds); |
354 for (int i = 0; i < view_model_->view_size(); ++i) { | 363 for (int i = 0; i < view_model_->view_size(); ++i) { |
355 bounds_animator_->AnimateViewTo(view_model_->view_at(i), | 364 bounds_animator_->AnimateViewTo(view_model_->view_at(i), |
356 view_model_->ideal_bounds(i)); | 365 view_model_->ideal_bounds(i)); |
357 } | 366 } |
358 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); | 367 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); |
368 FOR_EACH_OBSERVER(LauncherIconsObserver, observers_, | |
369 OnLauncherIconPositionsChanged()); | |
359 } | 370 } |
360 | 371 |
361 views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { | 372 views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { |
362 views::View* view = NULL; | 373 views::View* view = NULL; |
363 switch (item.type) { | 374 switch (item.type) { |
364 case TYPE_TABBED: { | 375 case TYPE_TABBED: { |
365 TabbedLauncherButton* button = | 376 TabbedLauncherButton* button = |
366 TabbedLauncherButton::Create( | 377 TabbedLauncherButton::Create( |
367 this, | 378 this, |
368 this, | 379 this, |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 837 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
827 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) | 838 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) |
828 return; | 839 return; |
829 | 840 |
830 Shell::GetInstance()->UpdateShelfVisibility(); | 841 Shell::GetInstance()->UpdateShelfVisibility(); |
831 #endif | 842 #endif |
832 } | 843 } |
833 | 844 |
834 } // namespace internal | 845 } // namespace internal |
835 } // namespace ash | 846 } // namespace ash |
OLD | NEW |