diff --git a/src/uxbox/shapes.cljs b/src/uxbox/shapes.cljs index 4d4cd8f946..2e04e806f0 100644 --- a/src/uxbox/shapes.cljs +++ b/src/uxbox/shapes.cljs @@ -104,6 +104,13 @@ (assoc shape :x2 x2 :y2 y2)) +(defmethod -resize :builtin/rect + [shape [x2 y2]] + (let [{:keys [x y]} shape] + (assoc shape + :width (- x2 x) + :height (- y2 y)))) + (defmethod -resize :default [shape _] (throw (ex-info "Not implemented" (select-keys shape [:type])))) diff --git a/src/uxbox/ui/shapes.cljs b/src/uxbox/ui/shapes.cljs index 0dd4adf000..42edcdf03f 100644 --- a/src/uxbox/ui/shapes.cljs +++ b/src/uxbox/ui/shapes.cljs @@ -68,6 +68,17 @@ (html [:line attrs]))) + +(defmethod sh/-render :builtin/rect + [{:keys [id x1 y1 x2 y2] :as shape}] + (let [key (str id) + props (select-keys shape [:x :y :width :height]) + attrs (-> (extract-style-attrs shape) + (merge {:id key :key key}) + (merge props))] + (html + [:rect attrs]))) + ;; FIXME: the impl should be more clear. (defmethod sh/-render :builtin/group diff --git a/src/uxbox/ui/workspace/canvas/draw.cljs b/src/uxbox/ui/workspace/canvas/draw.cljs index 5cfc2d9987..f5bbdaf40a 100644 --- a/src/uxbox/ui/workspace/canvas/draw.cljs +++ b/src/uxbox/ui/workspace/canvas/draw.cljs @@ -78,6 +78,7 @@ (when-let [shape (:drawing @wb/workspace-l)] (case (:type shape) :builtin/icon (init-icon shape) + :builtin/rect (init-shape shape) :builtin/line (init-shape shape))))] (as-> wb/interactions-b $ diff --git a/src/uxbox/ui/workspace/options.cljs b/src/uxbox/ui/workspace/options.cljs index 8a9549f9ff..396a9299d3 100644 --- a/src/uxbox/ui/workspace/options.cljs +++ b/src/uxbox/ui/workspace/options.cljs @@ -16,6 +16,7 @@ (def +menus-map+ {:builtin/icon [:menu/icon-measures :menu/fill :menu/stroke] :builtin/line [:menu/stroke] + :builtin/rect [:menu/icon-measures :menu/stroke :menu/fill] :builtin/group []}) (def +menus-by-id+