forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB53500dcTahinli1 month ago2998 commits

insert_hint_element.rs66 lines, 1.9 KiBHistoryRawDownload
1use niri_config::CornerRadius;
2use smithay::utils::{Logical, Point, Rectangle, Size};
3
4use super::focus_ring::{FocusRing, FocusRingRenderElement};
5use crate::render_helpers::renderer::NiriRenderer;
6
7#[derive(Debug)]
8pub struct InsertHintElement {
9 inner: FocusRing,
10}
11
12pub type InsertHintRenderElement = FocusRingRenderElement;
13
14impl 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: 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: 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 push: &mut dyn FnMut(FocusRingRenderElement),
63 ) {
64 self.inner.render(renderer, location, push)
65 }
66}