| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 gfx::Rect LauncherView::GetIdealBoundsOfItemIcon(LauncherID id) { | 465 gfx::Rect LauncherView::GetIdealBoundsOfItemIcon(LauncherID id) { |
| 466 int index = model_->ItemIndexByID(id); | 466 int index = model_->ItemIndexByID(id); |
| 467 if (index == -1 || (index > last_visible_index_ && | 467 if (index == -1 || (index > last_visible_index_ && |
| 468 index < model_->FirstPanelIndex())) | 468 index < model_->FirstPanelIndex())) |
| 469 return gfx::Rect(); | 469 return gfx::Rect(); |
| 470 const gfx::Rect& ideal_bounds(view_model_->ideal_bounds(index)); | 470 const gfx::Rect& ideal_bounds(view_model_->ideal_bounds(index)); |
| 471 DCHECK_NE(TYPE_APP_LIST, model_->items()[index].type); | 471 DCHECK_NE(TYPE_APP_LIST, model_->items()[index].type); |
| 472 LauncherButton* button = | 472 LauncherButton* button = |
| 473 static_cast<LauncherButton*>(view_model_->view_at(index)); | 473 static_cast<LauncherButton*>(view_model_->view_at(index)); |
| 474 gfx::Rect icon_bounds = button->GetIconBounds(); | 474 gfx::Rect icon_bounds = button->GetIconBounds(); |
| 475 return gfx::Rect(ideal_bounds.x() + icon_bounds.x(), | 475 return gfx::Rect(GetMirroredXWithWidthInView( |
| 476 ideal_bounds.x() + icon_bounds.x(), icon_bounds.width()), |
| 476 ideal_bounds.y() + icon_bounds.y(), | 477 ideal_bounds.y() + icon_bounds.y(), |
| 477 icon_bounds.width(), | 478 icon_bounds.width(), |
| 478 icon_bounds.height()); | 479 icon_bounds.height()); |
| 479 } | 480 } |
| 480 | 481 |
| 481 void LauncherView::UpdatePanelIconPosition(LauncherID id, | 482 void LauncherView::UpdatePanelIconPosition(LauncherID id, |
| 482 const gfx::Point& midpoint) { | 483 const gfx::Point& midpoint) { |
| 483 int current_index = model_->ItemIndexByID(id); | 484 int current_index = model_->ItemIndexByID(id); |
| 484 int first_panel_index = model_->FirstPanelIndex(); | 485 int first_panel_index = model_->FirstPanelIndex(); |
| 485 if (current_index < first_panel_index) | 486 if (current_index < first_panel_index) |
| 486 return; | 487 return; |
| 487 | 488 |
| 489 gfx::Point midpoint_in_view(GetMirroredXInView(midpoint.x()), |
| 490 midpoint.y()); |
| 488 ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager(); | 491 ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager(); |
| 489 int target_index = current_index; | 492 int target_index = current_index; |
| 490 while (target_index > first_panel_index && | 493 while (target_index > first_panel_index && |
| 491 shelf->PrimaryAxisValue(view_model_->ideal_bounds(target_index).x(), | 494 shelf->PrimaryAxisValue(view_model_->ideal_bounds(target_index).x(), |
| 492 view_model_->ideal_bounds(target_index).y()) > | 495 view_model_->ideal_bounds(target_index).y()) > |
| 493 shelf->PrimaryAxisValue(midpoint.x(), midpoint.y())) { | 496 shelf->PrimaryAxisValue(midpoint_in_view.x(), midpoint_in_view.y())) { |
| 494 --target_index; | 497 --target_index; |
| 495 } | 498 } |
| 496 while (target_index < view_model_->view_size() - 1 && | 499 while (target_index < view_model_->view_size() - 1 && |
| 497 shelf->PrimaryAxisValue( | 500 shelf->PrimaryAxisValue( |
| 498 view_model_->ideal_bounds(target_index).right(), | 501 view_model_->ideal_bounds(target_index).right(), |
| 499 view_model_->ideal_bounds(target_index).bottom()) < | 502 view_model_->ideal_bounds(target_index).bottom()) < |
| 500 shelf->PrimaryAxisValue(midpoint.x(), midpoint.y())) { | 503 shelf->PrimaryAxisValue(midpoint_in_view.x(), midpoint_in_view.y())) { |
| 501 ++target_index; | 504 ++target_index; |
| 502 } | 505 } |
| 503 if (current_index != target_index) | 506 if (current_index != target_index) |
| 504 model_->Move(current_index, target_index); | 507 model_->Move(current_index, target_index); |
| 505 } | 508 } |
| 506 | 509 |
| 507 bool LauncherView::IsShowingMenu() const { | 510 bool LauncherView::IsShowingMenu() const { |
| 508 #if !defined(OS_MACOSX) | 511 #if !defined(OS_MACOSX) |
| 509 return (launcher_menu_runner_.get() && | 512 return (launcher_menu_runner_.get() && |
| 510 launcher_menu_runner_->IsRunning()); | 513 launcher_menu_runner_->IsRunning()); |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 bool LauncherView::ShouldShowTooltipForView(const views::View* view) const { | 1646 bool LauncherView::ShouldShowTooltipForView(const views::View* view) const { |
| 1644 if (view == GetAppListButtonView() && | 1647 if (view == GetAppListButtonView() && |
| 1645 Shell::GetInstance()->GetAppListWindow()) | 1648 Shell::GetInstance()->GetAppListWindow()) |
| 1646 return false; | 1649 return false; |
| 1647 const LauncherItem* item = LauncherItemForView(view); | 1650 const LauncherItem* item = LauncherItemForView(view); |
| 1648 return (!item || delegate_->ShouldShowTooltip(*item)); | 1651 return (!item || delegate_->ShouldShowTooltip(*item)); |
| 1649 } | 1652 } |
| 1650 | 1653 |
| 1651 } // namespace internal | 1654 } // namespace internal |
| 1652 } // namespace ash | 1655 } // namespace ash |
| OLD | NEW |