Move Screenshot inside window module
This commit is contained in:
parent
93673836cd
commit
5ae726e02c
7 changed files with 13 additions and 10 deletions
|
|
@ -1,16 +1,17 @@
|
||||||
use ::image as img;
|
|
||||||
use ::image::ColorType;
|
|
||||||
use iced::alignment;
|
use iced::alignment;
|
||||||
use iced::keyboard::KeyCode;
|
use iced::keyboard::KeyCode;
|
||||||
use iced::theme::{Button, Container};
|
use iced::theme::{Button, Container};
|
||||||
use iced::widget::runtime::{CropError, Screenshot};
|
|
||||||
use iced::widget::{button, column, container, image, row, text, text_input};
|
use iced::widget::{button, column, container, image, row, text, text_input};
|
||||||
|
use iced::window::screenshot::{self, Screenshot};
|
||||||
use iced::{
|
use iced::{
|
||||||
event, executor, keyboard, subscription, Alignment, Application, Command,
|
event, executor, keyboard, subscription, Alignment, Application, Command,
|
||||||
ContentFit, Element, Event, Length, Rectangle, Renderer, Subscription,
|
ContentFit, Element, Event, Length, Rectangle, Renderer, Subscription,
|
||||||
Theme,
|
Theme,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use ::image as img;
|
||||||
|
use ::image::ColorType;
|
||||||
|
|
||||||
fn main() -> iced::Result {
|
fn main() -> iced::Result {
|
||||||
env_logger::builder().format_timestamp(None).init();
|
env_logger::builder().format_timestamp(None).init();
|
||||||
|
|
||||||
|
|
@ -21,7 +22,7 @@ struct Example {
|
||||||
screenshot: Option<Screenshot>,
|
screenshot: Option<Screenshot>,
|
||||||
saved_png_path: Option<Result<String, PngError>>,
|
saved_png_path: Option<Result<String, PngError>>,
|
||||||
png_saving: bool,
|
png_saving: bool,
|
||||||
crop_error: Option<CropError>,
|
crop_error: Option<screenshot::CropError>,
|
||||||
x_input_value: Option<u32>,
|
x_input_value: Option<u32>,
|
||||||
y_input_value: Option<u32>,
|
y_input_value: Option<u32>,
|
||||||
width_input_value: Option<u32>,
|
width_input_value: Option<u32>,
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ mod debug;
|
||||||
#[cfg(not(feature = "debug"))]
|
#[cfg(not(feature = "debug"))]
|
||||||
#[path = "debug/null.rs"]
|
#[path = "debug/null.rs"]
|
||||||
mod debug;
|
mod debug;
|
||||||
mod screenshot;
|
|
||||||
|
|
||||||
pub use iced_core as core;
|
pub use iced_core as core;
|
||||||
pub use iced_futures as futures;
|
pub use iced_futures as futures;
|
||||||
|
|
@ -69,5 +68,4 @@ pub use command::Command;
|
||||||
pub use debug::Debug;
|
pub use debug::Debug;
|
||||||
pub use font::Font;
|
pub use font::Font;
|
||||||
pub use program::Program;
|
pub use program::Program;
|
||||||
pub use screenshot::{CropError, Screenshot};
|
|
||||||
pub use user_interface::UserInterface;
|
pub use user_interface::UserInterface;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
//! Build window-based GUI applications.
|
//! Build window-based GUI applications.
|
||||||
mod action;
|
mod action;
|
||||||
|
|
||||||
|
pub mod screenshot;
|
||||||
|
|
||||||
pub use action::Action;
|
pub use action::Action;
|
||||||
|
pub use screenshot::Screenshot;
|
||||||
|
|
||||||
use crate::command::{self, Command};
|
use crate::command::{self, Command};
|
||||||
use crate::core::time::Instant;
|
use crate::core::time::Instant;
|
||||||
use crate::core::window::{Event, Icon, Level, Mode, UserAttention};
|
use crate::core::window::{Event, Icon, Level, Mode, UserAttention};
|
||||||
use crate::futures::subscription::{self, Subscription};
|
use crate::futures::subscription::{self, Subscription};
|
||||||
use crate::screenshot::Screenshot;
|
|
||||||
|
|
||||||
/// Subscribes to the frames of the window of the running application.
|
/// Subscribes to the frames of the window of the running application.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::core::window::{Icon, Level, Mode, UserAttention};
|
use crate::core::window::{Icon, Level, Mode, UserAttention};
|
||||||
use crate::futures::MaybeSend;
|
use crate::futures::MaybeSend;
|
||||||
|
use crate::window::Screenshot;
|
||||||
|
|
||||||
use crate::screenshot::Screenshot;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// An operation to be performed on some window.
|
/// An operation to be performed on some window.
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! Take screenshots of a window.
|
||||||
use crate::core::{Rectangle, Size};
|
use crate::core::{Rectangle, Size};
|
||||||
|
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
|
|
@ -276,6 +276,7 @@ pub mod widget {
|
||||||
mod native {}
|
mod native {}
|
||||||
mod renderer {}
|
mod renderer {}
|
||||||
mod style {}
|
mod style {}
|
||||||
|
mod runtime {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use application::Application;
|
pub use application::Application;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use crate::graphics::compositor::{self, Compositor};
|
||||||
use crate::runtime::clipboard;
|
use crate::runtime::clipboard;
|
||||||
use crate::runtime::program::Program;
|
use crate::runtime::program::Program;
|
||||||
use crate::runtime::user_interface::{self, UserInterface};
|
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::style::application::{Appearance, StyleSheet};
|
||||||
use crate::{Clipboard, Error, Proxy, Settings};
|
use crate::{Clipboard, Error, Proxy, Settings};
|
||||||
|
|
||||||
|
|
@ -819,7 +819,7 @@ pub fn run_command<A, C, E>(
|
||||||
);
|
);
|
||||||
|
|
||||||
proxy
|
proxy
|
||||||
.send_event(tag(Screenshot::new(
|
.send_event(tag(window::Screenshot::new(
|
||||||
bytes,
|
bytes,
|
||||||
state.physical_size(),
|
state.physical_size(),
|
||||||
)))
|
)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue