diff options
author | 2023-03-25 10:45:39 -0700 | |
---|---|---|
committer | 2023-06-06 15:37:30 +0200 | |
commit | 233196eb14b40f8bd5201ea0262571f82136ad53 (patch) | |
tree | 410cf71cda98bdcb55ecc384f7fbc2f4ef669edd /runtime/src/window.rs | |
parent | c15f1b5f6575792cc89bb5fba2e613428397e46a (diff) | |
download | iced-233196eb14b40f8bd5201ea0262571f82136ad53.tar.gz iced-233196eb14b40f8bd5201ea0262571f82136ad53.tar.bz2 iced-233196eb14b40f8bd5201ea0262571f82136ad53.zip |
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Diffstat (limited to 'runtime/src/window.rs')
-rw-r--r-- | runtime/src/window.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs index d4111293..9b66cb0e 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -7,6 +7,7 @@ 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. /// @@ -115,3 +116,10 @@ pub fn fetch_id<Message>( pub fn change_icon<Message>(icon: Icon) -> Command<Message> { Command::single(command::Action::Window(Action::ChangeIcon(icon))) } + +/// Captures a [`Screenshot`] from the window. +pub fn screenshot<Message>( + f: impl FnOnce(Screenshot) -> Message + Send + 'static, +) -> Command<Message> { + Command::single(command::Action::Window(Action::Screenshot(Box::new(f)))) +} |