#include "ui/gfx/font_list.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/point.h"
+#include "ui/gfx/shadow_value.h"
#include "ui/gfx/transform_util.h"
#include "ui/views/background.h"
#include "ui/views/controls/image_view.h"
// Delay in milliseconds of when the dragging UI should be shown for mouse drag.
const int kMouseDragUIDelayInMs = 200;
+const gfx::ShadowValues& GetIconShadows() {
+ CR_DEFINE_STATIC_LOCAL(
+ const gfx::ShadowValues,
+ icon_shadows,
+ (1,
+ gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0))));
+ return icon_shadows;
+}
+
} // namespace
// static
title_->Invalidate();
SetTitleSubpixelAA();
- const gfx::ShadowValue kIconShadows[] = {
- gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)),
- };
- icon_shadows_.assign(kIconShadows, kIconShadows + arraysize(kIconShadows));
-
AddChildView(icon_);
AddChildView(title_);
AddChildView(progress_bar_);
item_->RemoveObserver(this);
}
-void AppListItemView::SetIconSize(const gfx::Size& size) {
- if (icon_size_ == size)
- return;
-
- icon_size_ = size;
- UpdateIcon();
-}
-
void AppListItemView::UpdateIcon() {
- // Skip if |icon_size_| has not been determined.
- if (icon_size_.IsEmpty())
- return;
-
gfx::ImageSkia icon = item_->icon();
// Clear icon and bail out if item icon is empty.
if (icon.isNull()) {
return;
}
- gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(icon,
- skia::ImageOperations::RESIZE_BEST, icon_size_));
+ gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(
+ icon,
+ skia::ImageOperations::RESIZE_BEST,
+ gfx::Size(kGridIconDimension, kGridIconDimension)));
if (item_->has_shadow()) {
- gfx::ImageSkia shadow(
- gfx::ImageSkiaOperations::CreateImageWithDropShadow(resized,
- icon_shadows_));
+ gfx::ImageSkia shadow(gfx::ImageSkiaOperations::CreateImageWithDropShadow(
+ resized, GetIconShadows()));
icon_->SetImage(shadow);
return;
}
icon_->SetBoundsRect(GetIconBoundsForTargetViewBounds(GetContentsBounds()));
const gfx::Size title_size = title_->GetPreferredSize();
gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2,
- y + icon_size_.height() + kIconTitleSpacing,
+ y + kGridIconDimension + kIconTitleSpacing,
title_size.width(),
title_size.height());
title_bounds.Intersect(rect);
if (!menu_model)
return;
- context_menu_runner_.reset(new views::MenuRunner(menu_model));
+ context_menu_runner_.reset(
+ new views::MenuRunner(menu_model, views::MenuRunner::HAS_MNEMONICS));
if (context_menu_runner_->RunMenuAt(GetWidget(),
NULL,
gfx::Rect(point, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT,
- source_type,
- views::MenuRunner::HAS_MNEMONICS) ==
+ source_type) ==
views::MenuRunner::MENU_DELETED) {
return;
}
title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars);
rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0);
- gfx::Rect icon_bounds(rect.x(), rect.y(), rect.width(), icon_size_.height());
- icon_bounds.Inset(gfx::ShadowValue::GetMargin(icon_shadows_));
+ gfx::Rect icon_bounds(rect.x(), rect.y(), rect.width(), kGridIconDimension);
+ icon_bounds.Inset(gfx::ShadowValue::GetMargin(GetIconShadows()));
return icon_bounds;
}