From 99e0a71504456976ba88040f5d1d3bbc347694ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 5 Mar 2023 06:35:20 +0100 Subject: [PATCH] Rename `iced_native` to `iced_runtime` --- Cargo.toml | 2 +- examples/integration/src/controls.rs | 2 +- examples/integration/src/main.rs | 4 +-- native/src/window.rs | 23 --------------- {native => runtime}/Cargo.toml | 2 +- {native => runtime}/README.md | 0 {native => runtime}/src/clipboard.rs | 15 +++++++++- {native => runtime}/src/command.rs | 0 {native => runtime}/src/command/action.rs | 0 {native => runtime}/src/debug/basic.rs | 0 {native => runtime}/src/debug/null.rs | 0 {native => runtime}/src/font.rs | 0 {native => runtime}/src/keyboard.rs | 0 {native => runtime}/src/lib.rs | 0 {native => runtime}/src/program.rs | 0 {native => runtime}/src/program/state.rs | 0 {native => runtime}/src/system.rs | 0 {native => runtime}/src/system/action.rs | 0 {native => runtime}/src/system/information.rs | 0 {native => runtime}/src/user_interface.rs | 24 ++++++++-------- {winit => runtime}/src/window.rs | 28 ++++++++++++++++--- {native => runtime}/src/window/action.rs | 0 src/advanced.rs | 2 +- src/application.rs | 2 +- src/lib.rs | 10 +++---- src/window.rs | 3 +- tiny_skia/Cargo.toml | 4 --- tiny_skia/src/text.rs | 2 +- widget/Cargo.toml | 4 +-- widget/src/helpers.rs | 2 +- widget/src/lib.rs | 4 +-- widget/src/scrollable.rs | 2 +- widget/src/text_input.rs | 2 +- winit/Cargo.toml | 6 ++-- winit/src/application.rs | 14 +++++----- winit/src/application/state.rs | 2 +- winit/src/clipboard.rs | 14 ---------- winit/src/lib.rs | 7 ++--- winit/src/system.rs | 4 +-- 39 files changed, 87 insertions(+), 97 deletions(-) delete mode 100644 native/src/window.rs rename {native => runtime}/Cargo.toml (95%) rename {native => runtime}/README.md (100%) rename {native => runtime}/src/clipboard.rs (67%) rename {native => runtime}/src/command.rs (100%) rename {native => runtime}/src/command/action.rs (100%) rename {native => runtime}/src/debug/basic.rs (100%) rename {native => runtime}/src/debug/null.rs (100%) rename {native => runtime}/src/font.rs (100%) rename {native => runtime}/src/keyboard.rs (100%) rename {native => runtime}/src/lib.rs (100%) rename {native => runtime}/src/program.rs (100%) rename {native => runtime}/src/program/state.rs (100%) rename {native => runtime}/src/system.rs (100%) rename {native => runtime}/src/system/action.rs (100%) rename {native => runtime}/src/system/information.rs (100%) rename {native => runtime}/src/user_interface.rs (96%) rename {winit => runtime}/src/window.rs (79%) rename {native => runtime}/src/window/action.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 49a52311a1..a677569a24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ members = [ "core", "futures", "graphics", - "native", + "runtime", "renderer", "style", "tiny_skia", diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs index 16e2170966..5849f730d1 100644 --- a/examples/integration/src/controls.rs +++ b/examples/integration/src/controls.rs @@ -1,7 +1,7 @@ use iced_wgpu::Renderer; use iced_widget::{slider, text_input, Column, Row, Text}; use iced_winit::core::{Alignment, Color, Element, Length}; -use iced_winit::native::{Command, Program}; +use iced_winit::runtime::{Command, Program}; use iced_winit::style::Theme; pub struct Controls { diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index c1f1f076d3..9707eda78a 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -8,8 +8,8 @@ use iced_wgpu::graphics::Viewport; use iced_wgpu::{wgpu, Backend, Renderer, Settings}; use iced_winit::core::renderer; use iced_winit::core::{Color, Size}; -use iced_winit::native::program; -use iced_winit::native::Debug; +use iced_winit::runtime::program; +use iced_winit::runtime::Debug; use iced_winit::style::Theme; use iced_winit::{conversion, futures, winit, Clipboard}; diff --git a/native/src/window.rs b/native/src/window.rs deleted file mode 100644 index aa3f35c71b..0000000000 --- a/native/src/window.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! Build window-based GUI applications. -mod action; - -pub use action::Action; - -use crate::core::time::Instant; -use crate::core::window::Event; -use crate::futures::subscription::{self, Subscription}; - -/// 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 { - subscription::raw_events(|event, _status| match event { - iced_core::Event::Window(Event::RedrawRequested(at)) => Some(at), - _ => None, - }) -} diff --git a/native/Cargo.toml b/runtime/Cargo.toml similarity index 95% rename from native/Cargo.toml rename to runtime/Cargo.toml index bc4e7ca19c..2d3e8db3a2 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 "] edition = "2021" diff --git a/native/README.md b/runtime/README.md similarity index 100% rename from native/README.md rename to runtime/README.md diff --git a/native/src/clipboard.rs b/runtime/src/clipboard.rs similarity index 67% rename from native/src/clipboard.rs rename to runtime/src/clipboard.rs index e727c4a740..bc45091266 100644 --- a/native/src/clipboard.rs +++ b/runtime/src/clipboard.rs @@ -1,5 +1,6 @@ //! Access the clipboard. -use iced_futures::MaybeSend; +use crate::command::{self, Command}; +use crate::futures::MaybeSend; use std::fmt; @@ -38,3 +39,15 @@ impl fmt::Debug for Action { } } } + +/// Read the current contents of the clipboard. +pub fn read( + f: impl Fn(Option) -> Message + 'static, +) -> Command { + Command::single(command::Action::Clipboard(Action::Read(Box::new(f)))) +} + +/// Write the given contents to the clipboard. +pub fn write(contents: String) -> Command { + Command::single(command::Action::Clipboard(Action::Write(contents))) +} diff --git a/native/src/command.rs b/runtime/src/command.rs similarity index 100% rename from native/src/command.rs rename to runtime/src/command.rs diff --git a/native/src/command/action.rs b/runtime/src/command/action.rs similarity index 100% rename from native/src/command/action.rs rename to runtime/src/command/action.rs diff --git a/native/src/debug/basic.rs b/runtime/src/debug/basic.rs similarity index 100% rename from native/src/debug/basic.rs rename to runtime/src/debug/basic.rs diff --git a/native/src/debug/null.rs b/runtime/src/debug/null.rs similarity index 100% rename from native/src/debug/null.rs rename to runtime/src/debug/null.rs diff --git a/native/src/font.rs b/runtime/src/font.rs similarity index 100% rename from native/src/font.rs rename to runtime/src/font.rs diff --git a/native/src/keyboard.rs b/runtime/src/keyboard.rs similarity index 100% rename from native/src/keyboard.rs rename to runtime/src/keyboard.rs diff --git a/native/src/lib.rs b/runtime/src/lib.rs similarity index 100% rename from native/src/lib.rs rename to runtime/src/lib.rs diff --git a/native/src/program.rs b/runtime/src/program.rs similarity index 100% rename from native/src/program.rs rename to runtime/src/program.rs diff --git a/native/src/program/state.rs b/runtime/src/program/state.rs similarity index 100% rename from native/src/program/state.rs rename to runtime/src/program/state.rs diff --git a/native/src/system.rs b/runtime/src/system.rs similarity index 100% rename from native/src/system.rs rename to runtime/src/system.rs diff --git a/native/src/system/action.rs b/runtime/src/system/action.rs similarity index 100% rename from native/src/system/action.rs rename to runtime/src/system/action.rs diff --git a/native/src/system/information.rs b/runtime/src/system/information.rs similarity index 100% rename from native/src/system/information.rs rename to runtime/src/system/information.rs diff --git a/native/src/user_interface.rs b/runtime/src/user_interface.rs similarity index 96% rename from native/src/user_interface.rs rename to runtime/src/user_interface.rs index 315027fa08..2c76fd8a8a 100644 --- a/native/src/user_interface.rs +++ b/runtime/src/user_interface.rs @@ -32,7 +32,7 @@ pub struct UserInterface<'a, Message, Renderer> { impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> where - Renderer: iced_core::Renderer, + Renderer: crate::core::Renderer, { /// Builds a user interface for an [`Element`]. /// @@ -46,7 +46,7 @@ where /// /// ```no_run /// # mod iced_wgpu { - /// # pub use iced_native::core::renderer::Null as Renderer; + /// # pub use iced_runtime::core::renderer::Null as Renderer; /// # } /// # /// # pub struct Counter; @@ -56,8 +56,8 @@ where /// # pub fn view(&self) -> iced_core::Element<(), Renderer> { unimplemented!() } /// # pub fn update(&mut self, _: ()) {} /// # } - /// use iced_native::core::Size; - /// use iced_native::user_interface::{self, UserInterface}; + /// use iced_runtime::core::Size; + /// use iced_runtime::user_interface::{self, UserInterface}; /// use iced_wgpu::Renderer; /// /// // Initialization @@ -119,7 +119,7 @@ where /// /// ```no_run /// # mod iced_wgpu { - /// # pub use iced_native::core::renderer::Null as Renderer; + /// # pub use iced_runtime::core::renderer::Null as Renderer; /// # } /// # /// # pub struct Counter; @@ -129,8 +129,8 @@ where /// # pub fn view(&self) -> iced_core::Element<(), Renderer> { unimplemented!() } /// # pub fn update(&mut self, _: ()) {} /// # } - /// use iced_native::core::{clipboard, Size, Point}; - /// use iced_native::user_interface::{self, UserInterface}; + /// use iced_runtime::core::{clipboard, Size, Point}; + /// use iced_runtime::user_interface::{self, UserInterface}; /// use iced_wgpu::Renderer; /// /// let mut counter = Counter::new(); @@ -348,7 +348,7 @@ where /// /// ```no_run /// # mod iced_wgpu { - /// # pub use iced_native::core::renderer::Null as Renderer; + /// # pub use iced_runtime::core::renderer::Null as Renderer; /// # pub type Theme = (); /// # } /// # @@ -359,10 +359,10 @@ where /// # pub fn view(&self) -> Element<(), Renderer> { unimplemented!() } /// # pub fn update(&mut self, _: ()) {} /// # } - /// use iced_native::core::clipboard; - /// use iced_native::core::renderer; - /// use iced_native::core::{Element, Size, Point}; - /// use iced_native::user_interface::{self, UserInterface}; + /// 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(); diff --git a/winit/src/window.rs b/runtime/src/window.rs similarity index 79% rename from winit/src/window.rs rename to runtime/src/window.rs index 6ac58e2073..236064f77c 100644 --- a/winit/src/window.rs +++ b/runtime/src/window.rs @@ -1,7 +1,27 @@ -//! Interact with the window of your application. -use crate::core::window::{Mode, UserAttention}; -use crate::native::command::{self, Command}; -use crate::native::window::Action; +//! Build window-based GUI applications. +mod action; + +pub use action::Action; + +use crate::command::{self, Command}; +use crate::core::time::Instant; +use crate::core::window::{Event, Mode, UserAttention}; +use crate::futures::subscription::{self, Subscription}; + +/// 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 { + 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() -> Command { diff --git a/native/src/window/action.rs b/runtime/src/window/action.rs similarity index 100% rename from native/src/window/action.rs rename to runtime/src/window/action.rs diff --git a/src/advanced.rs b/src/advanced.rs index 9621c3bc02..7afba85ccc 100644 --- a/src/advanced.rs +++ b/src/advanced.rs @@ -10,5 +10,5 @@ pub use crate::core::{Clipboard, Shell}; pub mod subscription { //! Write your own subscriptions. - pub use crate::native::futures::subscription::{EventStream, Recipe}; + pub use crate::runtime::futures::subscription::{EventStream, Recipe}; } diff --git a/src/application.rs b/src/application.rs index f5cf3317ea..c9ddf840c3 100644 --- a/src/application.rs +++ b/src/application.rs @@ -215,7 +215,7 @@ pub trait Application: Sized { struct Instance(A); -impl crate::native::Program for Instance +impl crate::runtime::Program for Instance where A: Application, { diff --git a/src/lib.rs b/src/lib.rs index b9f87d5dd9..c59d505804 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,7 +169,7 @@ use iced_widget::renderer; use iced_widget::style; use iced_winit as shell; use iced_winit::core; -use iced_winit::native; +use iced_winit::runtime; pub use iced_futures::futures; @@ -192,11 +192,11 @@ pub use crate::core::{ color, Alignment, Background, Color, ContentFit, Length, Padding, Point, Rectangle, Size, Vector, }; -pub use crate::native::Command; +pub use crate::runtime::Command; pub mod clipboard { //! Access the clipboard. - pub use crate::shell::clipboard::{read, write}; + pub use crate::runtime::clipboard::{read, write}; } pub mod executor { @@ -219,7 +219,7 @@ pub mod executor { pub mod font { //! Load and use fonts. pub use crate::core::font::*; - pub use crate::native::font::*; + pub use crate::runtime::font::*; } pub mod keyboard { @@ -242,7 +242,7 @@ pub mod subscription { #[cfg(feature = "system")] pub mod system { //! Retrieve system information. - pub use crate::native::system::Information; + pub use crate::runtime::system::Information; pub use crate::shell::system::*; } diff --git a/src/window.rs b/src/window.rs index 2623906552..824915b284 100644 --- a/src/window.rs +++ b/src/window.rs @@ -9,5 +9,4 @@ pub use position::Position; pub use settings::Settings; pub use crate::core::window::*; -pub use crate::native::window::*; -pub use crate::shell::window::*; +pub use crate::runtime::window::*; diff --git a/tiny_skia/Cargo.toml b/tiny_skia/Cargo.toml index c4c36abad5..08e79bb8c6 100644 --- a/tiny_skia/Cargo.toml +++ b/tiny_skia/Cargo.toml @@ -17,10 +17,6 @@ rustc-hash = "1.1" ouroboros = "0.15" kurbo = "0.9" -[dependencies.iced_native] -version = "0.9" -path = "../native" - [dependencies.iced_graphics] version = "0.7" path = "../graphics" diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index 7a5034c2aa..c4edadb333 100644 --- a/tiny_skia/src/text.rs +++ b/tiny_skia/src/text.rs @@ -187,7 +187,7 @@ impl Pipeline { &self, content: &str, size: f32, - font: iced_native::Font, + font: Font, bounds: Size, point: Point, _nearest_only: bool, diff --git a/widget/Cargo.toml b/widget/Cargo.toml index fb617079c8..4c23f3e86e 100644 --- a/widget/Cargo.toml +++ b/widget/Cargo.toml @@ -15,9 +15,9 @@ unicode-segmentation = "1.6" num-traits = "0.2" thiserror = "1" -[dependencies.iced_native] +[dependencies.iced_runtime] version = "0.9" -path = "../native" +path = "../runtime" [dependencies.iced_renderer] version = "0.1" diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index 1a73c16f13..a43e7248a3 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -5,12 +5,12 @@ use crate::container::{self, Container}; use crate::core; use crate::core::widget::operation; use crate::core::{Element, Length, Pixels}; -use crate::native::Command; use crate::overlay; use crate::pick_list::{self, PickList}; use crate::progress_bar::{self, ProgressBar}; use crate::radio::{self, Radio}; use crate::rule::{self, Rule}; +use crate::runtime::Command; use crate::scrollable::{self, Scrollable}; use crate::slider::{self, Slider}; use crate::text::{self, Text}; diff --git a/widget/src/lib.rs b/widget/src/lib.rs index 4c1e7c1c0a..a3e7c8bc35 100644 --- a/widget/src/lib.rs +++ b/widget/src/lib.rs @@ -14,10 +14,10 @@ )] #![forbid(unsafe_code, rust_2018_idioms)] #![allow(clippy::inherent_to_string, clippy::type_complexity)] -pub use iced_native as native; -pub use iced_native::core; pub use iced_renderer as renderer; pub use iced_renderer::graphics; +pub use iced_runtime as runtime; +pub use iced_runtime::core; pub use iced_style as style; mod column; diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 49c780deac..5a7481f727 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -13,7 +13,7 @@ use crate::core::{ Background, Clipboard, Color, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size, Vector, Widget, }; -use crate::native::Command; +use crate::runtime::Command; pub use crate::style::scrollable::{Scrollbar, Scroller, StyleSheet}; pub use operation::scrollable::RelativeOffset; diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index d1c48fbdd5..d066109aab 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -28,7 +28,7 @@ use crate::core::{ Clipboard, Color, Element, Layout, Length, Padding, Pixels, Point, Rectangle, Shell, Size, Vector, Widget, }; -use crate::native::Command; +use crate::runtime::Command; pub use iced_style::text_input::{Appearance, StyleSheet}; diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 21c14f68ba..bfd2209344 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -13,7 +13,7 @@ categories = ["gui"] [features] trace = ["tracing", "tracing-core", "tracing-subscriber"] chrome-trace = ["trace", "tracing-chrome"] -debug = ["iced_native/debug"] +debug = ["iced_runtime/debug"] system = ["sysinfo"] application = [] @@ -27,9 +27,9 @@ version = "0.27" git = "https://github.com/iced-rs/winit.git" rev = "940457522e9fb9f5dac228b0ecfafe0138b4048c" -[dependencies.iced_native] +[dependencies.iced_runtime] version = "0.9" -path = "../native" +path = "../runtime" [dependencies.iced_graphics] version = "0.7" diff --git a/winit/src/application.rs b/winit/src/application.rs index d863c84648..9666fcae05 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -16,10 +16,10 @@ use crate::core::{Event, Size}; use crate::futures::futures; use crate::futures::{Executor, Runtime, Subscription}; use crate::graphics::compositor::{self, Compositor}; -use crate::native::clipboard; -use crate::native::program::Program; -use crate::native::user_interface::{self, UserInterface}; -use crate::native::{Command, Debug}; +use crate::runtime::clipboard; +use crate::runtime::program::Program; +use crate::runtime::user_interface::{self, UserInterface}; +use crate::runtime::{Command, Debug}; use crate::style::application::{Appearance, StyleSheet}; use crate::{Clipboard, Error, Proxy, Settings}; @@ -709,9 +709,9 @@ pub fn run_command( E: Executor, ::Theme: StyleSheet, { - use iced_native::command; - use iced_native::system; - use iced_native::window; + use crate::runtime::command; + use crate::runtime::system; + use crate::runtime::window; for action in command.actions() { match action { diff --git a/winit/src/application/state.rs b/winit/src/application/state.rs index b727e03ca9..c37ccca614 100644 --- a/winit/src/application/state.rs +++ b/winit/src/application/state.rs @@ -3,7 +3,7 @@ use crate::conversion; use crate::core; use crate::core::{Color, Point, Size}; use crate::graphics::Viewport; -use crate::native::Debug; +use crate::runtime::Debug; use crate::Application; use std::marker::PhantomData; diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs index 2250913080..7271441d60 100644 --- a/winit/src/clipboard.rs +++ b/winit/src/clipboard.rs @@ -1,6 +1,4 @@ //! Access the clipboard. -use crate::native::clipboard::Action; -use crate::native::command::{self, Command}; /// A buffer for short-term storage and transfer within and between /// applications. @@ -64,15 +62,3 @@ impl crate::core::Clipboard for Clipboard { self.write(contents) } } - -/// Read the current contents of the clipboard. -pub fn read( - f: impl Fn(Option) -> Message + 'static, -) -> Command { - Command::single(command::Action::Clipboard(Action::Read(Box::new(f)))) -} - -/// Write the given contents to the clipboard. -pub fn write(contents: String) -> Command { - Command::single(command::Action::Clipboard(Action::Write(contents))) -} diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 0d8c04d3d3..5cde510ac4 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -31,9 +31,9 @@ #![allow(clippy::inherent_to_string, clippy::type_complexity)] #![cfg_attr(docsrs, feature(doc_cfg))] pub use iced_graphics as graphics; -pub use iced_native as native; -pub use iced_native::core; -pub use iced_native::futures; +pub use iced_runtime as runtime; +pub use iced_runtime::core; +pub use iced_runtime::futures; pub use iced_style as style; pub use winit; @@ -42,7 +42,6 @@ pub mod application; pub mod clipboard; pub mod conversion; pub mod settings; -pub mod window; #[cfg(feature = "system")] pub mod system; diff --git a/winit/src/system.rs b/winit/src/system.rs index 3a6a8a8ec3..069efa29fd 100644 --- a/winit/src/system.rs +++ b/winit/src/system.rs @@ -1,7 +1,7 @@ //! Access the native system. use crate::graphics::compositor; -use crate::native::command::{self, Command}; -use crate::native::system::{Action, Information}; +use crate::runtime::command::{self, Command}; +use crate::runtime::system::{Action, Information}; /// Query for available system information. pub fn fetch_information(