summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorLibravatar gigas002 <gigas002@pm.me>2024-05-08 19:16:06 +0900
committerLibravatar gigas002 <gigas002@pm.me>2024-05-08 19:16:06 +0900
commit477887b3870aa5fbdab96c3a06f3b930462d7842 (patch)
tree2b3272bb178f8757169511966589fe6a106733f4 /runtime
parent0ebe0629cef37aee5c48b9409fc36618a3a3e60d (diff)
parente07b42ac96b8d098a883c93afe828a439f479c7b (diff)
downloadiced-477887b3870aa5fbdab96c3a06f3b930462d7842.tar.gz
iced-477887b3870aa5fbdab96c3a06f3b930462d7842.tar.bz2
iced-477887b3870aa5fbdab96c3a06f3b930462d7842.zip
Merge branch 'master' of https://github.com/iced-rs/iced into iced-rs-master
Diffstat (limited to '')
-rw-r--r--runtime/Cargo.toml1
-rw-r--r--runtime/src/multi_window/state.rs2
-rw-r--r--runtime/src/program/state.rs2
-rw-r--r--runtime/src/window/screenshot.rs16
4 files changed, 14 insertions, 7 deletions
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index 21503462..703c3ed9 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -18,6 +18,7 @@ debug = []
multi-window = []
[dependencies]
+bytes.workspace = true
iced_core.workspace = true
iced_futures.workspace = true
iced_futures.features = ["thread-pool"]
diff --git a/runtime/src/multi_window/state.rs b/runtime/src/multi_window/state.rs
index afd04519..10366ec0 100644
--- a/runtime/src/multi_window/state.rs
+++ b/runtime/src/multi_window/state.rs
@@ -48,7 +48,7 @@ where
caches,
queued_events: Vec::new(),
queued_messages: Vec::new(),
- mouse_interaction: mouse::Interaction::Idle,
+ mouse_interaction: mouse::Interaction::None,
}
}
diff --git a/runtime/src/program/state.rs b/runtime/src/program/state.rs
index d685b07c..c6589c22 100644
--- a/runtime/src/program/state.rs
+++ b/runtime/src/program/state.rs
@@ -47,7 +47,7 @@ where
cache,
queued_events: Vec::new(),
queued_messages: Vec::new(),
- mouse_interaction: mouse::Interaction::Idle,
+ mouse_interaction: mouse::Interaction::None,
}
}
diff --git a/runtime/src/window/screenshot.rs b/runtime/src/window/screenshot.rs
index 21e04718..fb318110 100644
--- a/runtime/src/window/screenshot.rs
+++ b/runtime/src/window/screenshot.rs
@@ -1,8 +1,8 @@
//! Take screenshots of a window.
use crate::core::{Rectangle, Size};
+use bytes::Bytes;
use std::fmt::{Debug, Formatter};
-use std::sync::Arc;
/// Data of a screenshot, captured with `window::screenshot()`.
///
@@ -10,7 +10,7 @@ use std::sync::Arc;
#[derive(Clone)]
pub struct Screenshot {
/// The bytes of the [`Screenshot`].
- pub bytes: Arc<Vec<u8>>,
+ pub bytes: Bytes,
/// The size of the [`Screenshot`].
pub size: Size<u32>,
}
@@ -28,9 +28,9 @@ impl Debug for Screenshot {
impl Screenshot {
/// Creates a new [`Screenshot`].
- pub fn new(bytes: Vec<u8>, size: Size<u32>) -> Self {
+ pub fn new(bytes: impl Into<Bytes>, size: Size<u32>) -> Self {
Self {
- bytes: Arc::new(bytes),
+ bytes: bytes.into(),
size,
}
}
@@ -68,7 +68,7 @@ impl Screenshot {
);
Ok(Self {
- bytes: Arc::new(chopped),
+ bytes: Bytes::from(chopped),
size: Size::new(region.width, region.height),
})
}
@@ -80,6 +80,12 @@ impl AsRef<[u8]> for Screenshot {
}
}
+impl From<Screenshot> for Bytes {
+ fn from(screenshot: Screenshot) -> Self {
+ screenshot.bytes
+ }
+}
+
#[derive(Debug, thiserror::Error)]
/// Errors that can occur when cropping a [`Screenshot`].
pub enum CropError {