diff --git a/src/uxbox/shapes.cljs b/src/uxbox/shapes.cljs index 8eca6ddb4..4d4cd8f94 100644 --- a/src/uxbox/shapes.cljs +++ b/src/uxbox/shapes.cljs @@ -9,12 +9,13 @@ (def ^:static +hierarchy+ (as-> (make-hierarchy) $ - (derive $ :builtin/icon ::shape) - (derive $ :builtin/rect ::shape) + (derive $ ::rect ::shape) + (derive $ :builtin/icon ::rect) + (derive $ :builtin/rect ::rect) (derive $ :builtin/line ::shape) (derive $ :builtin/circle ::shape) (derive $ :builtin/text ::shape) - (derive $ :builtin/group ::shape))) + (derive $ :builtin/group ::rect))) (defn shape? [type] @@ -107,13 +108,7 @@ [shape _] (throw (ex-info "Not implemented" (select-keys shape [:type])))) -(defmethod -resize' :builtin/icon - [shape [width height]] - (merge shape - (when width {:width width}) - (when height {:height height}))) - -(defmethod -resize' :builtin/group +(defmethod -resize' ::rect [shape [width height]] (merge shape (when width {:width width}) @@ -125,18 +120,12 @@ ;; Move -(defmethod -move ::shape +(defmethod -move ::rect [shape {:keys [dx dy] :as opts}] (assoc shape :x (+ (:x shape) dx) :y (+ (:y shape) dy))) -(defmethod -move :builtin/group - [shape {:keys [dx dy] :as opts}] - (assoc shape - :dx (+ (:dx shape 0) dx) - :dy (+ (:dy shape 0) dy))) - (defmethod -move :builtin/line [shape {:keys [dx dy] :as opts}] (assoc shape @@ -145,6 +134,10 @@ :x2 (+ (:x2 shape) dx) :y2 (+ (:y2 shape) dy))) +(defmethod -move :default + [shape _] + (throw (ex-info "Not implemented" (select-keys shape [:type])))) + (defmethod -rotate ::shape [shape rotation] (assoc shape :rotation rotation)) @@ -184,6 +177,10 @@ (merge $ {:width width :height height :x x :y y}) (container-rect $)))) +(defmethod -outer-rect :default + [shape _] + (throw (ex-info "Not implemented" (select-keys shape [:type])))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;