Adapt the code to use new shape geometry primitives.

This commit is contained in:
Andrey Antukh 2016-04-18 22:04:11 +03:00
parent 5597a87c72
commit 18190edcc8
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
23 changed files with 64 additions and 66 deletions

View file

@ -7,13 +7,13 @@
(ns uxbox.data.shapes (ns uxbox.data.shapes
(:require [beicon.core :as rx] (:require [beicon.core :as rx]
[uxbox.shapes :as sh]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.router :as r] [uxbox.router :as r]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.state.shapes :as stsh] [uxbox.state.shapes :as stsh]
[uxbox.schema :as sc] [uxbox.schema :as sc]
[uxbox.data.pages :as udp] [uxbox.data.pages :as udp]
[uxbox.util.geom :as geom]
[uxbox.util.geom.point :as gpt] [uxbox.util.geom.point :as gpt]
[uxbox.util.data :refer (index-of)])) [uxbox.util.data :refer (index-of)]))
@ -54,7 +54,7 @@
rs/UpdateEvent rs/UpdateEvent
(-apply-update [_ state] (-apply-update [_ state]
(let [shape (get-in state [:shapes-by-id sid])] (let [shape (get-in state [:shapes-by-id sid])]
(update-in state [:shapes-by-id sid] sh/move delta))))) (update-in state [:shapes-by-id sid] geom/move delta)))))
(defn update-line-attrs (defn update-line-attrs
[sid {:keys [x1 y1 x2 y2] :as opts}] [sid {:keys [x1 y1 x2 y2] :as opts}]
@ -65,7 +65,7 @@
(let [shape (get-in state [:shapes-by-id sid]) (let [shape (get-in state [:shapes-by-id sid])
props (select-keys opts [:x1 :y1 :x2 :y2]) props (select-keys opts [:x1 :y1 :x2 :y2])
props' (select-keys shape [:x1 :y1 :x2 :y2])] props' (select-keys shape [:x1 :y1 :x2 :y2])]
(update-in state [:shapes-by-id sid] sh/initialize (update-in state [:shapes-by-id sid] geom/setup
(merge props' props)))))) (merge props' props))))))
(defn update-rotation (defn update-rotation
@ -78,7 +78,7 @@
rs/UpdateEvent rs/UpdateEvent
(-apply-update [_ state] (-apply-update [_ state]
(update-in state [:shapes-by-id sid] (update-in state [:shapes-by-id sid]
sh/rotate rotation)))) geom/rotate rotation))))
(defn update-size (defn update-size
"A helper event just for update the position "A helper event just for update the position
@ -92,9 +92,15 @@
udp/IPageUpdate udp/IPageUpdate
rs/UpdateEvent rs/UpdateEvent
(-apply-update [_ state] (-apply-update [_ state]
(let [shape (get-in state [:shapes-by-id sid]) (letfn [(resize [shape {:keys [width height] :as size}]
size (merge (sh/size shape) opts)] (let [x1 (:x1 shape)
(update-in state [:shapes-by-id sid] sh/resize' size))))) y1 (:y1 shape)]
(assoc shape
:x2 (+ x1 width)
:y2 (+ y1 height))))]
(let [shape (get-in state [:shapes-by-id sid])
size (merge (geom/size shape) opts)]
(update-in state [:shapes-by-id sid] resize size))))))
(defn update-vertex-position (defn update-vertex-position
[id {:keys [vid delta]}] [id {:keys [vid delta]}]
@ -102,7 +108,7 @@
udp/IPageUpdate udp/IPageUpdate
rs/UpdateEvent rs/UpdateEvent
(-apply-update [_ state] (-apply-update [_ state]
(update-in state [:shapes-by-id id] sh/move-vertex vid delta)))) (update-in state [:shapes-by-id id] geom/move-vertex vid delta))))
(defn update-position (defn update-position
"Update the start position coordenate of the shape." "Update the start position coordenate of the shape."
@ -110,7 +116,7 @@
(reify (reify
rs/UpdateEvent rs/UpdateEvent
(-apply-update [_ state] (-apply-update [_ state]
(update-in state [:shapes-by-id sid] sh/move' opts)))) (update-in state [:shapes-by-id sid] geom/absolute-move opts))))
(defn update-text (defn update-text
"Update the start position coordenate of the shape." "Update the start position coordenate of the shape."
@ -314,11 +320,11 @@
(defn- has-blocked-parent? (defn- has-blocked-parent?
"Check if shape has blocked parent." "Check if shape has blocked parent."
[shape] [shape]
(sh/parent-satisfies? shape :blocked)) (geom/parent-satisfies? shape :blocked))
(defn- has-locked-parent? (defn- has-locked-parent?
[shape] [shape]
(sh/parent-satisfies? shape :locked)) (geom/parent-satisfies? shape :locked))
(defrecord SelectShapes [selrect] (defrecord SelectShapes [selrect]
rs/UpdateEvent rs/UpdateEvent
@ -330,8 +336,8 @@
(remove not-blocked-group?) (remove not-blocked-group?)
(remove has-locked-parent?) (remove has-locked-parent?)
(remove has-blocked-parent?) (remove has-blocked-parent?)
(map sh/outer-rect') (map geom/outer-rect)
(filter #(sh/contained-in? % selrect)) (filter #(geom/contained-in? % selrect))
(map :id))] (map :id))]
(->> (into #{} xform (vals (:shapes-by-id state))) (->> (into #{} xform (vals (:shapes-by-id state)))
(assoc-in state [:workspace :selected]))))) (assoc-in state [:workspace :selected])))))

View file

@ -8,7 +8,6 @@
(ns uxbox.data.workspace (ns uxbox.data.workspace
(:require [beicon.core :as rx] (:require [beicon.core :as rx]
[uxbox.constants :as c] [uxbox.constants :as c]
[uxbox.shapes :as sh]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state.shapes :as stsh] [uxbox.state.shapes :as stsh]
[uxbox.schema :as sc] [uxbox.schema :as sc]

View file

@ -9,7 +9,7 @@
(:refer-clojure :exclude [keyword uuid vector boolean map set]) (:refer-clojure :exclude [keyword uuid vector boolean map set])
(:require [struct.core :as st] (:require [struct.core :as st]
[uxbox.locales :refer (tr)] [uxbox.locales :refer (tr)]
[uxbox.shapes :refer (shape?)])) [uxbox.util.geom :refer (shape?)]))
;; (def datetime ;; (def datetime
;; {:message "must be an instant" ;; {:message "must be an instant"

View file

@ -1,7 +1,6 @@
(ns uxbox.state.shapes (ns uxbox.state.shapes
"A collection of functions for manage shapes insinde the state." "A collection of functions for manage shapes insinde the state."
(:require [uxbox.shapes :as sh] (:require [uxbox.util.data :refer (index-of)]))
[uxbox.util.data :refer (index-of)]))
;; --- Shape Creation ;; --- Shape Creation

View file

@ -5,13 +5,13 @@
[lentes.core :as l] [lentes.core :as l]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as ush]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.mixins :as mx] [uxbox.ui.mixins :as mx]
[uxbox.ui.keyboard :as kbd] [uxbox.ui.keyboard :as kbd]
[uxbox.ui.shapes.core :as uusc] [uxbox.ui.shapes.core :as uusc]
[uxbox.ui.shapes.icon :as uusi] [uxbox.ui.shapes.icon :as uusi]
[uxbox.util.geom :as geom]
[uxbox.util.dom :as dom])) [uxbox.util.dom :as dom]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -49,7 +49,7 @@
(on-mouse-up [vid event] (on-mouse-up [vid event]
(dom/stop-propagation event) (dom/stop-propagation event)
(uuc/release-action! "ui.shape.resize"))] (uuc/release-action! "ui.shape.resize"))]
(let [{:keys [x y width height]} (ush/outer-rect' shape)] (let [{:keys [x y width height]} (geom/outer-rect shape)]
(html (html
[:g.controls [:g.controls
[:rect {:x x :y y :width width :height height :stroke-dasharray "5,5" [:rect {:x x :y y :width width :height height :stroke-dasharray "5,5"
@ -93,7 +93,7 @@
(defmethod uusc/render-shape :builtin/circle (defmethod uusc/render-shape :builtin/circle
[{:keys [id] :as shape}] [{:keys [id] :as shape}]
(let [key (str id) (let [key (str id)
rfm (ush/transformation shape) rfm (geom/transformation-matrix shape)
props (select-keys shape [:cx :cy :rx :ry]) props (select-keys shape [:cx :cy :rx :ry])
attrs (-> (uusc/extract-style-attrs shape) attrs (-> (uusc/extract-style-attrs shape)
(merge {:id key :key key :transform (str rfm)}) (merge {:id key :key key :transform (str rfm)})

View file

@ -2,10 +2,9 @@
(:require [lentes.core :as l] (:require [lentes.core :as l]
[cuerdas.core :as str] [cuerdas.core :as str]
[rum.core :as rum] [rum.core :as rum]
[beicon.core :as rx]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as sh] [uxbox.ui.mixins :as mx]
[uxbox.ui.mixins :as mx])) [uxbox.util.geom :as geom]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Common constants ;; Common constants
@ -23,17 +22,21 @@
;; Implementation Api ;; Implementation Api
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn dispatch-by-type
[shape & params]
(:type shape))
(defmulti render-component (defmulti render-component
(fn [own shape] (:type shape)) (fn [own shape] (:type shape))
:hierarchy #'sh/+hierarchy+) :hierarchy #'geom/+hierarchy+)
(defmulti render-shape (defmulti render-shape
sh/dispatch-by-type dispatch-by-type
:hierarchy #'sh/+hierarchy+) :hierarchy #'geom/+hierarchy+)
(defmulti render-shape-svg (defmulti render-shape-svg
sh/dispatch-by-type dispatch-by-type
:hierarchy #'sh/+hierarchy+) :hierarchy #'geom/+hierarchy+)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lenses ;; Lenses

View file

@ -5,17 +5,17 @@
[lentes.core :as l] [lentes.core :as l]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as ush]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.keyboard :as kbd] [uxbox.ui.keyboard :as kbd]
[uxbox.ui.shapes.core :as uusc] [uxbox.ui.shapes.core :as uusc]
[uxbox.util.geom :as geom]
[uxbox.util.dom :as dom])) [uxbox.util.dom :as dom]))
(defmethod uusc/render-shape :builtin/group (defmethod uusc/render-shape :builtin/group
[{:keys [items id dx dy rotation] :as shape} factory] [{:keys [items id dx dy rotation] :as shape} factory]
(let [key (str "group-" id) (let [key (str "group-" id)
rfm (ush/transformation shape) rfm (geom/transformation-matrix shape)
attrs (merge {:id key :key key :transform (str rfm)} attrs (merge {:id key :key key :transform (str rfm)}
(uusc/extract-style-attrs shape) (uusc/extract-style-attrs shape)
(uusc/make-debug-attrs shape)) (uusc/make-debug-attrs shape))

View file

@ -5,13 +5,13 @@
[lentes.core :as l] [lentes.core :as l]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as ush]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.mixins :as mx] [uxbox.ui.mixins :as mx]
[uxbox.ui.keyboard :as kbd] [uxbox.ui.keyboard :as kbd]
[uxbox.ui.shapes.core :as uusc] [uxbox.ui.shapes.core :as uusc]
[uxbox.util.geom :as geom]
[uxbox.util.dom :as dom])) [uxbox.util.dom :as dom]))
;; --- Icon Component ;; --- Icon Component
@ -23,7 +23,7 @@
(when-not (:blocked shape) (when-not (:blocked shape)
(cond (cond
(or drawing? (or drawing?
(and group (:locked (ush/resolve-parent shape)))) (and group (:locked (geom/resolve-parent shape))))
nil nil
(and (not selected?) (empty? selected)) (and (not selected?) (empty? selected))
@ -50,7 +50,7 @@
(defn on-mouse-up (defn on-mouse-up
[event {:keys [id group] :as shape}] [event {:keys [id group] :as shape}]
(cond (cond
(and group (:locked (ush/resolve-parent shape))) (and group (:locked (geom/resolve-parent shape)))
nil nil
:else :else
@ -87,7 +87,7 @@
(on-mouse-up [vid event] (on-mouse-up [vid event]
(dom/stop-propagation event) (dom/stop-propagation event)
(uuc/release-action! "ui.shape.resize"))] (uuc/release-action! "ui.shape.resize"))]
(let [{:keys [x y width height]} (ush/outer-rect' shape)] (let [{:keys [x y width height]} (geom/outer-rect shape)]
(html (html
[:g.controls [:g.controls
[:rect {:x x :y y :width width :height height :stroke-dasharray "5,5" [:rect {:x x :y y :width width :height height :stroke-dasharray "5,5"
@ -129,7 +129,7 @@
(defmethod uusc/render-shape :builtin/icon (defmethod uusc/render-shape :builtin/icon
[{:keys [data id] :as shape} _] [{:keys [data id] :as shape} _]
(let [key (str id) (let [key (str id)
rfm (ush/transformation shape) rfm (geom/transformation-matrix shape)
attrs (merge {:id key :key key :transform (str rfm)} attrs (merge {:id key :key key :transform (str rfm)}
(uusc/extract-style-attrs shape) (uusc/extract-style-attrs shape)
(uusc/make-debug-attrs shape))] (uusc/make-debug-attrs shape))]

View file

@ -5,7 +5,6 @@
[lentes.core :as l] [lentes.core :as l]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as ush]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.keyboard :as kbd] [uxbox.ui.keyboard :as kbd]

View file

@ -5,18 +5,18 @@
[lentes.core :as l] [lentes.core :as l]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as ush]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.keyboard :as kbd] [uxbox.ui.keyboard :as kbd]
[uxbox.ui.shapes.core :as uusc] [uxbox.ui.shapes.core :as uusc]
[uxbox.util.geom :as geom]
[uxbox.util.dom :as dom])) [uxbox.util.dom :as dom]))
(defmethod uusc/render-shape :builtin/rect (defmethod uusc/render-shape :builtin/rect
[{:keys [id x1 y1 x2 y2] :as shape}] [{:keys [id x1 y1 x2 y2] :as shape}]
(let [key (str id) (let [key (str id)
rfm (ush/transformation shape) rfm (geom/transformation-matrix shape)
size (ush/size shape) size (geom/size shape)
props {:x x1 :y y1 :id key :key key :transform (str rfm)} props {:x x1 :y y1 :id key :key key :transform (str rfm)}
attrs (-> (uusc/extract-style-attrs shape) attrs (-> (uusc/extract-style-attrs shape)
(merge props size))] (merge props size))]

View file

@ -6,7 +6,6 @@
[goog.events :as events] [goog.events :as events]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as ush]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
@ -14,6 +13,7 @@
[uxbox.ui.keyboard :as kbd] [uxbox.ui.keyboard :as kbd]
[uxbox.ui.shapes.core :as uusc] [uxbox.ui.shapes.core :as uusc]
[uxbox.ui.shapes.icon :as uusi] [uxbox.ui.shapes.icon :as uusi]
[uxbox.util.geom :as geom]
[uxbox.util.color :as color] [uxbox.util.color :as color]
[uxbox.util.dom :as dom]) [uxbox.util.dom :as dom])
(:import goog.events.EventType)) (:import goog.events.EventType))
@ -27,7 +27,7 @@
(cond (cond
(or drawing? (or drawing?
(:edition @local) (:edition @local)
(and group (:locked (ush/resolve-parent shape)))) (and group (:locked (geom/resolve-parent shape))))
nil nil
(and (not selected?) (empty? selected)) (and (not selected?) (empty? selected))
@ -52,7 +52,7 @@
(defn on-mouse-up (defn on-mouse-up
[event {:keys [id group] :as shape}] [event {:keys [id group] :as shape}]
(cond (cond
(and group (:locked (ush/resolve-parent shape))) (and group (:locked (geom/resolve-parent shape)))
nil nil
:else :else
@ -167,8 +167,8 @@
(defmethod uusc/render-shape :builtin/text (defmethod uusc/render-shape :builtin/text
[{:keys [id x1 y1 x2 y2 content drawing? editing?] :as shape}] [{:keys [id x1 y1 x2 y2 content drawing? editing?] :as shape}]
(let [key (str id) (let [key (str id)
rfm (ush/transformation shape) rfm (geom/transformation-matrix shape)
size (ush/size shape) size (geom/size shape)
props {:x x1 :y y1 props {:x x1 :y y1
:transform (str rfm)} :transform (str rfm)}
attrs (merge props size) attrs (merge props size)

View file

@ -9,7 +9,6 @@
(:require [beicon.core :as rx] (:require [beicon.core :as rx]
[lentes.core :as l] [lentes.core :as l]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as sh]
[uxbox.data.core :refer (worker)] [uxbox.data.core :refer (worker)]
[uxbox.ui.workspace.base :as wb] [uxbox.ui.workspace.base :as wb]
[uxbox.util.geom.point :as gpt] [uxbox.util.geom.point :as gpt]

View file

@ -28,7 +28,7 @@
(letfn [(getter [state] (letfn [(getter [state]
(let [project (get-in state [:workspace :project])] (let [project (get-in state [:workspace :project])]
(get-in state [:projects-by-id project])))] (get-in state [:projects-by-id project])))]
(as-> (ul/getter getter) $ (as-> (l/getter getter) $
(l/focus-atom $ st/state)))) (l/focus-atom $ st/state))))
(def ^:const page-l (def ^:const page-l

View file

@ -13,7 +13,6 @@
[goog.events :as events] [goog.events :as events]
[uxbox.constants :as c] [uxbox.constants :as c]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.shapes :as sh]
[uxbox.data.projects :as dp] [uxbox.data.projects :as dp]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]

View file

@ -6,13 +6,11 @@
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com> ;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
(ns uxbox.ui.workspace.drawarea (ns uxbox.ui.workspace.drawarea
(:require-macros [uxbox.util.syntax :refer [define-once]])
(:require [sablono.core :as html :refer-macros [html]] (:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum] [rum.core :as rum]
[beicon.core :as rx] [beicon.core :as rx]
[lentes.core :as l] [lentes.core :as l]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.shapes :as ush]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.data.workspace :as udw] [uxbox.data.workspace :as udw]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
@ -20,6 +18,7 @@
[uxbox.ui.shapes.core :as uusc] [uxbox.ui.shapes.core :as uusc]
[uxbox.ui.workspace.base :as wb] [uxbox.ui.workspace.base :as wb]
[uxbox.ui.mixins :as mx] [uxbox.ui.mixins :as mx]
[uxbox.util.geom :as geom]
[uxbox.util.geom.point :as gpt] [uxbox.util.geom.point :as gpt]
[uxbox.util.dom :as dom])) [uxbox.util.dom :as dom]))
@ -38,7 +37,7 @@
position (rum/react drawing-position)] position (rum/react drawing-position)]
(when shape (when shape
(-> (assoc shape :drawing? true) (-> (assoc shape :drawing? true)
(ush/resize position) (geom/resize position)
(uusc/render-shape identity))))) (uusc/render-shape identity)))))
(defn- draw-area-will-mount (defn- draw-area-will-mount
@ -88,7 +87,7 @@
[shape] [shape]
(let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-l) (let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-l)
props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)} props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)}
shape (ush/initialize shape props)] shape (geom/setup shape props)]
(rs/emit! (uds/add-shape shape) (rs/emit! (uds/add-shape shape)
(udw/select-for-drawing nil) (udw/select-for-drawing nil)
(uds/select-first-shape)))) (uds/select-first-shape))))
@ -103,7 +102,7 @@
(on-complete [] (on-complete []
(let [shape @drawing-shape (let [shape @drawing-shape
shpos @drawing-position shpos @drawing-position
shape (ush/resize shape shpos)] shape (geom/resize shape shpos)]
(rs/emit! (uds/add-shape shape) (rs/emit! (uds/add-shape shape)
(udw/select-for-drawing nil) (udw/select-for-drawing nil)
(uds/select-first-shape)) (uds/select-first-shape))
@ -111,7 +110,7 @@
(reset! drawing-shape nil)))] (reset! drawing-shape nil)))]
(let [{:keys [x y] :as pt} (gpt/divide @wb/mouse-canvas-a @wb/zoom-l) (let [{:keys [x y] :as pt} (gpt/divide @wb/mouse-canvas-a @wb/zoom-l)
shape (ush/initialize shape {:x1 x :y1 y :x2 x :y2 y}) shape (geom/setup shape {:x1 x :y1 y :x2 x :y2 y})
stoper (->> uuc/actions-s stoper (->> uuc/actions-s
(rx/map :type) (rx/map :type)
(rx/filter #(empty? %)) (rx/filter #(empty? %))

View file

@ -12,11 +12,11 @@
[uxbox.constants :as c] [uxbox.constants :as c]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as sh]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.workspace.base :as wb] [uxbox.ui.workspace.base :as wb]
[uxbox.ui.workspace.align :as align] [uxbox.ui.workspace.align :as align]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
[uxbox.util.geom :as geom]
[uxbox.util.geom.point :as gpt])) [uxbox.util.geom.point :as gpt]))
(declare initialize) (declare initialize)
@ -98,7 +98,7 @@
(rx/take-until stoper $) (rx/take-until stoper $)
(rx/map #(gpt/divide % @wb/zoom-l) $) (rx/map #(gpt/divide % @wb/zoom-l) $)
(rx/scan (fn [acc delta] (rx/scan (fn [acc delta]
(let [xf (map #(sh/move % delta))] (let [xf (map #(geom/move % delta))]
(into [] xf acc))) shapes $) (into [] xf acc))) shapes $)
(rx/mapcat (fn [items] (rx/mapcat (fn [items]
(if align? (if align?

View file

@ -8,7 +8,6 @@
(ns uxbox.ui.workspace.resize (ns uxbox.ui.workspace.resize
(:require [beicon.core :as rx] (:require [beicon.core :as rx]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.shapes :as ush]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]
[uxbox.ui.workspace.base :as uuwb] [uxbox.ui.workspace.base :as uuwb]

View file

@ -11,8 +11,8 @@
[rum.core :as rum] [rum.core :as rum]
[lentes.core :as l] [lentes.core :as l]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as ush] [uxbox.ui.mixins :as mx]
[uxbox.ui.mixins :as mx])) [uxbox.util.geom :as geom]))
;; --- Lenses ;; --- Lenses
@ -29,7 +29,7 @@
[own] [own]
(let [shapes (rum/react selected-shapes-l)] (let [shapes (rum/react selected-shapes-l)]
(when (> (count shapes) 1) (when (> (count shapes) 1)
(let [{:keys [width height x y]} (ush/outer-rect shapes)] (let [{:keys [width height x y]} (geom/outer-rect-coll shapes)]
(html (html
[:g.controls [:g.controls
[:rect {:x x :y y :width width :height height [:rect {:x x :y y :width width :height height

View file

@ -12,7 +12,6 @@
[beicon.core :as rx] [beicon.core :as rx]
[uxbox.constants :as c] [uxbox.constants :as c]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.shapes :as sh]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
[uxbox.ui.core :as uuc] [uxbox.ui.core :as uuc]

View file

@ -13,7 +13,6 @@
[uxbox.router :as r] [uxbox.router :as r]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as shapes]
[uxbox.library :as library] [uxbox.library :as library]
[uxbox.util.data :refer (read-string)] [uxbox.util.data :refer (read-string)]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]

View file

@ -13,7 +13,6 @@
[uxbox.router :as r] [uxbox.router :as r]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as shapes]
[uxbox.library :as library] [uxbox.library :as library]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.data.pages :as udp] [uxbox.data.pages :as udp]

View file

@ -13,7 +13,6 @@
[uxbox.router :as r] [uxbox.router :as r]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.shapes :as sh]
[uxbox.library :as library] [uxbox.library :as library]
[uxbox.data.workspace :as udw] [uxbox.data.workspace :as udw]
[uxbox.data.shapes :as uds] [uxbox.data.shapes :as uds]
@ -23,6 +22,7 @@
[uxbox.ui.colorpicker :refer (colorpicker)] [uxbox.ui.colorpicker :refer (colorpicker)]
[uxbox.ui.workspace.recent-colors :refer (recent-colors)] [uxbox.ui.workspace.recent-colors :refer (recent-colors)]
[uxbox.ui.workspace.base :as wb] [uxbox.ui.workspace.base :as wb]
[uxbox.util.geom :as geom]
[uxbox.util.lens :as ul] [uxbox.util.lens :as ul]
[uxbox.util.dom :as dom] [uxbox.util.dom :as dom]
[uxbox.util.data :refer (parse-int parse-float read-string)])) [uxbox.util.data :refer (parse-int parse-float read-string)]))
@ -216,7 +216,7 @@
sid (:id shape) sid (:id shape)
props {attr value}] props {attr value}]
(rs/emit! (uds/update-radius-attrs sid props))))] (rs/emit! (uds/update-radius-attrs sid props))))]
(let [size (sh/size shape)] (let [size (geom/size shape)]
(html (html
[:div.element-set {:key (str (:id menu))} [:div.element-set {:key (str (:id menu))}
[:div.element-set-title (:name menu)] [:div.element-set-title (:name menu)]
@ -308,7 +308,7 @@
sid (:id shape) sid (:id shape)
props {attr value}] props {attr value}]
(rs/emit! (uds/update-position sid props))))] (rs/emit! (uds/update-position sid props))))]
(let [size (sh/size shape)] (let [size (geom/size shape)]
(html (html
[:div.element-set {:key (str (:id menu))} [:div.element-set {:key (str (:id menu))}
[:div.element-set-title (:name menu)] [:div.element-set-title (:name menu)]

View file

@ -15,7 +15,6 @@
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.state.project :as stpr] [uxbox.state.project :as stpr]
[uxbox.shapes :as shapes]
[uxbox.library :as library] [uxbox.library :as library]
[uxbox.data.projects :as dp] [uxbox.data.projects :as dp]
[uxbox.data.pages :as udp] [uxbox.data.pages :as udp]