From 77ec0e86d2a2f00ea853432eead12b777e8d8bda Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 26 Jan 2016 22:27:05 +0200 Subject: [PATCH] Move selrect and selection components under own namespace. --- src/uxbox/ui/workspace/canvas.cljs | 7 ++-- .../{selrect.cljs => canvas/selection.cljs} | 36 +++---------------- src/uxbox/ui/workspace/canvas/selrect.cljs | 33 +++++++++++++++++ 3 files changed, 42 insertions(+), 34 deletions(-) rename src/uxbox/ui/workspace/{selrect.cljs => canvas/selection.cljs} (58%) create mode 100644 src/uxbox/ui/workspace/canvas/selrect.cljs diff --git a/src/uxbox/ui/workspace/canvas.cljs b/src/uxbox/ui/workspace/canvas.cljs index dae243c2b..54a722f40 100644 --- a/src/uxbox/ui/workspace/canvas.cljs +++ b/src/uxbox/ui/workspace/canvas.cljs @@ -16,7 +16,8 @@ [uxbox.ui.mixins :as mx] [uxbox.ui.dom :as dom] [uxbox.ui.workspace.base :as wb] - [uxbox.ui.workspace.selrect :refer (mouse-selrect shapes-selrect)] + [uxbox.ui.workspace.canvas.selection :refer (shapes-selection)] + [uxbox.ui.workspace.canvas.selrect :refer (selrect)] [uxbox.ui.workspace.grid :refer (grid)] [uxbox.ui.workspace.options :refer (element-opts)]) (:import goog.events.EventType)) @@ -158,12 +159,12 @@ (background) (grid 1) [:svg.page-layout {} - (shapes-selrect shapes-selected) + (shapes-selection shapes-selected) [:g.main {} (for [item (sequence xf (:shapes page))] (-> (shape item workspace-selected) (rum/with-key (str (:id item))))) - (mouse-selrect)]]]))) + (selrect)]]]))) (def canvas (mx/component diff --git a/src/uxbox/ui/workspace/selrect.cljs b/src/uxbox/ui/workspace/canvas/selection.cljs similarity index 58% rename from src/uxbox/ui/workspace/selrect.cljs rename to src/uxbox/ui/workspace/canvas/selection.cljs index c56b09154..9abd453f2 100644 --- a/src/uxbox/ui/workspace/selrect.cljs +++ b/src/uxbox/ui/workspace/canvas/selection.cljs @@ -1,5 +1,4 @@ -(ns uxbox.ui.workspace.selrect - "Components for indicate the user selection and selected shapes group." +(ns uxbox.ui.workspace.canvas.selection (:require [sablono.core :as html :refer-macros [html]] [rum.core :as rum] [beicon.core :as rx] @@ -11,31 +10,6 @@ [uxbox.ui.mixins :as mx] [uxbox.ui.dom :as dom])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Mouse Selection Rect -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defn mouse-selrect-render - [own] - (when-let [data (rum/react wb/selrect-pos)] - (let [{:keys [x y width height]} (wb/selrect->rect data)] - (html - [:rect.selection-rect - {:x x - :y y - :width width - :height height}])))) - -(def ^:static mouse-selrect - (mx/component - {:render mouse-selrect-render - :name "mouse-selrect" - :mixins [mx/static rum/reactive]})) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Shapes Selection Rect -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (def ^:private selection-circle-style {:fillOpacity "0.5" :strokeWidth "1px" @@ -46,7 +20,7 @@ :fill "#333" :stroke "#333"}) -(defn shapes-selrect-render +(defn shapes-selection-render [own shapes] (when (seq shapes) (let [{:keys [width height x y]} (sh/outer-rect shapes)] @@ -64,8 +38,8 @@ [:circle.bottom-right (merge default-selection-props {:cx (+ x width) :cy (+ y height)})]])))) -(def ^:static shapes-selrect +(def ^:static shapes-selection (mx/component - {:render shapes-selrect-render - :name "shapes-selrect" + {:render shapes-selection-render + :name "shapes-selection" :mixins [mx/static]})) diff --git a/src/uxbox/ui/workspace/canvas/selrect.cljs b/src/uxbox/ui/workspace/canvas/selrect.cljs new file mode 100644 index 000000000..5943816e1 --- /dev/null +++ b/src/uxbox/ui/workspace/canvas/selrect.cljs @@ -0,0 +1,33 @@ +(ns uxbox.ui.workspace.canvas.selrect + "Components for indicate the user selection and selected shapes group." + (:require [sablono.core :as html :refer-macros [html]] + [rum.core :as rum] + [beicon.core :as rx] + [cats.labs.lens :as l] + [uxbox.rstore :as rs] + [uxbox.state :as st] + [uxbox.shapes :as sh] + [uxbox.ui.workspace.base :as wb] + [uxbox.ui.mixins :as mx] + [uxbox.ui.dom :as dom])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Component +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn selrect-render + [own] + (when-let [data (rum/react wb/selrect-pos)] + (let [{:keys [x y width height]} (wb/selrect->rect data)] + (html + [:rect.selection-rect + {:x x + :y y + :width width + :height height}])))) + +(def ^:static selrect + (mx/component + {:render selrect-render + :name "selrect" + :mixins [mx/static rum/reactive]}))