mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
Merge pull request #5409 from penpot/superalex-hidden-layer-support-for-wasm-render
🎉 Hidden layer support for wasm render
This commit is contained in:
commit
b332f128b0
5 changed files with 20 additions and 3 deletions
|
@ -216,6 +216,10 @@
|
||||||
[opacity]
|
[opacity]
|
||||||
(h/call internal-module "_set_shape_opacity" (or opacity 1)))
|
(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))
|
(def debounce-render-without-cache (fns/debounce render-without-cache 100))
|
||||||
|
|
||||||
(defn set-view
|
(defn set-view
|
||||||
|
@ -239,7 +243,9 @@
|
||||||
fills (dm/get-prop shape :fills)
|
fills (dm/get-prop shape :fills)
|
||||||
children (dm/get-prop shape :shapes)
|
children (dm/get-prop shape :shapes)
|
||||||
blend-mode (dm/get-prop shape :blend-mode)
|
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)
|
(use-shape id)
|
||||||
(set-shape-selrect selrect)
|
(set-shape-selrect selrect)
|
||||||
(set-shape-rotation rotation)
|
(set-shape-rotation rotation)
|
||||||
|
@ -247,6 +253,7 @@
|
||||||
(set-shape-blend-mode blend-mode)
|
(set-shape-blend-mode blend-mode)
|
||||||
(set-shape-children children)
|
(set-shape-children children)
|
||||||
(set-shape-opacity opacity)
|
(set-shape-opacity opacity)
|
||||||
|
(set-shape-hidden hidden)
|
||||||
(let [pending-fills (doall (set-shape-fills fills))]
|
(let [pending-fills (doall (set-shape-fills fills))]
|
||||||
(recur (inc index) (into pending pending-fills))))
|
(recur (inc index) (into pending pending-fills))))
|
||||||
pending))]
|
pending))]
|
||||||
|
@ -263,7 +270,6 @@
|
||||||
:stencil true
|
:stencil true
|
||||||
:alpha true})
|
:alpha true})
|
||||||
|
|
||||||
|
|
||||||
(defn clear-canvas
|
(defn clear-canvas
|
||||||
[]
|
[]
|
||||||
;; TODO: perform corresponding cleaning
|
;; TODO: perform corresponding cleaning
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
:fills (api/set-shape-fills v)
|
:fills (api/set-shape-fills v)
|
||||||
:blend-mode (api/set-shape-blend-mode v)
|
:blend-mode (api/set-shape-blend-mode v)
|
||||||
:opacity (api/set-shape-opacity v)
|
:opacity (api/set-shape-opacity v)
|
||||||
|
:hidden (api/set-shape-hidden v)
|
||||||
:shapes (api/set-shape-children v)
|
:shapes (api/set-shape-children v)
|
||||||
nil)
|
nil)
|
||||||
;; when something synced with wasm
|
;; when something synced with wasm
|
||||||
|
|
|
@ -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() {
|
fn main() {
|
||||||
init_gl();
|
init_gl();
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,7 +389,7 @@ impl RenderState {
|
||||||
let mut is_complete = self.viewbox.area.contains(shape.selrect);
|
let mut is_complete = self.viewbox.area.contains(shape.selrect);
|
||||||
|
|
||||||
if !id.is_nil() {
|
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);
|
self.render_debug_shape(shape, false);
|
||||||
// TODO: This means that not all the shapes are renderer so we
|
// TODO: This means that not all the shapes are renderer so we
|
||||||
// need to call a render_all on the zoom out.
|
// need to call a render_all on the zoom out.
|
||||||
|
|
|
@ -51,6 +51,7 @@ pub struct Shape {
|
||||||
fills: Vec<Fill>,
|
fills: Vec<Fill>,
|
||||||
pub blend_mode: BlendMode,
|
pub blend_mode: BlendMode,
|
||||||
pub opacity: f32,
|
pub opacity: f32,
|
||||||
|
pub hidden: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shape {
|
impl Shape {
|
||||||
|
@ -65,6 +66,7 @@ impl Shape {
|
||||||
fills: vec![],
|
fills: vec![],
|
||||||
blend_mode: BlendMode::default(),
|
blend_mode: BlendMode::default(),
|
||||||
opacity: 1.,
|
opacity: 1.,
|
||||||
|
hidden: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue