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 "ui/app_list/views/app_list_item_view.h" | 5 #include "ui/app_list/views/app_list_item_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
23 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
24 #include "ui/gfx/animation/throb_animation.h" | 24 #include "ui/gfx/animation/throb_animation.h" |
25 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
26 #include "ui/gfx/font_list.h" | 26 #include "ui/gfx/font_list.h" |
27 #include "ui/gfx/image/image_skia_operations.h" | 27 #include "ui/gfx/image/image_skia_operations.h" |
28 #include "ui/gfx/point.h" | 28 #include "ui/gfx/point.h" |
29 #include "ui/gfx/transform_util.h" | 29 #include "ui/gfx/transform_util.h" |
30 #include "ui/views/controls/image_view.h" | 30 #include "ui/views/controls/image_view.h" |
31 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
32 #include "ui/views/controls/menu/menu_item_view.h" | |
33 #include "ui/views/controls/menu/menu_runner.h" | 32 #include "ui/views/controls/menu/menu_runner.h" |
34 #include "ui/views/drag_controller.h" | 33 #include "ui/views/drag_controller.h" |
35 | 34 |
36 namespace app_list { | 35 namespace app_list { |
37 | 36 |
38 namespace { | 37 namespace { |
39 | 38 |
40 const int kTopPadding = 20; | 39 const int kTopPadding = 20; |
41 const int kIconTitleSpacing = 7; | 40 const int kIconTitleSpacing = 7; |
42 const int kProgressBarHorizontalPadding = 12; | 41 const int kProgressBarHorizontalPadding = 12; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 320 } |
322 | 321 |
323 void AppListItemView::ShowContextMenuForView(views::View* source, | 322 void AppListItemView::ShowContextMenuForView(views::View* source, |
324 const gfx::Point& point, | 323 const gfx::Point& point, |
325 ui::MenuSourceType source_type) { | 324 ui::MenuSourceType source_type) { |
326 ui::MenuModel* menu_model = item_->GetContextMenuModel(); | 325 ui::MenuModel* menu_model = item_->GetContextMenuModel(); |
327 if (!menu_model) | 326 if (!menu_model) |
328 return; | 327 return; |
329 | 328 |
330 context_menu_runner_.reset(new views::MenuRunner(menu_model)); | 329 context_menu_runner_.reset(new views::MenuRunner(menu_model)); |
331 if (context_menu_runner_->RunMenuAt( | 330 if (context_menu_runner_->RunMenuAt(GetWidget(), |
332 GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 331 NULL, |
333 views::MenuItemView::TOPLEFT, source_type, | 332 gfx::Rect(point, gfx::Size()), |
334 views::MenuRunner::HAS_MNEMONICS) == | 333 views::MENU_ANCHOR_TOPLEFT, |
335 views::MenuRunner::MENU_DELETED) | 334 source_type, |
| 335 views::MenuRunner::HAS_MNEMONICS) == |
| 336 views::MenuRunner::MENU_DELETED) { |
336 return; | 337 return; |
| 338 } |
337 } | 339 } |
338 | 340 |
339 void AppListItemView::StateChanged() { | 341 void AppListItemView::StateChanged() { |
340 const bool is_folder_ui_enabled = switches::IsFolderUIEnabled(); | 342 const bool is_folder_ui_enabled = switches::IsFolderUIEnabled(); |
341 if (is_folder_ui_enabled) | 343 if (is_folder_ui_enabled) |
342 apps_grid_view_->ClearAnySelectedView(); | 344 apps_grid_view_->ClearAnySelectedView(); |
343 | 345 |
344 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { | 346 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { |
345 if (!is_folder_ui_enabled) | 347 if (!is_folder_ui_enabled) |
346 apps_grid_view_->SetSelectedView(this); | 348 apps_grid_view_->SetSelectedView(this); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 const int left_right_padding = | 486 const int left_right_padding = |
485 title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); | 487 title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); |
486 rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); | 488 rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); |
487 | 489 |
488 gfx::Rect icon_bounds(rect.x(), rect.y(), rect.width(), icon_size_.height()); | 490 gfx::Rect icon_bounds(rect.x(), rect.y(), rect.width(), icon_size_.height()); |
489 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_)); | 491 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_)); |
490 return icon_bounds; | 492 return icon_bounds; |
491 } | 493 } |
492 | 494 |
493 } // namespace app_list | 495 } // namespace app_list |
OLD | NEW |