mirror of
https://github.com/penpot/penpot.git
synced 2025-01-25 07:58:49 -05:00
Merge pull request #3627 from penpot/niwinz-develop-bugfixes-4
Revert "⚡ Don't render not visible shapes on workspace"
This commit is contained in:
commit
c667d3ad46
6 changed files with 32 additions and 36 deletions
|
@ -275,19 +275,21 @@
|
|||
[a b]
|
||||
(mth/almost-zero? (- a b)))
|
||||
|
||||
;; FIXME: performance
|
||||
(defn overlaps-rects?
|
||||
"Check for two rects to overlap. Rects won't overlap only if
|
||||
one of them is fully to the left or the top"
|
||||
[rect-a rect-b]
|
||||
(let [x1a (dm/get-prop rect-a :x)
|
||||
y1a (dm/get-prop rect-a :y)
|
||||
x2a (+ x1a (dm/get-prop rect-a :width))
|
||||
y2a (+ y1a (dm/get-prop rect-a :height))
|
||||
|
||||
x1b (dm/get-prop rect-b :x)
|
||||
y1b (dm/get-prop rect-b :y)
|
||||
x2b (+ x1b (dm/get-prop rect-b :width))
|
||||
y2b (+ y1b (dm/get-prop rect-b :height))]
|
||||
(let [x1a (:x rect-a)
|
||||
y1a (:y rect-a)
|
||||
x2a (+ (:x rect-a) (:width rect-a))
|
||||
y2a (+ (:y rect-a) (:height rect-a))
|
||||
|
||||
x1b (:x rect-b)
|
||||
y1b (:y rect-b)
|
||||
x2b (+ (:x rect-b) (:width rect-b))
|
||||
y2b (+ (:y rect-b) (:height rect-b))]
|
||||
|
||||
(and (or (> x2a x1b) (s= x2a x1b))
|
||||
(or (>= x2b x1a) (s= x2b x1a))
|
||||
|
|
|
@ -307,12 +307,12 @@
|
|||
(defn overlaps?
|
||||
"General case to check for overlapping between shapes and a rectangle"
|
||||
[shape rect]
|
||||
(let [swidth (/ (or (:stroke-width shape) 0) 2)
|
||||
rect (-> rect
|
||||
(update :x - swidth)
|
||||
(update :y - swidth)
|
||||
(update :width + (* 2 swidth))
|
||||
(update :height + (* 2 swidth)))]
|
||||
(let [stroke-width (/ (or (:stroke-width shape) 0) 2)
|
||||
rect (-> rect
|
||||
(update :x - stroke-width)
|
||||
(update :y - stroke-width)
|
||||
(update :width + (* 2 stroke-width))
|
||||
(update :height + (* 2 stroke-width)))]
|
||||
(or (not shape)
|
||||
(cond
|
||||
(cph/path-shape? shape)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
(def current-project-id (mf/create-context nil))
|
||||
(def current-page-id (mf/create-context nil))
|
||||
(def current-file-id (mf/create-context nil))
|
||||
(def current-vbox (mf/create-context nil))
|
||||
|
||||
(def active-frames (mf/create-context nil))
|
||||
(def render-thumbnails (mf/create-context nil))
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
common."
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.rect :as grc]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.ui.context :as ctx]
|
||||
|
@ -50,14 +49,15 @@
|
|||
(let [objects (obj/get props "objects")
|
||||
active-frames (obj/get props "active-frames")
|
||||
shapes (cph/get-immediate-children objects)
|
||||
vbox (mf/use-ctx ctx/current-vbox)
|
||||
|
||||
shapes (mf/with-memo [shapes vbox]
|
||||
(if (some? vbox)
|
||||
(filter (fn [shape]
|
||||
(grc/overlaps-rects? vbox (dm/get-prop shape :selrect)))
|
||||
shapes)
|
||||
shapes))]
|
||||
;; vbox (mf/use-ctx ctx/current-vbox)
|
||||
;; shapes (mf/with-memo [shapes vbox]
|
||||
;; (if (some? vbox)
|
||||
;; (filter (fn [shape]
|
||||
;; (grc/overlaps-rects? vbox (dm/get-prop shape :selrect)))
|
||||
;; shapes)
|
||||
;; shapes))
|
||||
]
|
||||
|
||||
[:g {:id (dm/str "shape-" uuid/zero)}
|
||||
[:& (mf/provider ctx/active-frames) {:value active-frames}
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
(fdm/use-dynamic-modifiers objects (mf/ref-val node-ref) modifiers)
|
||||
[:& frame-shape {:shape shape :ref node-ref}]))))
|
||||
|
||||
|
||||
(defn root-frame-wrapper-factory
|
||||
[shape-wrapper]
|
||||
|
||||
|
@ -87,9 +86,9 @@
|
|||
thumbnail? (unchecked-get props "thumbnail?")
|
||||
|
||||
page-id (mf/use-ctx ctx/current-page-id)
|
||||
frame-id (dm/get-prop shape :id)
|
||||
frame-id (:id shape)
|
||||
|
||||
objects (wsh/lookup-page-objects @st/state page-id)
|
||||
objects (wsh/lookup-page-objects @st/state)
|
||||
|
||||
node-ref (mf/use-ref nil)
|
||||
root-ref (mf/use-ref nil)
|
||||
|
@ -115,7 +114,6 @@
|
|||
|
||||
on-frame-load
|
||||
(fns/use-node-store node-ref rendered-ref thumbnail? render-frame?)
|
||||
|
||||
]
|
||||
|
||||
(fdm/use-dynamic-modifiers objects (mf/ref-val node-ref) modifiers)
|
||||
|
|
|
@ -88,8 +88,6 @@
|
|||
show-distances?
|
||||
picking-color?]} wglobal
|
||||
|
||||
vbox' (mf/use-debounce 100 vbox)
|
||||
|
||||
;; CONTEXT
|
||||
page-id (mf/use-ctx ctx/current-page-id)
|
||||
|
||||
|
@ -325,13 +323,12 @@
|
|||
:y (:y vbox 0)
|
||||
:fill background}]
|
||||
|
||||
[:& (mf/provider ctx/current-vbox) {:value vbox'}
|
||||
[:& (mf/provider use/include-metadata-ctx) {:value (debug? :show-export-metadata)}
|
||||
[:& (mf/provider embed/context) {:value true}
|
||||
;; Render root shape
|
||||
[:& shapes/root-shape {:key page-id
|
||||
:objects base-objects
|
||||
:active-frames @active-frames}]]]]]
|
||||
[:& (mf/provider use/include-metadata-ctx) {:value (debug? :show-export-metadata)}
|
||||
[:& (mf/provider embed/context) {:value true}
|
||||
;; Render root shape
|
||||
[:& shapes/root-shape {:key page-id
|
||||
:objects base-objects
|
||||
:active-frames @active-frames}]]]]
|
||||
|
||||
[:svg.viewport-controls
|
||||
{:xmlns "http://www.w3.org/2000/svg"
|
||||
|
|
Loading…
Add table
Reference in a new issue