summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 22:08:46 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 22:08:46 +0000
commite9cd4f0316b92e8c2b9277ae5d2ce3f42836720a (patch)
tree08c2cbf398035a79a6ff37f4baf0dfd84f2e7485 /chrome
parent81bf14642cc1362edcd4073c8ef6abbbaaf2cabe (diff)
downloadchromium_src-e9cd4f0316b92e8c2b9277ae5d2ce3f42836720a.zip
chromium_src-e9cd4f0316b92e8c2b9277ae5d2ce3f42836720a.tar.gz
chromium_src-e9cd4f0316b92e8c2b9277ae5d2ce3f42836720a.tar.bz2
chromeos: Add support for multiple volume icons.
This makes us the appropriate icon depending on whether the volume is increasing, decreasing, or muted. BUG=chromium-os:8473 TEST=built it and tried the volume up, down, and mute keys in various combinations Review URL: http://codereview.chromium.org/5559004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/theme/theme_resources.grd4
-rw-r--r--chrome/app/theme/volume_icon.pngbin405 -> 0 bytes
-rw-r--r--chrome/browser/chromeos/setting_level_bubble.cc18
-rw-r--r--chrome/browser/chromeos/setting_level_bubble.h11
-rw-r--r--chrome/browser/chromeos/setting_level_bubble_view.cc22
-rw-r--r--chrome/browser/chromeos/setting_level_bubble_view.h3
-rw-r--r--chrome/browser/chromeos/volume_bubble.cc6
7 files changed, 48 insertions, 16 deletions
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 1f066d9..df00c32 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -584,7 +584,9 @@
<include name="IDR_USER_IMAGE_RECYCLE" file="discard_wide.png" type="BINDATA" />
<include name="IDR_USER_IMAGE_CAPTURE_DISABLED" file="snapshot_wide_disabled.png" type="BINDATA" />
<include name="IDR_USER_IMAGE_INITIALIZING" file="initializing_video.png" type="BINDATA" />
- <include name="IDR_VOLUMEBUBBLE_ICON" file="volume_icon.png" type="BINDATA" />
+ <include name="IDR_VOLUME_BUBBLE_UP_ICON" file="volume_up_icon.png" type="BINDATA" />
+ <include name="IDR_VOLUME_BUBBLE_DOWN_ICON" file="volume_down_icon.png" type="BINDATA" />
+ <include name="IDR_VOLUME_BUBBLE_MUTE_ICON" file="volume_mute_icon.png" type="BINDATA" />
<include name="IDR_SCROLL_BACKGROUND" file="chromeos_scroll_background.png" type="BINDATA" />
<include name="IDR_SCROLL_BACKGROUND_BORDER_UP" file="chromeos_scroll_background_border_up.png" type="BINDATA" />
<include name="IDR_SCROLL_BACKGROUND_BORDER_DOWN" file="chromeos_scroll_background_border_down.png" type="BINDATA" />
diff --git a/chrome/app/theme/volume_icon.png b/chrome/app/theme/volume_icon.png
deleted file mode 100644
index 1166fff..0000000
--- a/chrome/app/theme/volume_icon.png
+++ /dev/null
Binary files differ
diff --git a/chrome/browser/chromeos/setting_level_bubble.cc b/chrome/browser/chromeos/setting_level_bubble.cc
index 1847413..eb918e9 100644
--- a/chrome/browser/chromeos/setting_level_bubble.cc
+++ b/chrome/browser/chromeos/setting_level_bubble.cc
@@ -55,10 +55,14 @@ static views::Widget* GetToplevelWidget() {
return root->GetWidget();
}
-SettingLevelBubble::SettingLevelBubble(SkBitmap* icon)
+SettingLevelBubble::SettingLevelBubble(SkBitmap* increase_icon,
+ SkBitmap* decrease_icon,
+ SkBitmap* zero_icon)
: previous_percent_(-1),
current_percent_(-1),
- icon_(icon),
+ increase_icon_(increase_icon),
+ decrease_icon_(decrease_icon),
+ zero_icon_(zero_icon),
bubble_(NULL),
view_(NULL),
animation_(this) {
@@ -74,13 +78,20 @@ void SettingLevelBubble::ShowBubble(int percent) {
if (previous_percent_ == -1)
previous_percent_ = percent;
current_percent_ = percent;
+
+ SkBitmap* icon = increase_icon_;
+ if (current_percent_ == 0)
+ icon = zero_icon_;
+ else if (current_percent_ < previous_percent_)
+ icon = decrease_icon_;
+
if (!bubble_) {
views::Widget* widget = GetToplevelWidget();
if (widget == NULL)
return;
DCHECK(view_ == NULL);
view_ = new SettingLevelBubbleView;
- view_->Init(icon_, previous_percent_);
+ view_->Init(icon, previous_percent_);
// Calculate position of the bubble.
gfx::Rect bounds;
widget->GetBounds(&bounds, false);
@@ -94,6 +105,7 @@ void SettingLevelBubble::ShowBubble(int percent) {
} else {
DCHECK(view_);
timeout_timer_.Stop();
+ view_->SetIcon(icon);
}
if (animation_.is_animating())
animation_.End();
diff --git a/chrome/browser/chromeos/setting_level_bubble.h b/chrome/browser/chromeos/setting_level_bubble.h
index 2d36a87..4619127 100644
--- a/chrome/browser/chromeos/setting_level_bubble.h
+++ b/chrome/browser/chromeos/setting_level_bubble.h
@@ -25,7 +25,9 @@ class SettingLevelBubble : public InfoBubbleDelegate,
void ShowBubble(int percent);
protected:
- explicit SettingLevelBubble(SkBitmap* icon);
+ explicit SettingLevelBubble(SkBitmap* increase_icon,
+ SkBitmap* decrease_icon,
+ SkBitmap* zero_icon);
virtual ~SettingLevelBubble() {}
private:
@@ -45,8 +47,11 @@ class SettingLevelBubble : public InfoBubbleDelegate,
int previous_percent_;
int current_percent_;
- // Icon displayed in the bubble. Not owned by us.
- SkBitmap* icon_;
+ // Icons displayed in the bubble when increasing or decreasing the level or
+ // setting it to zero. Not owned by us.
+ SkBitmap* increase_icon_;
+ SkBitmap* decrease_icon_;
+ SkBitmap* zero_icon_;
// Currently shown bubble or NULL.
InfoBubble* bubble_;
diff --git a/chrome/browser/chromeos/setting_level_bubble_view.cc b/chrome/browser/chromeos/setting_level_bubble_view.cc
index 6a1f992..c566124 100644
--- a/chrome/browser/chromeos/setting_level_bubble_view.cc
+++ b/chrome/browser/chromeos/setting_level_bubble_view.cc
@@ -18,9 +18,10 @@ using views::Widget;
namespace {
// Bubble metrics.
-const int kWidth = 300, kHeight = 75;
-const int kMargin = 25;
-const int kProgressBarHeight = 20;
+const int kWidth = 350, kHeight = 100;
+const int kPadding = 20;
+const int kProgressBarWidth = 211;
+const int kProgressBarHeight = 17;
} // namespace
@@ -32,6 +33,7 @@ SettingLevelBubbleView::SettingLevelBubbleView()
}
void SettingLevelBubbleView::Init(SkBitmap* icon, int level_percent) {
+ DCHECK(icon);
DCHECK(level_percent >= 0 && level_percent <= 100);
icon_ = icon;
progress_bar_ = new views::ProgressBar();
@@ -39,6 +41,12 @@ void SettingLevelBubbleView::Init(SkBitmap* icon, int level_percent) {
Update(level_percent);
}
+void SettingLevelBubbleView::SetIcon(SkBitmap* icon) {
+ DCHECK(icon);
+ icon_ = icon;
+ SchedulePaint();
+}
+
void SettingLevelBubbleView::Update(int level_percent) {
DCHECK(level_percent >= 0 && level_percent <= 100);
progress_bar_->SetProgress(level_percent);
@@ -46,15 +54,13 @@ void SettingLevelBubbleView::Update(int level_percent) {
void SettingLevelBubbleView::Paint(gfx::Canvas* canvas) {
views::View::Paint(canvas);
- canvas->DrawBitmapInt(*icon_,
- icon_->width(), (height() - icon_->height()) / 2);
+ canvas->DrawBitmapInt(*icon_, kPadding, (height() - icon_->height()) / 2);
}
void SettingLevelBubbleView::Layout() {
- progress_bar_->SetBounds(icon_->width() + kMargin * 2,
+ progress_bar_->SetBounds(width() - kPadding - kProgressBarWidth,
(height() - kProgressBarHeight) / 2,
- width() - icon_->width() - kMargin * 3,
- kProgressBarHeight);
+ kProgressBarWidth, kProgressBarHeight);
}
gfx::Size SettingLevelBubbleView::GetPreferredSize() {
diff --git a/chrome/browser/chromeos/setting_level_bubble_view.h b/chrome/browser/chromeos/setting_level_bubble_view.h
index b1c43ec..519fef8 100644
--- a/chrome/browser/chromeos/setting_level_bubble_view.h
+++ b/chrome/browser/chromeos/setting_level_bubble_view.h
@@ -27,6 +27,9 @@ class SettingLevelBubbleView : public views::View {
// instance from ResourceBundle).
void Init(SkBitmap* icon, int level_percent);
+ // Change the icon that we're currently displaying.
+ void SetIcon(SkBitmap* icon);
+
// Set the progress bar to the specified position and redraw it.
void Update(int level_percent);
diff --git a/chrome/browser/chromeos/volume_bubble.cc b/chrome/browser/chromeos/volume_bubble.cc
index b10acb3..f1850be 100644
--- a/chrome/browser/chromeos/volume_bubble.cc
+++ b/chrome/browser/chromeos/volume_bubble.cc
@@ -12,7 +12,11 @@ namespace chromeos {
VolumeBubble::VolumeBubble()
: SettingLevelBubble(
ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_VOLUMEBUBBLE_ICON)) {
+ IDR_VOLUME_BUBBLE_UP_ICON),
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_VOLUME_BUBBLE_DOWN_ICON),
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_VOLUME_BUBBLE_MUTE_ICON)) {
}
} // namespace chromeos