diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index 73269e0ec..d881c212a 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -216,6 +216,10 @@ [opacity] (h/call internal-module "_set_shape_opacity" (or opacity 1))) +(defn set-shape-hidden + [hidden] + (h/call internal-module "_set_shape_hidden" hidden)) + (def debounce-render-without-cache (fns/debounce render-without-cache 100)) (defn set-view @@ -239,7 +243,9 @@ fills (dm/get-prop shape :fills) children (dm/get-prop shape :shapes) blend-mode (dm/get-prop shape :blend-mode) - opacity (dm/get-prop shape :opacity)] + opacity (dm/get-prop shape :opacity) + hidden (dm/get-prop shape :hidden)] + (use-shape id) (set-shape-selrect selrect) (set-shape-rotation rotation) @@ -247,6 +253,7 @@ (set-shape-blend-mode blend-mode) (set-shape-children children) (set-shape-opacity opacity) + (set-shape-hidden hidden) (let [pending-fills (doall (set-shape-fills fills))] (recur (inc index) (into pending pending-fills)))) pending))] @@ -263,7 +270,6 @@ :stencil true :alpha true}) - (defn clear-canvas [] ;; TODO: perform corresponding cleaning diff --git a/frontend/src/app/render_wasm/shape.cljs b/frontend/src/app/render_wasm/shape.cljs index df8beec4d..6290dbe79 100644 --- a/frontend/src/app/render_wasm/shape.cljs +++ b/frontend/src/app/render_wasm/shape.cljs @@ -118,6 +118,7 @@ :fills (api/set-shape-fills v) :blend-mode (api/set-shape-blend-mode v) :opacity (api/set-shape-opacity v) + :hidden (api/set-shape-hidden v) :shapes (api/set-shape-children v) nil) ;; when something synced with wasm diff --git a/render-wasm/src/main.rs b/render-wasm/src/main.rs index f7f082a95..efa0566bf 100644 --- a/render-wasm/src/main.rs +++ b/render-wasm/src/main.rs @@ -263,6 +263,14 @@ pub extern "C" fn set_shape_opacity(opacity: f32) { } } +#[no_mangle] +pub extern "C" fn set_shape_hidden(hidden: bool) { + let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer"); + if let Some(shape) = state.current_shape() { + shape.hidden = hidden; + } +} + fn main() { init_gl(); } diff --git a/render-wasm/src/render.rs b/render-wasm/src/render.rs index 15db8de67..d07cb96eb 100644 --- a/render-wasm/src/render.rs +++ b/render-wasm/src/render.rs @@ -389,7 +389,7 @@ impl RenderState { let mut is_complete = self.viewbox.area.contains(shape.selrect); if !id.is_nil() { - if !shape.selrect.intersects(self.viewbox.area) { + if !shape.selrect.intersects(self.viewbox.area) || shape.hidden { self.render_debug_shape(shape, false); // TODO: This means that not all the shapes are renderer so we // need to call a render_all on the zoom out. diff --git a/render-wasm/src/shapes.rs b/render-wasm/src/shapes.rs index b60712d8a..11785885e 100644 --- a/render-wasm/src/shapes.rs +++ b/render-wasm/src/shapes.rs @@ -51,6 +51,7 @@ pub struct Shape { fills: Vec, pub blend_mode: BlendMode, pub opacity: f32, + pub hidden: bool, } impl Shape { @@ -65,6 +66,7 @@ impl Shape { fills: vec![], blend_mode: BlendMode::default(), opacity: 1., + hidden: false, } }