summaryrefslogtreecommitdiffstats
path: root/ui/app_list
diff options
context:
space:
mode:
authorkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-08 10:56:08 +0000
committerkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-08 10:56:08 +0000
commit375c7f9f90e120170b9cf2547918c9489a62480f (patch)
treeb17d1a13db3b1a96812b97cc4bb4ed24dd70e36d /ui/app_list
parenta9b7d2a5e1b27b3f45bb4f2f499ac6d46da5c58c (diff)
downloadchromium_src-375c7f9f90e120170b9cf2547918c9489a62480f.zip
chromium_src-375c7f9f90e120170b9cf2547918c9489a62480f.tar.gz
chromium_src-375c7f9f90e120170b9cf2547918c9489a62480f.tar.bz2
[win] Add a progress bar in the app launcher for app installs.
BUG=152854 TBR=thakis@chromium.org for chrome/browser/ui/cocoa for adding a stub function Review URL: https://chromiumcodereview.appspot.com/12208040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list')
-rw-r--r--ui/app_list/app_list_item_model.cc25
-rw-r--r--ui/app_list/app_list_item_model.h8
-rw-r--r--ui/app_list/app_list_item_model_observer.h6
-rw-r--r--ui/app_list/views/app_list_item_view.cc35
-rw-r--r--ui/app_list/views/app_list_item_view.h2
-rw-r--r--ui/app_list/views/app_list_main_view.cc2
6 files changed, 77 insertions, 1 deletions
diff --git a/ui/app_list/app_list_item_model.cc b/ui/app_list/app_list_item_model.cc
index c3a74bf..c9a2831 100644
--- a/ui/app_list/app_list_item_model.cc
+++ b/ui/app_list/app_list_item_model.cc
@@ -9,7 +9,10 @@
namespace app_list {
-AppListItemModel::AppListItemModel() : highlighted_(false) {
+AppListItemModel::AppListItemModel()
+ : highlighted_(false),
+ is_installing_(false),
+ percent_downloaded_(-1) {
}
AppListItemModel::~AppListItemModel() {
@@ -38,6 +41,26 @@ void AppListItemModel::SetHighlighted(bool highlighted) {
ItemHighlightedChanged());
}
+void AppListItemModel::SetIsInstalling(bool is_installing) {
+ if (is_installing_ == is_installing)
+ return;
+
+ is_installing_ = is_installing;
+ FOR_EACH_OBSERVER(AppListItemModelObserver,
+ observers_,
+ ItemIsInstallingChanged());
+}
+
+void AppListItemModel::SetPercentDownloaded(int percent_downloaded) {
+ if (percent_downloaded_ == percent_downloaded)
+ return;
+
+ percent_downloaded_ = percent_downloaded;
+ FOR_EACH_OBSERVER(AppListItemModelObserver,
+ observers_,
+ ItemPercentDownloadedChanged());
+}
+
void AppListItemModel::AddObserver(AppListItemModelObserver* observer) {
observers_.AddObserver(observer);
}
diff --git a/ui/app_list/app_list_item_model.h b/ui/app_list/app_list_item_model.h
index ca382de..2960931 100644
--- a/ui/app_list/app_list_item_model.h
+++ b/ui/app_list/app_list_item_model.h
@@ -36,6 +36,12 @@ class APP_LIST_EXPORT AppListItemModel {
void SetHighlighted(bool highlighted);
bool highlighted() const { return highlighted_; }
+ void SetIsInstalling(bool is_installing);
+ bool is_installing() const { return is_installing_; }
+
+ void SetPercentDownloaded(int percent_downloaded);
+ int percent_downloaded() const { return percent_downloaded_; }
+
void AddObserver(AppListItemModelObserver* observer);
void RemoveObserver(AppListItemModelObserver* observer);
@@ -47,6 +53,8 @@ class APP_LIST_EXPORT AppListItemModel {
gfx::ImageSkia icon_;
std::string title_;
bool highlighted_;
+ bool is_installing_;
+ int percent_downloaded_;
ObserverList<AppListItemModelObserver> observers_;
diff --git a/ui/app_list/app_list_item_model_observer.h b/ui/app_list/app_list_item_model_observer.h
index 0e5f99d..80abb39 100644
--- a/ui/app_list/app_list_item_model_observer.h
+++ b/ui/app_list/app_list_item_model_observer.h
@@ -20,6 +20,12 @@ class APP_LIST_EXPORT AppListItemModelObserver {
// Invoked after item's highlighted state is changed.
virtual void ItemHighlightedChanged() = 0;
+ // Invoked after item begins or finishes installing.
+ virtual void ItemIsInstallingChanged() = 0;
+
+ // Invoked after item's download percentage changes.
+ virtual void ItemPercentDownloadedChanged() = 0;
+
protected:
virtual ~AppListItemModelObserver() {}
};
diff --git a/ui/app_list/views/app_list_item_view.cc b/ui/app_list/views/app_list_item_view.cc
index e481cb4..4793a99 100644
--- a/ui/app_list/views/app_list_item_view.cc
+++ b/ui/app_list/views/app_list_item_view.cc
@@ -31,6 +31,9 @@ namespace {
const int kTopBottomPadding = 10;
const int kTopPadding = 20;
const int kIconTitleSpacing = 7;
+const int kProgressBarHorizontalPadding = 8;
+const int kProgressBarVerticalPadding = 4;
+const int kProgressBarHeight = 4;
const SkColor kTitleColor = SkColorSetRGB(0x5A, 0x5A, 0x5A);
const SkColor kTitleHoverColor = SkColorSetRGB(0x3C, 0x3C, 0x3C);
@@ -38,6 +41,9 @@ const SkColor kTitleHoverColor = SkColorSetRGB(0x3C, 0x3C, 0x3C);
const SkColor kHoverAndPushedColor = SkColorSetARGB(0x19, 0, 0, 0);
const SkColor kSelectedColor = SkColorSetARGB(0x0D, 0, 0, 0);
const SkColor kHighlightedColor = kHoverAndPushedColor;
+const SkColor kDownloadProgressBackgroundColor =
+ SkColorSetRGB(0x90, 0x90, 0x90);
+const SkColor kDownloadProgressColor = SkColorSetRGB(0x20, 0xAA, 0x20);
const int kLeftRightPaddingChars = 1;
@@ -168,6 +174,16 @@ void AppListItemView::ItemHighlightedChanged() {
SchedulePaint();
}
+void AppListItemView::ItemIsInstallingChanged() {
+ if (model_->is_installing())
+ apps_grid_view_->EnsureViewVisible(this);
+ SchedulePaint();
+}
+
+void AppListItemView::ItemPercentDownloadedChanged() {
+ SchedulePaint();
+}
+
std::string AppListItemView::GetClassName() const {
return kViewClassName;
}
@@ -210,6 +226,25 @@ void AppListItemView::OnPaint(gfx::Canvas* canvas) {
} else if (apps_grid_view_->IsSelectedView(this)) {
canvas->FillRect(rect, kSelectedColor);
}
+
+ 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);
+
+ 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);
+ }
+ }
}
void AppListItemView::GetAccessibleState(ui::AccessibleViewState* state) {
diff --git a/ui/app_list/views/app_list_item_view.h b/ui/app_list/views/app_list_item_view.h
index 7cabc5f..a037de2 100644
--- a/ui/app_list/views/app_list_item_view.h
+++ b/ui/app_list/views/app_list_item_view.h
@@ -64,6 +64,8 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
virtual void ItemIconChanged() OVERRIDE;
virtual void ItemTitleChanged() OVERRIDE;
virtual void ItemHighlightedChanged() OVERRIDE;
+ virtual void ItemIsInstallingChanged() OVERRIDE;
+ virtual void ItemPercentDownloadedChanged() OVERRIDE;
// views::View overrides:
virtual std::string GetClassName() const OVERRIDE;
diff --git a/ui/app_list/views/app_list_main_view.cc b/ui/app_list/views/app_list_main_view.cc
index f73f428..bfadf21 100644
--- a/ui/app_list/views/app_list_main_view.cc
+++ b/ui/app_list/views/app_list_main_view.cc
@@ -60,6 +60,8 @@ class AppListMainView::IconLoader : public AppListItemModelObserver {
}
virtual void ItemTitleChanged() OVERRIDE {}
virtual void ItemHighlightedChanged() OVERRIDE {}
+ virtual void ItemIsInstallingChanged() OVERRIDE {};
+ virtual void ItemPercentDownloadedChanged() OVERRIDE {};
AppListMainView* owner_;
AppListItemModel* item_;