|
|
@ -31,14 +31,20 @@ use cursor_renderer::CursorRenderer;
|
|
|
|
#[derive(Clone)]
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct RendererSettings {
|
|
|
|
pub struct RendererSettings {
|
|
|
|
animation_length: f32,
|
|
|
|
animation_length: f32,
|
|
|
|
|
|
|
|
floating_opacity: f32,
|
|
|
|
|
|
|
|
floating_blur: bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn initialize_settings() {
|
|
|
|
pub fn initialize_settings() {
|
|
|
|
SETTINGS.set(&RendererSettings {
|
|
|
|
SETTINGS.set(&RendererSettings {
|
|
|
|
animation_length: 0.15,
|
|
|
|
animation_length: 0.15,
|
|
|
|
|
|
|
|
floating_opacity: 0.7,
|
|
|
|
|
|
|
|
floating_blur: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
register_nvim_setting!("window_animation_length", RendererSettings::animation_length);
|
|
|
|
register_nvim_setting!("window_animation_length", RendererSettings::animation_length);
|
|
|
|
|
|
|
|
register_nvim_setting!("floating_window_opacity", RendererSettings::floating_opacity);
|
|
|
|
|
|
|
|
register_nvim_setting!("floating_window_blur", RendererSettings::floating_opacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
@ -157,7 +163,8 @@ impl Renderer {
|
|
|
|
cell_width: u64,
|
|
|
|
cell_width: u64,
|
|
|
|
style: &Option<Arc<Style>>,
|
|
|
|
style: &Option<Arc<Style>>,
|
|
|
|
default_style: &Arc<Style>,
|
|
|
|
default_style: &Arc<Style>,
|
|
|
|
floating: bool
|
|
|
|
floating: bool,
|
|
|
|
|
|
|
|
settings: &RendererSettings
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
self.paint.set_blend_mode(BlendMode::Src);
|
|
|
|
self.paint.set_blend_mode(BlendMode::Src);
|
|
|
|
|
|
|
|
|
|
|
@ -167,7 +174,7 @@ impl Renderer {
|
|
|
|
let mut color = style.background(&default_style.colors);
|
|
|
|
let mut color = style.background(&default_style.colors);
|
|
|
|
|
|
|
|
|
|
|
|
if floating {
|
|
|
|
if floating {
|
|
|
|
color.a = 0.8;
|
|
|
|
color.a = color.a * settings.floating_opacity.min(1.0).max(0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.paint.set_color(color.to_color());
|
|
|
|
self.paint.set_color(color.to_color());
|
|
|
@ -307,7 +314,8 @@ impl Renderer {
|
|
|
|
cell_width,
|
|
|
|
cell_width,
|
|
|
|
&style,
|
|
|
|
&style,
|
|
|
|
&default_style,
|
|
|
|
&default_style,
|
|
|
|
window_render_info.floating
|
|
|
|
window_render_info.floating,
|
|
|
|
|
|
|
|
settings
|
|
|
|
);
|
|
|
|
);
|
|
|
|
self.draw_foreground(
|
|
|
|
self.draw_foreground(
|
|
|
|
&mut canvas,
|
|
|
|
&mut canvas,
|
|
|
@ -356,22 +364,27 @@ impl Renderer {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
root_canvas.save();
|
|
|
|
root_canvas.save();
|
|
|
|
// let region = Rect::new(5.0, 5.0, 500.0, 500.0);
|
|
|
|
|
|
|
|
// root_canvas.clip_rect(®ion, None, Some(false));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let blur = blur((5.0, 5.0), None, None, None).unwrap();
|
|
|
|
let region = Rect::from_point_and_size(rendered_window.current_position, (image_width, image_height));
|
|
|
|
// let save_layer_rec = SaveLayerRec::default()
|
|
|
|
root_canvas.clip_rect(®ion, None, Some(false));
|
|
|
|
// .backdrop(&blur)
|
|
|
|
if window_render_info.floating && settings.floating_blur {
|
|
|
|
// .bounds(®ion);
|
|
|
|
let blur = blur((2.0, 2.0), None, None, None).unwrap();
|
|
|
|
|
|
|
|
let save_layer_rec = SaveLayerRec::default()
|
|
|
|
|
|
|
|
.backdrop(&blur)
|
|
|
|
|
|
|
|
.bounds(®ion);
|
|
|
|
|
|
|
|
|
|
|
|
// root_canvas.save_layer(&save_layer_rec);
|
|
|
|
root_canvas.save_layer(&save_layer_rec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rendered_window.surface.draw(
|
|
|
|
rendered_window.surface.draw(
|
|
|
|
root_canvas.as_mut(),
|
|
|
|
root_canvas.as_mut(),
|
|
|
|
(rendered_window.current_position.x, rendered_window.current_position.y),
|
|
|
|
(rendered_window.current_position.x, rendered_window.current_position.y),
|
|
|
|
None);
|
|
|
|
None);
|
|
|
|
|
|
|
|
|
|
|
|
// root_canvas.restore();
|
|
|
|
if window_render_info.floating {
|
|
|
|
|
|
|
|
root_canvas.restore();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
root_canvas.restore();
|
|
|
|
root_canvas.restore();
|
|
|
|
|
|
|
|
|
|
|
|
let window_position = rendered_window.current_position.clone();
|
|
|
|
let window_position = rendered_window.current_position.clone();
|
|
|
|