Skip to content

Commit

Permalink
ui: Use ZeroOne type for ProgressBar widget progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Oct 24, 2024
1 parent d04fa4a commit 47a9186
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions all-is-cubes-ui/src/vui/widgets/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use num_traits::float::FloatCore as _;

use all_is_cubes::block::{self, Block, Composite, CompositeOperator, AIR};
use all_is_cubes::color_block;
use all_is_cubes::euclid::num::Zero as _;
use all_is_cubes::listen::{DirtyFlag, ListenableSource};
use all_is_cubes::math::{Face6, GridAab, GridCoordinate, GridSize, NotNan, Rgb};
use all_is_cubes::math::{Face6, GridAab, GridCoordinate, GridSize, Rgb, ZeroOne};
use all_is_cubes::space::SpaceTransaction;

use crate::vui;
Expand All @@ -35,7 +34,7 @@ pub struct ProgressBar {
#[non_exhaustive]
pub struct ProgressBarState {
/// A number from 0 to 1 which specifies how much of the progress bar is full.
fraction: NotNan<f64>,
fraction: ZeroOne<f64>,
}

/// Identical to [`ProgressBarState`] except rounded to the finest granularity we distinguish.
Expand Down Expand Up @@ -89,7 +88,7 @@ impl ProgressBarState {
/// full. If it is `NaN`, zero is substituted.
pub fn new(fraction: f64) -> Self {
Self {
fraction: NotNan::new(fraction.clamp(0.0, 1.0)).unwrap_or(NotNan::zero()),
fraction: ZeroOne::try_from(fraction.clamp(0.0, 1.0)).unwrap_or(ZeroOne::ZERO),
}
}
}
Expand Down

0 comments on commit 47a9186

Please sign in to comment.