Allow setting the progress bar height (#3183)

* allow setting the progress bar height

* changelog entry

* remove the changelog entry
This commit is contained in:
Sven Niederberger 2023-08-27 14:28:55 +02:00 committed by GitHub
parent c722b7fd46
commit 87f12d782e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -12,6 +12,7 @@ enum ProgressBarText {
pub struct ProgressBar {
progress: f32,
desired_width: Option<f32>,
desired_height: Option<f32>,
text: Option<ProgressBarText>,
fill: Option<Color32>,
animate: bool,
@ -23,6 +24,7 @@ impl ProgressBar {
Self {
progress: progress.clamp(0.0, 1.0),
desired_width: None,
desired_height: None,
text: None,
fill: None,
animate: false,
@ -35,6 +37,12 @@ impl ProgressBar {
self
}
/// The desired height of the bar. Will use the default interaction size if not set.
pub fn desired_height(mut self, desired_height: f32) -> Self {
self.desired_height = Some(desired_height);
self
}
/// The fill color of the bar.
pub fn fill(mut self, color: Color32) -> Self {
self.fill = Some(color);
@ -67,6 +75,7 @@ impl Widget for ProgressBar {
let ProgressBar {
progress,
desired_width,
desired_height,
text,
fill,
animate,
@ -76,7 +85,7 @@ impl Widget for ProgressBar {
let desired_width =
desired_width.unwrap_or_else(|| ui.available_size_before_wrap().x.at_least(96.0));
let height = ui.spacing().interact_size.y;
let height = desired_height.unwrap_or(ui.spacing().interact_size.y);
let (outer_rect, response) =
ui.allocate_exact_size(vec2(desired_width, height), Sense::hover());