minor changes

macos-click-through
keith 4 years ago
parent 965f06a361
commit 811c8ea2d1

@ -31,6 +31,7 @@ pub struct WindowRenderInfo {
pub grid_position: (f64, f64), pub grid_position: (f64, f64),
pub width: u64, pub width: u64,
pub height: u64, pub height: u64,
pub floating: bool,
pub draw_commands: Vec<DrawCommand> pub draw_commands: Vec<DrawCommand>
} }
@ -242,16 +243,19 @@ impl Editor {
} }
fn set_message_position(&mut self, grid: u64, row: u64) { fn set_message_position(&mut self, grid: u64, row: u64) {
let parent_width = self.windows.get(&1).map(|parent| parent.grid.width).unwrap_or(1);
if let Some(window) = self.windows.get_mut(&grid) { if let Some(window) = self.windows.get_mut(&grid) {
window.hidden = false; window.hidden = false;
window.anchor_grid_id = Some(1); window.anchor_grid_id = Some(1);
window.anchor_type = WindowAnchor::NorthWest; window.anchor_type = WindowAnchor::NorthWest;
window.anchor_row = row as f64; window.anchor_row = row as f64;
window.anchor_column = 0.0; window.anchor_column = 0.0;
} else if let Some(parent) = self.windows.get(&1) { window.resize(parent_width, window.grid.height);
} else {
let new_window = Window::new( let new_window = Window::new(
grid, grid,
parent.grid.width, parent_width,
1, 1,
None, None,
WindowAnchor::NorthWest, WindowAnchor::NorthWest,
@ -337,6 +341,7 @@ impl Editor {
grid_position, grid_position,
width, width,
height, height,
floating: window.anchor_grid_id.is_some(),
draw_commands draw_commands
}) })
} }

@ -4,9 +4,11 @@ use std::sync::Arc;
use log::trace; use log::trace;
use skulpin::skia_safe::gpu::SurfaceOrigin; use skulpin::skia_safe::gpu::SurfaceOrigin;
use skulpin::skia_safe::{ use skulpin::skia_safe::{
colors, dash_path_effect, Budgeted, Canvas, ImageInfo, Paint, Rect, Surface, Point colors, dash_path_effect, Budgeted, Canvas, ImageInfo, Paint, Rect, Surface, Point, BlendMode, image_filters::blur
};
use skulpin::skia_safe::canvas::{
SrcRectConstraint, SaveLayerRec
}; };
use skulpin::skia_safe::canvas::SrcRectConstraint;
use skulpin::CoordinateSystemHelper; use skulpin::CoordinateSystemHelper;
mod caching_shaper; mod caching_shaper;
@ -155,12 +157,20 @@ 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
) { ) {
self.paint.set_blend_mode(BlendMode::Src);
let region = self.compute_text_region(grid_pos, cell_width); let region = self.compute_text_region(grid_pos, cell_width);
let style = style.as_ref().unwrap_or(default_style); let style = style.as_ref().unwrap_or(default_style);
self.paint let mut color = style.background(&default_style.colors);
.set_color(style.background(&default_style.colors).to_color());
if floating {
color.a = 0.8;
}
self.paint.set_color(color.to_color());
canvas.draw_rect(region, &self.paint); canvas.draw_rect(region, &self.paint);
} }
@ -290,12 +300,14 @@ impl Renderer {
text, cell_width, grid_position, style text, cell_width, grid_position, style
} => { } => {
let mut canvas = rendered_window.surface.canvas(); let mut canvas = rendered_window.surface.canvas();
self.draw_background( self.draw_background(
&mut canvas, &mut canvas,
grid_position, grid_position,
cell_width, cell_width,
&style, &style,
&default_style, &default_style,
window_render_info.floating
); );
self.draw_foreground( self.draw_foreground(
&mut canvas, &mut canvas,
@ -343,13 +355,23 @@ impl Renderer {
REDRAW_SCHEDULER.queue_next_frame(); REDRAW_SCHEDULER.queue_next_frame();
} }
root_canvas.save_layer(&Default::default()); root_canvas.save();
// let region = Rect::new(5.0, 5.0, 500.0, 500.0);
// root_canvas.clip_rect(&region, None, Some(false));
// let blur = blur((5.0, 5.0), None, None, None).unwrap();
// let save_layer_rec = SaveLayerRec::default()
// .backdrop(&blur)
// .bounds(&region);
// 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();
root_canvas.restore(); root_canvas.restore();
let window_position = rendered_window.current_position.clone(); let window_position = rendered_window.current_position.clone();

Loading…
Cancel
Save