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

Side by Side Diff: ui/app_list/views/app_list_item_view.cc

Issue 231883003: [stash] 20140404-crbug-312961-mac-views-bridge-C-wholegrid Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « ui/app_list/views/app_list_folder_view.cc ('k') | ui/app_list/views/apps_grid_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/app_list/app_list_constants.h" 11 #include "ui/app_list/app_list_constants.h"
12 #include "ui/app_list/app_list_item.h" 12 #include "ui/app_list/app_list_item.h"
13 #include "ui/app_list/app_list_switches.h" 13 #include "ui/app_list/app_list_switches.h"
14 #include "ui/app_list/views/apps_grid_view.h" 14 #include "ui/app_list/views/apps_grid_view.h"
15 #include "ui/app_list/views/cached_label.h" 15 #include "ui/app_list/views/cached_label.h"
16 #include "ui/app_list/views/progress_bar_view.h" 16 #include "ui/app_list/views/progress_bar_view.h"
17 #include "ui/base/dragdrop/drag_utils.h" 17 #include "ui/base/dragdrop/drag_utils.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/compositor/layer.h" 19 #include "ui/compositor/layer.h"
20 #include "ui/compositor/scoped_layer_animation_settings.h" 20 #include "ui/compositor/scoped_layer_animation_settings.h"
21 #include "ui/gfx/animation/throb_animation.h" 21 #include "ui/gfx/animation/throb_animation.h"
22 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/font_list.h" 23 #include "ui/gfx/font_list.h"
24 #include "ui/gfx/image/image_skia_operations.h" 24 #include "ui/gfx/image/image_skia_operations.h"
25 #include "ui/gfx/point.h" 25 #include "ui/gfx/point.h"
26 #include "ui/gfx/transform_util.h" 26 #include "ui/gfx/transform_util.h"
27 #include "ui/views/background.h"
27 #include "ui/views/controls/image_view.h" 28 #include "ui/views/controls/image_view.h"
28 #include "ui/views/controls/label.h" 29 #include "ui/views/controls/label.h"
29 #include "ui/views/controls/menu/menu_item_view.h" 30 #include "ui/views/controls/menu/menu_item_view.h"
30 #include "ui/views/controls/menu/menu_runner.h" 31 #include "ui/views/controls/menu/menu_runner.h"
31 #include "ui/views/drag_controller.h" 32 #include "ui/views/drag_controller.h"
32 33
33 namespace app_list { 34 namespace app_list {
34 35
35 namespace { 36 namespace {
36 37
37 const int kTopPadding = 20; 38 const int kTopPadding = 20;
38 const int kIconTitleSpacing = 7; 39 const int kIconTitleSpacing = 7;
39 const int kProgressBarHorizontalPadding = 12; 40 const int kProgressBarHorizontalPadding = 12;
40 41
41 // Radius of the folder dropping preview circle. 42 // Radius of the folder dropping preview circle.
42 const int kFolderPreviewRadius = 40; 43 const int kFolderPreviewRadius = 40;
43 44
44 const int kLeftRightPaddingChars = 1; 45 const int kLeftRightPaddingChars = 1;
45 46
46 // Scale to transform the icon when a drag starts.
47 const float kDraggingIconScale = 1.5f;
48
49 // Delay in milliseconds of when the dragging UI should be shown for mouse drag. 47 // Delay in milliseconds of when the dragging UI should be shown for mouse drag.
50 const int kMouseDragUIDelayInMs = 200; 48 const int kMouseDragUIDelayInMs = 200;
51 49
52 } // namespace 50 } // namespace
53 51
54 // static 52 // static
55 const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; 53 const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView";
56 54
57 AppListItemView::AppListItemView(AppsGridView* apps_grid_view, 55 AppListItemView::AppListItemView(AppsGridView* apps_grid_view,
58 AppListItem* item) 56 AppListItem* item)
59 : CustomButton(apps_grid_view), 57 : CustomButton(apps_grid_view),
60 item_(item), 58 item_(item),
61 apps_grid_view_(apps_grid_view), 59 apps_grid_view_(apps_grid_view),
62 icon_(new views::ImageView), 60 icon_(new views::ImageView),
63 title_(new CachedLabel), 61 title_(new CachedLabel),
64 progress_bar_(new ProgressBarView), 62 progress_bar_(new ProgressBarView),
65 ui_state_(UI_STATE_NORMAL), 63 ui_state_(UI_STATE_NORMAL),
66 touch_dragging_(false) { 64 touch_dragging_(false) {
67 icon_->set_interactive(false); 65 icon_->set_interactive(false);
68 66
69 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 67 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
70 title_->SetBackgroundColor(0);
71 title_->SetAutoColorReadabilityEnabled(false); 68 title_->SetAutoColorReadabilityEnabled(false);
72 title_->SetEnabledColor(kGridTitleColor); 69 title_->SetEnabledColor(kGridTitleColor);
73 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); 70 title_->SetFontList(rb.GetFontList(kItemTextFontStyle));
74 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 71 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
75 title_->SetVisible(!item_->is_installing()); 72 title_->SetVisible(!item_->is_installing());
76 title_->Invalidate(); 73 title_->Invalidate();
77 74
75 title_->SetBackgroundColor(app_list::kContentsBackgroundColor);
76 title_->set_background(views::Background::CreateSolidBackground(
77 app_list::kContentsBackgroundColor));
78
78 const gfx::ShadowValue kIconShadows[] = { 79 const gfx::ShadowValue kIconShadows[] = {
79 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)), 80 gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)),
80 }; 81 };
81 icon_shadows_.assign(kIconShadows, kIconShadows + arraysize(kIconShadows)); 82 icon_shadows_.assign(kIconShadows, kIconShadows + arraysize(kIconShadows));
82 83
83 AddChildView(icon_); 84 AddChildView(icon_);
84 AddChildView(title_); 85 AddChildView(title_);
85 AddChildView(progress_bar_); 86 AddChildView(progress_bar_);
86 87
87 ItemIconChanged(); 88 ItemIconChanged();
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 void AppListItemView::ShowContextMenuForView(views::View* source, 319 void AppListItemView::ShowContextMenuForView(views::View* source,
319 const gfx::Point& point, 320 const gfx::Point& point,
320 ui::MenuSourceType source_type) { 321 ui::MenuSourceType source_type) {
321 ui::MenuModel* menu_model = item_->GetContextMenuModel(); 322 ui::MenuModel* menu_model = item_->GetContextMenuModel();
322 if (!menu_model) 323 if (!menu_model)
323 return; 324 return;
324 325
325 context_menu_runner_.reset(new views::MenuRunner(menu_model)); 326 context_menu_runner_.reset(new views::MenuRunner(menu_model));
326 if (context_menu_runner_->RunMenuAt( 327 if (context_menu_runner_->RunMenuAt(
327 GetWidget(), NULL, gfx::Rect(point, gfx::Size()), 328 GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
328 views::MenuItemView::TOPLEFT, source_type, 329 ui::TOPLEFT_MENU_ANCHOR, source_type,
329 views::MenuRunner::HAS_MNEMONICS) == 330 views::MenuRunner::HAS_MNEMONICS) ==
330 views::MenuRunner::MENU_DELETED) 331 views::MenuRunner::MENU_DELETED)
331 return; 332 return;
332 } 333 }
333 334
334 void AppListItemView::StateChanged() { 335 void AppListItemView::StateChanged() {
335 const bool is_folder_ui_enabled = switches::IsFolderUIEnabled(); 336 const bool is_folder_ui_enabled = switches::IsFolderUIEnabled();
336 if (is_folder_ui_enabled) 337 if (is_folder_ui_enabled)
337 apps_grid_view_->ClearAnySelectedView(); 338 apps_grid_view_->ClearAnySelectedView();
338 339
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 const int left_right_padding = 480 const int left_right_padding =
480 title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); 481 title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars);
481 rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); 482 rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0);
482 483
483 gfx::Rect icon_bounds(rect.x(), rect.y(), rect.width(), icon_size_.height()); 484 gfx::Rect icon_bounds(rect.x(), rect.y(), rect.width(), icon_size_.height());
484 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_)); 485 icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_));
485 return icon_bounds; 486 return icon_bounds;
486 } 487 }
487 488
488 } // namespace app_list 489 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_folder_view.cc ('k') | ui/app_list/views/apps_grid_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698