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

Unified Diff: ash/app_list/app_list_item_view.cc

Issue 9677065: ash: Update app list UI to match latest crwm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/app_list/app_list_item_view.h ('k') | ash/app_list/app_list_model_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/app_list/app_list_item_view.cc
diff --git a/ash/app_list/app_list_item_view.cc b/ash/app_list/app_list_item_view.cc
index 92c0c22e33ea05b64ac989235fdc323698edb25f..bac1724be2957dfadc7ac77c71a99ded6c7e1c2d 100644
--- a/ash/app_list/app_list_item_view.cc
+++ b/ash/app_list/app_list_item_view.cc
@@ -22,7 +22,9 @@ namespace ash {
namespace {
-const int kIconTitleSpacing = 5;
+const int kPadding = 10;
+const int kIconTitleSpacing = 10;
+const int kMinLabelWidth = 150;
const SkColor kTitleColor = SK_ColorWHITE;
@@ -74,7 +76,6 @@ AppListItemView::AppListItemView(AppListModelView* list_model_view,
title_->SetFont(GetTitleFont());
title_->SetBackgroundColor(0);
title_->SetEnabledColor(kTitleColor);
- title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(icon_);
AddChildView(title_);
@@ -91,6 +92,16 @@ AppListItemView::~AppListItemView() {
model_->RemoveObserver(this);
}
+// static
+gfx::Size AppListItemView::GetPreferredSizeForIconSize(
+ const gfx::Size& icon_size) {
+ gfx::Size size(
+ std::max(icon_size.width() + icon_size.width() / 2, kMinLabelWidth),
+ icon_size.height() + kIconTitleSpacing + GetTitleFont().GetHeight());
+ size.Enlarge(2 * kPadding, 2 * kPadding);
+ return size;
+}
+
void AppListItemView::SetSelected(bool selected) {
if (selected == selected_)
return;
@@ -112,27 +123,24 @@ std::string AppListItemView::GetClassName() const {
}
gfx::Size AppListItemView::GetPreferredSize() {
- gfx::Size title_size = title_->GetPreferredSize();
-
- gfx::Size preferred_size(
- icon_size_.width() + kIconTitleSpacing + title_size.width(),
- std::max(icon_size_.height(), title_size.height()));
- preferred_size.Enlarge(2 * kPadding, 2 * kPadding);
- return preferred_size;
+ return GetPreferredSizeForIconSize(icon_size_);
}
void AppListItemView::Layout() {
gfx::Rect rect(GetContentsBounds());
+ rect.Inset(kPadding, kPadding);
+ gfx::Size title_size = title_->GetPreferredSize();
icon_->SetImageSize(icon_size_);
- icon_->SetBounds(rect.x() + kPadding, rect.y(),
- icon_size_.width(), rect.height());
-
- title_->SetBounds(
- icon_->bounds().right() + kIconTitleSpacing,
- rect.y(),
- rect.right() - kPadding - icon_->bounds().right() - kIconTitleSpacing,
- rect.height());
+ icon_->SetBounds(rect.x(),
+ rect.y(),
+ rect.width(),
+ icon_size_.height());
+
+ title_->SetBounds(rect.x(),
+ icon_->bounds().bottom() + kIconTitleSpacing,
+ rect.width(),
+ title_size.height());
}
void AppListItemView::OnPaint(gfx::Canvas* canvas) {
« no previous file with comments | « ash/app_list/app_list_item_view.h ('k') | ash/app_list/app_list_model_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698