summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpml68 <contact@pml68.dev>2025-04-26 13:17:58 +0200
committerpml68 <contact@pml68.dev>2025-04-26 13:17:58 +0200
commit3bdd724119eb2dbcb2480e441cd13f82575c6536 (patch)
tree7db73d04dbb0c2f2450292b102e5c761af94cbaa
parentfeat(material_theme): create an iced `Palette` for `iced::theme::Base` impl (diff)
downloadiced-builder-3bdd724119eb2dbcb2480e441cd13f82575c6536.tar.gz
feat(material_theme): implement `image::Catalog` (under feature flag)
Diffstat (limited to '')
-rw-r--r--Cargo.lock89
-rw-r--r--crates/iced_drop/src/widget/droppable.rs2
-rw-r--r--crates/material_theme/Cargo.toml2
-rw-r--r--crates/material_theme/src/image.rs21
-rw-r--r--crates/material_theme/src/lib.rs2
-rw-r--r--theme_test/src/main.rs4
6 files changed, 78 insertions, 42 deletions
diff --git a/Cargo.lock b/Cargo.lock
index fd31403..9154eb4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -51,7 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [
"cfg-if",
- "getrandom 0.2.15",
+ "getrandom 0.2.16",
"once_cell",
"version_check",
"zerocopy 0.7.35",
@@ -657,9 +657,9 @@ checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3"
[[package]]
name = "cc"
-version = "1.2.19"
+version = "1.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362"
+checksum = "04da6a0d40b948dfc4fa8f5bbf402b0fc1a64a28dbf7d12ffd683550f2c1b63a"
dependencies = [
"jobserver",
"libc",
@@ -1592,9 +1592,9 @@ dependencies = [
[[package]]
name = "getrandom"
-version = "0.2.15"
+version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
+checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
dependencies = [
"cfg-if",
"libc",
@@ -1941,7 +1941,7 @@ dependencies = [
[[package]]
name = "iced"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"iced_core",
"iced_debug",
@@ -1958,7 +1958,7 @@ dependencies = [
[[package]]
name = "iced_anim"
version = "0.2.1"
-source = "git+https://github.com/pml68/iced_anim#0c833c0943493c8fc22a60e138785e4c688ef8d8"
+source = "git+https://github.com/pml68/iced_anim#c881a8a9c49b0536f4ee3c236ec24285eabc0d76"
dependencies = [
"iced",
"iced_anim_derive",
@@ -1967,7 +1967,7 @@ dependencies = [
[[package]]
name = "iced_anim_derive"
version = "0.2.0"
-source = "git+https://github.com/pml68/iced_anim#0c833c0943493c8fc22a60e138785e4c688ef8d8"
+source = "git+https://github.com/pml68/iced_anim#c881a8a9c49b0536f4ee3c236ec24285eabc0d76"
dependencies = [
"quote",
"syn",
@@ -1976,7 +1976,7 @@ dependencies = [
[[package]]
name = "iced_beacon"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"bincode",
"futures",
@@ -2017,7 +2017,7 @@ dependencies = [
[[package]]
name = "iced_core"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"bitflags 2.9.0",
"bytes",
@@ -2046,7 +2046,7 @@ dependencies = [
[[package]]
name = "iced_debug"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"iced_beacon",
"iced_core",
@@ -2056,7 +2056,7 @@ dependencies = [
[[package]]
name = "iced_devtools"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"iced_debug",
"iced_program",
@@ -2066,7 +2066,7 @@ dependencies = [
[[package]]
name = "iced_dialog"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced_dialog?branch=iced%2Fpersonal#6e901c21dbb259d337ed1ad2054da3862172b8b3"
+source = "git+https://github.com/pml68/iced_dialog?branch=iced%2Fpersonal#57388a202159052ccc771bfb537bd46e8f3b9e70"
dependencies = [
"iced_core",
"iced_widget",
@@ -2096,7 +2096,7 @@ dependencies = [
[[package]]
name = "iced_futures"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"futures",
"iced_core",
@@ -2110,7 +2110,7 @@ dependencies = [
[[package]]
name = "iced_graphics"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"bitflags 2.9.0",
"bytemuck",
@@ -2131,7 +2131,7 @@ dependencies = [
[[package]]
name = "iced_program"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"iced_graphics",
"iced_runtime",
@@ -2140,7 +2140,7 @@ dependencies = [
[[package]]
name = "iced_renderer"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"iced_graphics",
"iced_tiny_skia",
@@ -2152,7 +2152,7 @@ dependencies = [
[[package]]
name = "iced_runtime"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"bytes",
"iced_core",
@@ -2165,7 +2165,7 @@ dependencies = [
[[package]]
name = "iced_tiny_skia"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"bytemuck",
"cosmic-text",
@@ -2182,7 +2182,7 @@ dependencies = [
[[package]]
name = "iced_wgpu"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"bitflags 2.9.0",
"bytemuck",
@@ -2203,7 +2203,7 @@ dependencies = [
[[package]]
name = "iced_widget"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"iced_renderer",
"iced_runtime",
@@ -2221,7 +2221,7 @@ dependencies = [
[[package]]
name = "iced_winit"
version = "0.14.0-dev"
-source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#b6433c4637ddf4697154feeb14c66e06200e4e1b"
+source = "git+https://github.com/pml68/iced?branch=feat%2Frehighlight-on-redraw#64d4a365f3eb25f716c0632316d46d82bfe818c6"
dependencies = [
"iced_debug",
"iced_program",
@@ -3636,7 +3636,7 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
- "zerocopy 0.8.24",
+ "zerocopy 0.8.25",
]
[[package]]
@@ -3806,7 +3806,7 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
- "getrandom 0.2.15",
+ "getrandom 0.2.16",
]
[[package]]
@@ -3940,7 +3940,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
- "getrandom 0.2.15",
+ "getrandom 0.2.16",
"libredox",
"thiserror 1.0.69",
]
@@ -4060,7 +4060,7 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
dependencies = [
"cc",
"cfg-if",
- "getrandom 0.2.15",
+ "getrandom 0.2.16",
"libc",
"untrusted",
"windows-sys 0.52.0",
@@ -4943,9 +4943,9 @@ dependencies = [
[[package]]
name = "tokio-util"
-version = "0.7.14"
+version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034"
+checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df"
dependencies = [
"bytes",
"futures-core",
@@ -4956,9 +4956,9 @@ dependencies = [
[[package]]
name = "toml"
-version = "0.8.20"
+version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148"
+checksum = "900f6c86a685850b1bc9f6223b20125115ee3f31e01207d81655bbcc0aea9231"
dependencies = [
"serde",
"serde_spanned",
@@ -4968,27 +4968,34 @@ dependencies = [
[[package]]
name = "toml_datetime"
-version = "0.6.8"
+version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
+checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
-version = "0.22.24"
+version = "0.22.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
+checksum = "10558ed0bd2a1562e630926a2d1f0b98c827da99fabd3fe20920a59642504485"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
+ "toml_write",
"winnow",
]
[[package]]
+name = "toml_write"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28391a4201ba7eb1984cfeb6862c0b3ea2cfe23332298967c749dddc0d6cd976"
+
+[[package]]
name = "tower"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -6136,9 +6143,9 @@ dependencies = [
[[package]]
name = "winnow"
-version = "0.7.6"
+version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10"
+checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5"
dependencies = [
"memchr",
]
@@ -6384,11 +6391,11 @@ dependencies = [
[[package]]
name = "zerocopy"
-version = "0.8.24"
+version = "0.8.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
+checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb"
dependencies = [
- "zerocopy-derive 0.8.24",
+ "zerocopy-derive 0.8.25",
]
[[package]]
@@ -6404,9 +6411,9 @@ dependencies = [
[[package]]
name = "zerocopy-derive"
-version = "0.8.24"
+version = "0.8.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
+checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef"
dependencies = [
"proc-macro2",
"quote",
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<overlay::Element<'b, Message, Theme, Renderer>> {
let state: &mut State = tree.state.downcast_mut::<State>();
@@ -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;
diff --git a/theme_test/src/main.rs b/theme_test/src/main.rs
index 7ec7f15..b4a7731 100644
--- a/theme_test/src/main.rs
+++ b/theme_test/src/main.rs
@@ -1,6 +1,7 @@
use iced::widget::{
button, center, checkbox, column, container, horizontal_rule, pane_grid,
- pick_list, radio, row, slider, text_editor, text_input, toggler,
+ pick_list, progress_bar, radio, row, slider, text_editor, text_input,
+ toggler,
};
use iced::{Element, Length};
use iced_anim::{Animated, Animation, Event};
@@ -238,6 +239,7 @@ impl State {
.height(Length::Shrink),
slider(0.0..=100.0, self.value, Message::Slider)
.step(0.1),
+ progress_bar(0.0..=100.0, self.value),
horizontal_rule(1),
// Toggler
toggler(self.is_checked)