From d4743183d40c6044ce6fa39e2a52919a32912cda Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 14:23:28 +0200 Subject: Draft first working version of `iced_glow` :tada: --- examples/tour/src/main.rs | 68 +++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'examples/tour/src/main.rs') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index c9678b9d..729ae8fb 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -1,13 +1,20 @@ -use iced::{ - button, scrollable, slider, text_input, Button, Checkbox, Color, Column, - Container, Element, HorizontalAlignment, Image, Length, Radio, Row, - Sandbox, Scrollable, Settings, Slider, Space, Text, TextInput, +use iced_glow::{ + button, scrollable, slider, text_input, window, Button, Checkbox, Color, + Column, Command, Container, Element, HorizontalAlignment, Image, Length, + Radio, Row, Scrollable, Slider, Space, Text, TextInput, }; +use iced_winit::{executor, Application, Settings}; pub fn main() { env_logger::init(); - Tour::run(Settings::default()) + Tour::run( + Settings::default(), + iced_glow::Settings { + default_font: None, + antialiasing: None, + }, + ) } pub struct Tour { @@ -18,24 +25,30 @@ pub struct Tour { debug: bool, } -impl Sandbox for Tour { +impl Application for Tour { + type Backend = window::Backend; + type Executor = executor::Null; type Message = Message; - - fn new() -> Tour { - Tour { - steps: Steps::new(), - scroll: scrollable::State::new(), - back_button: button::State::new(), - next_button: button::State::new(), - debug: false, - } + type Flags = (); + + fn new(_flags: ()) -> (Tour, Command) { + ( + Tour { + steps: Steps::new(), + scroll: scrollable::State::new(), + back_button: button::State::new(), + next_button: button::State::new(), + debug: false, + }, + Command::none(), + ) } fn title(&self) -> String { format!("{} - Iced", self.steps.title()) } - fn update(&mut self, event: Message) { + fn update(&mut self, event: Message) -> Command { match event { Message::BackPressed => { self.steps.go_back(); @@ -47,6 +60,8 @@ impl Sandbox for Tour { self.steps.update(step_msg, &mut self.debug); } } + + Command::none() } fn view(&mut self) -> Element { @@ -678,17 +693,18 @@ impl<'a> Step { fn ferris<'a>(width: u16) -> Container<'a, StepMessage> { Container::new( + Text::new("Not supported yet!") // This should go away once we unify resource loading on native // platforms - if cfg!(target_arch = "wasm32") { - Image::new("images/ferris.png") - } else { - Image::new(format!( - "{}/images/ferris.png", - env!("CARGO_MANIFEST_DIR") - )) - } - .width(Length::Units(width)), + //if cfg!(target_arch = "wasm32") { + // Image::new("images/ferris.png") + //} else { + // Image::new(format!( + // "{}/images/ferris.png", + // env!("CARGO_MANIFEST_DIR") + // )) + //} + //.width(Length::Units(width)), ) .width(Length::Fill) .center_x() @@ -749,7 +765,7 @@ pub enum Layout { } mod style { - use iced::{button, Background, Color, Vector}; + use iced_glow::{button, Background, Color, Vector}; pub enum Button { Primary, -- cgit From 4aed0fa4b6d63b739b5557ef16f6077988cd2758 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 20:01:55 +0200 Subject: Rename `window::Backend` to `Compositor` --- examples/tour/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/tour/src/main.rs') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 729ae8fb..8c3b1d19 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -26,7 +26,7 @@ pub struct Tour { } impl Application for Tour { - type Backend = window::Backend; + type Compositor = window::Compositor; type Executor = executor::Null; type Message = Message; type Flags = (); -- cgit From e0e4ee73feead3f05730625c7e1917b63f0b384e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 May 2020 00:37:47 +0200 Subject: Implement `iced_glutin` :tada: --- examples/tour/src/main.rs | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'examples/tour/src/main.rs') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 8c3b1d19..ca7a4f5d 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -1,20 +1,14 @@ -use iced_glow::{ - button, scrollable, slider, text_input, window, Button, Checkbox, Color, - Column, Command, Container, Element, HorizontalAlignment, Image, Length, - Radio, Row, Scrollable, Slider, Space, Text, TextInput, +use iced::{ + button, executor, scrollable, slider, text_input, Application, Button, + Checkbox, Color, Column, Command, Container, Element, HorizontalAlignment, + Image, Length, Radio, Row, Scrollable, Settings, Slider, Space, Text, + TextInput, }; -use iced_winit::{executor, Application, Settings}; pub fn main() { env_logger::init(); - Tour::run( - Settings::default(), - iced_glow::Settings { - default_font: None, - antialiasing: None, - }, - ) + Tour::run(Settings::default()) } pub struct Tour { @@ -26,7 +20,6 @@ pub struct Tour { } impl Application for Tour { - type Compositor = window::Compositor; type Executor = executor::Null; type Message = Message; type Flags = (); @@ -693,18 +686,17 @@ impl<'a> Step { fn ferris<'a>(width: u16) -> Container<'a, StepMessage> { Container::new( - Text::new("Not supported yet!") // This should go away once we unify resource loading on native // platforms - //if cfg!(target_arch = "wasm32") { - // Image::new("images/ferris.png") - //} else { - // Image::new(format!( - // "{}/images/ferris.png", - // env!("CARGO_MANIFEST_DIR") - // )) - //} - //.width(Length::Units(width)), + if cfg!(target_arch = "wasm32") { + Image::new("images/ferris.png") + } else { + Image::new(format!( + "{}/images/ferris.png", + env!("CARGO_MANIFEST_DIR") + )) + } + .width(Length::Units(width)), ) .width(Length::Fill) .center_x() @@ -765,7 +757,7 @@ pub enum Layout { } mod style { - use iced_glow::{button, Background, Color, Vector}; + use iced::{button, Background, Color, Vector}; pub enum Button { Primary, -- cgit From 45511a442f707e93fe6e568d2100756b63af7362 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 27 May 2020 23:17:21 +0200 Subject: Target physical pixels for quads in `iced_glow` --- examples/tour/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/tour/src/main.rs') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index ca7a4f5d..c0bd2efe 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -772,7 +772,7 @@ mod style { Button::Secondary => Color::from_rgb(0.5, 0.5, 0.5), })), border_radius: 12, - shadow_offset: Vector::new(1.0, 1.0), + shadow_offset: Vector::new(0.0, 1.0), text_color: Color::from_rgb8(0xEE, 0xEE, 0xEE), ..button::Style::default() } @@ -781,7 +781,7 @@ mod style { fn hovered(&self) -> button::Style { button::Style { text_color: Color::WHITE, - shadow_offset: Vector::new(1.0, 2.0), + shadow_offset: Vector::new(0.0, 2.0), ..self.active() } } -- cgit