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

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

Issue 1154323002: Use app list item shadow for app list folders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_arrow_keys_crash
Patch Set: fix mac compile Created 5 years, 6 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_item_view.h ('k') | no next file » | 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"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 static const gfx::FontList font_list = GetFontList(); 103 static const gfx::FontList font_list = GetFontList();
104 title_->SetFontList(font_list); 104 title_->SetFontList(font_list);
105 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 105 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
106 title_->Invalidate(); 106 title_->Invalidate();
107 SetTitleSubpixelAA(); 107 SetTitleSubpixelAA();
108 108
109 AddChildView(icon_); 109 AddChildView(icon_);
110 AddChildView(title_); 110 AddChildView(title_);
111 AddChildView(progress_bar_); 111 AddChildView(progress_bar_);
112 112
113 SetIcon(item->icon(), item->has_shadow()); 113 SetIcon(item->icon());
114 SetItemName(base::UTF8ToUTF16(item->GetDisplayName()), 114 SetItemName(base::UTF8ToUTF16(item->GetDisplayName()),
115 base::UTF8ToUTF16(item->name())); 115 base::UTF8ToUTF16(item->name()));
116 SetItemIsInstalling(item->is_installing()); 116 SetItemIsInstalling(item->is_installing());
117 SetItemIsHighlighted(item->highlighted()); 117 SetItemIsHighlighted(item->highlighted());
118 item->AddObserver(this); 118 item->AddObserver(this);
119 119
120 set_context_menu_controller(this); 120 set_context_menu_controller(this);
121 set_request_focus_on_press(false); 121 set_request_focus_on_press(false);
122 122
123 SetAnimationDuration(0); 123 SetAnimationDuration(0);
124 } 124 }
125 125
126 AppListItemView::~AppListItemView() { 126 AppListItemView::~AppListItemView() {
127 if (item_weak_) 127 if (item_weak_)
128 item_weak_->RemoveObserver(this); 128 item_weak_->RemoveObserver(this);
129 } 129 }
130 130
131 void AppListItemView::SetIcon(const gfx::ImageSkia& icon, bool has_shadow) { 131 void AppListItemView::SetIcon(const gfx::ImageSkia& icon) {
132 // Clear icon and bail out if item icon is empty. 132 // Clear icon and bail out if item icon is empty.
133 if (icon.isNull()) { 133 if (icon.isNull()) {
134 icon_->SetImage(NULL); 134 icon_->SetImage(NULL);
135 return; 135 return;
136 } 136 }
137 137
138 gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage( 138 gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(
139 icon, 139 icon,
140 skia::ImageOperations::RESIZE_BEST, 140 skia::ImageOperations::RESIZE_BEST,
141 gfx::Size(kGridIconDimension, kGridIconDimension))); 141 gfx::Size(kGridIconDimension, kGridIconDimension)));
142 if (has_shadow || app_list::switches::IsExperimentalAppListEnabled()) { 142 shadow_animator_.SetOriginalImage(resized);
143 shadow_animator_.SetOriginalImage(resized);
144 return;
145 }
146
147 icon_->SetImage(resized);
148 } 143 }
149 144
150 void AppListItemView::SetUIState(UIState state) { 145 void AppListItemView::SetUIState(UIState state) {
151 if (ui_state_ == state) 146 if (ui_state_ == state)
152 return; 147 return;
153 148
154 ui_state_ = state; 149 ui_state_ = state;
155 150
156 switch (ui_state_) { 151 switch (ui_state_) {
157 case UI_STATE_NORMAL: 152 case UI_STATE_NORMAL:
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // In other cases, keep the background transparent to ensure correct 547 // In other cases, keep the background transparent to ensure correct
553 // interactions with animations. This will temporarily disable subpixel AA. 548 // interactions with animations. This will temporarily disable subpixel AA.
554 title_->SetBackgroundColor(0); 549 title_->SetBackgroundColor(0);
555 title_->set_background(NULL); 550 title_->set_background(NULL);
556 } 551 }
557 title_->Invalidate(); 552 title_->Invalidate();
558 title_->SchedulePaint(); 553 title_->SchedulePaint();
559 } 554 }
560 555
561 void AppListItemView::ItemIconChanged() { 556 void AppListItemView::ItemIconChanged() {
562 SetIcon(item_weak_->icon(), item_weak_->has_shadow()); 557 SetIcon(item_weak_->icon());
563 } 558 }
564 559
565 void AppListItemView::ItemNameChanged() { 560 void AppListItemView::ItemNameChanged() {
566 SetItemName(base::UTF8ToUTF16(item_weak_->GetDisplayName()), 561 SetItemName(base::UTF8ToUTF16(item_weak_->GetDisplayName()),
567 base::UTF8ToUTF16(item_weak_->name())); 562 base::UTF8ToUTF16(item_weak_->name()));
568 } 563 }
569 564
570 void AppListItemView::ItemIsInstallingChanged() { 565 void AppListItemView::ItemIsInstallingChanged() {
571 SetItemIsInstalling(item_weak_->is_installing()); 566 SetItemIsInstalling(item_weak_->is_installing());
572 } 567 }
573 568
574 void AppListItemView::ItemPercentDownloadedChanged() { 569 void AppListItemView::ItemPercentDownloadedChanged() {
575 SetItemPercentDownloaded(item_weak_->percent_downloaded()); 570 SetItemPercentDownloaded(item_weak_->percent_downloaded());
576 } 571 }
577 572
578 void AppListItemView::ItemBeingDestroyed() { 573 void AppListItemView::ItemBeingDestroyed() {
579 DCHECK(item_weak_); 574 DCHECK(item_weak_);
580 item_weak_->RemoveObserver(this); 575 item_weak_->RemoveObserver(this);
581 item_weak_ = NULL; 576 item_weak_ = NULL;
582 } 577 }
583 578
584 } // namespace app_list 579 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_item_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698