add visual feedback to scale text

This commit is contained in:
Aitor 2023-02-20 11:30:08 +01:00 committed by Alejandro Alonso
parent 9e190d9810
commit 1758b34eed
5 changed files with 24 additions and 5 deletions

View file

@ -41,6 +41,12 @@
(def rotate (cursor-fn :rotate 90))
(def text (cursor-fn :text 0))
;; text
(def scale-ew (cursor-fn :scale-h 0))
(def scale-nesw (cursor-fn :scale-h 45))
(def scale-ns (cursor-fn :scale-h 90))
(def scale-nwse (cursor-fn :scale-h 135))
;;
(def resize-ew-2 (cursor-fn :resize-h-2 0))
(def resize-ns-2 (cursor-fn :resize-h-2 90))

View file

@ -176,8 +176,11 @@
(mf/defc resize-point-handler
[{:keys [cx cy zoom position on-resize transform rotation color align]}]
(let [cursor (if (#{:top-left :bottom-right} position)
(cur/resize-nesw rotation) (cur/resize-nwse rotation))
(let [layout (mf/deref refs/workspace-layout)
scale-text (:scale-text layout)
cursor (if (#{:top-left :bottom-right} position)
(if scale-text (cur/scale-nesw rotation) (cur/resize-nesw rotation))
(if scale-text (cur/scale-nwse rotation) (cur/resize-nwse rotation)))
{cx' :x cy' :y} (gpt/transform (gpt/point cx cy) transform)]
[:g.resize-handler
@ -221,7 +224,8 @@
(let [res-point (if (#{:top :bottom} position)
{:y y}
{:x x})
layout (mf/deref refs/workspace-layout)
scale-text (:scale-text layout)
height (/ resize-side-height zoom)
offset-y (if (= align :outside) (- height) (- (/ height 2)))
target-y (+ y offset-y)
@ -246,8 +250,8 @@
:style {:fill (if (debug? :handlers) "yellow" "none")
:stroke-width 0
:cursor (if (#{:left :right} position)
(cur/resize-ew rotation)
(cur/resize-ns rotation)) }}]]))
(if scale-text (cur/scale-ew rotation) (cur/resize-ew rotation))
(if scale-text (cur/scale-ns rotation) (cur/resize-ns rotation))) }}]]))
(defn minimum-selrect [{:keys [x y width height] :as selrect}]
(let [final-width (max width min-selrect-side)