mirror of
https://github.com/penpot/penpot.git
synced 2025-06-14 06:41:39 +02:00
Minor fix on ruler tool impl.
Many bugs introduced in previous related commits.
This commit is contained in:
parent
993657a1cc
commit
df14f7e364
4 changed files with 50 additions and 23 deletions
|
@ -118,11 +118,7 @@
|
||||||
(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]
|
||||||
|
@ -132,11 +128,7 @@
|
||||||
(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]
|
||||||
|
@ -155,6 +147,40 @@
|
||||||
[flag]
|
[flag]
|
||||||
(ToggleFlag. flag))
|
(ToggleFlag. flag))
|
||||||
|
|
||||||
|
;; --- Workspace Ruler
|
||||||
|
|
||||||
|
(deftype ActivateRuler []
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(rx/of (set-tooltip "Drag to use the ruler")
|
||||||
|
(activate-flag :ruler))))
|
||||||
|
|
||||||
|
(defn activate-ruler
|
||||||
|
[]
|
||||||
|
(ActivateRuler.))
|
||||||
|
|
||||||
|
(deftype DeactivateRuler []
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(rx/of (set-tooltip nil)
|
||||||
|
(deactivate-flag :ruler))))
|
||||||
|
|
||||||
|
(defn deactivate-ruler
|
||||||
|
[]
|
||||||
|
(DeactivateRuler.))
|
||||||
|
|
||||||
|
(deftype ToggleRuler []
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [flags (get-in state [:workspace :flags])]
|
||||||
|
(if (contains? flags :ruler)
|
||||||
|
(rx/of (deactivate-ruler))
|
||||||
|
(rx/of (activate-ruler))))))
|
||||||
|
|
||||||
|
(defn toggle-ruler
|
||||||
|
[]
|
||||||
|
(ToggleRuler.))
|
||||||
|
|
||||||
;; --- Icons Toolbox
|
;; --- Icons Toolbox
|
||||||
|
|
||||||
(deftype SelectIconsToolboxCollection [id]
|
(deftype SelectIconsToolboxCollection [id]
|
||||||
|
|
|
@ -93,12 +93,12 @@
|
||||||
{:mixins [mx/reactive mx/static]}
|
{:mixins [mx/reactive mx/static]}
|
||||||
[tooltip]
|
[tooltip]
|
||||||
(let [coords (mx/react refs/window-mouse-position)]
|
(let [coords (mx/react refs/window-mouse-position)]
|
||||||
[:span.cursor-tooltip
|
[:span.cursor-tooltip
|
||||||
{:style
|
{:style
|
||||||
{:position "fixed"
|
{:position "fixed"
|
||||||
:left (str (+ (:x coords) 5) "px")
|
:left (str (+ (:x coords) 5) "px")
|
||||||
:top (str (- (:y coords) 25) "px")}}
|
:top (str (- (:y coords) 25) "px")}}
|
||||||
tooltip]))
|
tooltip]))
|
||||||
|
|
||||||
;; --- Canvas
|
;; --- Canvas
|
||||||
|
|
||||||
|
|
|
@ -8,17 +8,18 @@
|
||||||
(ns uxbox.main.ui.workspace.header
|
(ns uxbox.main.ui.workspace.header
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.config :as cfg]
|
[uxbox.config :as cfg]
|
||||||
[uxbox.util.router :as r]
|
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.builtins.icons :as i]
|
||||||
[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.workspace :as dw]
|
||||||
[uxbox.main.data.history :as udh]
|
[uxbox.main.data.history :as udh]
|
||||||
|
[uxbox.main.data.undo :as udu]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.workspace.clipboard]
|
[uxbox.main.ui.workspace.clipboard]
|
||||||
[uxbox.builtins.icons :as i]
|
|
||||||
[uxbox.main.ui.users :as ui.u]
|
[uxbox.main.ui.users :as ui.u]
|
||||||
[uxbox.main.ui.navigation :as nav]
|
[uxbox.main.ui.navigation :as nav]
|
||||||
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.math :as mth]))
|
[uxbox.util.math :as mth]))
|
||||||
|
|
|
@ -102,11 +102,11 @@
|
||||||
(sort-by (comp :priority second)))
|
(sort-by (comp :priority second)))
|
||||||
|
|
||||||
select-drawtool #(st/emit! ::uev/interrupt
|
select-drawtool #(st/emit! ::uev/interrupt
|
||||||
(udw/deactivate-flag :ruler)
|
(udw/deactivate-ruler)
|
||||||
(udw/select-for-drawing %))
|
(udw/select-for-drawing %))
|
||||||
toggle-flag #(st/emit! (udw/select-for-drawing nil)
|
toggle-ruler #(st/emit! (udw/select-for-drawing nil)
|
||||||
(uds/deselect-all)
|
(uds/deselect-all)
|
||||||
(udw/toggle-flag %))]
|
(udw/toggle-ruler))]
|
||||||
|
|
||||||
[:div#form-tools.tool-window.drawing-tools
|
[:div#form-tools.tool-window.drawing-tools
|
||||||
[:div.tool-window-bar
|
[:div.tool-window-bar
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
|
|
||||||
[:div.tool-btn.tooltip.tooltip-hover
|
[:div.tool-btn.tooltip.tooltip-hover
|
||||||
{:alt "Ruler"
|
{:alt "Ruler"
|
||||||
:on-click (partial toggle-flag :ruler)
|
:on-click toggle-ruler
|
||||||
:class (when (contains? flags :ruler) "selected")}
|
:class (when (contains? flags :ruler) "selected")}
|
||||||
i/ruler-tool]]]))
|
i/ruler-tool]]]))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue