0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-15 11:38:24 -05:00

Make coords indicator on workspace header aware of zoom.

This commit is contained in:
Andrey Antukh 2016-04-10 19:44:30 +03:00
parent 574d78871a
commit 55dfbd73e5
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
3 changed files with 16 additions and 12 deletions

View file

@ -156,7 +156,7 @@
height: 30px; height: 30px;
margin: 0 $small; margin: 0 $small;
position: relative; position: relative;
width: 50px; width: 60px;
&.zoom-input { &.zoom-input {
width: 85px; width: 85px;

View file

@ -21,6 +21,7 @@
[uxbox.ui.navigation :as nav] [uxbox.ui.navigation :as nav]
[uxbox.ui.mixins :as mx] [uxbox.ui.mixins :as mx]
[uxbox.ui.lightbox :as lightbox] [uxbox.ui.lightbox :as lightbox]
[uxbox.util.geom.point :as gpt]
[uxbox.util.math :as mth])) [uxbox.util.math :as mth]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -29,11 +30,16 @@
(defn- coordenates-render (defn- coordenates-render
[own] [own]
(when-let [{:keys [x y]} (rum/react wb/mouse-canvas-a)] (let [zoom (rum/react wb/zoom-l)
coords (some-> (rum/react wb/mouse-canvas-a)
(gpt/divide zoom)
(gpt/round 1))]
(html (html
[:ul.options-view [:ul.options-view
[:li.coordinates {:alt "x"} "X: " x] [:li.coordinates {:alt "x"}
[:li.coordinates {:alt "y"} "Y: " y] (str "X: " (:x coords "-"))]
[:li.coordinates {:alt "y"}
(str "Y: " (:y coords "-"))]
[:li.zoom-input [:li.zoom-input
[:span.add-zoom "+"] [:span.add-zoom "+"]
[:span "100%"] [:span "100%"]

View file

@ -6,6 +6,7 @@
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com> ;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
(ns uxbox.util.geom.point (ns uxbox.util.geom.point
(:refer-clojure :exclude [divide])
(:require [uxbox.util.math :as mth])) (:require [uxbox.util.math :as mth]))
(defrecord Point [x y]) (defrecord Point [x y])
@ -152,11 +153,8 @@
(if (>= y 0) 1 4) (if (>= y 0) 1 4)
(if (>= y 0) 2 3))) (if (>= y 0) 2 3)))
(defn transform-point (defn round
[pt mx] "Change the precision of the point coordinates."
(Point. (+ (* (:x pt) (:a mx)) [{:keys [x y]} decimanls]
(* (:y pt) (:c mx)) (Point. (mth/precision x decimanls)
(:tx mx)) (mth/precision y decimanls)))
(+ (* (:x pt) (:b mx))
(* (:y pt) (:d mx))
(:ty mx))))