0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-10 22:11:23 -05:00

🐛 Improve deeps selection of nested arboards

This commit is contained in:
alonso.torres 2023-03-07 16:58:35 +01:00
parent c3ce0eb794
commit f3f611848c
4 changed files with 28 additions and 12 deletions

View file

@ -22,6 +22,7 @@
- Fix problem when undoing multiple selected colors [Taiga #4920](https://tree.taiga.io/project/penpot/issue/4920)
- Allow selection of empty board by partial rect [Taiga #4806](https://tree.taiga.io/project/penpot/issue/4806)
- Improve behavior for undo on text edition [Taiga #4693](https://tree.taiga.io/project/penpot/issue/4693)
- Improve deeps selection of nested arboards [Taiga #4913](https://tree.taiga.io/project/penpot/issue/4913)
### :arrow_up: Deps updates

View file

@ -24,9 +24,11 @@
(and (= type :frame) (= id uuid/zero)))
(defn root-frame?
[{:keys [frame-id type]}]
(and (= type :frame)
(= frame-id uuid/zero)))
([objects id]
(root-frame? (get objects id)))
([{:keys [frame-id type]}]
(and (= type :frame)
(= frame-id uuid/zero))))
(defn frame-shape?
([objects id]

View file

@ -179,18 +179,22 @@
([objects ids {:keys [bottom-frames?] :as options}]
(letfn [(comp [id-a id-b]
(let [type-a (dm/get-in objects [id-a :type])
type-b (dm/get-in objects [id-b :type])]
(let [frame-a? (= :frame (dm/get-in objects [id-a :type]))
frame-b? (= :frame (dm/get-in objects [id-b :type]))]
(cond
(and (not= :frame type-a) (= :frame type-b))
(if bottom-frames? -1 1)
(and (= :frame type-a) (not= :frame type-b))
(if bottom-frames? 1 -1)
(= id-a id-b)
0
(and (not frame-a?) frame-b?)
(if bottom-frames? -1 1)
(and frame-a? (not frame-b?))
(if bottom-frames? 1 -1)
;; When comparing frames we invert the order if the flag `bottom-frames?` is on
(and frame-a? frame-b? bottom-frames?)
(if (is-shape-over-shape? objects id-b id-a) 1 -1)
(is-shape-over-shape? objects id-b id-a)
-1

View file

@ -7,6 +7,7 @@
(ns app.main.ui.workspace.viewport.hooks
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.geom.shapes :as gsh]
[app.common.pages :as cp]
[app.common.pages.helpers :as cph]
@ -169,7 +170,8 @@
;; but the mouse has not been moved from its position.
(->> mod-str
(rx/observe-on :async)
(rx/map #(deref last-point-ref)))
(rx/map #(deref last-point-ref))
(rx/merge-map query-point))
(->> move-stream
(rx/tap #(reset! last-point-ref %))
@ -241,10 +243,17 @@
remove-id?
(into selected-with-parents remove-id-xf ids)
no-fill-nested-frames?
(fn [id]
(and (cph/frame-shape? objects id)
(not (cph/root-frame? objects id))
(empty? (dm/get-in objects [id :fills]))))
hover-shape
(->> ids
(remove remove-id?)
(remove (partial cph/hidden-parent? objects))
(remove no-fill-nested-frames?)
(filter #(or (empty? focus) (cp/is-in-focus? objects focus %)))
(first)
(get objects))]