0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 10:41:29 -05:00

Minor fix on ruler tool impl.

Many bugs introduced in previous related commits.
This commit is contained in:
Andrey Antukh 2017-03-03 13:12:14 +01:00
parent 993657a1cc
commit df14f7e364
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
4 changed files with 50 additions and 23 deletions

View file

@ -118,11 +118,7 @@
(deftype ActivateFlag [flag]
ptk/UpdateEvent
(update [_ state]
(update-in state [:workspace :flags] conj flag))
ptk/WatchEvent
(watch [_ state stream]
(rx/of (set-tooltip "Drag to use the ruler"))))
(update-in state [:workspace :flags] conj flag)))
(defn activate-flag
[flag]
@ -132,11 +128,7 @@
(deftype DeactivateFlag [flag]
ptk/UpdateEvent
(update [_ state]
(update-in state [:workspace :flags] disj flag))
ptk/WatchEvent
(watch [_ state stream]
(rx/of (set-tooltip nil))))
(update-in state [:workspace :flags] disj flag)))
(defn deactivate-flag
[flag]
@ -155,6 +147,40 @@
[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
(deftype SelectIconsToolboxCollection [id]

View file

@ -93,12 +93,12 @@
{:mixins [mx/reactive mx/static]}
[tooltip]
(let [coords (mx/react refs/window-mouse-position)]
[:span.cursor-tooltip
{:style
{:position "fixed"
:left (str (+ (:x coords) 5) "px")
:top (str (- (:y coords) 25) "px")}}
tooltip]))
[:span.cursor-tooltip
{:style
{:position "fixed"
:left (str (+ (:x coords) 5) "px")
:top (str (- (:y coords) 25) "px")}}
tooltip]))
;; --- Canvas

View file

@ -8,17 +8,18 @@
(ns uxbox.main.ui.workspace.header
(:require [beicon.core :as rx]
[uxbox.config :as cfg]
[uxbox.util.router :as r]
[potok.core :as ptk]
[uxbox.builtins.icons :as i]
[uxbox.main.store :as st]
[uxbox.main.refs :as refs]
[uxbox.main.data.workspace :as dw]
[uxbox.main.data.history :as udh]
[uxbox.main.data.undo :as udu]
[uxbox.main.data.lightbox :as udl]
[uxbox.main.ui.workspace.clipboard]
[uxbox.builtins.icons :as i]
[uxbox.main.ui.users :as ui.u]
[uxbox.main.ui.navigation :as nav]
[uxbox.util.router :as r]
[uxbox.util.mixins :as mx :include-macros true]
[uxbox.util.geom.point :as gpt]
[uxbox.util.math :as mth]))

View file

@ -102,11 +102,11 @@
(sort-by (comp :priority second)))
select-drawtool #(st/emit! ::uev/interrupt
(udw/deactivate-flag :ruler)
(udw/deactivate-ruler)
(udw/select-for-drawing %))
toggle-flag #(st/emit! (udw/select-for-drawing nil)
(uds/deselect-all)
(udw/toggle-flag %))]
toggle-ruler #(st/emit! (udw/select-for-drawing nil)
(uds/deselect-all)
(udw/toggle-ruler))]
[:div#form-tools.tool-window.drawing-tools
[:div.tool-window-bar
@ -125,7 +125,7 @@
[:div.tool-btn.tooltip.tooltip-hover
{:alt "Ruler"
:on-click (partial toggle-flag :ruler)
:on-click toggle-ruler
:class (when (contains? flags :ruler) "selected")}
i/ruler-tool]]]))