From 3bdd724119eb2dbcb2480e441cd13f82575c6536 Mon Sep 17 00:00:00 2001 From: pml68 Date: Sat, 26 Apr 2025 13:17:58 +0200 Subject: feat(material_theme): implement `image::Catalog` (under feature flag) --- crates/iced_drop/src/widget/droppable.rs | 2 ++ crates/material_theme/Cargo.toml | 2 ++ crates/material_theme/src/image.rs | 21 +++++++++++++++++++++ crates/material_theme/src/lib.rs | 2 ++ 4 files changed, 27 insertions(+) create mode 100644 crates/material_theme/src/image.rs (limited to 'crates') diff --git a/crates/iced_drop/src/widget/droppable.rs b/crates/iced_drop/src/widget/droppable.rs index 947cf5b..196464a 100644 --- a/crates/iced_drop/src/widget/droppable.rs +++ b/crates/iced_drop/src/widget/droppable.rs @@ -418,6 +418,7 @@ where tree: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + _viewport: &iced::Rectangle, _translation: Vector, ) -> Option> { let state: &mut State = tree.state.downcast_mut::(); @@ -434,6 +435,7 @@ where &mut tree.children[0], layout, renderer, + _viewport, _translation, ) } diff --git a/crates/material_theme/Cargo.toml b/crates/material_theme/Cargo.toml index 941bc3e..30de38b 100644 --- a/crates/material_theme/Cargo.toml +++ b/crates/material_theme/Cargo.toml @@ -21,6 +21,8 @@ animate = ["dep:iced_anim"] dialog = ["dep:iced_dialog"] # Provides support for the markdown widget. markdown = ["iced_widget/markdown"] +# Provides support for the image widget. +image = ["iced_widget/image"] # Provides support for the SVG widget. svg = ["iced_widget/svg"] # Provides support for the QR code widget. diff --git a/crates/material_theme/src/image.rs b/crates/material_theme/src/image.rs new file mode 100644 index 0000000..de5942a --- /dev/null +++ b/crates/material_theme/src/image.rs @@ -0,0 +1,21 @@ +use iced_widget::core::{Background, Border, Color, border}; +use iced_widget::image::{Catalog, Style, StyleFn}; + +use super::Theme; +use crate::utils::{elevation, shadow_from_elevation}; + +impl Catalog for Theme { + type Class<'a> = StyleFn<'a, Self>; + + fn default<'a>() -> Self::Class<'a> { + Box::new(default) + } + + fn style(&self, class: &Self::Class<'_>) -> Style { + class(self) + } +} + +pub fn default(_theme: &Theme) -> Style { + Style::default() +} diff --git a/crates/material_theme/src/lib.rs b/crates/material_theme/src/lib.rs index 569b06c..1b4f90e 100644 --- a/crates/material_theme/src/lib.rs +++ b/crates/material_theme/src/lib.rs @@ -9,6 +9,8 @@ pub mod combo_box; pub mod container; #[cfg(feature = "dialog")] pub mod dialog; +#[cfg(feature = "image")] +pub mod image; #[cfg(feature = "markdown")] pub mod markdown; pub mod menu; -- cgit v1.2.3