summaryrefslogtreecommitdiffstats
path: root/runtime/src/window/action.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-06-27 20:37:19 +0200
committerLibravatar GitHub <noreply@github.com>2023-06-27 20:37:19 +0200
commitf6966268bb6d58b4b03ba61fc5732e1bf016e2a1 (patch)
treec8e79670b59fdd19103cb1a3a6d18783136e2294 /runtime/src/window/action.rs
parentef18ecf4ef0fe654578380059b467fe2fb34aa0a (diff)
parent5b6e205e998cbb20b3c8aaff8b515d78315d6703 (diff)
downloadiced-f6966268bb6d58b4b03ba61fc5732e1bf016e2a1.tar.gz
iced-f6966268bb6d58b4b03ba61fc5732e1bf016e2a1.tar.bz2
iced-f6966268bb6d58b4b03ba61fc5732e1bf016e2a1.zip
Merge pull request #1845 from bungoboingo/feat/offscreen-rendering
Feat: Offscreen Rendering & Screenshots
Diffstat (limited to '')
-rw-r--r--runtime/src/window/action.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs
index a9d2a3d0..09be1810 100644
--- a/runtime/src/window/action.rs
+++ b/runtime/src/window/action.rs
@@ -1,5 +1,6 @@
use crate::core::window::{Icon, Level, Mode, UserAttention};
use crate::futures::MaybeSend;
+use crate::window::Screenshot;
use std::fmt;
@@ -89,6 +90,8 @@ pub enum Action<T> {
/// - **X11:** Has no universal guidelines for icon sizes, so you're at the whims of the WM. That
/// said, it's usually in the same ballpark as on Windows.
ChangeIcon(Icon),
+ /// Screenshot the viewport of the window.
+ Screenshot(Box<dyn FnOnce(Screenshot) -> T + 'static>),
}
impl<T> Action<T> {
@@ -118,6 +121,11 @@ impl<T> Action<T> {
Self::ChangeLevel(level) => Action::ChangeLevel(level),
Self::FetchId(o) => Action::FetchId(Box::new(move |s| f(o(s)))),
Self::ChangeIcon(icon) => Action::ChangeIcon(icon),
+ Self::Screenshot(tag) => {
+ Action::Screenshot(Box::new(move |screenshot| {
+ f(tag(screenshot))
+ }))
+ }
}
}
}
@@ -155,6 +163,7 @@ impl<T> fmt::Debug for Action<T> {
Self::ChangeIcon(_icon) => {
write!(f, "Action::ChangeIcon(icon)")
}
+ Self::Screenshot(_) => write!(f, "Action::Screenshot"),
}
}
}