aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPolesznyák Márk <contact@pml68.dev>2025-10-20 14:23:22 +0200
committerPolesznyák Márk <contact@pml68.dev>2025-10-20 14:24:33 +0200
commitd3437d1b64cc632ab7358264825db683d15d1c69 (patch)
tree51b38588bf9b26f3664d89a575cf7e74696a1405
parentchore: update mailing list address (diff)
downloadiced_material-d3437d1b64cc632ab7358264825db683d15d1c69.tar.gz
feat: add support for `pml68/iced_selection`
-rw-r--r--Cargo.toml7
-rw-r--r--README.md3
-rw-r--r--src/lib.rs2
-rw-r--r--src/selection.rs22
4 files changed, 33 insertions, 1 deletions
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,
+ }
+}