Compare commits

...

2 Commits

Author SHA1 Message Date
alonso.torres
36aa6484d3 🐛 Set objects modified instead of modif-tree 2026-02-05 17:24:43 +01:00
Alejandro Alonso
f9b8df770e 🐛 Fix grid lines 2026-02-05 14:05:10 +01:00
3 changed files with 42 additions and 7 deletions

View File

@@ -705,8 +705,8 @@
[:& grid-layout/editor
{:zoom zoom
:objects objects-modified
:shape (or (get base-objects edition)
(get base-objects @hover-top-frame-id))
:shape (or (get objects-modified edition)
(get objects-modified @hover-top-frame-id))
:view-only (not show-grid-editor?)}])]
[:g.scrollbar-wrapper {:clipPath "url(#clip-handlers)"}

View File

@@ -1,21 +1,30 @@
use skia_safe::{self as skia};
use crate::math::Rect;
use crate::shapes::modifiers::grid_layout::grid_cell_data;
use crate::shapes::Shape;
use crate::state::ShapesPoolRef;
pub fn render_overlay(zoom: f32, canvas: &skia::Canvas, shape: &Shape, shapes: ShapesPoolRef) {
let cells = grid_cell_data(shape, shapes, true);
let cells: Vec<crate::shapes::grid_layout::CellData<'_>> = grid_cell_data(shape, shapes, true);
let bounds = shape.bounds();
let mut paint = skia::Paint::default();
paint.set_style(skia::PaintStyle::Stroke);
paint.set_color(skia::Color::from_rgb(255, 111, 224));
paint.set_anti_alias(shape.should_use_antialias(zoom));
paint.set_stroke_width(1.0 / zoom);
for cell in cells.iter() {
let rect = Rect::from_xywh(cell.anchor.x, cell.anchor.y, cell.width, cell.height);
canvas.draw_rect(rect, &paint);
let hv = bounds.hv(cell.width);
let vv = bounds.vv(cell.height);
let points = [
cell.anchor,
cell.anchor + hv,
cell.anchor + hv + vv,
cell.anchor + vv,
];
let polygon = skia::Path::polygon(&points, true, None, None);
canvas.draw_path(&polygon, &paint);
}
}

View File

@@ -2,6 +2,7 @@ use skia_safe::{self as skia, Color4f};
use super::{RenderState, ShapesPoolRef, SurfaceId};
use crate::render::grid_layout;
use crate::shapes::{Layout, Type};
pub fn render(render_state: &mut RenderState, shapes: ShapesPoolRef) {
let canvas = render_state.surfaces.canvas(SurfaceId::UI);
@@ -18,12 +19,37 @@ pub fn render(render_state: &mut RenderState, shapes: ShapesPoolRef) {
let canvas = render_state.surfaces.canvas(SurfaceId::UI);
if let Some(id) = render_state.show_grid {
let show_grid_id = render_state.show_grid;
if let Some(id) = show_grid_id {
if let Some(shape) = shapes.get(&id) {
grid_layout::render_overlay(zoom, canvas, shape, shapes);
}
}
// Render overlays for empty grid frames
for shape in shapes.iter() {
if shape.id.is_nil() || !shape.children.is_empty() {
continue;
}
if show_grid_id == Some(shape.id) {
continue;
}
let Type::Frame(frame) = &shape.shape_type else {
continue;
};
if !matches!(frame.layout, Some(Layout::GridLayout(_, _))) {
continue;
}
if let Some(shape) = shapes.get(&shape.id) {
grid_layout::render_overlay(zoom, canvas, shape, shapes);
}
}
canvas.restore();
render_state.surfaces.draw_into(
SurfaceId::UI,