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

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

Issue 14574009: Use correctly mirrored points for ideal bounds of launcher item icons. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add RTL icon reordering test. Created 7 years, 7 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/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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 gfx::Rect LauncherView::GetIdealBoundsOfItemIcon(LauncherID id) { 432 gfx::Rect LauncherView::GetIdealBoundsOfItemIcon(LauncherID id) {
433 int index = model_->ItemIndexByID(id); 433 int index = model_->ItemIndexByID(id);
434 if (index == -1 || (index > last_visible_index_ && 434 if (index == -1 || (index > last_visible_index_ &&
435 index < model_->FirstPanelIndex())) 435 index < model_->FirstPanelIndex()))
436 return gfx::Rect(); 436 return gfx::Rect();
437 const gfx::Rect& ideal_bounds(view_model_->ideal_bounds(index)); 437 const gfx::Rect& ideal_bounds(view_model_->ideal_bounds(index));
438 DCHECK_NE(TYPE_APP_LIST, model_->items()[index].type); 438 DCHECK_NE(TYPE_APP_LIST, model_->items()[index].type);
439 LauncherButton* button = 439 LauncherButton* button =
440 static_cast<LauncherButton*>(view_model_->view_at(index)); 440 static_cast<LauncherButton*>(view_model_->view_at(index));
441 gfx::Rect icon_bounds = button->GetIconBounds(); 441 gfx::Rect icon_bounds = button->GetIconBounds();
442 return gfx::Rect(ideal_bounds.x() + icon_bounds.x(), 442 return gfx::Rect(GetMirroredXWithWidthInView(ideal_bounds.x(),
443 ideal_bounds.y() + icon_bounds.y(), 443 icon_bounds.width()),
444 ideal_bounds.y(),
444 icon_bounds.width(), 445 icon_bounds.width(),
445 icon_bounds.height()); 446 icon_bounds.height());
446 } 447 }
447 448
448 void LauncherView::UpdatePanelIconPosition(LauncherID id, 449 void LauncherView::UpdatePanelIconPosition(LauncherID id,
449 const gfx::Point& midpoint) { 450 const gfx::Point& midpoint) {
450 int current_index = model_->ItemIndexByID(id); 451 int current_index = model_->ItemIndexByID(id);
451 int first_panel_index = model_->FirstPanelIndex(); 452 int first_panel_index = model_->FirstPanelIndex();
452 if (current_index < first_panel_index) 453 if (current_index < first_panel_index)
453 return; 454 return;
454 455
456 gfx::Point midpoint_in_view(GetMirroredXInView(midpoint.x()),
457 midpoint.y());
455 ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager(); 458 ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
456 int target_index = current_index; 459 int target_index = current_index;
457 while (target_index > first_panel_index && 460 while (target_index > first_panel_index &&
458 shelf->PrimaryAxisValue(view_model_->ideal_bounds(target_index).x(), 461 shelf->PrimaryAxisValue(view_model_->ideal_bounds(target_index).x(),
459 view_model_->ideal_bounds(target_index).y()) > 462 view_model_->ideal_bounds(target_index).y()) >
460 shelf->PrimaryAxisValue(midpoint.x(), midpoint.y())) { 463 shelf->PrimaryAxisValue(midpoint_in_view.x(), midpoint_in_view.y())) {
461 --target_index; 464 --target_index;
462 } 465 }
463 while (target_index < view_model_->view_size() - 1 && 466 while (target_index < view_model_->view_size() - 1 &&
464 shelf->PrimaryAxisValue( 467 shelf->PrimaryAxisValue(
465 view_model_->ideal_bounds(target_index).right(), 468 view_model_->ideal_bounds(target_index).right(),
466 view_model_->ideal_bounds(target_index).bottom()) < 469 view_model_->ideal_bounds(target_index).bottom()) <
467 shelf->PrimaryAxisValue(midpoint.x(), midpoint.y())) { 470 shelf->PrimaryAxisValue(midpoint_in_view.x(), midpoint_in_view.y())) {
468 ++target_index; 471 ++target_index;
469 } 472 }
470 if (current_index != target_index) 473 if (current_index != target_index)
471 model_->Move(current_index, target_index); 474 model_->Move(current_index, target_index);
472 } 475 }
473 476
474 bool LauncherView::IsShowingMenu() const { 477 bool LauncherView::IsShowingMenu() const {
475 #if !defined(OS_MACOSX) 478 #if !defined(OS_MACOSX)
476 return (launcher_menu_runner_.get() && 479 return (launcher_menu_runner_.get() &&
477 launcher_menu_runner_->IsRunning()); 480 launcher_menu_runner_->IsRunning());
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 bool LauncherView::ShouldShowTooltipForView(const views::View* view) const { 1498 bool LauncherView::ShouldShowTooltipForView(const views::View* view) const {
1496 if (view == GetAppListButtonView() && 1499 if (view == GetAppListButtonView() &&
1497 Shell::GetInstance()->GetAppListWindow()) 1500 Shell::GetInstance()->GetAppListWindow())
1498 return false; 1501 return false;
1499 const LauncherItem* item = LauncherItemForView(view); 1502 const LauncherItem* item = LauncherItemForView(view);
1500 return (!item || delegate_->ShouldShowTooltip(*item)); 1503 return (!item || delegate_->ShouldShowTooltip(*item));
1501 } 1504 }
1502 1505
1503 } // namespace internal 1506 } // namespace internal
1504 } // namespace ash 1507 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/launcher/launcher_view_unittest.cc » ('j') | ash/wm/panels/panel_layout_manager_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698