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

Unified Diff: ui/views/controls/progress_bar.h

Issue 2329633003: Implement progress bar spec (determinate and indeterminate). (Closed)
Patch Set: better example code Created 4 years, 3 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: ui/views/controls/progress_bar.h
diff --git a/ui/views/controls/progress_bar.h b/ui/views/controls/progress_bar.h
index 3fb5fb7f7f2cb496608d1aae9f3e0be7da7e2a5e..1189ec6633b5d602c9587666ee621dbdb4fdc939 100644
--- a/ui/views/controls/progress_bar.h
+++ b/ui/views/controls/progress_bar.h
@@ -7,8 +7,13 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "ui/gfx/animation/animation_delegate.h"
#include "ui/views/view.h"
+namespace gfx {
+class LinearAnimation;
+}
+
namespace views {
// Progress bar is a control that indicates progress visually.
@@ -20,6 +25,8 @@ class VIEWS_EXPORT ProgressBar : public View {
double current_value() const { return current_value_; }
+ virtual bool is_indeterminate() = 0;
+
// Gets a normalized current value in [0.0, 1.0] range based on current value
// range and the min/max display value range.
double GetNormalizedValue() const;
@@ -41,15 +48,19 @@ class VIEWS_EXPORT ProgressBar : public View {
bool GetTooltipText(const gfx::Point& p,
base::string16* tooltip) const override;
void GetAccessibleState(ui::AXViewState* state) override;
+ gfx::Size GetPreferredSize() const override;
+ const char* GetClassName() const override;
+ void OnPaint(gfx::Canvas* canvas) override = 0;
+
+ protected:
+ // The color of the progress portion.
+ SkColor GetForegroundColor() const;
+ // The color of the portion that displays potential progress.
+ SkColor GetBackgroundColor() const;
private:
static const char kViewClassName[];
- // Overridden from View:
- gfx::Size GetPreferredSize() const override;
- const char* GetClassName() const override;
- void OnPaint(gfx::Canvas* canvas) override;
-
// Inclusive range used when displaying values.
double min_display_value_;
double max_display_value_;
@@ -63,6 +74,41 @@ class VIEWS_EXPORT ProgressBar : public View {
DISALLOW_COPY_AND_ASSIGN(ProgressBar);
};
+class VIEWS_EXPORT DeterminateProgressBar : public ProgressBar {
tdanderson 2016/09/12 17:11:13 Class-level descriptions would be nice to include
Evan Stade 2016/09/13 02:05:14 Done.
+ public:
+ DeterminateProgressBar();
+ ~DeterminateProgressBar() override;
+
+ bool is_indeterminate() override;
+
+ private:
+ // Overriden from views::ProgressBar (originally from views::View)
+ void OnPaint(gfx::Canvas* canvas) override;
+
+ DISALLOW_COPY_AND_ASSIGN(DeterminateProgressBar);
+};
+
+class VIEWS_EXPORT IndeterminateProgressBar : public DeterminateProgressBar,
tdanderson 2016/09/12 17:11:13 I don't understand why you have chosen to have IPB
Evan Stade 2016/09/13 02:05:14 I don't understand either. Just a brain fart. I s
+ public gfx::AnimationDelegate {
+ public:
+ IndeterminateProgressBar();
+ ~IndeterminateProgressBar() override;
+
+ bool is_indeterminate() override;
+
+ private:
+ // Overriden from views::ProgressBar (originally from views::View)
+ void OnPaint(gfx::Canvas* canvas) override;
+
+ // Overriden from gfx::AnimationDelegate
+ void AnimationProgressed(const gfx::Animation* animation) override;
+ void AnimationEnded(const gfx::Animation* animation) override;
+
+ std::unique_ptr<gfx::LinearAnimation> indeterminate_bar_animation_;
+
+ DISALLOW_COPY_AND_ASSIGN(IndeterminateProgressBar);
+};
+
} // namespace views
#endif // UI_VIEWS_CONTROLS_PROGRESS_BAR_H_

Powered by Google App Engine
This is Rietveld 408576698