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..88422768ecf94d655b49aaf932ebbb04be5aef4b 100644 |
--- a/ui/views/controls/progress_bar.h |
+++ b/ui/views/controls/progress_bar.h |
@@ -7,58 +7,65 @@ |
#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(); |
~ProgressBar() override; |
- double current_value() const { return current_value_; } |
+ // This convenience function makes it easier to use ProgressBars with layout |
+ // managers that size to preferred size. |
+ void set_preferred_height(int preferred_height) { |
sky
2016/09/13 02:30:08
If the value changes won't this need to trigger a
Evan Stade
2016/09/13 15:45:39
Yea but I would expect that this is called by the
|
+ preferred_height_ = preferred_height; |
+ } |
- // 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; |
- // Inclusive range used when displaying values. |
- double min_display_value_; |
- double max_display_value_; |
+ bool IsIndeterminate(); |
+ void OnPaintIndeterminate(gfx::Canvas* canvas); |
- // Current value. May be outside of [min_display_value_, max_display_value_]. |
+ // Current progress to display, should be in the range 0.0 to 1.0. |
double current_value_; |
- // Tooltip text. |
- base::string16 tooltip_text_; |
+ // In DP, the preferred height of this progress bar. Default is 5. |
+ int preferred_height_; |
sky
2016/09/13 02:30:08
optional: = 5 and remove comment about default.
Evan Stade
2016/09/13 15:45:39
default moved to ctor
|
+ |
+ std::unique_ptr<gfx::LinearAnimation> indeterminate_bar_animation_; |
DISALLOW_COPY_AND_ASSIGN(ProgressBar); |
}; |