summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--runtime/Cargo.toml (renamed from native/Cargo.toml)10
-rw-r--r--runtime/README.md (renamed from native/README.md)20
-rw-r--r--runtime/src/clipboard.rs (renamed from native/src/clipboard.rs)37
-rw-r--r--runtime/src/command.rs (renamed from native/src/command.rs)55
-rw-r--r--runtime/src/command/action.rs (renamed from native/src/command/action.rs)8
-rw-r--r--runtime/src/debug/basic.rs (renamed from native/src/debug/basic.rs)2
-rw-r--r--runtime/src/debug/null.rs (renamed from native/src/debug/null.rs)0
-rw-r--r--runtime/src/font.rs (renamed from native/src/font.rs)0
-rw-r--r--runtime/src/keyboard.rs (renamed from native/src/keyboard.rs)0
-rw-r--r--runtime/src/lib.rs (renamed from native/src/lib.rs)45
-rw-r--r--runtime/src/program.rs (renamed from native/src/program.rs)6
-rw-r--r--runtime/src/program/state.rs (renamed from native/src/program/state.rs)18
-rw-r--r--runtime/src/system.rs (renamed from native/src/system.rs)0
-rw-r--r--runtime/src/system/action.rs (renamed from native/src/system/action.rs)0
-rw-r--r--runtime/src/system/information.rs (renamed from native/src/system/information.rs)0
-rw-r--r--runtime/src/user_interface.rs (renamed from native/src/user_interface.rs)82
-rw-r--r--runtime/src/window.rs (renamed from winit/src/window.rs)70
-rw-r--r--runtime/src/window/action.rs (renamed from native/src/window/action.rs)4
18 files changed, 154 insertions, 203 deletions
diff --git a/native/Cargo.toml b/runtime/Cargo.toml
index 3f92783e..2d3e8db3 100644
--- a/native/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "iced_native"
+name = "iced_runtime"
version = "0.9.1"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
@@ -11,9 +11,7 @@ repository = "https://github.com/iced-rs/iced"
debug = []
[dependencies]
-twox-hash = { version = "1.5", default-features = false }
-unicode-segmentation = "1.6"
-num-traits = "0.2"
+thiserror = "1"
[dependencies.iced_core]
version = "0.8"
@@ -23,7 +21,3 @@ path = "../core"
version = "0.6"
path = "../futures"
features = ["thread-pool"]
-
-[dependencies.iced_style]
-version = "0.7"
-path = "../style"
diff --git a/native/README.md b/runtime/README.md
index 996daa76..497fd145 100644
--- a/native/README.md
+++ b/runtime/README.md
@@ -1,22 +1,10 @@
-# `iced_native`
+# `iced_runtime`
[![Documentation](https://docs.rs/iced_native/badge.svg)][documentation]
[![Crates.io](https://img.shields.io/crates/v/iced_native.svg)](https://crates.io/crates/iced_native)
[![License](https://img.shields.io/crates/l/iced_native.svg)](https://github.com/iced-rs/iced/blob/master/LICENSE)
[![Discord Server](https://img.shields.io/discord/628993209984614400?label=&labelColor=6A7EC2&logo=discord&logoColor=ffffff&color=7389D8)](https://discord.gg/3xZJ65GAhd)
-`iced_native` takes [`iced_core`] and builds a native runtime on top of it, featuring:
-- A custom layout engine, greatly inspired by [`druid`]
-- Event handling for all the built-in widgets
-- A renderer-agnostic API
-
-To achieve this, it introduces a bunch of reusable interfaces:
-- A `Widget` trait, which is used to implement new widgets: from layout requirements to event and drawing logic.
-- A bunch of `Renderer` traits, meant to keep the crate renderer-agnostic.
-- A `Windowed` trait, leveraging [`raw-window-handle`], which can be implemented by graphical renderers that target _windows_. Window-based shells (like [`iced_winit`]) can use this trait to stay renderer-agnostic.
-
-<p align="center">
- <img alt="The native target" src="../docs/graphs/native.png" width="80%">
-</p>
+`iced_runtime` takes [`iced_core`] and builds a native runtime on top of it.
[documentation]: https://docs.rs/iced_native
[`iced_core`]: ../core
@@ -25,10 +13,10 @@ To achieve this, it introduces a bunch of reusable interfaces:
[`raw-window-handle`]: https://github.com/rust-windowing/raw-window-handle
## Installation
-Add `iced_native` as a dependency in your `Cargo.toml`:
+Add `iced_runtime` as a dependency in your `Cargo.toml`:
```toml
-iced_native = "0.9"
+iced_runtime = "0.9"
```
__Iced moves fast and the `master` branch can contain breaking changes!__ If
diff --git a/native/src/clipboard.rs b/runtime/src/clipboard.rs
index c9105bc0..bc450912 100644
--- a/native/src/clipboard.rs
+++ b/runtime/src/clipboard.rs
@@ -1,30 +1,9 @@
//! Access the clipboard.
-use iced_futures::MaybeSend;
+use crate::command::{self, Command};
+use crate::futures::MaybeSend;
use std::fmt;
-/// A buffer for short-term storage and transfer within and between
-/// applications.
-pub trait Clipboard {
- /// Reads the current content of the [`Clipboard`] as text.
- fn read(&self) -> Option<String>;
-
- /// Writes the given text contents to the [`Clipboard`].
- fn write(&mut self, contents: String);
-}
-
-/// A null implementation of the [`Clipboard`] trait.
-#[derive(Debug, Clone, Copy)]
-pub struct Null;
-
-impl Clipboard for Null {
- fn read(&self) -> Option<String> {
- None
- }
-
- fn write(&mut self, _contents: String) {}
-}
-
/// A clipboard action to be performed by some [`Command`].
///
/// [`Command`]: crate::Command
@@ -60,3 +39,15 @@ impl<T> fmt::Debug for Action<T> {
}
}
}
+
+/// Read the current contents of the clipboard.
+pub fn read<Message>(
+ f: impl Fn(Option<String>) -> Message + 'static,
+) -> Command<Message> {
+ Command::single(command::Action::Clipboard(Action::Read(Box::new(f))))
+}
+
+/// Write the given contents to the clipboard.
+pub fn write<Message>(contents: String) -> Command<Message> {
+ Command::single(command::Action::Clipboard(Action::Write(contents)))
+}
diff --git a/native/src/command.rs b/runtime/src/command.rs
index ca9d0b64..cd4c51ff 100644
--- a/native/src/command.rs
+++ b/runtime/src/command.rs
@@ -3,35 +3,39 @@ mod action;
pub use action::Action;
-use crate::widget;
-
-use iced_futures::MaybeSend;
+use crate::core::widget;
+use crate::futures::MaybeSend;
use std::fmt;
use std::future::Future;
/// A set of asynchronous actions to be performed by some runtime.
#[must_use = "`Command` must be returned to runtime to take effect"]
-pub struct Command<T>(iced_futures::Command<Action<T>>);
+pub struct Command<T>(Internal<Action<T>>);
+
+#[derive(Debug)]
+enum Internal<T> {
+ None,
+ Single(T),
+ Batch(Vec<T>),
+}
impl<T> Command<T> {
/// Creates an empty [`Command`].
///
/// In other words, a [`Command`] that does nothing.
pub const fn none() -> Self {
- Self(iced_futures::Command::none())
+ Self(Internal::None)
}
/// Creates a [`Command`] that performs a single [`Action`].
pub const fn single(action: Action<T>) -> Self {
- Self(iced_futures::Command::single(action))
+ Self(Internal::Single(action))
}
/// Creates a [`Command`] that performs a [`widget::Operation`].
pub fn widget(operation: impl widget::Operation<T> + 'static) -> Self {
- Self(iced_futures::Command::single(Action::Widget(
- widget::Action::new(operation),
- )))
+ Self::single(Action::Widget(Box::new(operation)))
}
/// Creates a [`Command`] that performs the action of the given future.
@@ -49,9 +53,17 @@ impl<T> Command<T> {
///
/// Once this command is run, all the commands will be executed at once.
pub fn batch(commands: impl IntoIterator<Item = Command<T>>) -> Self {
- Self(iced_futures::Command::batch(
- commands.into_iter().map(|Command(command)| command),
- ))
+ let mut batch = Vec::new();
+
+ for Command(command) in commands {
+ match command {
+ Internal::None => {}
+ Internal::Single(command) => batch.push(command),
+ Internal::Batch(commands) => batch.extend(commands),
+ }
+ }
+
+ Self(Internal::Batch(batch))
}
/// Applies a transformation to the result of a [`Command`].
@@ -63,16 +75,27 @@ impl<T> Command<T> {
T: 'static,
A: 'static,
{
- let Command(command) = self;
-
- Command(command.map(move |action| action.map(f.clone())))
+ match self.0 {
+ Internal::None => Command::none(),
+ Internal::Single(action) => Command::single(action.map(f)),
+ Internal::Batch(batch) => Command(Internal::Batch(
+ batch
+ .into_iter()
+ .map(|action| action.map(f.clone()))
+ .collect(),
+ )),
+ }
}
/// Returns all of the actions of the [`Command`].
pub fn actions(self) -> Vec<Action<T>> {
let Command(command) = self;
- command.actions()
+ match command {
+ Internal::None => Vec::new(),
+ Internal::Single(action) => vec![action],
+ Internal::Batch(batch) => batch,
+ }
}
}
diff --git a/native/src/command/action.rs b/runtime/src/command/action.rs
index d1589c05..6c74f0ef 100644
--- a/native/src/command/action.rs
+++ b/runtime/src/command/action.rs
@@ -1,7 +1,7 @@
use crate::clipboard;
+use crate::core::widget;
use crate::font;
use crate::system;
-use crate::widget;
use crate::window;
use iced_futures::MaybeSend;
@@ -28,7 +28,7 @@ pub enum Action<T> {
System(system::Action<T>),
/// Run a widget action.
- Widget(widget::Action<T>),
+ Widget(Box<dyn widget::Operation<T>>),
/// Load a font from its bytes.
LoadFont {
@@ -59,7 +59,9 @@ impl<T> Action<T> {
Self::Clipboard(action) => Action::Clipboard(action.map(f)),
Self::Window(window) => Action::Window(window.map(f)),
Self::System(system) => Action::System(system.map(f)),
- Self::Widget(widget) => Action::Widget(widget.map(f)),
+ Self::Widget(operation) => {
+ Action::Widget(Box::new(widget::operation::map(operation, f)))
+ }
Self::LoadFont { bytes, tagger } => Action::LoadFont {
bytes,
tagger: Box::new(move |result| f(tagger(result))),
diff --git a/native/src/debug/basic.rs b/runtime/src/debug/basic.rs
index 92f614da..32f725a1 100644
--- a/native/src/debug/basic.rs
+++ b/runtime/src/debug/basic.rs
@@ -1,5 +1,5 @@
#![allow(missing_docs)]
-use crate::time;
+use crate::core::time;
use std::collections::VecDeque;
diff --git a/native/src/debug/null.rs b/runtime/src/debug/null.rs
index 2db0eebb..2db0eebb 100644
--- a/native/src/debug/null.rs
+++ b/runtime/src/debug/null.rs
diff --git a/native/src/font.rs b/runtime/src/font.rs
index 15359694..15359694 100644
--- a/native/src/font.rs
+++ b/runtime/src/font.rs
diff --git a/native/src/keyboard.rs b/runtime/src/keyboard.rs
index 012538e3..012538e3 100644
--- a/native/src/keyboard.rs
+++ b/runtime/src/keyboard.rs
diff --git a/native/src/lib.rs b/runtime/src/lib.rs
index 27b6fc0d..aa45e57a 100644
--- a/native/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -33,7 +33,7 @@
)]
#![deny(
missing_debug_implementations,
- missing_docs,
+ //missing_docs,
unused_results,
clippy::extra_unused_lifetimes,
clippy::from_over_into,
@@ -42,33 +42,16 @@
clippy::useless_conversion
)]
#![forbid(unsafe_code, rust_2018_idioms)]
-#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_cfg))]
pub mod clipboard;
pub mod command;
-pub mod event;
pub mod font;
-pub mod image;
pub mod keyboard;
-pub mod layout;
-pub mod mouse;
-pub mod overlay;
pub mod program;
-pub mod renderer;
-pub mod subscription;
-pub mod svg;
pub mod system;
-pub mod text;
-pub mod touch;
pub mod user_interface;
-pub mod widget;
pub mod window;
-mod element;
-mod hasher;
-mod runtime;
-mod shell;
-
// We disable debug capabilities on release builds unless the `debug` feature
// is explicitly enabled.
#[cfg(feature = "debug")]
@@ -78,33 +61,11 @@ mod debug;
#[path = "debug/null.rs"]
mod debug;
-pub use iced_core::alignment;
-pub use iced_core::time;
-pub use iced_core::{
- color, Alignment, Background, Color, ContentFit, Length, Padding, Pixels,
- Point, Rectangle, Size, Vector,
-};
-pub use iced_futures::{executor, futures};
-pub use iced_style::application;
-pub use iced_style::theme;
-
-#[doc(no_inline)]
-pub use executor::Executor;
+pub use iced_core as core;
+pub use iced_futures as futures;
-pub use clipboard::Clipboard;
pub use command::Command;
pub use debug::Debug;
-pub use element::Element;
-pub use event::Event;
pub use font::Font;
-pub use hasher::Hasher;
-pub use layout::Layout;
-pub use overlay::Overlay;
pub use program::Program;
-pub use renderer::Renderer;
-pub use runtime::Runtime;
-pub use shell::Shell;
-pub use subscription::Subscription;
-pub use theme::Theme;
pub use user_interface::UserInterface;
-pub use widget::Widget;
diff --git a/native/src/program.rs b/runtime/src/program.rs
index 25cab332..44585cc5 100644
--- a/native/src/program.rs
+++ b/runtime/src/program.rs
@@ -1,6 +1,8 @@
//! Build interactive programs using The Elm Architecture.
-use crate::text;
-use crate::{Command, Element, Renderer};
+use crate::Command;
+
+use iced_core::text;
+use iced_core::{Element, Renderer};
mod state;
diff --git a/native/src/program/state.rs b/runtime/src/program/state.rs
index 8ae1cacb..2fa9934d 100644
--- a/native/src/program/state.rs
+++ b/runtime/src/program/state.rs
@@ -1,9 +1,9 @@
-use crate::application;
-use crate::event::{self, Event};
-use crate::mouse;
-use crate::renderer;
+use crate::core::event::{self, Event};
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::{Clipboard, Point, Size};
use crate::user_interface::{self, UserInterface};
-use crate::{Clipboard, Command, Debug, Point, Program, Size};
+use crate::{Command, Debug, Program};
/// The execution state of a [`Program`]. It leverages caching, event
/// processing, and rendering primitive storage.
@@ -22,7 +22,6 @@ where
impl<P> State<P>
where
P: Program + 'static,
- <P::Renderer as crate::Renderer>::Theme: application::StyleSheet,
{
/// Creates a new [`State`] with the provided [`Program`], initializing its
/// primitive with the given logical bounds and renderer.
@@ -91,7 +90,7 @@ where
bounds: Size,
cursor_position: Point,
renderer: &mut P::Renderer,
- theme: &<P::Renderer as crate::Renderer>::Theme,
+ theme: &<P::Renderer as iced_core::Renderer>::Theme,
style: &renderer::Style,
clipboard: &mut dyn Clipboard,
debug: &mut Debug,
@@ -182,10 +181,7 @@ fn build_user_interface<'a, P: Program>(
renderer: &mut P::Renderer,
size: Size,
debug: &mut Debug,
-) -> UserInterface<'a, P::Message, P::Renderer>
-where
- <P::Renderer as crate::Renderer>::Theme: application::StyleSheet,
-{
+) -> UserInterface<'a, P::Message, P::Renderer> {
debug.view_started();
let view = program.view();
debug.view_finished();
diff --git a/native/src/system.rs b/runtime/src/system.rs
index 61c8ff29..61c8ff29 100644
--- a/native/src/system.rs
+++ b/runtime/src/system.rs
diff --git a/native/src/system/action.rs b/runtime/src/system/action.rs
index dea9536f..dea9536f 100644
--- a/native/src/system/action.rs
+++ b/runtime/src/system/action.rs
diff --git a/native/src/system/information.rs b/runtime/src/system/information.rs
index 93e7a5a4..93e7a5a4 100644
--- a/native/src/system/information.rs
+++ b/runtime/src/system/information.rs
diff --git a/native/src/user_interface.rs b/runtime/src/user_interface.rs
index 68ccda55..2c76fd8a 100644
--- a/native/src/user_interface.rs
+++ b/runtime/src/user_interface.rs
@@ -1,14 +1,12 @@
//! Implement your own event loop to drive a user interface.
-use crate::application;
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::widget;
-use crate::window;
-use crate::{
- Clipboard, Element, Layout, Point, Rectangle, Shell, Size, Vector,
-};
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::widget;
+use crate::core::window;
+use crate::core::{Clipboard, Point, Rectangle, Size, Vector};
+use crate::core::{Element, Layout, Shell};
/// A set of interactive graphical elements with a specific [`Layout`].
///
@@ -34,8 +32,7 @@ pub struct UserInterface<'a, Message, Renderer> {
impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
- Renderer::Theme: application::StyleSheet,
+ Renderer: crate::core::Renderer,
{
/// Builds a user interface for an [`Element`].
///
@@ -48,24 +45,21 @@ where
/// is naive way to set up our application loop:
///
/// ```no_run
- /// use iced_native::Size;
- /// use iced_native::user_interface::{self, UserInterface};
- /// use iced_wgpu::Renderer;
- ///
/// # mod iced_wgpu {
- /// # pub use iced_native::renderer::Null as Renderer;
+ /// # pub use iced_runtime::core::renderer::Null as Renderer;
/// # }
/// #
- /// # use iced_native::widget::Column;
- /// #
/// # pub struct Counter;
/// #
/// # impl Counter {
/// # pub fn new() -> Self { Counter }
- /// # pub fn view(&self) -> Column<(), Renderer> {
- /// # Column::new()
- /// # }
+ /// # pub fn view(&self) -> iced_core::Element<(), Renderer> { unimplemented!() }
+ /// # pub fn update(&mut self, _: ()) {}
/// # }
+ /// use iced_runtime::core::Size;
+ /// use iced_runtime::user_interface::{self, UserInterface};
+ /// use iced_wgpu::Renderer;
+ ///
/// // Initialization
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
@@ -124,25 +118,21 @@ where
/// completing [the previous example](#example):
///
/// ```no_run
- /// use iced_native::{clipboard, Size, Point};
- /// use iced_native::user_interface::{self, UserInterface};
- /// use iced_wgpu::Renderer;
- ///
/// # mod iced_wgpu {
- /// # pub use iced_native::renderer::Null as Renderer;
+ /// # pub use iced_runtime::core::renderer::Null as Renderer;
/// # }
/// #
- /// # use iced_native::widget::Column;
- /// #
/// # pub struct Counter;
/// #
/// # impl Counter {
/// # pub fn new() -> Self { Counter }
- /// # pub fn view(&self) -> Column<(), Renderer> {
- /// # Column::new()
- /// # }
- /// # pub fn update(&mut self, message: ()) {}
+ /// # pub fn view(&self) -> iced_core::Element<(), Renderer> { unimplemented!() }
+ /// # pub fn update(&mut self, _: ()) {}
/// # }
+ /// use iced_runtime::core::{clipboard, Size, Point};
+ /// use iced_runtime::user_interface::{self, UserInterface};
+ /// use iced_wgpu::Renderer;
+ ///
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
/// let mut renderer = Renderer::new();
@@ -357,27 +347,24 @@ where
/// [completing the last example](#example-1):
///
/// ```no_run
- /// use iced_native::clipboard;
- /// use iced_native::renderer;
- /// use iced_native::user_interface::{self, UserInterface};
- /// use iced_native::{Size, Point, Theme};
- /// use iced_wgpu::Renderer;
- ///
/// # mod iced_wgpu {
- /// # pub use iced_native::renderer::Null as Renderer;
+ /// # pub use iced_runtime::core::renderer::Null as Renderer;
+ /// # pub type Theme = ();
/// # }
/// #
- /// # use iced_native::widget::Column;
- /// #
/// # pub struct Counter;
/// #
/// # impl Counter {
/// # pub fn new() -> Self { Counter }
- /// # pub fn view(&self) -> Column<(), Renderer> {
- /// # Column::new()
- /// # }
- /// # pub fn update(&mut self, message: ()) {}
+ /// # pub fn view(&self) -> Element<(), Renderer> { unimplemented!() }
+ /// # pub fn update(&mut self, _: ()) {}
/// # }
+ /// use iced_runtime::core::clipboard;
+ /// use iced_runtime::core::renderer;
+ /// use iced_runtime::core::{Element, Size, Point};
+ /// use iced_runtime::user_interface::{self, UserInterface};
+ /// use iced_wgpu::{Renderer, Theme};
+ ///
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
/// let mut renderer = Renderer::new();
@@ -386,6 +373,7 @@ where
/// let mut clipboard = clipboard::Null;
/// let mut events = Vec::new();
/// let mut messages = Vec::new();
+ /// let mut theme = Theme::default();
///
/// loop {
/// // Obtain system events...
@@ -407,7 +395,7 @@ where
/// );
///
/// // Draw the user interface
- /// let mouse_cursor = user_interface.draw(&mut renderer, &Theme::default(), &renderer::Style::default(), cursor_position);
+ /// let mouse_cursor = user_interface.draw(&mut renderer, &theme, &renderer::Style::default(), cursor_position);
///
/// cache = user_interface.into_cache();
///
diff --git a/winit/src/window.rs b/runtime/src/window.rs
index 961562bd..236064f7 100644
--- a/winit/src/window.rs
+++ b/runtime/src/window.rs
@@ -1,68 +1,78 @@
-//! Interact with the window of your application.
+//! Build window-based GUI applications.
+mod action;
+
+pub use action::Action;
+
use crate::command::{self, Command};
-use iced_native::window;
+use crate::core::time::Instant;
+use crate::core::window::{Event, Mode, UserAttention};
+use crate::futures::subscription::{self, Subscription};
-pub use window::{frames, Event, Mode, RedrawRequest, UserAttention};
+/// Subscribes to the frames of the window of the running application.
+///
+/// The resulting [`Subscription`] will produce items at a rate equal to the
+/// refresh rate of the window. Note that this rate may be variable, as it is
+/// normally managed by the graphics driver and/or the OS.
+///
+/// In any case, this [`Subscription`] is useful to smoothly draw application-driven
+/// animations without missing any frames.
+pub fn frames() -> Subscription<Instant> {
+ subscription::raw_events(|event, _status| match event {
+ iced_core::Event::Window(Event::RedrawRequested(at)) => Some(at),
+ _ => None,
+ })
+}
/// Closes the current window and exits the application.
pub fn close<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Close))
+ Command::single(command::Action::Window(Action::Close))
}
/// Begins dragging the window while the left mouse button is held.
pub fn drag<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Drag))
+ Command::single(command::Action::Window(Action::Drag))
}
/// Resizes the window to the given logical dimensions.
pub fn resize<Message>(width: u32, height: u32) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Resize {
- width,
- height,
- }))
+ Command::single(command::Action::Window(Action::Resize { width, height }))
}
/// Maximizes the window.
pub fn maximize<Message>(maximized: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Maximize(
- maximized,
- )))
+ Command::single(command::Action::Window(Action::Maximize(maximized)))
}
/// Minimes the window.
pub fn minimize<Message>(minimized: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Minimize(
- minimized,
- )))
+ Command::single(command::Action::Window(Action::Minimize(minimized)))
}
/// Moves a window to the given logical coordinates.
pub fn move_to<Message>(x: i32, y: i32) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Move { x, y }))
+ Command::single(command::Action::Window(Action::Move { x, y }))
}
/// Sets the [`Mode`] of the window.
pub fn change_mode<Message>(mode: Mode) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ChangeMode(mode)))
+ Command::single(command::Action::Window(Action::ChangeMode(mode)))
}
/// Fetches the current [`Mode`] of the window.
pub fn fetch_mode<Message>(
f: impl FnOnce(Mode) -> Message + 'static,
) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::FetchMode(
- Box::new(f),
- )))
+ Command::single(command::Action::Window(Action::FetchMode(Box::new(f))))
}
/// Toggles the window to maximized or back.
pub fn toggle_maximize<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ToggleMaximize))
+ Command::single(command::Action::Window(Action::ToggleMaximize))
}
/// Toggles the window decorations.
pub fn toggle_decorations<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ToggleDecorations))
+ Command::single(command::Action::Window(Action::ToggleDecorations))
}
/// Request user attention to the window, this has no effect if the application
@@ -74,9 +84,9 @@ pub fn toggle_decorations<Message>() -> Command<Message> {
pub fn request_user_attention<Message>(
user_attention: Option<UserAttention>,
) -> Command<Message> {
- Command::single(command::Action::Window(
- window::Action::RequestUserAttention(user_attention),
- ))
+ Command::single(command::Action::Window(Action::RequestUserAttention(
+ user_attention,
+ )))
}
/// Brings the window to the front and sets input focus. Has no effect if the window is
@@ -86,21 +96,17 @@ pub fn request_user_attention<Message>(
/// you are certain that's what the user wants. Focus stealing can cause an extremely disruptive
/// user experience.
pub fn gain_focus<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::GainFocus))
+ Command::single(command::Action::Window(Action::GainFocus))
}
/// Changes whether or not the window will always be on top of other windows.
pub fn change_always_on_top<Message>(on_top: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ChangeAlwaysOnTop(
- on_top,
- )))
+ Command::single(command::Action::Window(Action::ChangeAlwaysOnTop(on_top)))
}
/// Fetches an identifier unique to the window.
pub fn fetch_id<Message>(
f: impl FnOnce(u64) -> Message + 'static,
) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::FetchId(Box::new(
- f,
- ))))
+ Command::single(command::Action::Window(Action::FetchId(Box::new(f))))
}
diff --git a/native/src/window/action.rs b/runtime/src/window/action.rs
index ce36d129..c1dbd84f 100644
--- a/native/src/window/action.rs
+++ b/runtime/src/window/action.rs
@@ -1,6 +1,6 @@
-use crate::window::{Mode, UserAttention};
+use crate::core::window::{Mode, UserAttention};
+use crate::futures::MaybeSend;
-use iced_futures::MaybeSend;
use std::fmt;
/// An operation to be performed on some window.