summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-10 00:34:21 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-10 00:34:21 +0200
commitb8e5693a3089d728b4f8d4b3b0b7197202ebd732 (patch)
tree79a9f84f9920525657fbe03d53ce33bab09053d7 /style
parent956512338905bac0b156fdaf16fe3c3e07e97a84 (diff)
parenta3489e4af960388e9f73988b88df361022a654a4 (diff)
downloadiced-b8e5693a3089d728b4f8d4b3b0b7197202ebd732.tar.gz
iced-b8e5693a3089d728b4f8d4b3b0b7197202ebd732.tar.bz2
iced-b8e5693a3089d728b4f8d4b3b0b7197202ebd732.zip
Merge branch 'master' into explicit-text-caching
Diffstat (limited to '')
-rw-r--r--style/Cargo.toml30
-rw-r--r--style/src/lib.rs8
-rw-r--r--style/src/theme.rs27
3 files changed, 40 insertions, 25 deletions
diff --git a/style/Cargo.toml b/style/Cargo.toml
index 689cf978..3f00e787 100644
--- a/style/Cargo.toml
+++ b/style/Cargo.toml
@@ -1,22 +1,18 @@
[package]
name = "iced_style"
-version = "0.9.0"
-authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
-edition = "2021"
description = "The default set of styles of Iced"
-license = "MIT"
-repository = "https://github.com/iced-rs/iced"
-documentation = "https://docs.rs/iced_style"
-keywords = ["gui", "ui", "graphics", "interface", "widgets"]
-categories = ["gui"]
+version.workspace = true
+edition.workspace = true
+authors.workspace = true
+license.workspace = true
+repository.workspace = true
+homepage.workspace = true
+categories.workspace = true
+keywords.workspace = true
-[dependencies.iced_core]
-version = "0.10"
-path = "../core"
-features = ["palette"]
+[dependencies]
+iced_core.workspace = true
+iced_core.features = ["palette"]
-[dependencies.palette]
-version = "0.7"
-
-[dependencies.once_cell]
-version = "1.15"
+palette.workspace = true
+once_cell.workspace = true
diff --git a/style/src/lib.rs b/style/src/lib.rs
index 286ff9db..0c555ed8 100644
--- a/style/src/lib.rs
+++ b/style/src/lib.rs
@@ -7,16 +7,18 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
+#![forbid(unsafe_code, rust_2018_idioms)]
#![deny(
unused_results,
clippy::extra_unused_lifetimes,
clippy::from_over_into,
clippy::needless_borrow,
clippy::new_without_default,
- clippy::useless_conversion
+ clippy::useless_conversion,
+ missing_docs,
+ unused_results,
+ rustdoc::broken_intra_doc_links
)]
-#![deny(missing_docs, unused_results)]
-#![forbid(unsafe_code, rust_2018_idioms)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
pub use iced_core as core;
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 64497181..893d7202 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -1,8 +1,7 @@
//! Use the built-in theme and styles.
pub mod palette;
-use self::palette::Extended;
-pub use self::palette::Palette;
+pub use palette::Palette;
use crate::application;
use crate::button;
@@ -40,7 +39,16 @@ pub enum Theme {
impl Theme {
/// Creates a new custom [`Theme`] from the given [`Palette`].
pub fn custom(palette: Palette) -> Self {
- Self::Custom(Box::new(Custom::new(palette)))
+ Self::custom_with_fn(palette, palette::Extended::generate)
+ }
+
+ /// Creates a new custom [`Theme`] from the given [`Palette`], with
+ /// a custom generator of a [`palette::Extended`].
+ pub fn custom_with_fn(
+ palette: Palette,
+ generate: impl FnOnce(Palette) -> palette::Extended,
+ ) -> Self {
+ Self::Custom(Box::new(Custom::with_fn(palette, generate)))
}
/// Returns the [`Palette`] of the [`Theme`].
@@ -66,15 +74,24 @@ impl Theme {
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Custom {
palette: Palette,
- extended: Extended,
+ extended: palette::Extended,
}
impl Custom {
/// Creates a [`Custom`] theme from the given [`Palette`].
pub fn new(palette: Palette) -> Self {
+ Self::with_fn(palette, palette::Extended::generate)
+ }
+
+ /// Creates a [`Custom`] theme from the given [`Palette`] with
+ /// a custom generator of a [`palette::Extended`].
+ pub fn with_fn(
+ palette: Palette,
+ generate: impl FnOnce(Palette) -> palette::Extended,
+ ) -> Self {
Self {
palette,
- extended: Extended::generate(palette),
+ extended: generate(palette),
}
}
}