use super::{NcProgBar, NcProgBarOptions};
use crate::{c_api, error, NcPlane, NcResult};
impl NcProgBarOptions {
pub fn new() -> Self {
Self { ulchannel: 0, urchannel: 0, blchannel: 0, brchannel: 0, flags: 0 }
}
}
impl NcProgBar {
pub fn new<'a>(plane: &mut NcPlane) -> &'a mut Self {
Self::with_options(plane, &NcProgBarOptions::new())
}
pub fn with_options<'a>(plane: &mut NcPlane, options: &NcProgBarOptions) -> &'a mut Self {
unsafe { &mut *c_api::ncprogbar_create(plane, options) }
}
pub fn destroy(&mut self) {
unsafe {
c_api::ncprogbar_destroy(self);
}
}
pub fn plane(&mut self) -> &mut NcPlane {
unsafe { &mut *c_api::ncprogbar_plane(self) }
}
pub fn progress(&self) -> f64 {
unsafe { c_api::ncprogbar_progress(self) }
}
pub fn set_progress(&mut self, progress: f64) -> NcResult<()> {
error![unsafe { c_api::ncprogbar_set_progress(self, progress) }]
}
}