use crate::math::MintVec2;
use crate::sys;
use crate::Ui;
#[derive(Copy, Clone, Debug)]
#[must_use]
pub struct ProgressBar<T = &'static str> {
fraction: f32,
size: [f32; 2],
overlay_text: Option<T>,
}
impl ProgressBar {
#[inline]
#[doc(alias = "ProgressBar")]
pub fn new(fraction: f32) -> Self {
ProgressBar {
fraction,
size: [-1.0, 0.0],
overlay_text: None,
}
}
}
impl<T: AsRef<str>> ProgressBar<T> {
pub fn overlay_text<T2: AsRef<str>>(self, overlay_text: T2) -> ProgressBar<T2> {
ProgressBar {
fraction: self.fraction,
size: self.size,
overlay_text: Some(overlay_text),
}
}
#[inline]
pub fn size(mut self, size: impl Into<MintVec2>) -> Self {
self.size = size.into().into();
self
}
pub fn build(self, ui: &Ui) {
unsafe {
sys::igProgressBar(
self.fraction,
self.size.into(),
ui.scratch_txt_opt(self.overlay_text),
);
}
}
}