Merge pull request #1292 from penpot/bugfix

Bug fixing
This commit is contained in:
Andrey Antukh 2021-10-20 15:05:50 +02:00 committed by GitHub
commit 5ec73da17f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 63 additions and 22 deletions

View file

@ -41,6 +41,12 @@
- Fix path stroke is not working properly with high thickness [Taiga #2154](https://tree.taiga.io/project/penpot/issue/2154). - Fix path stroke is not working properly with high thickness [Taiga #2154](https://tree.taiga.io/project/penpot/issue/2154).
- Fix bug with transformation operations [Taiga #2155](https://tree.taiga.io/project/penpot/issue/2155). - Fix bug with transformation operations [Taiga #2155](https://tree.taiga.io/project/penpot/issue/2155).
- Fix bug in firefox when a text box is inside a mask [Taiga #2152](https://tree.taiga.io/project/penpot/issue/2152). - Fix bug in firefox when a text box is inside a mask [Taiga #2152](https://tree.taiga.io/project/penpot/issue/2152).
- Fix problem with stroke inside/outside [Taiga #2186](https://tree.taiga.io/project/penpot/issue/2186)
- Fix masks export area [Taiga #2189](https://tree.taiga.io/project/penpot/issue/2189)
- Fix paste in place in arboards [Taiga #2188](https://tree.taiga.io/project/penpot/issue/2188)
- Fix font size input stuck on selection change [Taiga #2184](https://tree.taiga.io/project/penpot/issue/2184)
- Fix stroke cut on shapes export [Taiga #2171](https://tree.taiga.io/project/penpot/issue/2171)
- Fix no color when boolean with an SVG [Taiga #2193](https://tree.taiga.io/project/penpot/issue/2193)
### :arrow_up: Deps updates ### :arrow_up: Deps updates

View file

@ -13,7 +13,8 @@
[app.common.geom.shapes.intersect :as gin] [app.common.geom.shapes.intersect :as gin]
[app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.path :as gsp]
[app.common.geom.shapes.rect :as gpr] [app.common.geom.shapes.rect :as gpr]
[app.common.geom.shapes.transforms :as gtr])) [app.common.geom.shapes.transforms :as gtr]
[app.common.math :as mth]))
;; --- Setup (Initialize) ;; --- Setup (Initialize)
;; FIXME: Is this the correct place for these functions? ;; FIXME: Is this the correct place for these functions?
@ -127,6 +128,13 @@
(assoc :selrect selrect (assoc :selrect selrect
:points points)))) :points points))))
(defn shape-stroke-margin
[shape stroke-width]
(if (= (:type shape) :path)
;; TODO: Calculate with the stroke offset (not implemented yet
(mth/sqrt (* 2 stroke-width stroke-width))
(- (mth/sqrt (* 2 stroke-width stroke-width)) stroke-width)))
;; EXPORTS ;; EXPORTS
(d/export gco/center-shape) (d/export gco/center-shape)

View file

@ -176,7 +176,12 @@
(let [children (->> (:shapes shape) (let [children (->> (:shapes shape)
(map #(get objects %)) (map #(get objects %))
(map #(convert-to-path % objects))) (map #(convert-to-path % objects)))
head (first children) bool-type (:bool-type shape)
head (if (= bool-type :difference) (first children) (last children))
head (cond-> head
(and (contains? head :svg-attrs) (nil? (:fill-color head)))
(assoc :fill-color "#000000"))
head-data (select-keys head style-properties) head-data (select-keys head style-properties)
content (pb/content-bool (:bool-type shape) (mapv :content children))] content (pb/content-bool (:bool-type shape) (mapv :content children))]

View file

@ -1648,7 +1648,6 @@
;; Procceed with the standard shape paste procediment. ;; Procceed with the standard shape paste procediment.
(do-paste [it state mouse-pos media] (do-paste [it state mouse-pos media]
(let [page-objects (wsh/lookup-page-objects state) (let [page-objects (wsh/lookup-page-objects state)
all-objects (merge page-objects paste-objects)
media-idx (d/index-by :prev-id media) media-idx (d/index-by :prev-id media)
;; Calculate position for the pasted elements ;; Calculate position for the pasted elements
@ -1670,6 +1669,8 @@
:shape-ref :shape-ref
:touched)))))) :touched))))))
all-objects (merge page-objects paste-objects)
page-id (:current-page-id state) page-id (:current-page-id state)
unames (-> (wsh/lookup-page-objects state page-id) unames (-> (wsh/lookup-page-objects state page-id)
(dwc/retrieve-used-names)) ;; TODO: move this calculation inside prepare-duplcate-changes? (dwc/retrieve-used-names)) ;; TODO: move this calculation inside prepare-duplcate-changes?

View file

@ -33,6 +33,10 @@
[bool-type name shapes objects] [bool-type name shapes objects]
(let [shapes (mapv #(stp/convert-to-path % objects) shapes) (let [shapes (mapv #(stp/convert-to-path % objects) shapes)
head (if (= bool-type :difference) (first shapes) (last shapes)) head (if (= bool-type :difference) (first shapes) (last shapes))
head (cond-> head
(and (contains? head :svg-attrs) (nil? (:fill-color head)))
(assoc :fill-color "#000000"))
head-data (select-keys head stp/style-properties)] head-data (select-keys head stp/style-properties)]
[(-> {:id (uuid/next) [(-> {:id (uuid/next)
:type :bool :type :bool
@ -51,7 +55,10 @@
(let [shapes (->> (:shapes group) (let [shapes (->> (:shapes group)
(map #(get objects %)) (map #(get objects %))
(mapv #(stp/convert-to-path % objects))) (mapv #(stp/convert-to-path % objects)))
head (first shapes) head (if (= bool-type :difference) (first shapes) (last shapes))
head (cond-> head
(and (contains? head :svg-attrs) (nil? (:fill-color head)))
(assoc :fill-color "#000000"))
head-data (select-keys head stp/style-properties)] head-data (select-keys head stp/style-properties)]
(-> group (-> group

View file

@ -76,6 +76,7 @@
handle-key-down handle-key-down
(mf/use-callback (mf/use-callback
(mf/deps set-value)
(fn [event] (fn [event]
(when (= type "number") (when (= type "number")
(let [up? (kbd/up-arrow? event) (let [up? (kbd/up-arrow? event)

View file

@ -37,11 +37,17 @@
(update :width + (* 2 padding)) (update :width + (* 2 padding))
(update :height + (* 2 padding)))] (update :height + (* 2 padding)))]
(if (= :group (:type object)) (cond
(and (= :group (:type object))
(:masked-group? object))
(calc-bounds (get objects (first (:shapes object))) objects)
(= :group (:type object))
(->> (:shapes object) (->> (:shapes object)
(into [obj-bounds] xf-get-bounds) (into [obj-bounds] xf-get-bounds)
(gsh/join-rects)) (gsh/join-rects))
:else
obj-bounds))) obj-bounds)))
(mf/defc object-svg (mf/defc object-svg

View file

@ -35,8 +35,22 @@
[{:keys [shape render-id]}] [{:keys [shape render-id]}]
(let [stroke-mask-id (str "outer-stroke-" render-id) (let [stroke-mask-id (str "outer-stroke-" render-id)
shape-id (str "stroke-shape-" render-id) shape-id (str "stroke-shape-" render-id)
stroke-width (:stroke-width shape 0)] stroke-width (case (:stroke-alignment shape :center)
[:mask {:id stroke-mask-id} :center (/ (:stroke-width shape 0) 2)
:outer (:stroke-width shape 0)
0)
margin (gsh/shape-stroke-margin shape stroke-width)
bounding-box (-> (gsh/points->selrect (:points shape))
(update :x - (+ stroke-width margin))
(update :y - (+ stroke-width margin))
(update :width + (* 2 (+ stroke-width margin)))
(update :height + (* 2 (+ stroke-width margin))))]
[:mask {:id stroke-mask-id
:x (:x bounding-box)
:y (:y bounding-box)
:width (:width bounding-box)
:height (:height bounding-box)
:maskUnits "userSpaceOnUse"}
[:use {:xlinkHref (str "#" shape-id) [:use {:xlinkHref (str "#" shape-id)
:style #js {:fill "none" :stroke "white" :strokeWidth (* stroke-width 2)}}] :style #js {:fill "none" :stroke "white" :strokeWidth (* stroke-width 2)}}]
@ -146,8 +160,8 @@
(mf/defc stroke-defs (mf/defc stroke-defs
[{:keys [shape render-id]}] [{:keys [shape render-id]}]
(when (and (= (:type shape) :path) (when (or (not= (:type shape) :path)
(gsh/open-path? shape)) (not (gsh/open-path? shape)))
(cond (cond
(and (= :inner (:stroke-alignment shape :center)) (and (= :inner (:stroke-alignment shape :center))
(> (:stroke-width shape 0) 0)) (> (:stroke-width shape 0) 0))

View file

@ -202,17 +202,12 @@
:height (- y2 y1)}))))) :height (- y2 y1)})))))
(defn calculate-padding [shape] (defn calculate-padding [shape]
(let [{:keys [stroke-style stroke-alignment stroke-width]} shape] (let [stroke-width (case (:stroke-alignment shape :center)
(cond :center (/ (:stroke-width shape 0) 2)
(and (not= stroke-style :none) :outer (:stroke-width shape 0)
(= stroke-alignment :outer)) 0)
stroke-width margin (gsh/shape-stroke-margin shape stroke-width)]
(+ stroke-width margin)))
(and (not= stroke-style :none)
(= stroke-alignment :center))
(mth/ceil (/ stroke-width 2))
:else 0)))
(mf/defc filters (mf/defc filters
[{:keys [filter-id shape]}] [{:keys [filter-id shape]}]
@ -221,9 +216,7 @@
;; Adds the previous filter as `filter-in` parameter ;; Adds the previous filter as `filter-in` parameter
filters (map #(assoc %1 :filter-in %2) filters (cons nil (map :id filters))) filters (map #(assoc %1 :filter-in %2) filters (cons nil (map :id filters)))
bounds (get-filters-bounds shape filters (or (-> shape :blur :value) 0)) bounds (get-filters-bounds shape filters (or (-> shape :blur :value) 0))
padding (calculate-padding shape)] padding (calculate-padding shape)]
[:* [:*