From d3437d1b64cc632ab7358264825db683d15d1c69 Mon Sep 17 00:00:00 2001 From: Polesznyák Márk Date: Mon, 20 Oct 2025 14:23:22 +0200 Subject: feat: add support for `pml68/iced_selection` --- Cargo.toml | 7 +++++++ README.md | 3 ++- src/lib.rs | 2 ++ src/selection.rs | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/selection.rs diff --git a/Cargo.toml b/Cargo.toml index 18ddb8f..64bb14e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,8 @@ animate = ["dep:iced_anim"] crisp = ["iced_widget/crisp"] # Provides support for `iced_dialog`. dialog = ["dep:iced_dialog"] +# Provides support for `iced_selection`. +selection = ["dep:iced_selection"] # Provides support for the markdown widget. markdown = ["iced_widget/markdown"] # Provides support for the SVG widget. @@ -39,6 +41,11 @@ git = "https://git.sr.ht/~pml68/iced_dialog" branch = "master" optional = true +[dependencies.iced_selection] +git = "https://git.sr.ht/~pml68/iced_selection" +branch = "master" +optional = true + [dependencies.iced_anim] git = "https://github.com/bradysimon/iced_anim" branch = "iced/master" diff --git a/README.md b/README.md index 1119dd5..89cd02a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ - `serde`: Provides [`serde`](https://docs.rs/serde) support. - `animate`: Provides support for animating with [`iced_anim`](https://github.com/bradysimon/iced_anim/tree/iced/master). - `crisp`: Enables pixel snapping for crisp edges by default (can cause jitter!). -- `dialog`: Provides support for [`iced_dialog`](https://github.com/pml68/iced_dialog). +- `dialog`: Provides support for [`iced_dialog`](https://git.sr.ht/~pml68/iced_dialog). +- `selection`: Provides support for [`iced_selection`](https://git.sr.ht/~pml68/iced_selection). - `markdown`: Provides support for the markdown widget. - `svg`: Provides support for the SVG widget. - `qr_code`: Provides support for the QR code widget. diff --git a/src/lib.rs b/src/lib.rs index ba82f6b..26828f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,8 @@ pub mod qr_code; pub mod radio; pub mod rule; pub mod scrollable; +#[cfg(feature = "selection")] +pub mod selection; pub mod slider; #[cfg(feature = "svg")] pub mod svg; diff --git a/src/selection.rs b/src/selection.rs new file mode 100644 index 0000000..cbf8bd4 --- /dev/null +++ b/src/selection.rs @@ -0,0 +1,22 @@ +use iced_selection::text::{Catalog, Style, StyleFn}; + +use super::Theme; + +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 { + color: None, + selection: theme.colors().primary.primary_container, + } +} -- cgit v1.2.3