Commit d8e8864b authored by koz@chromium.org's avatar koz@chromium.org

Make the app list use images for the progress bar.

BUG=152854


Review URL: https://chromiumcodereview.appspot.com/12217129

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182195 0039d316-1c4b-4281-b951-d872f2087c98
parent f900ab5c
......@@ -2,6 +2,7 @@ include_rules = [
"+skia",
"+third_party/skia",
"+ui",
"+grit",
# Allow inclusion of third-party code:
"+third_party/GTM", # Google Toolbox for Mac.
......
......@@ -16,6 +16,7 @@
'../../skia/skia.gyp:skia',
'../compositor/compositor.gyp:compositor',
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
],
'defines': [
'APP_LIST_IMPLEMENTATION',
......
......@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/utf_string_conversions.h"
#include "grit/ui_resources.h"
#include "ui/app_list/app_list_item_model.h"
#include "ui/app_list/views/apps_grid_view.h"
#include "ui/base/accessibility/accessible_view_state.h"
......@@ -31,7 +32,7 @@ namespace {
const int kTopBottomPadding = 10;
const int kTopPadding = 20;
const int kIconTitleSpacing = 7;
const int kProgressBarHorizontalPadding = 8;
const int kProgressBarHorizontalPadding = 12;
const int kProgressBarVerticalPadding = 4;
const int kProgressBarHeight = 4;
......@@ -75,6 +76,7 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view,
title_->SetEnabledColor(kTitleColor);
title_->SetFont(rb.GetFont(ui::ResourceBundle::SmallBoldFont));
title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
title_->SetVisible(!model_->is_installing());
const gfx::ShadowValue kIconShadows[] = {
gfx::ShadowValue(gfx::Point(0, 2), 2, SkColorSetARGB(0x24, 0, 0, 0)),
......@@ -177,6 +179,7 @@ void AppListItemView::ItemHighlightedChanged() {
void AppListItemView::ItemIsInstallingChanged() {
if (model_->is_installing())
apps_grid_view_->EnsureViewVisible(this);
title_->SetVisible(!model_->is_installing());
SchedulePaint();
}
......@@ -228,21 +231,29 @@ void AppListItemView::OnPaint(gfx::Canvas* canvas) {
}
if (model_->is_installing()) {
gfx::Rect progress_bar_background(
rect.x() + kProgressBarHorizontalPadding,
rect.bottom() - kProgressBarVerticalPadding - kProgressBarHeight,
rect.width() - 2 * kProgressBarHorizontalPadding,
kProgressBarHeight);
canvas->FillRect(progress_bar_background, kDownloadProgressBackgroundColor);
gfx::ImageSkia background = *ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_APP_LIST_ITEM_PROGRESS_BACKGROUND);
gfx::ImageSkia left = *ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_APP_LIST_ITEM_PROGRESS_LEFT);
gfx::ImageSkia center = *ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_APP_LIST_ITEM_PROGRESS_CENTER);
gfx::ImageSkia right = *ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_APP_LIST_ITEM_PROGRESS_RIGHT);
int bar_x = rect.x() + kProgressBarHorizontalPadding;
int bar_y = icon_->bounds().bottom() + kIconTitleSpacing;
canvas->DrawImageInt(background, bar_x, bar_y);
if (model_->percent_downloaded() != -1) {
float percent = model_->percent_downloaded() / 100.0;
gfx::Rect progress_bar(
progress_bar_background.x(),
progress_bar_background.y(),
progress_bar_background.width() * percent,
progress_bar_background.height());
canvas->FillRect(progress_bar, kDownloadProgressColor);
int bar_width = percent *
(background.width() - (left.width() + right.width()));
canvas->DrawImageInt(left, bar_x, bar_y);
int x = bar_x + left.width();
canvas->TileImageInt(center, x, bar_y, bar_width, center.height());
x += bar_width;
canvas->DrawImageInt(right, x, bar_y);
}
}
}
......
......@@ -20,6 +20,12 @@
<!-- KEEP THESE IN ALPHABETICAL ORDER! DO NOT ADD TO RANDOM PLACES JUST
BECAUSE YOUR RESOURCES ARE FUNCTIONALLY RELATED OR FALL UNDER THE
SAME CONDITIONALS. -->
<if expr="pp_ifdef('enable_app_list')">
<structure type="chrome_scaled_image" name="IDR_APP_LIST_ITEM_PROGRESS_BACKGROUND" file="common/app_list_progress_bar_background.png" />
<structure type="chrome_scaled_image" name="IDR_APP_LIST_ITEM_PROGRESS_LEFT" file="common/app_list_progress_bar_left.png" />
<structure type="chrome_scaled_image" name="IDR_APP_LIST_ITEM_PROGRESS_CENTER" file="common/app_list_progress_bar_center.png" />
<structure type="chrome_scaled_image" name="IDR_APP_LIST_ITEM_PROGRESS_RIGHT" file="common/app_list_progress_bar_right.png" />
</if>
<structure type="chrome_scaled_image" name="IDR_APP_TOP_CENTER" file="app_top_center.png" />
<if expr="pp_ifdef('toolkit_views')">
<structure type="chrome_scaled_image" name="IDR_APP_TOP_LEFT" file="app_top_left.png" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment