From 5ae726e02c4d6c9889ef7335d9bc80ef1992e34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 27 Jun 2023 19:41:03 +0200 Subject: [PATCH] Move `Screenshot` inside `window` module --- examples/screenshot/src/main.rs | 9 +++++---- runtime/src/lib.rs | 2 -- runtime/src/window.rs | 4 +++- runtime/src/window/action.rs | 2 +- runtime/src/{ => window}/screenshot.rs | 1 + src/lib.rs | 1 + winit/src/application.rs | 4 ++-- 7 files changed, 13 insertions(+), 10 deletions(-) rename runtime/src/{ => window}/screenshot.rs (98%) diff --git a/examples/screenshot/src/main.rs b/examples/screenshot/src/main.rs index ef2be4fe..83824535 100644 --- a/examples/screenshot/src/main.rs +++ b/examples/screenshot/src/main.rs @@ -1,16 +1,17 @@ -use ::image as img; -use ::image::ColorType; use iced::alignment; use iced::keyboard::KeyCode; use iced::theme::{Button, Container}; -use iced::widget::runtime::{CropError, Screenshot}; use iced::widget::{button, column, container, image, row, text, text_input}; +use iced::window::screenshot::{self, Screenshot}; use iced::{ event, executor, keyboard, subscription, Alignment, Application, Command, ContentFit, Element, Event, Length, Rectangle, Renderer, Subscription, Theme, }; +use ::image as img; +use ::image::ColorType; + fn main() -> iced::Result { env_logger::builder().format_timestamp(None).init(); @@ -21,7 +22,7 @@ struct Example { screenshot: Option, saved_png_path: Option>, png_saving: bool, - crop_error: Option, + crop_error: Option, x_input_value: Option, y_input_value: Option, width_input_value: Option, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 32ed14d8..50abf7b2 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -60,7 +60,6 @@ mod debug; #[cfg(not(feature = "debug"))] #[path = "debug/null.rs"] mod debug; -mod screenshot; pub use iced_core as core; pub use iced_futures as futures; @@ -69,5 +68,4 @@ pub use command::Command; pub use debug::Debug; pub use font::Font; pub use program::Program; -pub use screenshot::{CropError, Screenshot}; pub use user_interface::UserInterface; diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 9b66cb0e..e448edef 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -1,13 +1,15 @@ //! Build window-based GUI applications. mod action; +pub mod screenshot; + pub use action::Action; +pub use screenshot::Screenshot; use crate::command::{self, Command}; use crate::core::time::Instant; use crate::core::window::{Event, Icon, Level, Mode, UserAttention}; use crate::futures::subscription::{self, Subscription}; -use crate::screenshot::Screenshot; /// Subscribes to the frames of the window of the running application. /// diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs index cb430681..09be1810 100644 --- a/runtime/src/window/action.rs +++ b/runtime/src/window/action.rs @@ -1,7 +1,7 @@ use crate::core::window::{Icon, Level, Mode, UserAttention}; use crate::futures::MaybeSend; +use crate::window::Screenshot; -use crate::screenshot::Screenshot; use std::fmt; /// An operation to be performed on some window. diff --git a/runtime/src/screenshot.rs b/runtime/src/window/screenshot.rs similarity index 98% rename from runtime/src/screenshot.rs rename to runtime/src/window/screenshot.rs index b88f2c20..c84286b6 100644 --- a/runtime/src/screenshot.rs +++ b/runtime/src/window/screenshot.rs @@ -1,3 +1,4 @@ +//! Take screenshots of a window. use crate::core::{Rectangle, Size}; use std::fmt::{Debug, Formatter}; diff --git a/src/lib.rs b/src/lib.rs index a0b8a956..513fb432 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -276,6 +276,7 @@ pub mod widget { mod native {} mod renderer {} mod style {} + mod runtime {} } pub use application::Application; diff --git a/winit/src/application.rs b/winit/src/application.rs index 5176bec6..a4687375 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -19,7 +19,7 @@ use crate::graphics::compositor::{self, Compositor}; use crate::runtime::clipboard; use crate::runtime::program::Program; use crate::runtime::user_interface::{self, UserInterface}; -use crate::runtime::{Command, Debug, Screenshot}; +use crate::runtime::{Command, Debug}; use crate::style::application::{Appearance, StyleSheet}; use crate::{Clipboard, Error, Proxy, Settings}; @@ -819,7 +819,7 @@ pub fn run_command( ); proxy - .send_event(tag(Screenshot::new( + .send_event(tag(window::Screenshot::new( bytes, state.physical_size(), )))