mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
Show proper tooltip when ruler tool is selected.
This commit is contained in:
parent
d54f70f1d7
commit
34e476a4db
2 changed files with 32 additions and 22 deletions
|
@ -102,12 +102,27 @@
|
||||||
[project page]
|
[project page]
|
||||||
(InitializeWorkspace. 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
|
;; --- Workspace Flags
|
||||||
|
|
||||||
(deftype ActivateFlag [flag]
|
(deftype ActivateFlag [flag]
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(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
|
(defn activate-flag
|
||||||
[flag]
|
[flag]
|
||||||
|
@ -117,7 +132,11 @@
|
||||||
(deftype DeactivateFlag [flag]
|
(deftype DeactivateFlag [flag]
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(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
|
(defn deactivate-flag
|
||||||
[flag]
|
[flag]
|
||||||
|
@ -255,17 +274,6 @@
|
||||||
[]
|
[]
|
||||||
(ResetZoom.))
|
(ResetZoom.))
|
||||||
|
|
||||||
;; --- Tooltips
|
|
||||||
|
|
||||||
(defrecord SetTooltip [text]
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(assoc-in state [:workspace :tooltip] text)))
|
|
||||||
|
|
||||||
(defn set-tooltip
|
|
||||||
[text]
|
|
||||||
(SetTooltip. text))
|
|
||||||
|
|
||||||
;; --- Grid Alignment
|
;; --- Grid Alignment
|
||||||
|
|
||||||
(declare initialize-alignment?)
|
(declare initialize-alignment?)
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.refs :as refs]
|
[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.main.user-events :as uev]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
|
@ -91,20 +92,21 @@
|
||||||
|
|
||||||
;; --- Draw Toolbox (Component)
|
;; --- Draw Toolbox (Component)
|
||||||
|
|
||||||
(defn- select-for-draw
|
|
||||||
[shape]
|
|
||||||
(st/emit! ::uev/interrupt
|
|
||||||
(dw/select-for-drawing shape)))
|
|
||||||
|
|
||||||
(mx/defc draw-toolbox
|
(mx/defc draw-toolbox
|
||||||
{:mixins [mx/static mx/reactive]}
|
{:mixins [mx/static mx/reactive]}
|
||||||
[]
|
[]
|
||||||
(let [drawing-tool (mx/react refs/selected-drawing-tool)
|
(let [drawing-tool (mx/react refs/selected-drawing-tool)
|
||||||
flags (mx/react refs/flags)
|
flags (mx/react refs/flags)
|
||||||
close #(st/emit! (dw/toggle-flag :drawtools))
|
close #(st/emit! (udw/toggle-flag :drawtools))
|
||||||
tools (->> (into [] +draw-tools+)
|
tools (->> (into [] +draw-tools+)
|
||||||
(sort-by (comp :priority second)))
|
(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#form-tools.tool-window.drawing-tools
|
||||||
[:div.tool-window-bar
|
[:div.tool-window-bar
|
||||||
|
@ -118,7 +120,7 @@
|
||||||
{:alt (:help props)
|
{:alt (:help props)
|
||||||
:class (when selected? "selected")
|
:class (when selected? "selected")
|
||||||
:key (str i)
|
:key (str i)
|
||||||
:on-click (partial select-for-draw (:shape props))}
|
:on-click (partial select-drawtool (:shape props))}
|
||||||
(:icon props)])
|
(:icon props)])
|
||||||
|
|
||||||
[:div.tool-btn.tooltip.tooltip-hover
|
[:div.tool-btn.tooltip.tooltip-hover
|
||||||
|
|
Loading…
Add table
Reference in a new issue