mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
Add move cursor when shape is displaced on viewport.
This commit is contained in:
parent
4dc728378c
commit
99f935863a
9 changed files with 50 additions and 18 deletions
|
@ -204,6 +204,10 @@ h4 {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.move-cursor {
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
border-top: solid 1px $color-gray-light;
|
border-top: solid 1px $color-gray-light;
|
||||||
border-right: 0;
|
border-right: 0;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
[uxbox.main.geom :as geom]
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.geom.matrix :as gmt]
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]))
|
[uxbox.util.mixins :as mx :include-macros true]))
|
||||||
|
@ -45,10 +46,13 @@
|
||||||
(:cy shape))
|
(:cy shape))
|
||||||
rotation (or rotation 0)
|
rotation (or rotation 0)
|
||||||
|
|
||||||
|
moving? (boolean displacement)
|
||||||
|
|
||||||
xfmt (-> (gmt/matrix)
|
xfmt (-> (gmt/matrix)
|
||||||
(gmt/rotate* rotation center))
|
(gmt/rotate* rotation center))
|
||||||
|
|
||||||
props {:id (str "shape-" id)
|
props {:id (str "shape-" id)
|
||||||
|
:class (classnames :move-cursor moving?)
|
||||||
:transform (str xfmt)}
|
:transform (str xfmt)}
|
||||||
|
|
||||||
attrs (merge props
|
attrs (merge props
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
[uxbox.main.ui.shapes.text :as text]
|
[uxbox.main.ui.shapes.text :as text]
|
||||||
[uxbox.main.ui.shapes.path :as path]
|
[uxbox.main.ui.shapes.path :as path]
|
||||||
[uxbox.main.ui.shapes.image :as image]
|
[uxbox.main.ui.shapes.image :as image]
|
||||||
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.geom.matrix :as gmt]
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]))
|
[uxbox.util.mixins :as mx :include-macros true]))
|
||||||
|
|
||||||
|
@ -75,7 +76,9 @@
|
||||||
resize (gmt/multiply resize)
|
resize (gmt/multiply resize)
|
||||||
displacement (gmt/multiply displacement))
|
displacement (gmt/multiply displacement))
|
||||||
|
|
||||||
|
moving? (boolean displacement)
|
||||||
attrs {:id (str "shape-" id)
|
attrs {:id (str "shape-" id)
|
||||||
|
:class (classnames :move-cursor moving?)
|
||||||
:transform (str xfmt)}]
|
:transform (str xfmt)}]
|
||||||
[:g attrs
|
[:g attrs
|
||||||
(for [item (reverse items)
|
(for [item (reverse items)
|
||||||
|
|
|
@ -9,9 +9,11 @@
|
||||||
[uxbox.main.refs :as refs]
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.geom.matrix :as gmt]
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.geom.point :as gpt]))
|
[uxbox.util.geom.point :as gpt]
|
||||||
|
[uxbox.util.mixins :as mx :include-macros true]))
|
||||||
|
|
||||||
|
|
||||||
;; --- Icon Component
|
;; --- Icon Component
|
||||||
|
|
||||||
|
@ -39,7 +41,6 @@
|
||||||
center (gpt/point x-center y-center)]
|
center (gpt/point x-center y-center)]
|
||||||
(gmt/rotate* mt rotation center)))
|
(gmt/rotate* mt rotation center)))
|
||||||
|
|
||||||
|
|
||||||
(mx/defc icon-shape
|
(mx/defc icon-shape
|
||||||
{:mixins [mx/static]}
|
{:mixins [mx/static]}
|
||||||
[{:keys [id content metadata rotation x1 y1 modifiers] :as shape}]
|
[{:keys [id content metadata rotation x1 y1 modifiers] :as shape}]
|
||||||
|
@ -56,10 +57,12 @@
|
||||||
xfmt (cond-> (gmt/matrix)
|
xfmt (cond-> (gmt/matrix)
|
||||||
(pos? rotation) (rotate shape))
|
(pos? rotation) (rotate shape))
|
||||||
|
|
||||||
|
moving? (boolean displacement)
|
||||||
props {:id (str id)
|
props {:id (str id)
|
||||||
:x x1
|
:x x1
|
||||||
:y y1
|
:y y1
|
||||||
:view-box view-box
|
:view-box view-box
|
||||||
|
:class (classnames :move-cursor moving?)
|
||||||
:width width
|
:width width
|
||||||
:height height
|
:height height
|
||||||
:preserve-aspect-ratio "none"
|
:preserve-aspect-ratio "none"
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
[uxbox.main.data.images :as udi]
|
[uxbox.main.data.images :as udi]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.geom.matrix :as gmt]))
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
|
[uxbox.util.mixins :as mx :include-macros true]))
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
|
@ -62,9 +63,11 @@
|
||||||
resize (gmt/multiply resize)
|
resize (gmt/multiply resize)
|
||||||
displacement (gmt/multiply displacement))
|
displacement (gmt/multiply displacement))
|
||||||
|
|
||||||
|
moving? (boolean displacement)
|
||||||
props {:x x1 :y y1
|
props {:x x1 :y y1
|
||||||
:id (str "shape-" id)
|
:id (str "shape-" id)
|
||||||
:preserve-aspect-ratio "none"
|
:preserve-aspect-ratio "none"
|
||||||
|
:class (classnames :move-cursor moving?)
|
||||||
:xlink-href (:url image)
|
:xlink-href (:url image)
|
||||||
:transform (str xfmt)
|
:transform (str xfmt)
|
||||||
:width width
|
:width width
|
||||||
|
|
|
@ -7,12 +7,13 @@
|
||||||
(ns uxbox.main.ui.shapes.path
|
(ns uxbox.main.ui.shapes.path
|
||||||
(:require [potok.core :as ptk]
|
(:require [potok.core :as ptk]
|
||||||
[cuerdas.core :as str :include-macros true]
|
[cuerdas.core :as str :include-macros true]
|
||||||
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.refs :as refs]
|
[uxbox.main.refs :as refs]
|
||||||
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.main.geom :as geom]
|
|
||||||
[uxbox.util.geom.matrix :as gmt]
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]))
|
[uxbox.util.mixins :as mx :include-macros true]))
|
||||||
|
@ -69,9 +70,14 @@
|
||||||
shape (cond-> shape
|
shape (cond-> shape
|
||||||
displacement (geom/transform displacement)
|
displacement (geom/transform displacement)
|
||||||
resize (geom/transform resize))
|
resize (geom/transform resize))
|
||||||
|
moving? (boolean displacement)
|
||||||
|
|
||||||
pdata (render-path shape)
|
pdata (render-path shape)
|
||||||
attrs (merge {:id (str id) :d pdata}
|
props {:id (str id)
|
||||||
(attrs/extract-style-attrs shape))]
|
:class (classnames :move-cursor moving?)
|
||||||
|
:d pdata}
|
||||||
|
|
||||||
|
attrs (merge (attrs/extract-style-attrs shape) props)]
|
||||||
(if background?
|
(if background?
|
||||||
[:g {}
|
[:g {}
|
||||||
[:path {:stroke "transparent"
|
[:path {:stroke "transparent"
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[uxbox.util.geom.matrix :as gmt]
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.dom :as dom]))
|
[uxbox.util.dom :as dom]))
|
||||||
|
|
||||||
;; --- Rect Component
|
;; --- Rect Component
|
||||||
|
@ -53,11 +54,13 @@
|
||||||
xfmt (cond-> (gmt/matrix)
|
xfmt (cond-> (gmt/matrix)
|
||||||
(pos? rotation) (rotate shape))
|
(pos? rotation) (rotate shape))
|
||||||
|
|
||||||
|
moving? (boolean displacement)
|
||||||
|
|
||||||
props {:x x1 :y y1
|
props {:x x1 :y y1
|
||||||
:id (str "shape-" id)
|
:id (str "shape-" id)
|
||||||
|
:class (classnames :move-cursor moving?)
|
||||||
:width width
|
:width width
|
||||||
:height height
|
:height height
|
||||||
:transform (str xfmt)}
|
:transform (str xfmt)}
|
||||||
|
|
||||||
attrs (merge (attrs/extract-style-attrs shape) props)]
|
attrs (merge (attrs/extract-style-attrs shape) props)]
|
||||||
[:rect attrs]))
|
[:rect attrs]))
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
[uxbox.util.color :as color]
|
[uxbox.util.color :as color]
|
||||||
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.geom.matrix :as gmt]
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.mixins :as mx :include-macros true])
|
[uxbox.util.mixins :as mx :include-macros true])
|
||||||
|
@ -166,8 +167,10 @@
|
||||||
|
|
||||||
{:keys [x1 y1 width height] :as shape} (-> (geom/transform shape xfmt)
|
{:keys [x1 y1 width height] :as shape} (-> (geom/transform shape xfmt)
|
||||||
(geom/size))
|
(geom/size))
|
||||||
|
moving? (boolean displacement)
|
||||||
props {:x x1
|
props {:x x1
|
||||||
:y y1
|
:y y1
|
||||||
|
:class (classnames :move-cursor moving?)
|
||||||
:id (str id)
|
:id (str id)
|
||||||
:ref "fobject"
|
:ref "fobject"
|
||||||
:width width
|
:width width
|
||||||
|
@ -187,16 +190,19 @@
|
||||||
{:mixins [mx/static]
|
{:mixins [mx/static]
|
||||||
:did-mount text-shape-wrapper-did-mount
|
:did-mount text-shape-wrapper-did-mount
|
||||||
:did-remount text-shape-wrapper-did-remount}
|
:did-remount text-shape-wrapper-did-remount}
|
||||||
[{:keys [id content tmp-resize-xform tmp-displacement] :as shape}]
|
[{:keys [id content modifiers] :as shape}]
|
||||||
(let [xfmt (cond-> (gmt/matrix)
|
(let [{:keys [displacement resize]} modifiers
|
||||||
tmp-displacement (gmt/translate tmp-displacement)
|
xfmt (cond-> (gmt/matrix)
|
||||||
tmp-resize-xform (gmt/multiply tmp-resize-xform))
|
displacement (gmt/multiply displacement)
|
||||||
|
resize (gmt/multiply resize))
|
||||||
|
|
||||||
{:keys [x1 y1 width height] :as shape} (-> (geom/transform shape xfmt)
|
{:keys [x1 y1 width height] :as shape} (-> (geom/transform shape xfmt)
|
||||||
(geom/size))
|
(geom/size))
|
||||||
|
moving? (boolean displacement)
|
||||||
style (make-style shape)]
|
style (make-style shape)]
|
||||||
[:foreignObject {:x x1
|
[:foreignObject {:x x1
|
||||||
:y y1
|
:y y1
|
||||||
|
:class (classnames :move-cursor moving?)
|
||||||
:id (str id)
|
:id (str id)
|
||||||
:ref "fobject"
|
:ref "fobject"
|
||||||
:width width
|
:width width
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.refs :as refs]
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.main.data.projects :as dp]
|
[uxbox.main.data.projects :as dp]
|
||||||
|
@ -17,13 +18,12 @@
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.workspace.sidebar.sitemap-pageform]
|
[uxbox.main.ui.workspace.sidebar.sitemap-pageform]
|
||||||
[uxbox.main.ui.lightbox :as lbx]
|
[uxbox.main.ui.lightbox :as lbx]
|
||||||
[uxbox.builtins.icons :as i]
|
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.data :refer (classnames)]
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.dom.dnd :as dnd]
|
[uxbox.util.dom.dnd :as dnd]
|
||||||
[uxbox.util.dom :as dom]))
|
[uxbox.util.dom :as dom]
|
||||||
|
[uxbox.util.mixins :as mx :include-macros true]))
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue