Fix examples and doc-tests

This commit is contained in:
Héctor Ramón Jiménez 2022-05-26 23:12:11 +02:00
parent cf0230072c
commit d5bc610d01
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
9 changed files with 23 additions and 178 deletions

View file

@ -178,10 +178,7 @@ fn view_controls<'a>(
.width(Length::Fill)
.align_items(Alignment::Center)
.spacing(10)
.push(
slider(1.0..=1000.0, speed as f32, Message::SpeedChanged)
.style(style::Slider),
)
.push(slider(1.0..=1000.0, speed as f32, Message::SpeedChanged))
.push(text(format!("x{}", speed)).size(16));
row()

View file

@ -1,16 +1,4 @@
use iced::{container, pick_list, slider, Color};
const ACTIVE: Color = Color::from_rgb(
0x72 as f32 / 255.0,
0x89 as f32 / 255.0,
0xDA as f32 / 255.0,
);
const HOVERED: Color = Color::from_rgb(
0x67 as f32 / 255.0,
0x7B as f32 / 255.0,
0xC4 as f32 / 255.0,
);
use iced::{container, pick_list, Color};
pub const BACKGROUND: Color = Color::from_rgb(
0x2F as f32 / 255.0,
@ -29,46 +17,6 @@ impl container::StyleSheet for Container {
}
}
pub struct Slider;
impl slider::StyleSheet for Slider {
fn active(&self) -> slider::Style {
slider::Style {
rail_colors: (ACTIVE, Color { a: 0.1, ..ACTIVE }),
handle: slider::Handle {
shape: slider::HandleShape::Circle { radius: 9.0 },
color: ACTIVE,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
}
}
fn hovered(&self) -> slider::Style {
let active = self.active();
slider::Style {
handle: slider::Handle {
color: HOVERED,
..active.handle
},
..active
}
}
fn dragging(&self) -> slider::Style {
let active = self.active();
slider::Style {
handle: slider::Handle {
color: Color::from_rgb(0.85, 0.85, 0.85),
..active.handle
},
..active
}
}
}
pub struct PickList;
impl pick_list::StyleSheet for PickList {

View file

@ -6,7 +6,7 @@ use iced::pure::{
};
use iced::pure::{Element, Sandbox};
use iced::theme;
use iced::{Color, Length, Settings};
use iced::{Color, Length, Renderer, Settings};
pub fn main() -> iced::Result {
env_logger::init();
@ -622,7 +622,7 @@ fn button<'a, Message: Clone>(label: &str) -> Button<'a, Message> {
fn color_slider<'a>(
component: f32,
update: impl Fn(f32) -> Color + 'a,
) -> Slider<'a, f64, StepMessage> {
) -> Slider<'a, f64, StepMessage, Renderer> {
slider(0.0..=1.0, f64::from(component), move |c| {
StepMessage::TextColorChanged(update(c as f32))
})