Remove Sandbox trait 🎉

This commit is contained in:
Héctor Ramón Jiménez 2024-03-17 13:46:52 +01:00
parent 9152904af1
commit 846d76cd3f
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 169 additions and 240 deletions

View file

@ -1,22 +1,17 @@
use iced::application;
use iced::gradient;
use iced::widget::{
checkbox, column, container, horizontal_space, row, slider, text,
};
use iced::{gradient, window};
use iced::{
Alignment, Color, Element, Length, Radians, Sandbox, Settings, Theme,
};
use iced::{Alignment, Color, Element, Length, Radians, Theme};
pub fn main() -> iced::Result {
tracing_subscriber::fmt::init();
Gradient::run(Settings {
window: window::Settings {
transparent: true,
..Default::default()
},
..Default::default()
})
iced::application("Gradient - Iced", Gradient::update, Gradient::view)
.style(Gradient::style)
.transparent(true)
.run()
}
#[derive(Debug, Clone, Copy)]
@ -35,9 +30,7 @@ enum Message {
TransparentToggled(bool),
}
impl Sandbox for Gradient {
type Message = Message;
impl Gradient {
fn new() -> Self {
Self {
start: Color::WHITE,
@ -47,10 +40,6 @@ impl Sandbox for Gradient {
}
}
fn title(&self) -> String {
String::from("Gradient")
}
fn update(&mut self, message: Message) {
match message {
Message::StartChanged(color) => self.start = color,
@ -118,6 +107,12 @@ impl Sandbox for Gradient {
}
}
impl Default for Gradient {
fn default() -> Self {
Self::new()
}
}
fn color_picker(label: &str, color: Color) -> Element<'_, Color> {
row![
text(label).width(64),