From bd862fcd94bd97b48be4b87a11a9e38505f4d518 Mon Sep 17 00:00:00 2001 From: Sven Niederberger Date: Thu, 27 Jul 2023 13:35:18 +0200 Subject: [PATCH 1/3] allow setting the progress bar height --- crates/egui/src/widgets/progress_bar.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/progress_bar.rs b/crates/egui/src/widgets/progress_bar.rs index ef6d16c3da3..239069595e9 100644 --- a/crates/egui/src/widgets/progress_bar.rs +++ b/crates/egui/src/widgets/progress_bar.rs @@ -12,6 +12,7 @@ enum ProgressBarText { pub struct ProgressBar { progress: f32, desired_width: Option, + desired_height: Option, text: Option, fill: Option, 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()); From a3b9a6279448807cf4432b5038340986d839d9b7 Mon Sep 17 00:00:00 2001 From: Sven Niederberger Date: Thu, 27 Jul 2023 13:37:02 +0200 Subject: [PATCH 2/3] changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cddbc286a00..9f62c62b66b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ NOTE: [`epaint`](crates/epaint/CHANGELOG.md), [`eframe`](crates/eframe/CHANGELOG ## Unreleased +### ⭐ Added +* The progress bar height can now be customized [#3183](https://github.com/emilk/egui/pull/3183) ## 0.22.0 - 2023-05-23 - A plethora of small improvements ### ⭐ Added From 4edbdbd17d243b12a90c12d92ee82811b2d3ef5c Mon Sep 17 00:00:00 2001 From: Sven Niederberger Date: Wed, 23 Aug 2023 09:13:06 +0200 Subject: [PATCH 3/3] remove the changelog entry --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f62c62b66b..cddbc286a00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,6 @@ NOTE: [`epaint`](crates/epaint/CHANGELOG.md), [`eframe`](crates/eframe/CHANGELOG ## Unreleased -### ⭐ Added -* The progress bar height can now be customized [#3183](https://github.com/emilk/egui/pull/3183) ## 0.22.0 - 2023-05-23 - A plethora of small improvements ### ⭐ Added