forge
Explore
Log in

Don't you dare go Hollow

Add impl From<Color> for Gradient

Browse files at this commit

d5592743cb04cef3fe50c987b7ba9349c5090dbdIvan MolodetskikhParent: 019e759
niri-config/src/lib.rsmodified+12 -0
@@ -530,6 +530,18 @@ pub struct Gradient {
530 pub in_: GradientInterpolation,530 pub in_: GradientInterpolation,
531 }531 }
532 532
533+impl From<Color> for Gradient {
534+ fn from(value: Color) -> Self {
535+ Self {
536+ from: value,
537+ to: value,
538+ angle: 0,
539+ relative_to: GradientRelativeTo::Window,
540+ in_: GradientInterpolation::default(),
541+ }
542+ }
543+}
544+
533 #[derive(knuffel::DecodeScalar, Debug, Default, Clone, Copy, PartialEq, Eq)]545 #[derive(knuffel::DecodeScalar, Debug, Default, Clone, Copy, PartialEq, Eq)]
534 pub enum GradientRelativeTo {546 pub enum GradientRelativeTo {
535 #[default]547 #[default]
src/layout/focus_ring.rsmodified+2 -8
@@ -1,7 +1,7 @@
1 use std::iter::zip;1 use std::iter::zip;
2 2
3 use arrayvec::ArrayVec;3 use arrayvec::ArrayVec;
4-use niri_config::{CornerRadius, Gradient, GradientInterpolation, GradientRelativeTo};4+use niri_config::{CornerRadius, Gradient, GradientRelativeTo};
5 use smithay::backend::renderer::element::Kind;5 use smithay::backend::renderer::element::Kind;
6 use smithay::utils::{Logical, Point, Rectangle, Size};6 use smithay::utils::{Logical, Point, Rectangle, Size};
7 7
@@ -86,13 +86,7 @@ impl FocusRing {
86 self.use_border_shader = radius != CornerRadius::default() || gradient.is_some();86 self.use_border_shader = radius != CornerRadius::default() || gradient.is_some();
87 87
88 // Set the defaults for solid color + rounded corners.88 // Set the defaults for solid color + rounded corners.
89- let gradient = gradient.unwrap_or(Gradient {89+ let gradient = gradient.unwrap_or_else(|| Gradient::from(color));
90- from: color,
91- to: color,
92- angle: 0,
93- relative_to: GradientRelativeTo::Window,
94- in_: GradientInterpolation::default(),
95- });
96 90
97 let full_rect = Rectangle::new(Point::from((-width, -width)), self.full_size);91 let full_rect = Rectangle::new(Point::from((-width, -width)), self.full_size);
98 let gradient_area = match gradient.relative_to {92 let gradient_area = match gradient.relative_to {