diff --git a/frontend/src/uxbox/main/data/workspace.cljs b/frontend/src/uxbox/main/data/workspace.cljs index 6d56b0045..d2bd006d9 100644 --- a/frontend/src/uxbox/main/data/workspace.cljs +++ b/frontend/src/uxbox/main/data/workspace.cljs @@ -102,12 +102,27 @@ [project page] (InitializeWorkspace. project page)) +;; --- Workspace Tooltips + +(defrecord SetTooltip [text] + ptk/UpdateEvent + (update [_ state] + (assoc-in state [:workspace :tooltip] text))) + +(defn set-tooltip + [text] + (SetTooltip. text)) + ;; --- Workspace Flags (deftype ActivateFlag [flag] ptk/UpdateEvent (update [_ state] - (update-in state [:workspace :flags] conj flag))) + (update-in state [:workspace :flags] conj flag)) + + ptk/WatchEvent + (watch [_ state stream] + (rx/of (set-tooltip "Drag to use the ruler")))) (defn activate-flag [flag] @@ -117,7 +132,11 @@ (deftype DeactivateFlag [flag] ptk/UpdateEvent (update [_ state] - (update-in state [:workspace :flags] disj flag))) + (update-in state [:workspace :flags] disj flag)) + + ptk/WatchEvent + (watch [_ state stream] + (rx/of (set-tooltip nil)))) (defn deactivate-flag [flag] @@ -255,17 +274,6 @@ [] (ResetZoom.)) -;; --- Tooltips - -(defrecord SetTooltip [text] - ptk/UpdateEvent - (update [_ state] - (assoc-in state [:workspace :tooltip] text))) - -(defn set-tooltip - [text] - (SetTooltip. text)) - ;; --- Grid Alignment (declare initialize-alignment?) diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs index a113d0daf..666c1f3e4 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs @@ -11,7 +11,8 @@ [potok.core :as ptk] [uxbox.main.store :as st] [uxbox.main.refs :as refs] - [uxbox.main.data.workspace :as dw] + [uxbox.main.data.shapes :as uds] + [uxbox.main.data.workspace :as udw] [uxbox.main.user-events :as uev] [uxbox.builtins.icons :as i] [uxbox.util.uuid :as uuid] @@ -91,20 +92,21 @@ ;; --- Draw Toolbox (Component) -(defn- select-for-draw - [shape] - (st/emit! ::uev/interrupt - (dw/select-for-drawing shape))) - (mx/defc draw-toolbox {:mixins [mx/static mx/reactive]} [] (let [drawing-tool (mx/react refs/selected-drawing-tool) flags (mx/react refs/flags) - close #(st/emit! (dw/toggle-flag :drawtools)) + close #(st/emit! (udw/toggle-flag :drawtools)) tools (->> (into [] +draw-tools+) (sort-by (comp :priority second))) - toggle-flag #(st/emit! (dw/toggle-flag %))] + + select-drawtool #(st/emit! ::uev/interrupt + (udw/deactivate-flag :ruler) + (udw/select-for-drawing %)) + toggle-flag #(st/emit! (udw/select-for-drawing nil) + (uds/deselect-all) + (udw/toggle-flag %))] [:div#form-tools.tool-window.drawing-tools [:div.tool-window-bar @@ -118,7 +120,7 @@ {:alt (:help props) :class (when selected? "selected") :key (str i) - :on-click (partial select-for-draw (:shape props))} + :on-click (partial select-drawtool (:shape props))} (:icon props)]) [:div.tool-btn.tooltip.tooltip-hover