#ifndef UI_VIEWS_CONTROLS_PROGRESS_BAR_H_
#define UI_VIEWS_CONTROLS_PROGRESS_BAR_H_
#include <memory>
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/color/color_id.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/views/view.h"
namespace gfx {
class LinearAnimation;
}
namespace views {
class VIEWS_EXPORT ProgressBar : public View, public gfx::AnimationDelegate {
public:
METADATA_HEADER(ProgressBar);
explicit ProgressBar(int preferred_height = 5,
bool allow_round_corner = true);
ProgressBar(const ProgressBar&) = delete;
ProgressBar& operator=(const ProgressBar&) = delete;
~ProgressBar() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
gfx::Size CalculatePreferredSize() const override;
void VisibilityChanged(View* starting_from, bool is_visible) override;
void AddedToWidget() override;
void OnPaint(gfx::Canvas* canvas) override;
double GetValue() const;
void SetValue(double value);
void SetPaused(bool is_paused);
SkColor GetForegroundColor() const;
void SetForegroundColor(SkColor color);
absl::optional<ui::ColorId> GetForegroundColorId() const;
void SetForegroundColorId(absl::optional<ui::ColorId> color_id);
SkColor GetBackgroundColor() const;
void SetBackgroundColor(SkColor color);
absl::optional<ui::ColorId> GetBackgroundColorId() const;
void SetBackgroundColorId(absl::optional<ui::ColorId> color_id);
protected:
int preferred_height() const { return preferred_height_; }
private:
void AnimationProgressed(const gfx::Animation* animation) override;
void AnimationEnded(const gfx::Animation* animation) override;
bool IsIndeterminate();
bool GetPaused() const { return is_paused_; }
void OnPaintIndeterminate(gfx::Canvas* canvas);
void MaybeNotifyAccessibilityValueChanged();
double current_value_ = 0.0;
bool is_paused_ = false;
const int preferred_height_;
const bool allow_round_corner_;
absl::optional<SkColor> foreground_color_;
absl::optional<ui::ColorId> foreground_color_id_;
absl::optional<SkColor> background_color_;
absl::optional<ui::ColorId> background_color_id_;
std::unique_ptr<gfx::LinearAnimation> indeterminate_bar_animation_;
int last_announced_percentage_ = -1;
};
}
#endif