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

Unified Diff: chrome/browser/chromeos/volume_bubble_view.cc

Issue 2790012: Volume bubble added for ChromeOS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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
Index: chrome/browser/chromeos/volume_bubble_view.cc
===================================================================
--- chrome/browser/chromeos/volume_bubble_view.cc (revision 0)
+++ chrome/browser/chromeos/volume_bubble_view.cc (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/volume_bubble_view.h"
+
+#include <string>
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "gfx/canvas.h"
+#include "grit/theme_resources.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "views/controls/progress_bar.h"
+
+using views::Background;
+using views::View;
+using views::Widget;
+
+namespace {
+
+// Volume bubble metrics.
+const int kWidth = 300, kHeight = 75;
+const int kMargin = 25;
+const int kProgressBarHeight = 20;
+
+} // namespace
+
+namespace chromeos {
+
+VolumeBubbleView::VolumeBubbleView() : progress_bar_(NULL) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ volume_icon_ = rb.GetBitmapNamed(IDR_VOLUMEBUBBLE_ICON);
+}
+
+void VolumeBubbleView::Init(int volume_level_percent) {
+ DCHECK(volume_level_percent >= 0 && volume_level_percent <= 100);
+ progress_bar_ = new views::ProgressBar();
+ AddChildView(progress_bar_);
+ Update(volume_level_percent);
+}
+
+void VolumeBubbleView::Update(int volume_level_percent) {
+ DCHECK(volume_level_percent >= 0 && volume_level_percent <= 100);
+ progress_bar_->SetProgress(volume_level_percent);
+}
+
+void VolumeBubbleView::Paint(gfx::Canvas* canvas) {
+ views::View::Paint(canvas);
+ canvas->DrawBitmapInt(*volume_icon_,
+ volume_icon_->width(),
+ (height() - volume_icon_->height()) / 2);
+}
+
+void VolumeBubbleView::Layout() {
+ progress_bar_->SetBounds(volume_icon_->width() + kMargin * 2,
+ (height() - kProgressBarHeight) / 2,
+ width() - volume_icon_->width() - kMargin * 3,
+ kProgressBarHeight);
+}
+
+gfx::Size VolumeBubbleView::GetPreferredSize() {
+ return gfx::Size(kWidth, kHeight);
+}
+
+} // namespace chromeos
Property changes on: chrome/browser/chromeos/volume_bubble_view.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698