aboutsummaryrefslogtreecommitdiff
path: root/src/layout/insert_hint_element.rs
blob: 89dfcd14c16b4add35fcb2585374c3fd14d224c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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, 1.);
    }

    pub fn render(
        &self,
        renderer: &mut impl NiriRenderer,
        location: Point<f64, Logical>,
    ) -> impl Iterator<Item = FocusRingRenderElement> {
        self.inner.render(renderer, location)
    }
}