mirror of
https://github.com/penpot/penpot.git
synced 2025-06-10 20:11:37 +02:00
Add specific selection handler for text edition.
This commit is contained in:
parent
b00992881c
commit
20e7afeee5
2 changed files with 25 additions and 10 deletions
|
@ -5,8 +5,7 @@
|
||||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
(ns uxbox.main.ui.shapes.common
|
(ns uxbox.main.ui.shapes.common
|
||||||
(:require [sablono.core :refer-macros [html]]
|
(:require [lentes.core :as l]
|
||||||
[lentes.core :as l]
|
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
[uxbox.store :as st]
|
[uxbox.store :as st]
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
;; (defonce edition-ref (atom nil))
|
|
||||||
(def edition-ref
|
(def edition-ref
|
||||||
(-> (l/in [:workspace :edition])
|
(-> (l/in [:workspace :edition])
|
||||||
(l/derive st/state)))
|
(l/derive st/state)))
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
(-> (l/lens focus-selected-shapes)
|
(-> (l/lens focus-selected-shapes)
|
||||||
(l/derive st/state)))
|
(l/derive st/state)))
|
||||||
|
|
||||||
(def edition-ref scommon/edition-ref)
|
(def ^:private edition-ref scommon/edition-ref)
|
||||||
|
|
||||||
;; --- Resize Implementation
|
;; --- Resize Implementation
|
||||||
|
|
||||||
|
@ -362,22 +362,39 @@
|
||||||
shape (geom/selection-rect shape)]
|
shape (geom/selection-rect shape)]
|
||||||
(controls shape zoom on-click)))
|
(controls shape zoom on-click)))
|
||||||
|
|
||||||
|
(mx/defc text-edition-selection-handlers
|
||||||
|
{:mixins [mx/static]}
|
||||||
|
[{:keys [id] :as shape} zoom]
|
||||||
|
(let [{:keys [x1 y1 width height] :as shape} (geom/selection-rect shape)]
|
||||||
|
[:g.controls
|
||||||
|
[:rect.main {:x x1 :y y1
|
||||||
|
:width width
|
||||||
|
:height height
|
||||||
|
;; :stroke-dasharray (str (/ 5.0 zoom) "," (/ 5 zoom))
|
||||||
|
:style {:stroke "#333"
|
||||||
|
:stroke-width "0.5"
|
||||||
|
:stroke-opacity "0.5"
|
||||||
|
:fill "transparent"}}]]))
|
||||||
|
|
||||||
(mx/defc selection-handlers
|
(mx/defc selection-handlers
|
||||||
{:mixins [mx/reactive mx/static]}
|
{:mixins [mx/reactive mx/static]}
|
||||||
[]
|
[]
|
||||||
(let [shapes (mx/react selected-shapes-ref)
|
(let [shapes (mx/react selected-shapes-ref)
|
||||||
edition (mx/react scommon/edition-ref)
|
edition? (mx/react edition-ref)
|
||||||
zoom (mx/react wb/zoom-ref)
|
zoom (mx/react wb/zoom-ref)
|
||||||
shapes-num (count shapes)
|
num (count shapes)
|
||||||
shape (first shapes)]
|
{:keys [type] :as shape} (first shapes)]
|
||||||
(cond
|
(cond
|
||||||
(zero? shapes-num)
|
(zero? num)
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(> shapes-num 1)
|
(> num 1)
|
||||||
(multiple-selection-handlers shapes zoom)
|
(multiple-selection-handlers shapes zoom)
|
||||||
|
|
||||||
(= :path (:type shape))
|
(and (= type :text) edition?)
|
||||||
|
(text-edition-selection-handlers shape zoom)
|
||||||
|
|
||||||
|
(= type :path)
|
||||||
(if (= @edition-ref (:id shape))
|
(if (= @edition-ref (:id shape))
|
||||||
(path-edition-selection-handlers shape zoom)
|
(path-edition-selection-handlers shape zoom)
|
||||||
(single-selection-handlers shape zoom))
|
(single-selection-handlers shape zoom))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue