1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use imgui::{ImStr, ImVec2, ProgressBar, Ui};
#[derive(Copy, Clone)]
pub struct ProgressParams<'p> {
pub overlay: Option<&'p ImStr>,
pub size: Option<ImVec2>,
}
pub trait Progress {
fn build(ui: &Ui, elem: &Self, params: ProgressParams);
}
impl Progress for f32 {
fn build(ui: &Ui, elem: &Self, params: ProgressParams) {
let mut pro = ProgressBar::new(ui, *elem);
if let Some(overlay) = params.overlay {
pro = pro.overlay_text(overlay);
}
if let Some(size) = params.size {
pro = pro.size(size);
}
pro.build();
}
}
impl Progress for Option<f32> {
#[inline]
fn build(ui: &Ui, elem: &Self, params: ProgressParams) {
if let Some(elem) = elem {
f32::build(ui, elem, params)
}
}
}