| 1 | use niri_config::{CornerRadius, FloatOrInt}; |
| 2 | use smithay::utils::{Logical, Point, Rectangle, Size}; |
| 3 | |
| 4 | use super::focus_ring::{FocusRing, FocusRingRenderElement}; |
| 5 | use crate::render_helpers::renderer::NiriRenderer; |
| 6 | |
| 7 | #[derive(Debug)] |
| 8 | pub struct InsertHintElement { |
| 9 | inner: FocusRing, |
| 10 | } |
| 11 | |
| 12 | pub type InsertHintRenderElement = FocusRingRenderElement; |
| 13 | |
| 14 | impl InsertHintElement { |
| 15 | pub fn new(config: niri_config::InsertHint) -> Self { |
| 16 | Self { |
| 17 | inner: FocusRing::new(niri_config::FocusRing { |
| 18 | off: config.off, |
| 19 | width: FloatOrInt(0.), |
| 20 | active_color: config.color, |
| 21 | inactive_color: config.color, |
| 22 | urgent_color: config.color, |
| 23 | active_gradient: config.gradient, |
| 24 | inactive_gradient: config.gradient, |
| 25 | urgent_gradient: config.gradient, |
| 26 | }), |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | pub fn update_config(&mut self, config: niri_config::InsertHint) { |
| 31 | self.inner.update_config(niri_config::FocusRing { |
| 32 | off: config.off, |
| 33 | width: FloatOrInt(0.), |
| 34 | active_color: config.color, |
| 35 | inactive_color: config.color, |
| 36 | urgent_color: config.color, |
| 37 | active_gradient: config.gradient, |
| 38 | inactive_gradient: config.gradient, |
| 39 | urgent_gradient: config.gradient, |
| 40 | }); |
| 41 | } |
| 42 | |
| 43 | pub fn update_shaders(&mut self) { |
| 44 | self.inner.update_shaders(); |
| 45 | } |
| 46 | |
| 47 | pub fn update_render_elements( |
| 48 | &mut self, |
| 49 | size: Size<f64, Logical>, |
| 50 | view_rect: Rectangle<f64, Logical>, |
| 51 | radius: CornerRadius, |
| 52 | scale: f64, |
| 53 | ) { |
| 54 | self.inner |
| 55 | .update_render_elements(size, true, false, false, view_rect, radius, scale, 1.); |
| 56 | } |
| 57 | |
| 58 | pub fn render( |
| 59 | &self, |
| 60 | renderer: &mut impl NiriRenderer, |
| 61 | location: Point<f64, Logical>, |
| 62 | ) -> impl Iterator<Item = FocusRingRenderElement> { |
| 63 | self.inner.render(renderer, location) |
| 64 | } |
| 65 | } |