@@ -12,6 +12,7 @@ enum ProgressBarText {
12
12
pub struct ProgressBar {
13
13
progress : f32 ,
14
14
desired_width : Option < f32 > ,
15
+ desired_height : Option < f32 > ,
15
16
text : Option < ProgressBarText > ,
16
17
fill : Option < Color32 > ,
17
18
animate : bool ,
@@ -23,6 +24,7 @@ impl ProgressBar {
23
24
Self {
24
25
progress : progress. clamp ( 0.0 , 1.0 ) ,
25
26
desired_width : None ,
27
+ desired_height : None ,
26
28
text : None ,
27
29
fill : None ,
28
30
animate : false ,
@@ -35,6 +37,12 @@ impl ProgressBar {
35
37
self
36
38
}
37
39
40
+ /// The desired height of the bar. Will use the default interaction size if not set.
41
+ pub fn desired_height ( mut self , desired_height : f32 ) -> Self {
42
+ self . desired_height = Some ( desired_height) ;
43
+ self
44
+ }
45
+
38
46
/// The fill color of the bar.
39
47
pub fn fill ( mut self , color : Color32 ) -> Self {
40
48
self . fill = Some ( color) ;
@@ -67,6 +75,7 @@ impl Widget for ProgressBar {
67
75
let ProgressBar {
68
76
progress,
69
77
desired_width,
78
+ desired_height,
70
79
text,
71
80
fill,
72
81
animate,
@@ -76,7 +85,7 @@ impl Widget for ProgressBar {
76
85
77
86
let desired_width =
78
87
desired_width. unwrap_or_else ( || ui. available_size_before_wrap ( ) . x . at_least ( 96.0 ) ) ;
79
- let height = ui. spacing ( ) . interact_size . y ;
88
+ let height = desired_height . unwrap_or ( ui. spacing ( ) . interact_size . y ) ;
80
89
let ( outer_rect, response) =
81
90
ui. allocate_exact_size ( vec2 ( desired_width, height) , Sense :: hover ( ) ) ;
82
91
0 commit comments