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 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { | 520 bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { |
521 // TODO(msw): Push this app list state into ShelfItem::shows_tooltip. | 521 // TODO(msw): Push this app list state into ShelfItem::shows_tooltip. |
522 if (view == GetAppListButton() && GetAppListButton()->is_showing_app_list()) | 522 if (view == GetAppListButton() && GetAppListButton()->is_showing_app_list()) |
523 return false; | 523 return false; |
524 const ShelfItem* item = ShelfItemForView(view); | 524 const ShelfItem* item = ShelfItemForView(view); |
525 return item && item->shows_tooltip; | 525 return item && item->shows_tooltip; |
526 } | 526 } |
527 | 527 |
528 base::string16 ShelfView::GetTitleForView(const views::View* view) const { | 528 base::string16 ShelfView::GetTitleForView(const views::View* view) const { |
529 const ShelfItem* item = ShelfItemForView(view); | 529 const ShelfItem* item = ShelfItemForView(view); |
530 if (!item || !model_->GetShelfItemDelegate(item->id)) | 530 return item ? item->title : base::string16(); |
531 return base::string16(); | |
532 return model_->GetShelfItemDelegate(item->id)->GetTitle(); | |
533 } | 531 } |
534 | 532 |
535 gfx::Rect ShelfView::GetVisibleItemsBoundsInScreen() { | 533 gfx::Rect ShelfView::GetVisibleItemsBoundsInScreen() { |
536 gfx::Size preferred_size = GetPreferredSize(); | 534 gfx::Size preferred_size = GetPreferredSize(); |
537 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); | 535 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); |
538 ConvertPointToScreen(this, &origin); | 536 ConvertPointToScreen(this, &origin); |
539 return gfx::Rect(origin, preferred_size); | 537 return gfx::Rect(origin, preferred_size); |
540 } | 538 } |
541 | 539 |
542 void ShelfView::ButtonPressed(views::Button* sender, | 540 void ShelfView::ButtonPressed(views::Button* sender, |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 | 1878 |
1881 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1879 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1882 const gfx::Rect bounds = GetBoundsInScreen(); | 1880 const gfx::Rect bounds = GetBoundsInScreen(); |
1883 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1881 int distance = wm_shelf_->SelectValueForShelfAlignment( |
1884 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1882 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1885 bounds.x() - coordinate.x()); | 1883 bounds.x() - coordinate.x()); |
1886 return distance > 0 ? distance : 0; | 1884 return distance > 0 ? distance : 0; |
1887 } | 1885 } |
1888 | 1886 |
1889 } // namespace ash | 1887 } // namespace ash |
OLD | NEW |