par_term_render/renderer/shaders/
shared.rs1use super::super::Renderer;
8
9impl Renderer {
10 pub fn set_shader_mouse_position(&mut self, x: f32, y: f32) {
12 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
13 custom_shader.set_mouse_position(x, y);
14 }
15 }
16
17 pub fn set_shader_mouse_button(&mut self, pressed: bool, x: f32, y: f32) {
19 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
20 custom_shader.set_mouse_button(pressed, x, y);
21 }
22 }
23
24 pub fn update_key_press_time(&mut self) {
26 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
27 custom_shader.update_key_press();
28 }
29 if let Some(ref mut cursor_shader) = self.cursor_shader_renderer {
30 cursor_shader.update_key_press();
31 }
32 }
33
34 pub fn update_shader_cursor(
39 &mut self,
40 col: usize,
41 row: usize,
42 opacity: f32,
43 color: [f32; 4],
44 style: par_term_emu_core_rust::cursor::CursorStyle,
45 ) {
46 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
47 custom_shader.update_cursor(col, row, opacity, color, style);
48 }
49 if let Some(ref mut cursor_shader) = self.cursor_shader_renderer {
50 cursor_shader.update_cursor(col, row, opacity, color, style);
51 }
52 }
53
54 pub fn update_shader_progress(
62 &mut self,
63 state: f32,
64 percent: f32,
65 is_active: f32,
66 active_count: f32,
67 ) {
68 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
69 custom_shader.update_progress(state, percent, is_active, active_count);
70 }
71 if let Some(ref mut cursor_shader) = self.cursor_shader_renderer {
72 cursor_shader.update_progress(state, percent, is_active, active_count);
73 }
74 }
75
76 pub fn update_cursor_shader_config(
80 &mut self,
81 color: [u8; 3],
82 trail_duration: f32,
83 glow_radius: f32,
84 glow_intensity: f32,
85 ) {
86 let physical_glow_radius = glow_radius * self.cell_renderer.scale_factor;
87 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
88 custom_shader.update_cursor_shader_config(
89 color,
90 trail_duration,
91 physical_glow_radius,
92 glow_intensity,
93 );
94 }
95 if let Some(ref mut cursor_shader) = self.cursor_shader_renderer {
96 cursor_shader.update_cursor_shader_config(
97 color,
98 trail_duration,
99 physical_glow_radius,
100 glow_intensity,
101 );
102 }
103 }
104
105 pub fn pause_shader_animations(&mut self) {
107 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
108 custom_shader.set_animation_enabled(false);
109 }
110 if let Some(ref mut cursor_shader) = self.cursor_shader_renderer {
111 cursor_shader.set_animation_enabled(false);
112 }
113 log::info!("[SHADER] Shader animations paused");
114 }
115
116 pub fn resume_shader_animations(
120 &mut self,
121 custom_shader_animation: bool,
122 cursor_shader_animation: bool,
123 ) {
124 if let Some(ref mut custom_shader) = self.custom_shader_renderer {
125 custom_shader.set_animation_enabled(custom_shader_animation);
126 }
127 if let Some(ref mut cursor_shader) = self.cursor_shader_renderer {
128 cursor_shader.set_animation_enabled(cursor_shader_animation);
129 }
130 self.dirty = true;
131 log::info!(
132 "[SHADER] Shader animations resumed (custom: {}, cursor: {})",
133 custom_shader_animation,
134 cursor_shader_animation
135 );
136 }
137}