From 55dfbd73e569077200f9dac6be7e460635aebf77 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 10 Apr 2016 19:44:30 +0300 Subject: [PATCH] Make coords indicator on workspace header aware of zoom. --- resources/styles/partials/workspace-bar.scss | 2 +- src/uxbox/ui/workspace/header.cljs | 12 +++++++++--- src/uxbox/util/geom/point.cljs | 14 ++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/resources/styles/partials/workspace-bar.scss b/resources/styles/partials/workspace-bar.scss index ec41b6967..53d86ea0e 100644 --- a/resources/styles/partials/workspace-bar.scss +++ b/resources/styles/partials/workspace-bar.scss @@ -156,7 +156,7 @@ height: 30px; margin: 0 $small; position: relative; - width: 50px; + width: 60px; &.zoom-input { width: 85px; diff --git a/src/uxbox/ui/workspace/header.cljs b/src/uxbox/ui/workspace/header.cljs index 6faaa0704..002490c0f 100644 --- a/src/uxbox/ui/workspace/header.cljs +++ b/src/uxbox/ui/workspace/header.cljs @@ -21,6 +21,7 @@ [uxbox.ui.navigation :as nav] [uxbox.ui.mixins :as mx] [uxbox.ui.lightbox :as lightbox] + [uxbox.util.geom.point :as gpt] [uxbox.util.math :as mth])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -29,11 +30,16 @@ (defn- coordenates-render [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 [:ul.options-view - [:li.coordinates {:alt "x"} "X: " x] - [:li.coordinates {:alt "y"} "Y: " y] + [:li.coordinates {:alt "x"} + (str "X: " (:x coords "-"))] + [:li.coordinates {:alt "y"} + (str "Y: " (:y coords "-"))] [:li.zoom-input [:span.add-zoom "+"] [:span "100%"] diff --git a/src/uxbox/util/geom/point.cljs b/src/uxbox/util/geom/point.cljs index a5de1f4c4..b6b03be66 100644 --- a/src/uxbox/util/geom/point.cljs +++ b/src/uxbox/util/geom/point.cljs @@ -6,6 +6,7 @@ ;; Copyright (c) 2015-2016 Juan de la Cruz (ns uxbox.util.geom.point + (:refer-clojure :exclude [divide]) (:require [uxbox.util.math :as mth])) (defrecord Point [x y]) @@ -152,11 +153,8 @@ (if (>= y 0) 1 4) (if (>= y 0) 2 3))) -(defn transform-point - [pt mx] - (Point. (+ (* (:x pt) (:a mx)) - (* (:y pt) (:c mx)) - (:tx mx)) - (+ (* (:x pt) (:b mx)) - (* (:y pt) (:d mx)) - (:ty mx)))) +(defn round + "Change the precision of the point coordinates." + [{:keys [x y]} decimanls] + (Point. (mth/precision x decimanls) + (mth/precision y decimanls)))