0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

Show proper tooltip when ruler tool is selected.

This commit is contained in:
Andrey Antukh 2017-03-02 17:46:37 +01:00
parent d54f70f1d7
commit 34e476a4db
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
2 changed files with 32 additions and 22 deletions

View file

@ -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?)

View file

@ -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