mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Add impl From<Color> for Gradient
This commit is contained in:
@@ -530,6 +530,18 @@ pub struct Gradient {
|
|||||||
pub in_: GradientInterpolation,
|
pub in_: GradientInterpolation,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Color> for Gradient {
|
||||||
|
fn from(value: Color) -> Self {
|
||||||
|
Self {
|
||||||
|
from: value,
|
||||||
|
to: value,
|
||||||
|
angle: 0,
|
||||||
|
relative_to: GradientRelativeTo::Window,
|
||||||
|
in_: GradientInterpolation::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(knuffel::DecodeScalar, Debug, Default, Clone, Copy, PartialEq, Eq)]
|
#[derive(knuffel::DecodeScalar, Debug, Default, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum GradientRelativeTo {
|
pub enum GradientRelativeTo {
|
||||||
#[default]
|
#[default]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::iter::zip;
|
use std::iter::zip;
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use niri_config::{CornerRadius, Gradient, GradientInterpolation, GradientRelativeTo};
|
use niri_config::{CornerRadius, Gradient, GradientRelativeTo};
|
||||||
use smithay::backend::renderer::element::Kind;
|
use smithay::backend::renderer::element::Kind;
|
||||||
use smithay::utils::{Logical, Point, Rectangle, Size};
|
use smithay::utils::{Logical, Point, Rectangle, Size};
|
||||||
|
|
||||||
@@ -86,13 +86,7 @@ impl FocusRing {
|
|||||||
self.use_border_shader = radius != CornerRadius::default() || gradient.is_some();
|
self.use_border_shader = radius != CornerRadius::default() || gradient.is_some();
|
||||||
|
|
||||||
// Set the defaults for solid color + rounded corners.
|
// Set the defaults for solid color + rounded corners.
|
||||||
let gradient = gradient.unwrap_or(Gradient {
|
let gradient = gradient.unwrap_or_else(|| Gradient::from(color));
|
||||||
from: color,
|
|
||||||
to: color,
|
|
||||||
angle: 0,
|
|
||||||
relative_to: GradientRelativeTo::Window,
|
|
||||||
in_: GradientInterpolation::default(),
|
|
||||||
});
|
|
||||||
|
|
||||||
let full_rect = Rectangle::new(Point::from((-width, -width)), self.full_size);
|
let full_rect = Rectangle::new(Point::from((-width, -width)), self.full_size);
|
||||||
let gradient_area = match gradient.relative_to {
|
let gradient_area = match gradient.relative_to {
|
||||||
|
|||||||
Reference in New Issue
Block a user