Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
progress_bar.h
1 #pragma once
2 
3 #include "widget.h"
4 
5 namespace smlt {
6 namespace ui {
7 
8 enum ProgressBarMode {
9  PROGRESS_BAR_MODE_PULSE,
10  PROGRESS_BAR_MODE_FRACTION
11 };
12 
14  public Widget {
15 
16 public:
17  using Widget::init; // Pull in init to satisfy Managed<Button>
18  using Widget::clean_up;
19 
20  ProgressBar(UIManager* owner, UIConfig* config);
21  virtual ~ProgressBar();
22 
23  void pulse();
24  void set_pulse_step(Px value);
25  void set_pulse_fraction(float value);
26 
27  void set_fraction(float fraction);
28  void set_value(float value);
29  void set_range(float min, float max);
30 
31  float value() const;
32  float min() const;
33  float max() const;
34 
35  ProgressBarMode current_mode() const { return mode_; }
36 
37  void update(float dt) override;
38 private:
39  ProgressBarMode mode_ = PROGRESS_BAR_MODE_FRACTION;
40 
41  float value_ = 0.0f;
42  float min_ = 0.0f;
43  float max_ = 100.0f;
44 
45  float pulse_position_ = 0.0f;
46  float pulse_step_ = 300.0f;
47  float pulse_fraction_ = 0.33f;
48  bool pulse_right_ = true;
49  float pulse_width_ = 1.0f;
50  float fraction_ = 0.0f;
51 
52  bool needs_refresh_ = true;
53 
54  void refresh_pulse(float dt);
55  void refresh_fraction();
56  void refresh_bar(float dt);
57 
58  WidgetBounds calculate_foreground_size(const UIDim& content_dimensions) const override;
59 };
60 
61 }
62 }
smlt::ui::UIManager
Definition: ui_manager.h:54
smlt
Definition: animation.cpp:25
smlt::ui::Widget
Definition: widget.h:84
smlt::ui::UIConfig
Definition: ui_config.h:172
smlt::ui::Px
Definition: ui_config.h:37
smlt::ui::Widget::WidgetBounds
Definition: widget.h:273
smlt::ui::ProgressBar
Definition: progress_bar.h:14
smlt::ui::UIDim
Definition: ui_config.h:120