summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-05-23 13:29:45 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-05-23 13:29:45 +0200
commitd8ba6b0673a33724a177f3a1ba59705527280142 (patch)
tree89482c8d1e3a03e00b3a8151abbb81e30ae5898c /runtime
parent72ed8bcc8def9956e25f3720a3095fc96bb2eef0 (diff)
parent468794d918eb06c1dbebb33c32b10017ad335f05 (diff)
downloadiced-d8ba6b0673a33724a177f3a1ba59705527280142.tar.gz
iced-d8ba6b0673a33724a177f3a1ba59705527280142.tar.bz2
iced-d8ba6b0673a33724a177f3a1ba59705527280142.zip
Merge branch 'master' into feat/text-macro
Diffstat (limited to 'runtime')
-rw-r--r--runtime/Cargo.toml4
-rw-r--r--runtime/src/lib.rs7
-rw-r--r--runtime/src/multi_window/state.rs2
-rw-r--r--runtime/src/program.rs4
-rw-r--r--runtime/src/program/state.rs2
-rw-r--r--runtime/src/user_interface.rs12
-rw-r--r--runtime/src/window.rs2
-rw-r--r--runtime/src/window/action.rs2
-rw-r--r--runtime/src/window/screenshot.rs16
9 files changed, 27 insertions, 24 deletions
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index 3a47a971..703c3ed9 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -10,11 +10,15 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
+[lints]
+workspace = true
+
[features]
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/lib.rs b/runtime/src/lib.rs
index 5c2836a5..5f054c46 100644
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -8,13 +8,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
-#![forbid(unsafe_code, rust_2018_idioms)]
-#![deny(
- missing_debug_implementations,
- missing_docs,
- unused_results,
- rustdoc::broken_intra_doc_links
-)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub mod clipboard;
pub mod command;
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.rs b/runtime/src/program.rs
index 6c1b8f07..0ea94d3b 100644
--- a/runtime/src/program.rs
+++ b/runtime/src/program.rs
@@ -2,7 +2,7 @@
use crate::Command;
use iced_core::text;
-use iced_core::{Element, Renderer};
+use iced_core::Element;
mod state;
@@ -11,7 +11,7 @@ pub use state::State;
/// The core of a user interface application following The Elm Architecture.
pub trait Program: Sized {
/// The graphics backend to use to draw the [`Program`].
- type Renderer: Renderer + text::Renderer;
+ type Renderer: text::Renderer;
/// The theme used to draw the [`Program`].
type Theme;
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/user_interface.rs b/runtime/src/user_interface.rs
index 748fb651..006225ed 100644
--- a/runtime/src/user_interface.rs
+++ b/runtime/src/user_interface.rs
@@ -45,7 +45,7 @@ where
///
/// ```no_run
/// # mod iced_wgpu {
- /// # pub use iced_runtime::core::renderer::Null as Renderer;
+ /// # pub type Renderer = ();
/// # }
/// #
/// # pub struct Counter;
@@ -62,7 +62,7 @@ where
/// // Initialization
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
- /// let mut renderer = Renderer::new();
+ /// let mut renderer = Renderer::default();
/// let mut window_size = Size::new(1024.0, 768.0);
///
/// // Application loop
@@ -121,7 +121,7 @@ where
///
/// ```no_run
/// # mod iced_wgpu {
- /// # pub use iced_runtime::core::renderer::Null as Renderer;
+ /// # pub type Renderer = ();
/// # }
/// #
/// # pub struct Counter;
@@ -139,7 +139,7 @@ where
///
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
- /// let mut renderer = Renderer::new();
+ /// let mut renderer = Renderer::default();
/// let mut window_size = Size::new(1024.0, 768.0);
/// let mut cursor = mouse::Cursor::default();
/// let mut clipboard = clipboard::Null;
@@ -374,7 +374,7 @@ where
///
/// ```no_run
/// # mod iced_wgpu {
- /// # pub use iced_runtime::core::renderer::Null as Renderer;
+ /// # pub type Renderer = ();
/// # pub type Theme = ();
/// # }
/// #
@@ -394,7 +394,7 @@ where
///
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
- /// let mut renderer = Renderer::new();
+ /// let mut renderer = Renderer::default();
/// let mut window_size = Size::new(1024.0, 768.0);
/// let mut cursor = mouse::Cursor::default();
/// let mut clipboard = clipboard::Null;
diff --git a/runtime/src/window.rs b/runtime/src/window.rs
index 24171e3e..e32465d3 100644
--- a/runtime/src/window.rs
+++ b/runtime/src/window.rs
@@ -197,7 +197,7 @@ pub fn change_icon<Message>(id: Id, icon: Icon) -> Command<Message> {
/// Note that if the window closes before this call is processed the callback will not be run.
pub fn run_with_handle<Message>(
id: Id,
- f: impl FnOnce(&WindowHandle<'_>) -> Message + 'static,
+ f: impl FnOnce(WindowHandle<'_>) -> Message + 'static,
) -> Command<Message> {
Command::single(command::Action::Window(Action::RunWithHandle(
id,
diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs
index e44ff5a6..07e77872 100644
--- a/runtime/src/window/action.rs
+++ b/runtime/src/window/action.rs
@@ -106,7 +106,7 @@ pub enum Action<T> {
/// said, it's usually in the same ballpark as on Windows.
ChangeIcon(Id, Icon),
/// Runs the closure with the native window handle of the window with the given [`Id`].
- RunWithHandle(Id, Box<dyn FnOnce(&WindowHandle<'_>) -> T + 'static>),
+ RunWithHandle(Id, Box<dyn FnOnce(WindowHandle<'_>) -> T + 'static>),
/// Screenshot the viewport of the window.
Screenshot(Id, Box<dyn FnOnce(Screenshot) -> T + 'static>),
}
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 {