Index: ui/app_list/views/app_list_item_view.cc |
diff --git a/ui/app_list/views/app_list_item_view.cc b/ui/app_list/views/app_list_item_view.cc |
index b3053fbd4f806bb3c0f6840263a6523ae98b9e6e..67b0d6659a333eda60f9a527f27d02940813e8c4 100644 |
--- a/ui/app_list/views/app_list_item_view.cc |
+++ b/ui/app_list/views/app_list_item_view.cc |
@@ -10,6 +10,7 @@ |
#include "build/build_config.h" |
#include "ui/accessibility/ax_node_data.h" |
#include "ui/app_list/app_list_constants.h" |
+#include "ui/app_list/app_list_features.h" |
#include "ui/app_list/app_list_folder_item.h" |
#include "ui/app_list/app_list_item.h" |
#include "ui/app_list/app_list_switches.h" |
@@ -38,16 +39,16 @@ namespace app_list { |
namespace { |
-const int kTopPadding = 18; |
-const int kIconTitleSpacing = 6; |
+constexpr int kTopPadding = 18; |
+constexpr int kIconTitleSpacing = 6; |
// Radius of the folder dropping preview circle. |
-const int kFolderPreviewRadius = 40; |
+constexpr int kFolderPreviewRadius = 40; |
-const int kLeftRightPaddingChars = 1; |
+constexpr int kLeftRightPaddingChars = 1; |
// Delay in milliseconds of when the dragging UI should be shown for mouse drag. |
-const int kMouseDragUIDelayInMs = 200; |
+constexpr int kMouseDragUIDelayInMs = 200; |
gfx::FontList GetFontList() { |
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
@@ -69,25 +70,31 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view, |
icon_(new views::ImageView), |
title_(new views::Label), |
progress_bar_(new views::ProgressBar), |
- ui_state_(UI_STATE_NORMAL), |
- touch_dragging_(false), |
shadow_animator_(this), |
- is_installing_(false), |
- is_highlighted_(false) { |
+ is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) { |
shadow_animator_.animation()->SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN); |
shadow_animator_.SetStartAndEndShadows(IconStartShadows(), IconEndShadows()); |
icon_->set_can_process_events_within_subtree(false); |
icon_->SetVerticalAlignment(views::ImageView::LEADING); |
- title_->SetBackgroundColor(0); |
+ title_->SetBackgroundColor(SK_ColorTRANSPARENT); |
title_->SetAutoColorReadabilityEnabled(false); |
- title_->SetEnabledColor(kGridTitleColor); |
title_->SetHandlesTooltips(false); |
- static const gfx::FontList font_list = GetFontList(); |
- title_->SetFontList(font_list); |
- title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ if (is_fullscreen_app_list_enabled_) { |
+ const gfx::FontList& base_font = |
+ ui::ResourceBundle::GetSharedInstance().GetFontList( |
+ ui::ResourceBundle::BaseFont); |
+ title_->SetFontList(base_font.DeriveWithSizeDelta(1)); |
+ title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
+ title_->SetEnabledColor(kGridTitleColorFullscreen); |
+ } else { |
+ const gfx::FontList& font_list = GetFontList(); |
+ title_->SetFontList(font_list); |
+ title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ title_->SetEnabledColor(kGridTitleColor); |
+ } |
SetTitleSubpixelAA(); |
AddChildView(icon_); |
@@ -313,27 +320,54 @@ const char* AppListItemView::GetClassName() const { |
void AppListItemView::Layout() { |
gfx::Rect rect(GetContentsBounds()); |
+ if (rect.IsEmpty()) |
+ return; |
- const int left_right_padding = |
- title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); |
- rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); |
- const int y = rect.y(); |
- |
- icon_->SetBoundsRect(GetIconBoundsForTargetViewBounds(GetContentsBounds())); |
+ if (is_fullscreen_app_list_enabled_) { |
+ icon_->SetBoundsRect(GetIconBoundsForTargetViewBounds(GetContentsBounds())); |
+ |
+ rect.Inset(kGridTitleHorizontalPadding, |
+ kGridIconTopPadding + kGridIconDimension + kGridTitleSpacing, |
+ kGridTitleHorizontalPadding, 0); |
+ rect.set_height(title_->GetPreferredSize().height()); |
+ title_->SetBoundsRect(rect); |
+ SetTitleSubpixelAA(); |
+ |
+ gfx::Rect progress_bar_bounds(progress_bar_->GetPreferredSize()); |
+ progress_bar_bounds.set_x( |
+ (GetContentsBounds().width() - progress_bar_bounds.width()) / 2); |
+ progress_bar_bounds.set_y(rect.y()); |
+ progress_bar_->SetBoundsRect(progress_bar_bounds); |
+ } else { |
+ icon_->SetBoundsRect(GetIconBoundsForTargetViewBounds(GetContentsBounds())); |
+ |
+ const int left_right_padding = |
+ title_->font_list().GetExpectedTextWidth(kLeftRightPaddingChars); |
+ rect.Inset(left_right_padding, kTopPadding, left_right_padding, 0); |
+ const int y = rect.y(); |
+ |
+ const gfx::Size title_size = title_->GetPreferredSize(); |
+ gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, |
+ y + kGridIconDimension + kIconTitleSpacing, |
+ title_size.width(), title_size.height()); |
+ title_bounds.Intersect(rect); |
+ title_->SetBoundsRect(title_bounds); |
+ SetTitleSubpixelAA(); |
+ |
+ gfx::Rect progress_bar_bounds(progress_bar_->GetPreferredSize()); |
+ progress_bar_bounds.set_x( |
+ (GetContentsBounds().width() - progress_bar_bounds.width()) / 2); |
+ progress_bar_bounds.set_y(title_bounds.y()); |
+ progress_bar_->SetBoundsRect(progress_bar_bounds); |
+ } |
+} |
- const gfx::Size title_size = title_->GetPreferredSize(); |
- gfx::Rect title_bounds(rect.x() + (rect.width() - title_size.width()) / 2, |
- y + kGridIconDimension + kIconTitleSpacing, |
- title_size.width(), title_size.height()); |
- title_bounds.Intersect(rect); |
- title_->SetBoundsRect(title_bounds); |
- SetTitleSubpixelAA(); |
+gfx::Size AppListItemView::CalculatePreferredSize() const { |
+ if (is_fullscreen_app_list_enabled_) { |
+ return gfx::Size(kGridTileWidth, kGridTileHeight); |
+ } |
- gfx::Rect progress_bar_bounds(progress_bar_->GetPreferredSize()); |
- progress_bar_bounds.set_x( |
- (GetContentsBounds().width() - progress_bar_bounds.width()) / 2); |
- progress_bar_bounds.set_y(title_bounds.y()); |
- progress_bar_->SetBoundsRect(progress_bar_bounds); |
+ return views::View::CalculatePreferredSize(); |
} |
bool AppListItemView::OnKeyPressed(const ui::KeyEvent& event) { |
@@ -460,7 +494,9 @@ void AppListItemView::SetDragUIState() { |
gfx::Rect AppListItemView::GetIconBoundsForTargetViewBounds( |
const gfx::Rect& target_bounds) { |
gfx::Rect rect(target_bounds); |
- rect.Inset(0, kTopPadding, 0, 0); |
+ rect.Inset( |
+ 0, is_fullscreen_app_list_enabled_ ? kGridIconTopPadding : kTopPadding, 0, |
+ 0); |
rect.set_height(icon_->GetImage().height()); |
rect.ClampToCenteredSize(icon_->GetImage().size()); |
return rect; |