From af9e353f5003cb323a46340acf1939123147a041 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 7 Jan 2025 13:56:58 -0800 Subject: [PATCH 1/4] dnd_source: Add suppport for surface offset The `drag_icon` callback is passed the offset of the cursor within the widget at the start of the drag, and can return an offset the drag surface should be placed relative to the cursor. --- iced | 2 +- src/widget/dnd_source.rs | 17 +++++++++++------ src/widget/text_input/input.rs | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/iced b/iced index 2cc6865c..9ad04dad 160000 --- a/iced +++ b/iced @@ -1 +1 @@ -Subproject commit 2cc6865c908d025e43d7fc937f6b67defd51ea18 +Subproject commit 9ad04dadde75ac4b445602fc6f31e05d7b7003c3 diff --git a/src/widget/dnd_source.rs b/src/widget/dnd_source.rs index 38b921ee..d57e099b 100644 --- a/src/widget/dnd_source.rs +++ b/src/widget/dnd_source.rs @@ -32,7 +32,7 @@ pub struct DndSource<'a, Message, D> { container: Element<'a, Message>, window: Option, drag_content: Option D>>, - drag_icon: Option (Element<'static, ()>, tree::State)>>, + drag_icon: Option (Element<'static, ()>, tree::State, Vector)>>, on_start: Option, on_cancelled: Option, on_finish: Option, @@ -90,7 +90,7 @@ impl< #[must_use] pub fn drag_icon( mut self, - f: impl Fn() -> (Element<'static, ()>, tree::State) + 'static, + f: impl Fn(Vector) -> (Element<'static, ()>, tree::State, Vector) + 'static, ) -> Self { self.drag_icon = Some(Box::new(f)); self @@ -102,7 +102,7 @@ impl< self } - pub fn start_dnd(&self, clipboard: &mut dyn Clipboard, bounds: Rectangle) { + pub fn start_dnd(&self, clipboard: &mut dyn Clipboard, bounds: Rectangle, offset: Vector) { let Some(content) = self.drag_content.as_ref().map(|f| f()) else { return; }; @@ -116,13 +116,14 @@ impl< Some(iced_core::clipboard::DndSource::Widget(self.id.clone())) }, self.drag_icon.as_ref().map(|f| { - let (icon, state) = f(); - ( + let (icon, state, offset) = f(offset); + iced_core::clipboard::IconSurface::new( container(icon) .width(Length::Fixed(bounds.width)) .height(Length::Fixed(bounds.height)) .into(), state, + offset, ) }), Box::new(content), @@ -262,7 +263,11 @@ impl< if let Some(on_start) = self.on_start.as_ref() { shell.publish(on_start.clone()) } - self.start_dnd(clipboard, state.cached_bounds); + let offset = Vector::new( + left_pressed_position.x - layout.bounds().x, + left_pressed_position.y - layout.bounds().y, + ); + self.start_dnd(clipboard, state.cached_bounds, offset); state.is_dragging = true; state.left_pressed_position = None; } diff --git a/src/widget/text_input/input.rs b/src/widget/text_input/input.rs index 80bd8b54..0ff27127 100644 --- a/src/widget/text_input/input.rs +++ b/src/widget/text_input/input.rs @@ -1350,12 +1350,13 @@ where clipboard, false, id.map(|id| iced_core::clipboard::DndSource::Widget(id)), - Some(( + Some(iced_core::clipboard::IconSurface::new( Element::from( TextInput::<'static, ()>::new("", input_text.clone()) .dnd_icon(true), ), iced_core::widget::tree::State::new(state_clone), + Vector::ZERO, )), Box::new(TextInputString(input_text)), DndAction::Move, From bd8347f7fcb8acad3bfd90cb0bc0891330db12e6 Mon Sep 17 00:00:00 2001 From: Dryadxon <81884588+Dryadxon@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:31:26 +0000 Subject: [PATCH 2/4] fix: impl combo_box::Catalog --- src/theme/style/iced.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index b12d77f4..37920618 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -8,8 +8,8 @@ use cosmic_theme::composite::over; use iced::{ overlay::menu, widget::{ - button as iced_button, checkbox as iced_checkbox, container as iced_container, pane_grid, - pick_list, progress_bar, radio, rule, scrollable, + button as iced_button, checkbox as iced_checkbox, combo_box, container as iced_container, + pane_grid, pick_list, progress_bar, radio, rule, scrollable, slider::{self, Rail}, svg, toggler, }, @@ -1481,3 +1481,5 @@ impl iced_widget::qr_code::Catalog for Theme { class(self) } } + +impl combo_box::Catalog for Theme {} From 99b729faff21946ca4104578de01543e8df1faa2 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 14 Jan 2025 21:41:16 +0100 Subject: [PATCH 3/4] chore: update image-rs and set defaults to only png + jpeg --- Cargo.toml | 16 +++++++++++++--- iced | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b2afe43f..ee230e34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ a11y = ["iced/a11y", "iced_accessibility"] # Enable about widget about = ["desktop", "dep:license"] # Builds support for animated images -animated-image = ["image", "dep:async-fs", "tokio?/io-util", "tokio?/fs"] +animated-image = ["dep:async-fs", "tokio?/io-util", "tokio?/fs"] # XXX autosize should not be used on winit windows unless dialogs autosize = [] applet = [ @@ -95,7 +95,10 @@ cosmic-config = { path = "cosmic-config" } cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true } css-color = "0.2.5" derive_setters = "0.1.5" -image = { version = "0.25.1", optional = true } +image = { version = "0.25.5", default-features = false, features = [ + "jpeg", + "png", +] } lazy_static = "1.4.0" libc = { version = "0.2.155", optional = true } license = { version = "3.5.1", optional = true } @@ -127,7 +130,14 @@ path = "cosmic-theme" [dependencies.iced] path = "./iced" default-features = false -features = ["advanced", "image", "lazy", "svg", "web-colors", "tiny-skia"] +features = [ + "advanced", + "image-without-codecs", + "lazy", + "svg", + "web-colors", + "tiny-skia", +] [dependencies.iced_runtime] path = "./iced/runtime" diff --git a/iced b/iced index 9ad04dad..82b87f9c 160000 --- a/iced +++ b/iced @@ -1 +1 @@ -Subproject commit 9ad04dadde75ac4b445602fc6f31e05d7b7003c3 +Subproject commit 82b87f9caac6be9e1a6d75425e7a39d193a8590d From 4a97b3ddd2f972cb8fdc6b7c0482596aa31a8fb8 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 14 Jan 2025 21:45:10 +0100 Subject: [PATCH 4/4] chore: enable image/gif when using animated-image feature --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ee230e34..c5b9bcc1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ a11y = ["iced/a11y", "iced_accessibility"] # Enable about widget about = ["desktop", "dep:license"] # Builds support for animated images -animated-image = ["dep:async-fs", "tokio?/io-util", "tokio?/fs"] +animated-image = ["dep:async-fs", "image/gif", "tokio?/io-util", "tokio?/fs"] # XXX autosize should not be used on winit windows unless dialogs autosize = [] applet = [