From 238154af4ac8dda7f12dd90aa7be106e933bcb30 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Feb 2023 11:12:15 +0100 Subject: Implement `font::load` command in `iced_native` --- winit/src/application.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 9781a453..889becad 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -851,6 +851,16 @@ pub fn run_command( current_cache = user_interface.into_cache(); *cache = current_cache; } + command::Action::LoadFont { bytes, tagger } => { + use crate::text::Renderer; + + // TODO: Error handling (?) + renderer.load_font(bytes); + + proxy + .send_event(tagger(Ok(()))) + .expect("Send message to event loop"); + } } } } -- cgit From a0597471b81b122b43e1bb90e43e1bcde1e8a892 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 10 Feb 2023 20:24:18 +0100 Subject: Remove `iced_glutin` and `iced_glow` leftovers --- winit/src/settings.rs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'winit') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 78d58000..5c64727b 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -51,14 +51,6 @@ pub struct Settings { /// /// [`Application`]: crate::Application pub exit_on_close_request: bool, - - /// Whether the [`Application`] should try to build the context - /// using OpenGL ES first then OpenGL. - /// - /// NOTE: Only works for the `glow` backend. - /// - /// [`Application`]: crate::Application - pub try_opengles_first: bool, } /// The window settings of an application. -- cgit From 5100b5d0a1f654ec1254b7765ceadfb9091d6939 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 24 Feb 2023 23:24:48 +0100 Subject: Introduce `iced_renderer` subcrate featuring runtime renderer fallback --- winit/src/application.rs | 2 +- winit/src/system.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 889becad..1bfce3a1 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -17,8 +17,8 @@ use crate::{ use iced_futures::futures; use iced_futures::futures::channel::mpsc; -use iced_graphics::compositor; use iced_graphics::window; +use iced_graphics::window::compositor; use iced_native::program::Program; use iced_native::time::Instant; use iced_native::user_interface::{self, UserInterface}; diff --git a/winit/src/system.rs b/winit/src/system.rs index 619086b8..8a7b2a11 100644 --- a/winit/src/system.rs +++ b/winit/src/system.rs @@ -2,7 +2,7 @@ use crate::command::{self, Command}; pub use iced_native::system::*; -use iced_graphics::compositor; +use iced_graphics::window::compositor; /// Query for available system information. pub fn fetch_information( -- cgit From 535d7a4d57e131e661587b36e41820dd6ccccc3e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 25 Feb 2023 16:05:42 +0100 Subject: Implement basic presentation with `softbuffer` for `iced_tiny_skia` --- winit/src/application.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 1bfce3a1..b52f0197 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -285,21 +285,18 @@ async fn run_instance( use winit::event; use winit::event_loop::ControlFlow; - let mut clipboard = Clipboard::connect(&window); - let mut cache = user_interface::Cache::default(); - let mut surface = compositor.create_surface(&window); - let mut should_exit = false; - let mut state = State::new(&application, &window); let mut viewport_version = state.viewport_version(); - let physical_size = state.physical_size(); - compositor.configure_surface( - &mut surface, + let mut clipboard = Clipboard::connect(&window); + let mut cache = user_interface::Cache::default(); + let mut surface = compositor.create_surface( + &window, physical_size.width, physical_size.height, ); + let mut should_exit = false; if should_be_visible { window.set_visible(true); -- cgit From 3a0d34c0240f4421737a6a08761f99d6f8140d02 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Mar 2023 05:37:11 +0100 Subject: Create `iced_widget` subcrate and re-organize the whole codebase --- winit/Cargo.toml | 6 ++-- winit/src/application.rs | 77 ++++++++++++++++++++---------------------- winit/src/application/state.rs | 14 +++++--- winit/src/clipboard.rs | 7 ++-- winit/src/conversion.rs | 11 +++--- winit/src/error.rs | 7 ++-- winit/src/lib.rs | 8 +++-- winit/src/proxy.rs | 2 +- winit/src/system.rs | 7 ++-- winit/src/window.rs | 52 +++++++++++----------------- 10 files changed, 90 insertions(+), 101 deletions(-) (limited to 'winit') diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 60e464c6..21c14f68 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -35,9 +35,9 @@ path = "../native" version = "0.7" path = "../graphics" -[dependencies.iced_futures] -version = "0.6" -path = "../futures" +[dependencies.iced_style] +version = "0.7" +path = "../style" [dependencies.tracing] version = "0.1.37" diff --git a/winit/src/application.rs b/winit/src/application.rs index b52f0197..c8162c9b 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -5,25 +5,25 @@ mod state; pub use state::State; -use crate::clipboard::{self, Clipboard}; use crate::conversion; -use crate::mouse; -use crate::renderer; -use crate::widget::operation; -use crate::{ - Command, Debug, Error, Event, Executor, Proxy, Runtime, Settings, Size, - Subscription, -}; - -use iced_futures::futures; -use iced_futures::futures::channel::mpsc; -use iced_graphics::window; -use iced_graphics::window::compositor; -use iced_native::program::Program; -use iced_native::time::Instant; -use iced_native::user_interface::{self, UserInterface}; - -pub use iced_native::application::{Appearance, StyleSheet}; +use crate::core; +use crate::core::mouse; +use crate::core::renderer; +use crate::core::time::Instant; +use crate::core::widget::operation; +use crate::core::window; +use crate::core::{Event, Size}; +use crate::futures::futures; +use crate::futures::Executor; +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, Runtime, Subscription}; +use crate::style::application::{Appearance, StyleSheet}; +use crate::{Clipboard, Error, Proxy, Settings}; + +use futures::channel::mpsc; use std::mem::ManuallyDrop; @@ -45,7 +45,7 @@ use tracing::{info_span, instrument::Instrument}; /// can be toggled by pressing `F12`. pub trait Application: Program where - ::Theme: StyleSheet, + ::Theme: StyleSheet, { /// The data needed to initialize your [`Application`]. type Flags; @@ -67,12 +67,12 @@ where fn title(&self) -> String; /// Returns the current `Theme` of the [`Application`]. - fn theme(&self) -> ::Theme; + fn theme(&self) -> ::Theme; /// Returns the `Style` variation of the `Theme`. fn style( &self, - ) -> <::Theme as StyleSheet>::Style { + ) -> <::Theme as StyleSheet>::Style { Default::default() } @@ -112,8 +112,8 @@ pub fn run( where A: Application + 'static, E: Executor + 'static, - C: window::Compositor + 'static, - ::Theme: StyleSheet, + C: Compositor + 'static, + ::Theme: StyleSheet, { use futures::task; use futures::Future; @@ -278,10 +278,10 @@ async fn run_instance( ) where A: Application + 'static, E: Executor + 'static, - C: window::Compositor + 'static, - ::Theme: StyleSheet, + C: Compositor + 'static, + ::Theme: StyleSheet, { - use iced_futures::futures::stream::StreamExt; + use futures::stream::StreamExt; use winit::event; use winit::event_loop::ControlFlow; @@ -411,7 +411,7 @@ async fn run_instance( // Then, we can use the `interface_state` here to decide if a redraw // is needed right away, or simply wait until a specific time. let redraw_event = Event::Window( - crate::window::Event::RedrawRequested(Instant::now()), + window::Event::RedrawRequested(Instant::now()), ); let (interface_state, _) = user_interface.update( @@ -442,17 +442,14 @@ async fn run_instance( } window.request_redraw(); - runtime - .broadcast((redraw_event, crate::event::Status::Ignored)); + runtime.broadcast((redraw_event, core::event::Status::Ignored)); let _ = control_sender.start_send(match interface_state { user_interface::State::Updated { redraw_request: Some(redraw_request), } => match redraw_request { - crate::window::RedrawRequest::NextFrame => { - ControlFlow::Poll - } - crate::window::RedrawRequest::At(at) => { + window::RedrawRequest::NextFrame => ControlFlow::Poll, + window::RedrawRequest::At(at) => { ControlFlow::WaitUntil(at) } }, @@ -464,9 +461,9 @@ async fn run_instance( event::Event::PlatformSpecific(event::PlatformSpecific::MacOS( event::MacOS::ReceivedUrl(url), )) => { - use iced_native::event; + use crate::core::event; - events.push(iced_native::Event::PlatformSpecific( + events.push(Event::PlatformSpecific( event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl( url, )), @@ -615,7 +612,7 @@ pub fn build_user_interface<'a, A: Application>( debug: &mut Debug, ) -> UserInterface<'a, A::Message, A::Renderer> where - ::Theme: StyleSheet, + ::Theme: StyleSheet, { #[cfg(feature = "trace")] let view_span = info_span!("Application", "VIEW").entered(); @@ -656,7 +653,7 @@ pub fn update( window: &winit::window::Window, graphics_info: impl FnOnce() -> compositor::Information + Copy, ) where - ::Theme: StyleSheet, + ::Theme: StyleSheet, { for message in messages.drain(..) { #[cfg(feature = "trace")] @@ -708,7 +705,7 @@ pub fn run_command( ) where A: Application, E: Executor, - ::Theme: StyleSheet, + ::Theme: StyleSheet, { use iced_native::command; use iced_native::system; @@ -767,7 +764,7 @@ pub fn run_command( let mode = if window.is_visible().unwrap_or(true) { conversion::mode(window.fullscreen()) } else { - window::Mode::Hidden + core::window::Mode::Hidden }; proxy @@ -849,7 +846,7 @@ pub fn run_command( *cache = current_cache; } command::Action::LoadFont { bytes, tagger } => { - use crate::text::Renderer; + use crate::core::text::Renderer; // TODO: Error handling (?) renderer.load_font(bytes); diff --git a/winit/src/application/state.rs b/winit/src/application/state.rs index 8d6a1df1..b727e03c 100644 --- a/winit/src/application/state.rs +++ b/winit/src/application/state.rs @@ -1,6 +1,10 @@ use crate::application::{self, StyleSheet as _}; use crate::conversion; -use crate::{Application, Color, Debug, Point, Size, Viewport}; +use crate::core; +use crate::core::{Color, Point, Size}; +use crate::graphics::Viewport; +use crate::native::Debug; +use crate::Application; use std::marker::PhantomData; use winit::event::{Touch, WindowEvent}; @@ -10,7 +14,7 @@ use winit::window::Window; #[allow(missing_debug_implementations)] pub struct State where - ::Theme: application::StyleSheet, + ::Theme: application::StyleSheet, { title: String, scale_factor: f64, @@ -18,14 +22,14 @@ where viewport_version: usize, cursor_position: winit::dpi::PhysicalPosition, modifiers: winit::event::ModifiersState, - theme: ::Theme, + theme: ::Theme, appearance: application::Appearance, application: PhantomData, } impl State where - ::Theme: application::StyleSheet, + ::Theme: application::StyleSheet, { /// Creates a new [`State`] for the provided [`Application`] and window. pub fn new(application: &A, window: &Window) -> Self { @@ -98,7 +102,7 @@ where } /// Returns the current theme of the [`State`]. - pub fn theme(&self) -> &::Theme { + pub fn theme(&self) -> &::Theme { &self.theme } diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs index c1fd8813..22509130 100644 --- a/winit/src/clipboard.rs +++ b/winit/src/clipboard.rs @@ -1,7 +1,6 @@ //! Access the clipboard. -pub use iced_native::clipboard::Action; - -use crate::command::{self, Command}; +use crate::native::clipboard::Action; +use crate::native::command::{self, Command}; /// A buffer for short-term storage and transfer within and between /// applications. @@ -56,7 +55,7 @@ impl Clipboard { } } -impl iced_native::Clipboard for Clipboard { +impl crate::core::Clipboard for Clipboard { fn read(&self) -> Option { self.read() } diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 1b2ead36..0759ad9d 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -2,11 +2,12 @@ //! //! [`winit`]: https://github.com/rust-windowing/winit //! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native -use crate::keyboard; -use crate::mouse; -use crate::touch; -use crate::window; -use crate::{Event, Point, Position}; +use crate::core::keyboard; +use crate::core::mouse; +use crate::core::touch; +use crate::core::window; +use crate::core::{Event, Point}; +use crate::Position; /// Converts a winit window event into an iced event. pub fn window_event( diff --git a/winit/src/error.rs b/winit/src/error.rs index eaeafd51..7687fb17 100644 --- a/winit/src/error.rs +++ b/winit/src/error.rs @@ -1,4 +1,5 @@ -use iced_futures::futures; +use crate::futures::futures; +use crate::graphics; /// An error that occurred while running an application. #[derive(Debug, thiserror::Error)] @@ -13,10 +14,10 @@ pub enum Error { /// The application graphics context could not be created. #[error("the application graphics context could not be created")] - GraphicsCreationFailed(iced_graphics::Error), + GraphicsCreationFailed(graphics::Error), } -impl From for Error { +impl From for Error { fn from(error: iced_graphics::Error) -> Error { Error::GraphicsCreationFailed(error) } diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 3a33e174..0d8c04d3 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -30,9 +30,11 @@ #![forbid(rust_2018_idioms, unsafe_code)] #![allow(clippy::inherent_to_string, clippy::type_complexity)] #![cfg_attr(docsrs, feature(doc_cfg))] - -#[doc(no_inline)] -pub use iced_native::*; +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_style as style; pub use winit; #[cfg(feature = "application")] diff --git a/winit/src/proxy.rs b/winit/src/proxy.rs index 7b9074d7..1d6c48bb 100644 --- a/winit/src/proxy.rs +++ b/winit/src/proxy.rs @@ -1,4 +1,4 @@ -use iced_native::futures::{ +use crate::futures::futures::{ channel::mpsc, task::{Context, Poll}, Sink, diff --git a/winit/src/system.rs b/winit/src/system.rs index 8a7b2a11..3a6a8a8e 100644 --- a/winit/src/system.rs +++ b/winit/src/system.rs @@ -1,8 +1,7 @@ //! Access the native system. -use crate::command::{self, Command}; -pub use iced_native::system::*; - -use iced_graphics::window::compositor; +use crate::graphics::compositor; +use crate::native::command::{self, Command}; +use crate::native::system::{Action, Information}; /// Query for available system information. pub fn fetch_information( diff --git a/winit/src/window.rs b/winit/src/window.rs index 961562bd..6ac58e20 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -1,68 +1,58 @@ //! Interact with the window of your application. -use crate::command::{self, Command}; -use iced_native::window; - -pub use window::{frames, Event, Mode, RedrawRequest, UserAttention}; +use crate::core::window::{Mode, UserAttention}; +use crate::native::command::{self, Command}; +use crate::native::window::Action; /// Closes the current window and exits the application. pub fn close() -> Command { - 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() -> Command { - 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(width: u32, height: u32) -> Command { - 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(maximized: bool) -> Command { - Command::single(command::Action::Window(window::Action::Maximize( - maximized, - ))) + Command::single(command::Action::Window(Action::Maximize(maximized))) } /// Minimes the window. pub fn minimize(minimized: bool) -> Command { - 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(x: i32, y: i32) -> Command { - 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(mode: Mode) -> Command { - 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( f: impl FnOnce(Mode) -> Message + 'static, ) -> Command { - 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() -> Command { - Command::single(command::Action::Window(window::Action::ToggleMaximize)) + Command::single(command::Action::Window(Action::ToggleMaximize)) } /// Toggles the window decorations. pub fn toggle_decorations() -> Command { - 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 +64,9 @@ pub fn toggle_decorations() -> Command { pub fn request_user_attention( user_attention: Option, ) -> Command { - 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 +76,17 @@ pub fn request_user_attention( /// you are certain that's what the user wants. Focus stealing can cause an extremely disruptive /// user experience. pub fn gain_focus() -> Command { - 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(on_top: bool) -> Command { - 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( f: impl FnOnce(u64) -> Message + 'static, ) -> Command { - Command::single(command::Action::Window(window::Action::FetchId(Box::new( - f, - )))) + Command::single(command::Action::Window(Action::FetchId(Box::new(f)))) } -- cgit From f4cf488e0b083b5d7b7612c650917233163ee9cb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Mar 2023 04:15:10 +0100 Subject: Remove generic `Hasher` and `Event` from `subscription::Recipe` --- winit/src/application.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index c8162c9b..c95dbf62 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -14,12 +14,12 @@ use crate::core::widget::operation; use crate::core::window; use crate::core::{Event, Size}; use crate::futures::futures; -use crate::futures::Executor; +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, Runtime, Subscription}; +use crate::native::{Command, Debug}; use crate::style::application::{Appearance, StyleSheet}; use crate::{Clipboard, Error, Proxy, Settings}; @@ -316,7 +316,7 @@ async fn run_instance( &window, || compositor.fetch_information(), ); - runtime.track(application.subscription()); + runtime.track(application.subscription().into_recipes()); let mut user_interface = ManuallyDrop::new(build_user_interface( &application, @@ -360,8 +360,10 @@ async fn run_instance( debug.event_processing_finished(); - for event in events.drain(..).zip(statuses.into_iter()) { - runtime.broadcast(event); + for (event, status) in + events.drain(..).zip(statuses.into_iter()) + { + runtime.broadcast(event, status); } if !messages.is_empty() @@ -442,7 +444,7 @@ async fn run_instance( } window.request_redraw(); - runtime.broadcast((redraw_event, core::event::Status::Ignored)); + runtime.broadcast(redraw_event, core::event::Status::Ignored); let _ = control_sender.start_send(match interface_state { user_interface::State::Updated { @@ -685,7 +687,7 @@ pub fn update( } let subscription = application.subscription(); - runtime.track(subscription); + runtime.track(subscription.into_recipes()); } /// Runs the actions of a [`Command`]. -- cgit From 8af69be47e88896b3c5f70174db609eee0c67971 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Mar 2023 06:23:40 +0100 Subject: Converge `Command` types from `iced_futures` and `iced_native` --- winit/src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index c95dbf62..d863c846 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -818,7 +818,7 @@ pub fn run_command( }, command::Action::Widget(action) => { let mut current_cache = std::mem::take(cache); - let mut current_operation = Some(action.into_operation()); + let mut current_operation = Some(action); let mut user_interface = build_user_interface( application, -- cgit From 99e0a71504456976ba88040f5d1d3bbc347694ea Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Mar 2023 06:35:20 +0100 Subject: Rename `iced_native` to `iced_runtime` --- 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 +- winit/src/window.rs | 92 ------------------------------------------ 7 files changed, 16 insertions(+), 123 deletions(-) delete mode 100644 winit/src/window.rs (limited to 'winit') diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 21c14f68..bfd22093 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 d863c846..9666fcae 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 b727e03c..c37ccca6 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 22509130..7271441d 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 0d8c04d3..5cde510a 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 3a6a8a8e..069efa29 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( diff --git a/winit/src/window.rs b/winit/src/window.rs deleted file mode 100644 index 6ac58e20..00000000 --- a/winit/src/window.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! Interact with the window of your application. -use crate::core::window::{Mode, UserAttention}; -use crate::native::command::{self, Command}; -use crate::native::window::Action; - -/// Closes the current window and exits the application. -pub fn close() -> Command { - Command::single(command::Action::Window(Action::Close)) -} - -/// Begins dragging the window while the left mouse button is held. -pub fn drag() -> Command { - Command::single(command::Action::Window(Action::Drag)) -} - -/// Resizes the window to the given logical dimensions. -pub fn resize(width: u32, height: u32) -> Command { - Command::single(command::Action::Window(Action::Resize { width, height })) -} - -/// Maximizes the window. -pub fn maximize(maximized: bool) -> Command { - Command::single(command::Action::Window(Action::Maximize(maximized))) -} - -/// Minimes the window. -pub fn minimize(minimized: bool) -> Command { - Command::single(command::Action::Window(Action::Minimize(minimized))) -} - -/// Moves a window to the given logical coordinates. -pub fn move_to(x: i32, y: i32) -> Command { - Command::single(command::Action::Window(Action::Move { x, y })) -} - -/// Sets the [`Mode`] of the window. -pub fn change_mode(mode: Mode) -> Command { - Command::single(command::Action::Window(Action::ChangeMode(mode))) -} - -/// Fetches the current [`Mode`] of the window. -pub fn fetch_mode( - f: impl FnOnce(Mode) -> Message + 'static, -) -> Command { - Command::single(command::Action::Window(Action::FetchMode(Box::new(f)))) -} - -/// Toggles the window to maximized or back. -pub fn toggle_maximize() -> Command { - Command::single(command::Action::Window(Action::ToggleMaximize)) -} - -/// Toggles the window decorations. -pub fn toggle_decorations() -> Command { - Command::single(command::Action::Window(Action::ToggleDecorations)) -} - -/// Request user attention to the window, this has no effect if the application -/// is already focused. How requesting for user attention manifests is platform dependent, -/// see [`UserAttention`] for details. -/// -/// Providing `None` will unset the request for user attention. Unsetting the request for -/// user attention might not be done automatically by the WM when the window receives input. -pub fn request_user_attention( - user_attention: Option, -) -> Command { - 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 -/// already in focus, minimized, or not visible. -/// -/// This [`Command`] steals input focus from other applications. Do not use this method unless -/// you are certain that's what the user wants. Focus stealing can cause an extremely disruptive -/// user experience. -pub fn gain_focus() -> Command { - 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(on_top: bool) -> Command { - Command::single(command::Action::Window(Action::ChangeAlwaysOnTop(on_top))) -} - -/// Fetches an identifier unique to the window. -pub fn fetch_id( - f: impl FnOnce(u64) -> Message + 'static, -) -> Command { - Command::single(command::Action::Window(Action::FetchId(Box::new(f)))) -} -- cgit