diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs
index 75d2ce08..82dac0cd 100644
--- a/examples/tour/src/main.rs
+++ b/examples/tour/src/main.rs
@@ -452,6 +452,7 @@ impl<'a> Step {
.map(Element::from)
.collect()
)
+ .spacing(10)
]
.padding(20)
.spacing(10);
@@ -594,10 +595,7 @@ fn ferris<'a>(width: u16) -> Container<'a, StepMessage> {
if cfg!(target_arch = "wasm32") {
image("tour/images/ferris.png")
} else {
- image(format!(
- "{}/../../tour/images/ferris.png",
- env!("CARGO_MANIFEST_DIR")
- ))
+ image(format!("{}/images/ferris.png", env!("CARGO_MANIFEST_DIR")))
}
.width(Length::Units(width)),
)
diff --git a/glutin/src/application.rs b/glutin/src/application.rs
index dddf0067..96b982ac 100644
--- a/glutin/src/application.rs
+++ b/glutin/src/application.rs
@@ -12,7 +12,7 @@ use iced_winit::futures;
use iced_winit::futures::channel::mpsc;
use iced_winit::renderer;
use iced_winit::user_interface;
-use iced_winit::{Clipboard, Debug, Proxy, Settings};
+use iced_winit::{Clipboard, Command, Debug, Proxy, Settings};
use glutin::window::Window;
use std::mem::ManuallyDrop;
@@ -39,9 +39,9 @@ where
debug.startup_started();
let mut event_loop = EventLoop::with_user_event();
- let mut proxy = event_loop.create_proxy();
+ let proxy = event_loop.create_proxy();
- let mut runtime = {
+ let runtime = {
let executor = E::new().map_err(Error::ExecutorCreationFailed)?;
let proxy = Proxy::new(event_loop.create_proxy());
@@ -54,8 +54,6 @@ where
runtime.enter(|| A::new(flags))
};
- let subscription = application.subscription();
-
let context = {
let builder = settings.window.into_builder(
&application.title(),
@@ -125,18 +123,6 @@ where
})?
};
- let mut clipboard = Clipboard::connect(context.window());
-
- application::run_command(
- init_command,
- &mut runtime,
- &mut clipboard,
- &mut proxy,
- context.window(),
- || compositor.fetch_information(),
- );
- runtime.track(subscription);
-
let (mut sender, receiver) = mpsc::unbounded();
let mut instance = Box::pin(run_instance::(
@@ -144,11 +130,11 @@ where
compositor,
renderer,
runtime,
- clipboard,
proxy,
debug,
receiver,
context,
+ init_command,
settings.exit_on_close_request,
));
@@ -196,11 +182,11 @@ async fn run_instance(
mut compositor: C,
mut renderer: A::Renderer,
mut runtime: Runtime, A::Message>,
- mut clipboard: Clipboard,
mut proxy: glutin::event_loop::EventLoopProxy,
mut debug: Debug,
mut receiver: mpsc::UnboundedReceiver>,
mut context: glutin::ContextWrapper,
+ init_command: Command,
exit_on_close_request: bool,
) where
A: Application + 'static,
@@ -211,9 +197,26 @@ async fn run_instance(
use glutin::event;
use iced_winit::futures::stream::StreamExt;
+ let mut clipboard = Clipboard::connect(&context.window());
+ let mut cache = user_interface::Cache::default();
let mut state = application::State::new(&application, context.window());
let mut viewport_version = state.viewport_version();
+ application::run_command(
+ &application,
+ &mut cache,
+ &state,
+ &mut renderer,
+ init_command,
+ &mut runtime,
+ &mut clipboard,
+ &mut proxy,
+ &mut debug,
+ context.window(),
+ || compositor.fetch_information(),
+ );
+ runtime.track(application.subscription());
+
let mut user_interface =
ManuallyDrop::new(application::build_user_interface(
&mut application,
@@ -258,12 +261,15 @@ async fn run_instance(
user_interface::State::Outdated
)
{
- let cache =
+ let mut cache =
ManuallyDrop::into_inner(user_interface).into_cache();
// Update application
application::update(
&mut application,
+ &mut cache,
+ &state,
+ &mut renderer,
&mut runtime,
&mut clipboard,
&mut proxy,
diff --git a/native/src/command.rs b/native/src/command.rs
index 89d0f045..b0b12805 100644
--- a/native/src/command.rs
+++ b/native/src/command.rs
@@ -3,6 +3,8 @@ mod action;
pub use action::Action;
+use crate::widget;
+
use iced_futures::MaybeSend;
use std::fmt;
@@ -24,6 +26,13 @@ impl Command {
Self(iced_futures::Command::single(action))
}
+ /// Creates a [`Command`] that performs a [`widget::Operation`].
+ pub fn widget(operation: impl widget::Operation + 'static) -> Self {
+ Self(iced_futures::Command::single(Action::Widget(
+ widget::Action::new(operation),
+ )))
+ }
+
/// Creates a [`Command`] that performs the action of the given future.
pub fn perform(
future: impl Future