0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Add horizontal resize handlers (#25)

This commit is contained in:
Jesús Espino 2016-05-10 09:57:08 +02:00 committed by Andrey Antukh
parent c88e5fc266
commit 15d5748922
3 changed files with 57 additions and 9 deletions

View file

@ -50,6 +50,10 @@
circle.bottom-right { cursor: nwse-resize; }
circle.top-right { cursor: nesw-resize; }
circle.bottom-left { cursor: nesw-resize; }
rect.top { cursor: ns-resize; }
rect.bottom { cursor: ns-resize; }
rect.left { cursor: ew-resize; }
rect.right { cursor: ew-resize; }
}
}

View file

@ -93,6 +93,38 @@
[:rect {:x x :y y :width width :height height :stroke-dasharray "5,5"
:style {:stroke "#333" :fill "transparent"
:stroke-opacity "1"}}]
[:rect.top
{:fill "#333"
:on-mouse-up #(on-mouse-up 5 %)
:on-mouse-down #(on-mouse-down 5 %)
:x (- (+ x (/ width 2)) 7)
:width 14
:height 3
:y (- y 5)}]
[:rect.right
{:fill "#333"
:on-mouse-up #(on-mouse-up 6 %)
:on-mouse-down #(on-mouse-down 6 %)
:y (- (+ y (/ height 2)) 7)
:width 3
:height 14
:x (+ x width 2)}]
[:rect.bottom
{:fill "#333"
:on-mouse-up #(on-mouse-up 7 %)
:on-mouse-down #(on-mouse-down 7 %)
:x (- (+ x (/ width 2)) 7)
:width 14
:height 3
:y (+ y height 2)}]
[:rect.left
{:fill "#333"
:on-mouse-up #(on-mouse-up 8 %)
:on-mouse-down #(on-mouse-down 8 %)
:y (- (+ y (/ height 2)) 7)
:width 3
:height 14
:x (- x 5)}]
[:circle.top-left
(merge uusc/+circle-props+
{:on-mouse-up #(on-mouse-up 1 %)

View file

@ -195,7 +195,15 @@
:y2 (max y1 (+ y2 dy)))
4 (assoc shape
:x2 (max x1 (+ x2 dx))
:y2 (max y1 (+ y2 dy))))))
: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))))))
(defn- move-circle-vertex
"A specialized function for vertex movement
@ -204,17 +212,21 @@
(let [[dx dy] (if lock [dx dx] [dx dy])]
(case vid
1 (assoc shape
:rx (- (:rx shape) dx)
:ry (- (:ry shape) dy))
:rx (max 0 (- (:rx shape) dx))
:ry (max 0 (- (:ry shape) dy)))
2 (assoc shape
:rx (+ (:rx shape) dx)
:ry (- (:ry shape) dy))
:rx (max 0 (+ (:rx shape) dx))
:ry (max 0 (- (:ry shape) dy)))
3 (assoc shape
:rx (- (:rx shape) dx)
:ry (+ (:ry shape) dy))
:rx (max 0 (- (:rx shape) dx))
:ry (max 0 (+ (:ry shape) dy)))
4 (assoc shape
:rx (+ (:rx shape) dx)
:ry (+ (:ry shape) dy)))))
: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))))))
;; --- Resize (Absolute)