mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Allow setting the progress bar height (#3183)
* allow setting the progress bar height * changelog entry * remove the changelog entry
This commit is contained in:
committed by
GitHub
parent
c722b7fd46
commit
87f12d782e
@@ -12,6 +12,7 @@ enum ProgressBarText {
|
|||||||
pub struct ProgressBar {
|
pub struct ProgressBar {
|
||||||
progress: f32,
|
progress: f32,
|
||||||
desired_width: Option<f32>,
|
desired_width: Option<f32>,
|
||||||
|
desired_height: Option<f32>,
|
||||||
text: Option<ProgressBarText>,
|
text: Option<ProgressBarText>,
|
||||||
fill: Option<Color32>,
|
fill: Option<Color32>,
|
||||||
animate: bool,
|
animate: bool,
|
||||||
@@ -23,6 +24,7 @@ impl ProgressBar {
|
|||||||
Self {
|
Self {
|
||||||
progress: progress.clamp(0.0, 1.0),
|
progress: progress.clamp(0.0, 1.0),
|
||||||
desired_width: None,
|
desired_width: None,
|
||||||
|
desired_height: None,
|
||||||
text: None,
|
text: None,
|
||||||
fill: None,
|
fill: None,
|
||||||
animate: false,
|
animate: false,
|
||||||
@@ -35,6 +37,12 @@ impl ProgressBar {
|
|||||||
self
|
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.
|
/// The fill color of the bar.
|
||||||
pub fn fill(mut self, color: Color32) -> Self {
|
pub fn fill(mut self, color: Color32) -> Self {
|
||||||
self.fill = Some(color);
|
self.fill = Some(color);
|
||||||
@@ -67,6 +75,7 @@ impl Widget for ProgressBar {
|
|||||||
let ProgressBar {
|
let ProgressBar {
|
||||||
progress,
|
progress,
|
||||||
desired_width,
|
desired_width,
|
||||||
|
desired_height,
|
||||||
text,
|
text,
|
||||||
fill,
|
fill,
|
||||||
animate,
|
animate,
|
||||||
@@ -76,7 +85,7 @@ impl Widget for ProgressBar {
|
|||||||
|
|
||||||
let desired_width =
|
let desired_width =
|
||||||
desired_width.unwrap_or_else(|| ui.available_size_before_wrap().x.at_least(96.0));
|
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) =
|
let (outer_rect, response) =
|
||||||
ui.allocate_exact_size(vec2(desired_width, height), Sense::hover());
|
ui.allocate_exact_size(vec2(desired_width, height), Sense::hover());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user