From c46fe5157398f3cc8319f46c1c115ae71eca92bc Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 30 Nov 2023 14:16:00 -0500 Subject: [PATCH] chore: fix examples --- examples/counter/Cargo.toml | 1 - examples/counter/src/main.rs | 2 +- examples/pokedex/Cargo.toml | 2 +- examples/pokedex/src/main.rs | 4 ++-- examples/pong/Cargo.toml | 3 --- examples/pong/src/layer.rs | 25 +++++++++++++++++++++---- examples/pong/src/main.rs | 8 ++++++-- examples/pong/src/theme.rs | 3 +++ examples/stopwatch/Cargo.toml | 2 +- 9 files changed, 35 insertions(+), 15 deletions(-) diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml index 73c4073..bde5aca 100644 --- a/examples/counter/Cargo.toml +++ b/examples/counter/Cargo.toml @@ -6,5 +6,4 @@ edition = "2021" publish = false [dependencies] -iced = "0.10.0" cosmic-time = { path = "../..", default-features = false, features = ["iced", "once_cell"] } diff --git a/examples/counter/src/main.rs b/examples/counter/src/main.rs index 171979f..fd6a542 100644 --- a/examples/counter/src/main.rs +++ b/examples/counter/src/main.rs @@ -5,7 +5,7 @@ use iced::{ Alignment, Application, Command, Element, Event, Length, Settings, Subscription, Theme, }; -use cosmic_time::{self, anim, chain, id, once_cell::sync::Lazy, Timeline}; +use cosmic_time::{self, anim, chain, id, once_cell::sync::Lazy, reexports::iced, Timeline}; static CONTAINER: Lazy = Lazy::new(id::Container::unique); diff --git a/examples/pokedex/Cargo.toml b/examples/pokedex/Cargo.toml index 430f692..41c7723 100644 --- a/examples/pokedex/Cargo.toml +++ b/examples/pokedex/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -iced = { version = "0.10.0", features = ["image", "debug", "tokio"] } +iced = { git = "https://github.com/iced-rs/iced", rev = "7f8b176", features = ["image", "debug", "tokio"] } cosmic-time = { path = "../..", default-features = false, features = ["iced", "once_cell"] } serde_json = "1.0" diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs index 76f1b7b..7f2dd1a 100644 --- a/examples/pokedex/src/main.rs +++ b/examples/pokedex/src/main.rs @@ -6,8 +6,8 @@ use iced::{ }; use cosmic_time::{ - self, anim, chain, id, once_cell::sync::Lazy, Back, Bounce, Circular, Ease, Elastic, - Exponential, Linear, Quadratic, Quartic, Quintic, Sinusoidal, Timeline, + self, anim, chain, id, once_cell::sync::Lazy, reexports::iced, Back, Bounce, Circular, Ease, + Elastic, Exponential, Linear, Quadratic, Quartic, Quintic, Sinusoidal, Timeline, }; static SPACE: Lazy = Lazy::new(id::Space::unique); diff --git a/examples/pong/Cargo.toml b/examples/pong/Cargo.toml index ed5db27..c94e9aa 100644 --- a/examples/pong/Cargo.toml +++ b/examples/pong/Cargo.toml @@ -6,8 +6,5 @@ edition = "2021" publish = false [dependencies] -iced = "0.10.0" -iced_core = "0.10.0" -iced_runtime = "0.1.1" cosmic-time = { path = "../..", default-features = false, features = ["iced", "once_cell"] } rand = "0.8.5" diff --git a/examples/pong/src/layer.rs b/examples/pong/src/layer.rs index f8f385e..30a4e0a 100644 --- a/examples/pong/src/layer.rs +++ b/examples/pong/src/layer.rs @@ -5,6 +5,7 @@ * */ +use cosmic_time::reexports::iced_core::{self, Vector}; use iced_core::widget::{self, Tree}; use iced_core::{ event, layout, mouse, overlay, renderer, Clipboard, Color, Element, Event, Layout, Length, @@ -51,8 +52,15 @@ where self.base.as_widget().height() } - fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> layout::Node { - self.base.as_widget().layout(renderer, limits) + fn layout( + &self, + tree: &mut Tree, + renderer: &Renderer, + limits: &layout::Limits, + ) -> layout::Node { + self.base + .as_widget() + .layout(&mut tree.children[0], renderer, limits) } fn on_event( @@ -157,12 +165,21 @@ where Renderer: iced_core::Renderer, Message: Clone, { - fn layout(&self, renderer: &Renderer, _bounds: Size, position: Point) -> layout::Node { + fn layout( + &mut self, + renderer: &Renderer, + _bounds: Size, + position: Point, + _translation: Vector, + ) -> layout::Node { let limits = layout::Limits::new(Size::ZERO, self.size) .width(Length::Fill) .height(Length::Fill); - let child = self.content.as_widget().layout(renderer, &limits); + let child = self + .content + .as_widget() + .layout(&mut self.tree.children[0], renderer, &limits); let mut node = layout::Node::with_children(self.size, vec![child]); node.move_to(position); diff --git a/examples/pong/src/main.rs b/examples/pong/src/main.rs index 104aa27..432e71d 100644 --- a/examples/pong/src/main.rs +++ b/examples/pong/src/main.rs @@ -1,3 +1,4 @@ +use cosmic_time::reexports::iced_futures::event::listen_raw; use iced::event; use iced::keyboard::{self, KeyCode}; use iced::subscription; @@ -6,7 +7,10 @@ use iced::{executor, Application, Command, Event, Length, Settings, Subscription use iced_core::window; use cosmic_time::{ - self, anim, chain, id, once_cell::sync::Lazy, Duration, Instant, Speed, Timeline, + self, anim, chain, id, + once_cell::sync::Lazy, + reexports::{iced, iced_core}, + Duration, Instant, Speed, Timeline, }; use rand::prelude::*; @@ -90,7 +94,7 @@ impl Application for Pong { fn subscription(&self) -> Subscription { Subscription::batch(vec![ self.timeline.as_subscription::().map(Message::Tick), - subscription::events_with(|event, status| match (event, status) { + listen_raw(|event, status| match (event, status) { ( Event::Keyboard(keyboard::Event::KeyPressed { key_code, diff --git a/examples/pong/src/theme.rs b/examples/pong/src/theme.rs index 1604643..5e6afa9 100644 --- a/examples/pong/src/theme.rs +++ b/examples/pong/src/theme.rs @@ -1,3 +1,4 @@ +use cosmic_time::reexports::iced; use iced::widget::{container, text}; use iced::{application, color}; @@ -57,6 +58,8 @@ impl container::StyleSheet for Theme { pub mod widget { #![allow(dead_code)] + use cosmic_time::reexports::iced; + use crate::theme::Theme; pub type Renderer = iced::Renderer; diff --git a/examples/stopwatch/Cargo.toml b/examples/stopwatch/Cargo.toml index df890a2..862e551 100644 --- a/examples/stopwatch/Cargo.toml +++ b/examples/stopwatch/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" publish = false [dependencies] -iced = { version = "0.10.0", features = ["smol"] } +iced = { git = "https://github.com/iced-rs/iced", rev = "7f8b176", features = ["smol"] } cosmic-time = { path = "../..", default-features = false, features = ["iced", "once_cell"] }