From d882c2dfdb8bd9a35fe508004082382fcf206275 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 24 Oct 2016 22:17:27 +0200 Subject: [PATCH] Respect proportion of icon or image when is added/imported to workspace. --- src/uxbox/main/ui/workspace/drawarea.cljs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/uxbox/main/ui/workspace/drawarea.cljs b/src/uxbox/main/ui/workspace/drawarea.cljs index 060c62b713..9f0fdcd547 100644 --- a/src/uxbox/main/ui/workspace/drawarea.cljs +++ b/src/uxbox/main/ui/workspace/drawarea.cljs @@ -110,6 +110,7 @@ (when-let [shape (:drawing @wb/workspace-ref)] (case (:type shape) :icon (on-init-draw-icon shape) + :image (on-init-draw-icon shape) :path (if (:free shape) (on-init-draw-free-path shape) (on-init-draw-path shape)) @@ -118,9 +119,14 @@ ;; --- Icon Drawing (defn- on-init-draw-icon - [shape] + [{:keys [metadata] :as shape}] (let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-ref) - props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)} + {:keys [width height]} metadata + proportion (/ width height) + props {:x1 x + :y1 y + :x2 (+ x 200) + :y2 (+ y (/ 200 proportion))} shape (geom/setup shape props)] (rs/emit! (uds/add-shape shape) (udw/select-for-drawing nil)