diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 09:33:44 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 10:53:55 +0300 |
| commit | 05d218113c1209f58b0dcdd415f1e095d4ff2b46 (patch) | |
| tree | 57a10521ada23b1974e67f144a02fd92ad6a2c40 /src/layout/insert_hint_element.rs | |
| parent | ef6af6adc1094db05d1df3953a18f6550816f71e (diff) | |
| download | niri-05d218113c1209f58b0dcdd415f1e095d4ff2b46.tar.gz niri-05d218113c1209f58b0dcdd415f1e095d4ff2b46.tar.bz2 niri-05d218113c1209f58b0dcdd415f1e095d4ff2b46.zip | |
Add gradient support for the insert hint
Implement it via FocusRing which already handles SolidColor vs. Border
render element.
Diffstat (limited to 'src/layout/insert_hint_element.rs')
| -rw-r--r-- | src/layout/insert_hint_element.rs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/layout/insert_hint_element.rs b/src/layout/insert_hint_element.rs new file mode 100644 index 00000000..5f70295c --- /dev/null +++ b/src/layout/insert_hint_element.rs @@ -0,0 +1,61 @@ +use niri_config::{CornerRadius, FloatOrInt}; +use smithay::utils::{Logical, Point, Rectangle, Size}; + +use super::focus_ring::{FocusRing, FocusRingRenderElement}; +use crate::render_helpers::renderer::NiriRenderer; + +#[derive(Debug)] +pub struct InsertHintElement { + inner: FocusRing, +} + +pub type InsertHintRenderElement = FocusRingRenderElement; + +impl InsertHintElement { + pub fn new(config: niri_config::InsertHint) -> Self { + Self { + inner: FocusRing::new(niri_config::FocusRing { + off: config.off, + width: FloatOrInt(0.), + active_color: config.color, + inactive_color: config.color, + active_gradient: config.gradient, + inactive_gradient: config.gradient, + }), + } + } + + pub fn update_config(&mut self, config: niri_config::InsertHint) { + self.inner.update_config(niri_config::FocusRing { + off: config.off, + width: FloatOrInt(0.), + active_color: config.color, + inactive_color: config.color, + active_gradient: config.gradient, + inactive_gradient: config.gradient, + }); + } + + pub fn update_shaders(&mut self) { + self.inner.update_shaders(); + } + + pub fn update_render_elements( + &mut self, + size: Size<f64, Logical>, + view_rect: Rectangle<f64, Logical>, + radius: CornerRadius, + scale: f64, + ) { + self.inner + .update_render_elements(size, true, false, view_rect, radius, scale); + } + + pub fn render( + &self, + renderer: &mut impl NiriRenderer, + location: Point<f64, Logical>, + ) -> impl Iterator<Item = FocusRingRenderElement> { + self.inner.render(renderer, location) + } +} |
