Add invisible background to paths.

In order to make more easy to the
user select and move them.
This commit is contained in:
Andrey Antukh 2017-02-26 21:19:39 +01:00
parent 4a804ae467
commit ac49728758
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -25,7 +25,9 @@
(let [modifiers (mx/react (common/modifiers-ref id)) (let [modifiers (mx/react (common/modifiers-ref id))
selected (mx/react common/selected-ref) selected (mx/react common/selected-ref)
selected? (contains? selected id) selected? (contains? selected id)
shape (assoc shape :modifiers modifiers)] shape (assoc shape
:modifiers modifiers
:background? true)]
(letfn [(on-mouse-down [event] (letfn [(on-mouse-down [event]
(common/on-mouse-down event shape selected)) (common/on-mouse-down event shape selected))
(on-double-click [event] (on-double-click [event]
@ -61,14 +63,19 @@
(mx/defc path-shape (mx/defc path-shape
{:mixins [mx/static]} {:mixins [mx/static]}
[{:keys [id modifiers rotation] :as shape}] [{:keys [id modifiers background?] :as shape}]
(let [{:keys [resize displacement]} modifiers (let [{:keys [resize displacement]} modifiers
shape (cond-> shape shape (cond-> shape
displacement (geom/transform displacement) displacement (geom/transform displacement)
resize (geom/transform resize) resize (geom/transform resize))
(pos? rotation) (geom/rotate-shape)) pdata (render-path shape)
attrs (merge {:id (str id) :d pdata}
props {:id (str id) (attrs/extract-style-attrs shape))]
:d (render-path shape)} (if background?
attrs (merge props (attrs/extract-style-attrs shape))] [:g {}
[:path attrs])) [:path {:stroke "transparent"
:fill "transparent"
:stroke-width "20px"
:d pdata}]
[:path attrs]]
[:path attrs])))