diff --git a/src/uxbox/ui/workspace/selection.cljs b/src/uxbox/ui/workspace/selection.cljs index 3c09d01f3..896899d4f 100644 --- a/src/uxbox/ui/workspace/selection.cljs +++ b/src/uxbox/ui/workspace/selection.cljs @@ -63,50 +63,50 @@ :style {:stroke "#333" :fill "transparent" :stroke-opacity "1"}}] [:circle.top (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 5 %) - :on-mouse-down #(on-mouse-down 5 %) + {:on-mouse-up #(on-mouse-up :top %) + :on-mouse-down #(on-mouse-down :top %) :cx (+ x (/ width 2)) :cy (- y 2)})] [:circle.right (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 6 %) - :on-mouse-down #(on-mouse-down 6 %) + {:on-mouse-up #(on-mouse-up :right %) + :on-mouse-down #(on-mouse-down :right %) :cy (+ y (/ height 2)) :cx (+ x width 1)})] [:circle.bottom (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 7 %) - :on-mouse-down #(on-mouse-down 7 %) + {:on-mouse-up #(on-mouse-up :bottom %) + :on-mouse-down #(on-mouse-down :bottom %) :cx (+ x (/ width 2)) :cy (+ y height 2)})] [:circle.left (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 8 %) - :on-mouse-down #(on-mouse-down 8 %) + {:on-mouse-up #(on-mouse-up :left %) + :on-mouse-down #(on-mouse-down :left %) :cy (+ y (/ height 2)) :cx (- x 3)})] [:circle.top-left (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 1 %) - :on-mouse-down #(on-mouse-down 1 %) + {:on-mouse-up #(on-mouse-up :top-left %) + :on-mouse-down #(on-mouse-down :top-left %) :cx x :cy y})] [:circle.top-right (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 2 %) - :on-mouse-down #(on-mouse-down 2 %) + {:on-mouse-up #(on-mouse-up :top-right %) + :on-mouse-down #(on-mouse-down :top-right %) :cx (+ x width) :cy y})] [:circle.bottom-left (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 3 %) - :on-mouse-down #(on-mouse-down 3 %) + {:on-mouse-up #(on-mouse-up :bottom-left %) + :on-mouse-down #(on-mouse-down :bottom-left %) :cx x :cy (+ y height)})] [:circle.bottom-right (merge +circle-props+ - {:on-mouse-up #(on-mouse-up 4 %) - :on-mouse-down #(on-mouse-down 4 %) + {:on-mouse-up #(on-mouse-up :bottom-right %) + :on-mouse-down #(on-mouse-down :bottom-right %) :cx (+ x width) :cy (+ y height)})]])))) diff --git a/src/uxbox/util/geom.cljs b/src/uxbox/util/geom.cljs index 22d6b9d8c..124346bb8 100644 --- a/src/uxbox/util/geom.cljs +++ b/src/uxbox/util/geom.cljs @@ -181,29 +181,26 @@ (defn- move-rect-vertex "A specialized function for vertex movement for rect-like shapes." - [shape vid {dx :x dy :y}] - (let [{:keys [x1 x2 y1 y2]} shape] + [shape vid {dx :x dy :y lock? :lock}] + (let [{:keys [x1 x2 y1 y2]} shape + dy (if lock? dx dy)] (case vid - 1 (assoc shape - :x1 (min x2 (+ x1 dx)) - :y1 (min y2 (+ y1 dy))) - 2 (assoc shape - :x2 (max x1 (+ x2 dx)) - :y1 (min y2 (+ y1 dy))) - 3 (assoc shape - :x1 (min x2 (+ x1 dx)) - :y2 (max y1 (+ y2 dy))) - 4 (assoc shape - :x2 (max x1 (+ x2 dx)) - :y2 (max y1 (+ y2 dy))) - 5 (assoc shape - :y1 (min y2 (+ y1 dy))) - 6 (assoc shape - :x2 (max x1 (+ x2 dx))) - 7 (assoc shape - :y2 (max y1 (+ y2 dy))) - 8 (assoc shape - :x1 (min x2 (+ x1 dx)))))) + :top-left (assoc shape + :x1 (min x2 (+ x1 dx)) + :y1 (min y2 (+ y1 dy))) + :top-right (assoc shape + :x2 (max x1 (+ x2 dx)) + :y1 (min y2 (+ y1 dy))) + :bottom-left (assoc shape + :x1 (min x2 (+ x1 dx)) + :y2 (max y1 (+ y2 dy))) + :bottom-right (assoc shape + :x2 (max x1 (+ x2 dx)) + :y2 (max y1 (+ y2 dy))) + :top (assoc shape :y1 (min y2 (+ y1 dy))) + :right (assoc shape :x2 (max x1 (+ x2 dx))) + :bottom (assoc shape :y2 (max y1 (+ y2 dy))) + :left (assoc shape :x1 (min x2 (+ x1 dx)))))) (defn- move-circle-vertex "A specialized function for vertex movement @@ -211,22 +208,22 @@ [shape vid {dx :x dy :y lock :lock}] (let [[dx dy] (if lock [dx dx] [dx dy])] (case vid - 1 (assoc shape - :rx (max 0 (- (:rx shape) dx)) - :ry (max 0 (- (:ry shape) dy))) - 2 (assoc shape - :rx (max 0 (+ (:rx shape) dx)) - :ry (max 0 (- (:ry shape) dy))) - 3 (assoc shape - :rx (max 0 (- (:rx shape) dx)) - :ry (max 0 (+ (:ry shape) dy))) - 4 (assoc shape - :rx (max 0 (+ (:rx shape) dx)) - :ry (max 0 (+ (:ry shape) dy))) - 5 (assoc shape :ry (max 0 (- (:ry shape) dy))) - 6 (assoc shape :rx (max 0 (+ (:rx shape) dx))) - 7 (assoc shape :ry (max 0 (+ (:ry shape) dy))) - 8 (assoc shape :rx (max 0 (+ (:rx shape) dx)))))) + :top-left (assoc shape + :rx (max 0 (- (:rx shape) dx)) + :ry (max 0 (- (:ry shape) dy))) + :top-right (assoc shape + :rx (max 0 (+ (:rx shape) dx)) + :ry (max 0 (- (:ry shape) dy))) + :bottom-left (assoc shape + :rx (max 0 (- (:rx shape) dx)) + :ry (max 0 (+ (:ry shape) dy))) + :bottom-right (assoc shape + :rx (max 0 (+ (:rx shape) dx)) + :ry (max 0 (+ (:ry shape) dy))) + :top (assoc shape :ry (max 0 (- (:ry shape) dy))) + :right (assoc shape :rx (max 0 (+ (:rx shape) dx))) + :bottom (assoc shape :ry (max 0 (+ (:ry shape) dy))) + :left (assoc shape :rx (max 0 (+ (:rx shape) dx)))))) ;; --- Resize (Absolute)