From 7da06056fac9fb26b9b61dc08ee48f6816340f9b Mon Sep 17 00:00:00 2001 From: Casper Rogild Storm Date: Fri, 15 Mar 2024 12:39:28 +0100 Subject: feat: added ferra --- core/src/theme.rs | 6 ++++++ core/src/theme/palette.rs | 15 +++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'core') diff --git a/core/src/theme.rs b/core/src/theme.rs index 21ba2a37..948aaf83 100644 --- a/core/src/theme.rs +++ b/core/src/theme.rs @@ -52,6 +52,8 @@ pub enum Theme { Nightfly, /// The built-in Oxocarbon variant. Oxocarbon, + /// The built-in Ferra variant: + Ferra, /// A [`Theme`] that uses a [`Custom`] palette. Custom(Arc), } @@ -80,6 +82,7 @@ impl Theme { Self::Moonfly, Self::Nightfly, Self::Oxocarbon, + Self::Ferra, ]; /// Creates a new custom [`Theme`] from the given [`Palette`]. @@ -121,6 +124,7 @@ impl Theme { Self::Moonfly => Palette::MOONFLY, Self::Nightfly => Palette::NIGHTFLY, Self::Oxocarbon => Palette::OXOCARBON, + Self::Ferra => Palette::FERRA, Self::Custom(custom) => custom.palette, } } @@ -151,6 +155,7 @@ impl Theme { Self::Moonfly => &palette::EXTENDED_MOONFLY, Self::Nightfly => &palette::EXTENDED_NIGHTFLY, Self::Oxocarbon => &palette::EXTENDED_OXOCARBON, + Self::Ferra => &palette::EXTENDED_FERRA, Self::Custom(custom) => &custom.extended, } } @@ -180,6 +185,7 @@ impl fmt::Display for Theme { Self::Moonfly => write!(f, "Moonfly"), Self::Nightfly => write!(f, "Nightfly"), Self::Oxocarbon => write!(f, "Oxocarbon"), + Self::Ferra => write!(f, "Ferra"), Self::Custom(custom) => custom.fmt(f), } } diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index 985a54a8..ca91c248 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -276,6 +276,17 @@ impl Palette { success: color!(0x00c15a), danger: color!(0xf62d0f), }; + + /// The built-in [Ferra] variant of a [`Palette`]. + /// + /// [Ferra]: https://github.com/casperstorm/ferra + pub const FERRA: Self = Self { + background: color!(0x2b292d), + text: color!(0xfecdb2), + primary: color!(0xd1d1e0), + success: color!(0xb1b695), + danger: color!(0xe06b75), + }; } /// An extended set of colors generated from a [`Palette`]. @@ -379,6 +390,10 @@ pub static EXTENDED_NIGHTFLY: Lazy = pub static EXTENDED_OXOCARBON: Lazy = Lazy::new(|| Extended::generate(Palette::OXOCARBON)); +/// The built-in Ferra variant of an [`Extended`] palette. +pub static EXTENDED_FERRA: Lazy = + Lazy::new(|| Extended::generate(Palette::FERRA)); + impl Extended { /// Generates an [`Extended`] palette from a simple [`Palette`]. pub fn generate(palette: Palette) -> Self { -- cgit From bad3b1ac4777b4d9b57c6ba9473fb97753a77124 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 16 Mar 2024 16:52:21 +0100 Subject: Show name of current `Theme` in `clock` example --- core/src/angle.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'core') diff --git a/core/src/angle.rs b/core/src/angle.rs index 30ddad83..dc3c0e93 100644 --- a/core/src/angle.rs +++ b/core/src/angle.rs @@ -7,6 +7,18 @@ use std::ops::{Add, AddAssign, Div, Mul, RangeInclusive, Sub, SubAssign}; #[derive(Debug, Copy, Clone, PartialEq, PartialOrd)] pub struct Degrees(pub f32); +impl PartialEq for Degrees { + fn eq(&self, other: &f32) -> bool { + self.0.eq(other) + } +} + +impl PartialOrd for Degrees { + fn partial_cmp(&self, other: &f32) -> Option { + self.0.partial_cmp(other) + } +} + /// Radians #[derive(Debug, Copy, Clone, PartialEq, PartialOrd)] pub struct Radians(pub f32); @@ -140,3 +152,15 @@ impl Div for Radians { Self(self.0 / rhs.0) } } + +impl PartialEq for Radians { + fn eq(&self, other: &f32) -> bool { + self.0.eq(other) + } +} + +impl PartialOrd for Radians { + fn partial_cmp(&self, other: &f32) -> Option { + self.0.partial_cmp(other) + } +} -- cgit From 784fa80c0d92a7d1fda8a7ff77185d50423e228a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 17 Mar 2024 17:57:24 +0100 Subject: Use `Program` API in `todos` example --- core/src/size.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'core') diff --git a/core/src/size.rs b/core/src/size.rs index 90e50d13..267fc90e 100644 --- a/core/src/size.rs +++ b/core/src/size.rs @@ -53,20 +53,20 @@ impl Size { } } -impl From<[f32; 2]> for Size { - fn from([width, height]: [f32; 2]) -> Self { +impl From<[T; 2]> for Size { + fn from([width, height]: [T; 2]) -> Self { Size { width, height } } } -impl From<[u16; 2]> for Size { - fn from([width, height]: [u16; 2]) -> Self { - Size::new(width.into(), height.into()) +impl From<(T, T)> for Size { + fn from((width, height): (T, T)) -> Self { + Self { width, height } } } -impl From> for Size { - fn from(vector: Vector) -> Self { +impl From> for Size { + fn from(vector: Vector) -> Self { Size { width: vector.x, height: vector.y, @@ -74,20 +74,23 @@ impl From> for Size { } } -impl From for [f32; 2] { - fn from(size: Size) -> [f32; 2] { +impl From> for [T; 2] { + fn from(size: Size) -> Self { [size.width, size.height] } } -impl From for Vector { - fn from(size: Size) -> Self { +impl From> for Vector { + fn from(size: Size) -> Self { Vector::new(size.width, size.height) } } -impl std::ops::Sub for Size { - type Output = Size; +impl std::ops::Sub for Size +where + T: std::ops::Sub, +{ + type Output = Size; fn sub(self, rhs: Self) -> Self::Output { Size { -- cgit From 8ce16aba6204cb5c02a709cdf79c309f7b7e0196 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 Mar 2024 07:13:34 +0100 Subject: Fix redundant import in `window::redraw_request` --- core/src/window/redraw_request.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/src/window/redraw_request.rs b/core/src/window/redraw_request.rs index 8a59e83c..b0c000d6 100644 --- a/core/src/window/redraw_request.rs +++ b/core/src/window/redraw_request.rs @@ -13,7 +13,7 @@ pub enum RedrawRequest { #[cfg(test)] mod tests { use super::*; - use crate::time::{Duration, Instant}; + use crate::time::Duration; #[test] fn ordering() { -- cgit