Skip to content

Commit

Permalink
chore: fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Nov 30, 2023
1 parent 2d6bea2 commit c46fe51
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 15 deletions.
1 change: 0 additions & 1 deletion examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ edition = "2021"
publish = false

[dependencies]
iced = "0.10.0"
cosmic-time = { path = "../..", default-features = false, features = ["iced", "once_cell"] }
2 changes: 1 addition & 1 deletion examples/counter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<id::Container> = Lazy::new(id::Container::unique);

Expand Down
2 changes: 1 addition & 1 deletion examples/pokedex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions examples/pokedex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<id::Space> = Lazy::new(id::Space::unique);
Expand Down
3 changes: 0 additions & 3 deletions examples/pong/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
25 changes: 21 additions & 4 deletions examples/pong/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 6 additions & 2 deletions examples/pong/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cosmic_time::reexports::iced_futures::event::listen_raw;
use iced::event;
use iced::keyboard::{self, KeyCode};
use iced::subscription;

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (ubuntu-latest, stable)

unused import: `iced::subscription`

Check failure on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / all

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (ubuntu-latest, beta)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (windows-latest, stable)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (windows-latest, beta)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (macOS-latest, stable)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (macOS-latest, beta)

unused import: `iced::subscription`

Check failure on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / all

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (ubuntu-latest, stable)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (ubuntu-latest, beta)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (windows-latest, stable)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (windows-latest, beta)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (macOS-latest, stable)

unused import: `iced::subscription`

Check warning on line 4 in examples/pong/src/main.rs

View workflow job for this annotation

GitHub Actions / native (macOS-latest, beta)

unused import: `iced::subscription`
Expand All @@ -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::*;
Expand Down Expand Up @@ -90,7 +94,7 @@ impl Application for Pong {
fn subscription(&self) -> Subscription<Message> {
Subscription::batch(vec![
self.timeline.as_subscription::<Event>().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,
Expand Down
3 changes: 3 additions & 0 deletions examples/pong/src/theme.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cosmic_time::reexports::iced;
use iced::widget::{container, text};
use iced::{application, color};

Expand Down Expand Up @@ -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<Theme>;
Expand Down
2 changes: 1 addition & 1 deletion examples/stopwatch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

0 comments on commit c46fe51

Please sign in to comment.