forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB99bf2dfIvan Molodetskikh1 year ago2106 commits

insert_hint_element.rs61 lines, 1.8 KiBHistoryRawDownload
1use niri_config::{CornerRadius, FloatOrInt};
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: FloatOrInt(0.),
20 active_color: config.color,
21 inactive_color: config.color,
22 active_gradient: config.gradient,
23 inactive_gradient: config.gradient,
24 }),
25 }
26 }
27
28 pub fn update_config(&mut self, config: niri_config::InsertHint) {
29 self.inner.update_config(niri_config::FocusRing {
30 off: config.off,
31 width: FloatOrInt(0.),
32 active_color: config.color,
33 inactive_color: config.color,
34 active_gradient: config.gradient,
35 inactive_gradient: config.gradient,
36 });
37 }
38
39 pub fn update_shaders(&mut self) {
40 self.inner.update_shaders();
41 }
42
43 pub fn update_render_elements(
44 &mut self,
45 size: Size<f64, Logical>,
46 view_rect: Rectangle<f64, Logical>,
47 radius: CornerRadius,
48 scale: f64,
49 ) {
50 self.inner
51 .update_render_elements(size, true, false, view_rect, radius, scale, 1.);
52 }
53
54 pub fn render(
55 &self,
56 renderer: &mut impl NiriRenderer,
57 location: Point<f64, Logical>,
58 ) -> impl Iterator<Item = FocusRingRenderElement> {
59 self.inner.render(renderer, location)
60 }
61}