Merge branch 'master' into feature/custom-styling
This commit is contained in:
commit
bbc8f837d7
20 changed files with 818 additions and 9 deletions
|
|
@ -3,6 +3,7 @@ mod checkbox;
|
|||
mod column;
|
||||
mod container;
|
||||
mod image;
|
||||
mod progress_bar;
|
||||
mod radio;
|
||||
mod row;
|
||||
mod scrollable;
|
||||
|
|
|
|||
51
wgpu/src/renderer/widget/progress_bar.rs
Normal file
51
wgpu/src/renderer/widget/progress_bar.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
use crate::{Primitive, Renderer};
|
||||
use iced_native::{progress_bar, Background, Color, MouseCursor, Rectangle};
|
||||
|
||||
impl progress_bar::Renderer for Renderer {
|
||||
const DEFAULT_HEIGHT: u16 = 30;
|
||||
|
||||
fn draw(
|
||||
&self,
|
||||
bounds: Rectangle,
|
||||
range: std::ops::RangeInclusive<f32>,
|
||||
value: f32,
|
||||
background: Option<Background>,
|
||||
active_color: Option<Color>,
|
||||
) -> Self::Output {
|
||||
let (range_start, range_end) = range.into_inner();
|
||||
let active_progress_width = bounds.width
|
||||
* ((value - range_start) / (range_end - range_start).max(1.0));
|
||||
|
||||
let background = Primitive::Group {
|
||||
primitives: vec![Primitive::Quad {
|
||||
bounds: Rectangle { ..bounds },
|
||||
background: background
|
||||
.unwrap_or(Background::Color([0.6, 0.6, 0.6].into()))
|
||||
.into(),
|
||||
border_radius: 5,
|
||||
border_width: 0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
}],
|
||||
};
|
||||
|
||||
let active_progress = Primitive::Quad {
|
||||
bounds: Rectangle {
|
||||
width: active_progress_width,
|
||||
..bounds
|
||||
},
|
||||
background: Background::Color(
|
||||
active_color.unwrap_or([0.0, 0.95, 0.0].into()),
|
||||
),
|
||||
border_radius: 5,
|
||||
border_width: 0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
};
|
||||
|
||||
(
|
||||
Primitive::Group {
|
||||
primitives: vec![background, active_progress],
|
||||
},
|
||||
MouseCursor::OutOfBounds,
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue