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..605e081f046bc80a4bcca48c2436d36ecc216fa4 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. |
+ int preferred_height_; |
sky
2016/09/13 19:22:15
const
Evan Stade
2016/09/13 22:01:24
Done.
|
- // Tooltip text. |
- base::string16 tooltip_text_; |
+ std::unique_ptr<gfx::LinearAnimation> indeterminate_bar_animation_; |
DISALLOW_COPY_AND_ASSIGN(ProgressBar); |
}; |