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/common/shelf/shelf_view.h" | 5 #include "ash/common/shelf/shelf_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 gfx::Rect tooltip_bounds; | 520 gfx::Rect tooltip_bounds; |
521 for (int i = 0; i < child_count(); ++i) { | 521 for (int i = 0; i < child_count(); ++i) { |
522 const views::View* child = child_at(i); | 522 const views::View* child = child_at(i); |
523 if (child != overflow_button_ && ShouldShowTooltipForView(child)) | 523 if (child != overflow_button_ && ShouldShowTooltipForView(child)) |
524 tooltip_bounds.Union(child->GetMirroredBounds()); | 524 tooltip_bounds.Union(child->GetMirroredBounds()); |
525 } | 525 } |
526 return !tooltip_bounds.Contains(cursor_location); | 526 return !tooltip_bounds.Contains(cursor_location); |
527 } | 527 } |
528 | 528 |
529 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { | 529 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { |
530 if (view == GetAppListButton() && | 530 // TODO(msw): Push this app list state into ShelfItem::shows_tooltip. |
531 WmShell::Get()->GetAppListTargetVisibility()) { | 531 if (view == GetAppListButton() && GetAppListButton()->is_showing_app_list()) |
532 return false; | 532 return false; |
533 } | |
534 const ShelfItem* item = ShelfItemForView(view); | 533 const ShelfItem* item = ShelfItemForView(view); |
535 if (!item) | 534 return item && item->shows_tooltip; |
536 return false; | |
537 return model_->GetShelfItemDelegate(item->id)->ShouldShowTooltip(); | |
538 } | 535 } |
539 | 536 |
540 base::string16 ShelfView::GetTitleForView(const views::View* view) const { | 537 base::string16 ShelfView::GetTitleForView(const views::View* view) const { |
541 const ShelfItem* item = ShelfItemForView(view); | 538 const ShelfItem* item = ShelfItemForView(view); |
542 if (!item || !model_->GetShelfItemDelegate(item->id)) | 539 if (!item || !model_->GetShelfItemDelegate(item->id)) |
543 return base::string16(); | 540 return base::string16(); |
544 return model_->GetShelfItemDelegate(item->id)->GetTitle(); | 541 return model_->GetShelfItemDelegate(item->id)->GetTitle(); |
545 } | 542 } |
546 | 543 |
547 gfx::Rect ShelfView::GetVisibleItemsBoundsInScreen() { | 544 gfx::Rect ShelfView::GetVisibleItemsBoundsInScreen() { |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 | 1910 |
1914 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1911 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1915 const gfx::Rect bounds = GetBoundsInScreen(); | 1912 const gfx::Rect bounds = GetBoundsInScreen(); |
1916 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1913 int distance = wm_shelf_->SelectValueForShelfAlignment( |
1917 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1914 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1918 bounds.x() - coordinate.x()); | 1915 bounds.x() - coordinate.x()); |
1919 return distance > 0 ? distance : 0; | 1916 return distance > 0 ? distance : 0; |
1920 } | 1917 } |
1921 | 1918 |
1922 } // namespace ash | 1919 } // namespace ash |
OLD | NEW |