summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authoravayvod@google.com <avayvod@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 12:39:13 +0000
committeravayvod@google.com <avayvod@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 12:39:13 +0000
commit857e79dae449847fe9045034039e57b1433ddb38 (patch)
treeb6be69ac644126f33ab5f32933ef720929ff6409 /views
parent6a6ce8b3a868dd1f94f8731ebd05abd39da46fec (diff)
downloadchromium_src-857e79dae449847fe9045034039e57b1433ddb38.zip
chromium_src-857e79dae449847fe9045034039e57b1433ddb38.tar.gz
chromium_src-857e79dae449847fe9045034039e57b1433ddb38.tar.bz2
Switched progress bar to integral positions (from 0 to 100).
BUG=none TEST=Launch with --login-manager --login-screen=update and verify that progress bar shows increasing progress and login screen is shown at the end. Review URL: http://codereview.chromium.org/945003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/progress_bar.cc24
-rw-r--r--views/controls/progress_bar.h22
-rw-r--r--views/controls/progress_bar_unittest.cc13
3 files changed, 26 insertions, 33 deletions
diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc
index 96ceb44..1f5cba1 100644
--- a/views/controls/progress_bar.cc
+++ b/views/controls/progress_bar.cc
@@ -4,6 +4,8 @@
#include "views/controls/progress_bar.h"
+#include <string>
+
#include "app/gfx/canvas.h"
#include "app/gfx/color_utils.h"
#include "app/gfx/font.h"
@@ -99,13 +101,11 @@ namespace views {
// static
const char ProgressBar::kViewClassName[] = "views/ProgressBar";
+// static: progress bar's maximum value.
+const int ProgressBar::kMaxProgress = 100;
-ProgressBar::ProgressBar() {
- Init(0);
-}
-ProgressBar::ProgressBar(double progress) {
- Init(progress);
+ProgressBar::ProgressBar(): progress_(0) {
}
ProgressBar::~ProgressBar() {
@@ -131,7 +131,7 @@ void ProgressBar::Paint(gfx::Canvas* canvas) {
if (progress_ * width() > 1) {
FillRoundRect(canvas,
0, 0,
- int(progress_ * width()), height(),
+ progress_ * width() / kMaxProgress, height(),
kCornerRadius,
bar_color_start,
bar_color_end,
@@ -149,16 +149,16 @@ std::string ProgressBar::GetClassName() const {
return kViewClassName;
}
-void ProgressBar::SetProgress(double progress) {
+void ProgressBar::SetProgress(int progress) {
progress_ = progress;
if (progress_ < 0)
progress_ = 0;
- else if (progress_ > 1)
- progress_ = 1;
+ else if (progress_ > kMaxProgress)
+ progress_ = kMaxProgress;
SchedulePaint();
}
-double ProgressBar::GetProgress() const {
+int ProgressBar::GetProgress() const {
return progress_;
}
@@ -205,8 +205,4 @@ bool ProgressBar::GetAccessibleState(AccessibilityTypes::State* state) {
return true;
}
-void ProgressBar::Init(double progress) {
- progress_ = progress;
-}
-
} // namespace views
diff --git a/views/controls/progress_bar.h b/views/controls/progress_bar.h
index e5587d5..128941f 100644
--- a/views/controls/progress_bar.h
+++ b/views/controls/progress_bar.h
@@ -5,6 +5,8 @@
#ifndef VIEWS_CONTROLS_PROGRESS_BAR_H_
#define VIEWS_CONTROLS_PROGRESS_BAR_H_
+#include <string>
+
#include "views/view.h"
namespace gfx {
@@ -25,12 +27,7 @@ namespace views {
class ProgressBar : public View {
public:
- // Creates a new progress bar with progress zero.
ProgressBar();
-
- // Creates a new progress bar with specified progress.
- explicit ProgressBar(double progress);
-
virtual ~ProgressBar();
// Overridden to return preferred size of the progress bar.
@@ -42,9 +39,9 @@ class ProgressBar : public View {
// Overridden to paint
virtual void Paint(gfx::Canvas* canvas);
- // Set and get the progress bar progress in range [0, 1].
- virtual void SetProgress(double progress);
- virtual double GetProgress() const;
+ // Set and get the progress bar progress in range [0, kMaxProgress].
+ virtual void SetProgress(int progress);
+ virtual int GetProgress() const;
// Sets the tooltip text. Default behavior for a progress bar is to show
// no tooltip on mouse hover. Calling this lets you set a custom tooltip.
@@ -62,11 +59,12 @@ class ProgressBar : public View {
virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleState(AccessibilityTypes::State* state);
- private:
- void Init(double progress);
+ // Maximum value of progress.
+ static const int kMaxProgress;
- // Progress in range [0, 1].
- double progress_;
+ private:
+ // Progress in range [0, kMaxProgress].
+ int progress_;
// Tooltip text.
std::wstring tooltip_text_;
diff --git a/views/controls/progress_bar_unittest.cc b/views/controls/progress_bar_unittest.cc
index 1f653b7..971b424 100644
--- a/views/controls/progress_bar_unittest.cc
+++ b/views/controls/progress_bar_unittest.cc
@@ -11,16 +11,15 @@ namespace views {
TEST(ProgressBarTest, ProgressProperty) {
ProgressBar bar;
- double progress = 0;
bar.SetProgress(-1);
- progress = bar.GetProgress();
+ int progress = bar.GetProgress();
EXPECT_EQ(0, progress);
- bar.SetProgress(3);
+ bar.SetProgress(300);
progress = bar.GetProgress();
- EXPECT_EQ(1, progress);
- bar.SetProgress(0.618);
+ EXPECT_EQ(100, progress);
+ bar.SetProgress(62);
progress = bar.GetProgress();
- EXPECT_EQ(0.618, progress);
+ EXPECT_EQ(62, progress);
}
TEST(ProgressBarTest, TooltipTextProperty) {
@@ -36,7 +35,7 @@ TEST(ProgressBarTest, TooltipTextProperty) {
TEST(ProgressBarTest, Accessibility) {
ProgressBar bar;
- bar.SetProgress(0.618);
+ bar.SetProgress(62);
AccessibilityTypes::Role role;
EXPECT_TRUE(bar.GetAccessibleRole(&role));