From 3d18f2d95e1b5249b7916efbde656a3cd47ec436 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 24 Aug 2016 16:43:45 +0300 Subject: [PATCH] Remove line draw tool and line shape support. The path support is superset of line and it just replaces the line functionality. --- src/uxbox/main/geom.cljs | 15 ------ src/uxbox/main/ui/shapes/group.cljs | 2 - src/uxbox/main/ui/shapes/line.cljs | 52 ------------------- src/uxbox/main/ui/workspace/shortcuts.cljs | 1 - .../main/ui/workspace/sidebar/drawtools.cljs | 10 ---- src/uxbox/view/ui/viewer/shapes.cljs | 2 - 6 files changed, 82 deletions(-) delete mode 100644 src/uxbox/main/ui/shapes/line.cljs diff --git a/src/uxbox/main/geom.cljs b/src/uxbox/main/geom.cljs index 9ae97525f..fc3932ea7 100644 --- a/src/uxbox/main/geom.cljs +++ b/src/uxbox/main/geom.cljs @@ -17,7 +17,6 @@ (derive ::rect ::shape) (derive :icon ::rect) (derive :rect ::rect) - (derive :line ::shape) (derive :circle ::shape) (derive :text ::rect) (derive :group ::rect))) @@ -41,7 +40,6 @@ :icon (move-rect shape dpoint) :rect (move-rect shape dpoint) :text (move-rect shape dpoint) - :line (move-rect shape dpoint) :path (move-path shape dpoint) ;; :path (move-rect shape dpoint) :circle (move-circle shape dpoint) @@ -95,7 +93,6 @@ (case (:type shape) :icon (absolute-move-rect shape point) :rect (absolute-move-rect shape point) - :line (absolute-move-rect shape point) :circle (absolute-move-circle shape point) :group (absolute-move-group shape point))) @@ -142,7 +139,6 @@ :text (rect-size shape) :rect (rect-size shape) :icon (rect-size shape) - :line (rect-size shape) :path (rect-size shape))) (defn- rect-size @@ -258,7 +254,6 @@ ;; --- Resize (Absolute) (declare resize-rect) -(declare resize-line) (declare resize-circle) (declare normalize-shape) (declare equalize-sides) @@ -271,7 +266,6 @@ :rect (resize-rect shape point) :icon (resize-rect shape point) :text (resize-rect shape point) - :line (resize-line shape point) :path (resize-rect shape point) :circle (resize-circle shape point))) @@ -298,12 +292,6 @@ (assoc shape :rx rx :ry rx) (assoc shape :rx rx :ry ry)))) -(defn- resize-line - "A specialized function for absolute resize - for line shapes." - [shape {:keys [x y] :as pos}] - (assoc shape :x2 x :y2 y)) - (defn- normalize-shape "Normalize shape coordinates." [shape] @@ -346,7 +334,6 @@ (case (:type shape) :rect (setup-rect shape props) :icon (setup-rect shape props) - :line (setup-rect shape props) :text (setup-rect shape props) :circle (setup-circle shape props) :group (setup-group shape props))) @@ -389,7 +376,6 @@ :icon (generic-inner-rect state shape) :rect (generic-inner-rect state shape) :text (generic-inner-rect shape shape) - :line (generic-inner-rect state shape) :path (path-inner-rect state shape) :circle (circle-inner-rect state shape) :group (group-inner-rect state shape)))) @@ -455,7 +441,6 @@ :rect (generic-outer-rect state shape) :text (generic-outer-rect state shape) :icon (generic-outer-rect state shape) - :line (generic-outer-rect state shape) ;; :path (generic-outer-rect state shape) :path (path-outer-rect state shape) :circle (circle-outer-rect state shape) diff --git a/src/uxbox/main/ui/shapes/group.cljs b/src/uxbox/main/ui/shapes/group.cljs index 9666c31fd..3ac60c096 100644 --- a/src/uxbox/main/ui/shapes/group.cljs +++ b/src/uxbox/main/ui/shapes/group.cljs @@ -16,7 +16,6 @@ [uxbox.main.ui.shapes.rect :as rect] [uxbox.main.ui.shapes.circle :as circle] [uxbox.main.ui.shapes.text :as text] - [uxbox.main.ui.shapes.line :as line] [uxbox.main.ui.shapes.path :as path] [uxbox.main.geom :as geom])) @@ -30,7 +29,6 @@ (case type :group (group-component shape) :text (text/text-component shape) - :line (line/line-component shape) :icon (icon/icon-component shape) :rect (rect/rect-component shape) :path (path/path-component shape) diff --git a/src/uxbox/main/ui/shapes/line.cljs b/src/uxbox/main/ui/shapes/line.cljs deleted file mode 100644 index 29b8e3caf..000000000 --- a/src/uxbox/main/ui/shapes/line.cljs +++ /dev/null @@ -1,52 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) 2016 Andrey Antukh - -(ns uxbox.main.ui.shapes.line - (:require [sablono.core :refer-macros [html]] - [rum.core :as rum] - [uxbox.util.mixins :as mx] - [uxbox.main.ui.shapes.common :as common] - [uxbox.main.ui.shapes.attrs :as attrs] - [uxbox.main.geom :as geom])) - -;; --- Line Component - -(declare line-shape) - -(defn- line-component-render - [own shape] - (let [{:keys [id x y width height group]} shape - selected (mx/react common/selected-ref) - selected? (contains? selected id) - on-mouse-down #(common/on-mouse-down % shape selected)] - (html - [:g.shape {:class (when selected? "selected") - :on-mouse-down on-mouse-down} - (line-shape shape identity)]))) - -(def line-component - (mx/component - {:render line-component-render - :name "line-component" - :mixins [mx/static mx/reactive]})) - -;; --- Line Shape - -(defn- line-shape-render - [own {:keys [id x1 y1 x2 y2] :as shape}] - (let [key (str "shape-" id) - props (select-keys shape [:x1 :x2 :y2 :y1]) - attrs (-> (attrs/extract-style-attrs shape) - (merge {:id key :key key}) - (merge props))] - (html - [:line attrs]))) - -(def line-shape - (mx/component - {:render line-shape-render - :name "line-shape" - :mixins [mx/static]})) diff --git a/src/uxbox/main/ui/workspace/shortcuts.cljs b/src/uxbox/main/ui/workspace/shortcuts.cljs index eadf4a918..2a4e386a2 100644 --- a/src/uxbox/main/ui/workspace/shortcuts.cljs +++ b/src/uxbox/main/ui/workspace/shortcuts.cljs @@ -42,7 +42,6 @@ :ctrl+shift+z #(rs/emit! (udu/redo)) :ctrl+b #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-rect+)) :ctrl+e #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-circle+)) - :ctrl+l #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-line+)) :ctrl+t #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-text+)) :esc #(rs/emit! (uds/deselect-all)) :backspace #(rs/emit! (uds/delete-selected)) diff --git a/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs b/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs index 3d50884fd..1d02eeb7e 100644 --- a/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs +++ b/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs @@ -41,12 +41,6 @@ {:type :circle :name "Circle"}) -(def +draw-tool-line+ - {:type :line - :name "Line" - :stroke-type :solid - :stroke "#000000"}) - (def +draw-tool-path+ {:type :path :name "Path" @@ -72,10 +66,6 @@ :help (tr "ds.help.circle") :shape +draw-tool-circle+ :priority 2} - {:icon i/line - :help (tr "ds.help.line") - :shape +draw-tool-line+ - :priority 3} {:icon i/text :help (tr "ds.help.text") :shape +draw-tool-text+ diff --git a/src/uxbox/view/ui/viewer/shapes.cljs b/src/uxbox/view/ui/viewer/shapes.cljs index 21f02bfd2..d8c3cfbb6 100644 --- a/src/uxbox/view/ui/viewer/shapes.cljs +++ b/src/uxbox/view/ui/viewer/shapes.cljs @@ -14,7 +14,6 @@ [uxbox.main.ui.shapes.icon :refer (icon-shape)] [uxbox.main.ui.shapes.text :refer (text-shape)] [uxbox.main.ui.shapes.group :refer (group-shape)] - [uxbox.main.ui.shapes.line :refer (line-shape)] [uxbox.main.ui.shapes.path :refer (path-shape)] [uxbox.main.ui.shapes.circle :refer (circle-shape)] [uxbox.view.ui.viewer.interactions :as itx]) @@ -65,7 +64,6 @@ (case type :group (group-shape shape #(interactions-wrapper % shape*)) :text (text-shape shape) - :line (line-shape shape) :icon (icon-shape shape) :rect (rect-shape shape) :path (path-shape shape)