From 7354f68b3ca345767de3f09dccddf168493977bf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 12 Jan 2023 02:59:08 +0100 Subject: Draft `Shell:request_redraw` API ... and implement `TextInput` cursor blink :tada: --- native/src/subscription.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'native/src/subscription.rs') diff --git a/native/src/subscription.rs b/native/src/subscription.rs index c60b1281..980a8116 100644 --- a/native/src/subscription.rs +++ b/native/src/subscription.rs @@ -1,5 +1,6 @@ //! Listen to external events in your application. use crate::event::{self, Event}; +use crate::window; use crate::Hasher; use iced_futures::futures::{self, Future, Stream}; @@ -33,7 +34,7 @@ pub type Tracker = pub use iced_futures::subscription::Recipe; -/// Returns a [`Subscription`] to all the runtime events. +/// Returns a [`Subscription`] to all the ignored runtime events. /// /// This subscription will notify your application of any [`Event`] that was /// not captured by any widget. @@ -65,7 +66,10 @@ where use futures::stream::StreamExt; events.filter_map(move |(event, status)| { - future::ready(f(event, status)) + future::ready(match event { + Event::Window(window::Event::RedrawRequested(_)) => None, + _ => f(event, status), + }) }) }, }) -- cgit From 0b86c4a299d384cafca31206eac8c94f1123518d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 12 Jan 2023 04:35:41 +0100 Subject: Implement `window::frames` subscription ... and use it in the `solar_system` example :tada: --- native/src/subscription.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'native/src/subscription.rs') diff --git a/native/src/subscription.rs b/native/src/subscription.rs index 980a8116..4c0d80a7 100644 --- a/native/src/subscription.rs +++ b/native/src/subscription.rs @@ -59,8 +59,11 @@ pub fn events_with( where Message: 'static + MaybeSend, { + #[derive(Hash)] + struct EventsWith; + Subscription::from_recipe(Runner { - id: f, + id: (EventsWith, f), spawn: move |events| { use futures::future; use futures::stream::StreamExt; @@ -75,6 +78,28 @@ where }) } +pub(crate) fn raw_events( + f: fn(Event, event::Status) -> Option, +) -> Subscription +where + Message: 'static + MaybeSend, +{ + #[derive(Hash)] + struct RawEvents; + + Subscription::from_recipe(Runner { + id: (RawEvents, f), + spawn: move |events| { + use futures::future; + use futures::stream::StreamExt; + + events.filter_map(move |(event, status)| { + future::ready(f(event, status)) + }) + }, + }) +} + /// Returns a [`Subscription`] that will create and asynchronously run the /// given [`Stream`]. /// -- cgit From 9fe46de13f86967543de8f00b5a4f9e45d8f5bcf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 14 Jan 2023 00:49:58 +0100 Subject: Bump versions :tada: --- native/src/subscription.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native/src/subscription.rs') diff --git a/native/src/subscription.rs b/native/src/subscription.rs index 4c0d80a7..8c92efad 100644 --- a/native/src/subscription.rs +++ b/native/src/subscription.rs @@ -184,7 +184,7 @@ where /// Check out the [`websocket`] example, which showcases this pattern to maintain a WebSocket /// connection open. /// -/// [`websocket`]: https://github.com/iced-rs/iced/tree/0.6/examples/websocket +/// [`websocket`]: https://github.com/iced-rs/iced/tree/0.7/examples/websocket pub fn unfold( id: I, initial: T, -- cgit