From 17cb548e20a0594684b00c2eeda0e81cc8d06095 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Feb 2024 18:51:30 +0100 Subject: Use `Theme::ALL` for theme selector in `styling` example --- style/src/theme.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'style/src/theme.rs') diff --git a/style/src/theme.rs b/style/src/theme.rs index b1902b06..890f6dce 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -25,6 +25,7 @@ use crate::core::{Background, Border, Color, Shadow, Vector}; use std::fmt; use std::rc::Rc; +use std::sync::Arc; /// A built-in theme. #[derive(Debug, Clone, PartialEq, Default)] @@ -47,12 +48,21 @@ pub enum Theme { /// The built-in gruvbox dark variant. GruvboxDark, /// A [`Theme`] that uses a [`Custom`] palette. - Custom(Box), + Custom(Arc), } impl Theme { /// A list with all the defined themes. - pub const ALL: &'static [Self] = &[Self::Light, Self::Dark]; + pub const ALL: &'static [Self] = &[ + Self::Light, + Self::Dark, + Self::Dracula, + Self::Nord, + Self::SolarizedLight, + Self::SolarizedDark, + Self::GruvboxLight, + Self::GruvboxDark, + ]; /// Creates a new custom [`Theme`] from the given [`Palette`]. pub fn custom(name: String, palette: Palette) -> Self { @@ -66,7 +76,7 @@ impl Theme { palette: Palette, generate: impl FnOnce(Palette) -> palette::Extended, ) -> Self { - Self::Custom(Box::new(Custom::with_fn(name, palette, generate))) + Self::Custom(Arc::new(Custom::with_fn(name, palette, generate))) } /// Returns the [`Palette`] of the [`Theme`]. -- cgit