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

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

Issue 2329633003: Implement progress bar spec (determinate and indeterminate). (Closed)
Patch Set: attempt to unbreak mac and unit test 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
« no previous file with comments | « ui/message_center/views/notification_view.cc ('k') | ui/views/controls/progress_bar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..aa09845c7a8cf1f7eddf3c74e702b65c797b9b9b 100644
--- a/ui/views/controls/progress_bar.h
+++ b/ui/views/controls/progress_bar.h
@@ -7,58 +7,60 @@
#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.
-class VIEWS_EXPORT ProgressBar : public View {
+class VIEWS_EXPORT ProgressBar : public View, public gfx::AnimationDelegate {
public:
- // The value range defaults to [0.0, 1.0].
- ProgressBar();
+ // The preferred height parameter makes it easier to use a ProgressBar with
+ // layout managers that size to preferred size.
+ explicit ProgressBar(int preferred_height = 5);
~ProgressBar() override;
- double current_value() const { return current_value_; }
-
- // 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;
+ // Overridden from View:
+ void GetAccessibleState(ui::AXViewState* state) override;
+ gfx::Size GetPreferredSize() const override;
+ const char* GetClassName() const override;
+ void OnPaint(gfx::Canvas* canvas) override;
- // Sets the inclusive range of values to be displayed. Values outside of the
- // range will be capped when displayed.
- void SetDisplayRange(double min_display_value, double max_display_value);
+ double current_value() const { return current_value_; }
- // Sets the current value. Values outside of the range [min_display_value_,
- // max_display_value_] will be stored unmodified and capped for display.
+ // Sets the current value. Values outside of the display range of 0.0-1.0 will
+ // be displayed with an infinite loading animation.
void SetValue(double value);
- // 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. To
- // revert to default behavior, call this with an empty string.
- void SetTooltipText(const base::string16& tooltip_text);
+ protected:
+ // The color of the progress portion.
+ SkColor GetForegroundColor() const;
+ // The color of the portion that displays potential progress.
+ SkColor GetBackgroundColor() const;
- // Overridden from View:
- bool GetTooltipText(const gfx::Point& p,
- base::string16* tooltip) const override;
- void GetAccessibleState(ui::AXViewState* state) override;
+ int preferred_height() const { return preferred_height_; }
private:
static const char kViewClassName[];
- // Overridden from View:
- gfx::Size GetPreferredSize() const override;
- const char* GetClassName() const override;
- void OnPaint(gfx::Canvas* canvas) override;
+ // gfx::AnimationDelegate:
+ void AnimationProgressed(const gfx::Animation* animation) override;
+ void AnimationEnded(const gfx::Animation* animation) override;
+
+ bool IsIndeterminate();
+ void OnPaintIndeterminate(gfx::Canvas* canvas);
- // Inclusive range used when displaying values.
- double min_display_value_;
- double max_display_value_;
+ // Current progress to display, should be in the range 0.0 to 1.0.
+ double current_value_ = 0.0;
- // Current value. May be outside of [min_display_value_, max_display_value_].
- double current_value_;
+ // In DP, the preferred height of this progress bar.
+ const int preferred_height_;
- // Tooltip text.
- base::string16 tooltip_text_;
+ std::unique_ptr<gfx::LinearAnimation> indeterminate_bar_animation_;
DISALLOW_COPY_AND_ASSIGN(ProgressBar);
};
« no previous file with comments | « ui/message_center/views/notification_view.cc ('k') | ui/views/controls/progress_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698