<commit_before>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2015-2016 <NAME> <<EMAIL>>
;; Copyright (c) 2015-2016 <NAME> <<EMAIL>>

(ns uxbox.main.ui.workspace.sidebar.options.circle-measures
  (:require [sablono.core :as html :refer-macros [html]]
            [rum.core :as rum]
            [lentes.core :as l]
            [uxbox.util.i18n :refer (tr)]
            [uxbox.util.router :as r]
            [potok.core :as ptk]
            [uxbox.store :as st]
            [uxbox.main.data.workspace :as udw]
            [uxbox.main.data.shapes :as uds]
            [uxbox.main.ui.icons :as i]
            [uxbox.util.mixins :as mx :include-macros true]
            [uxbox.main.geom :as geom]
            [uxbox.util.dom :as dom]
            [uxbox.util.math :refer (precision)]
            [uxbox.util.data :refer (parse-int parse-float read-string)]))

(mx/defc circle-measures-menu
  {:mixins [mx/static]}
  [menu {:keys [id] :as shape}]
  (letfn [(on-size-change [attr event]
            (let [value (dom/event->value event)
                  value (parse-int value 0)
                  sid (:id shape)
                  props {attr value}]
              (st/emit! (uds/update-size sid props))))
          (on-rotation-change [event]
            (let [value (dom/event->value event)
                  value (parse-int value 0)
                  sid (:id shape)]
              (st/emit! (uds/update-rotation sid value))))
          (on-pos-change [attr event]
            (let [value (dom/event->value event)
                  value (parse-int value nil)
                  sid (:id shape)
                  props {attr value}]
              (st/emit! (uds/update-position sid props))))
          (on-proportion-lock-change [event]
            (if (:proportion-lock shape)
              (st/emit! (uds/unlock-proportions id))
              (st/emit! (uds/lock-proportions id))))]
    [:div.element-set {:key (str (:id menu))}
     [:div.element-set-title (:name menu)]
     [:div.element-set-content
      ;; SLIDEBAR FOR ROTATION AND OPACITY
      [:span "Size"]
      [:div.row-flex
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "Width"
          :type "number"
          :min "0"
          :value (precision (:rx shape 0) 2)
          :on-change (partial on-size-change :rx)}]]
       [:div.lock-size
        {:class (when (:proportion-lock shape) "selected")
         :on-click on-proportion-lock-change}
        i/lock]
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "Height"
          :type "number"
          :min "0"
          :value (precision (:ry shape 0) 2)
          :on-change (partial on-size-change :ry)}]]]

      [:span "Position"]
      [:div.row-flex
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "cx"
          :type "number"
          :value (precision (:cx shape 0) 2)
          :on-change (partial on-pos-change :x)}]]
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "cy"
          :type "number"
          :value (precision (:cy shape 0) 2)
          :on-change (partial on-pos-change :y)}]]]

      [:span "Rotation"]
      [:div.row-flex
       [:input.slidebar
        {:type "range"
         :min 0
         :max 360
         :value (:rotation shape 0)
         :on-change on-rotation-change}]]

      [:div.row-flex
       [:div.input-element.degrees
        [:input.input-text
         {:placeholder ""
          :type "number"
          :min 0
          :max 360
          :value (precision (:rotation shape "0") 2)
          :on-change on-rotation-change
          }]]
       [:input.input-text
        {:style {:visibility "hidden"}}]]]]))<commit_msg>Fix precision problem on circle<commit_after>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2015-2016 <NAME> <<EMAIL>>
;; Copyright (c) 2015-2016 <NAME> <<EMAIL>>

(ns uxbox.main.ui.workspace.sidebar.options.circle-measures
  (:require [sablono.core :as html :refer-macros [html]]
            [rum.core :as rum]
            [lentes.core :as l]
            [uxbox.util.i18n :refer (tr)]
            [uxbox.util.router :as r]
            [potok.core :as ptk]
            [uxbox.store :as st]
            [uxbox.main.data.workspace :as udw]
            [uxbox.main.data.shapes :as uds]
            [uxbox.main.ui.icons :as i]
            [uxbox.util.mixins :as mx :include-macros true]
            [uxbox.main.geom :as geom]
            [uxbox.util.dom :as dom]
            [uxbox.util.math :refer (precision)]
            [uxbox.util.data :refer (parse-int parse-float read-string)]))

(mx/defc circle-measures-menu
  {:mixins [mx/static]}
  [menu {:keys [id] :as shape}]
  (letfn [(on-size-change [attr event]
            (let [value (dom/event->value event)
                  value (parse-int value 0)
                  sid (:id shape)
                  props {attr value}]
              (st/emit! (uds/update-size sid props))))
          (on-rotation-change [event]
            (let [value (dom/event->value event)
                  value (parse-int value 0)
                  sid (:id shape)]
              (st/emit! (uds/update-rotation sid value))))
          (on-pos-change [attr event]
            (let [value (dom/event->value event)
                  value (parse-int value nil)
                  sid (:id shape)
                  props {attr value}]
              (st/emit! (uds/update-position sid props))))
          (on-proportion-lock-change [event]
            (if (:proportion-lock shape)
              (st/emit! (uds/unlock-proportions id))
              (st/emit! (uds/lock-proportions id))))]
    [:div.element-set {:key (str (:id menu))}
     [:div.element-set-title (:name menu)]
     [:div.element-set-content
      ;; SLIDEBAR FOR ROTATION AND OPACITY
      [:span "Size"]
      [:div.row-flex
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "Width"
          :type "number"
          :min "0"
          :value (precision (:rx shape 0) 2)
          :on-change (partial on-size-change :rx)}]]
       [:div.lock-size
        {:class (when (:proportion-lock shape) "selected")
         :on-click on-proportion-lock-change}
        i/lock]
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "Height"
          :type "number"
          :min "0"
          :value (precision (:ry shape 0) 2)
          :on-change (partial on-size-change :ry)}]]]

      [:span "Position"]
      [:div.row-flex
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "cx"
          :type "number"
          :value (precision (:cx shape 0) 2)
          :on-change (partial on-pos-change :x)}]]
       [:div.input-element.pixels
        [:input.input-text
         {:placeholder "cy"
          :type "number"
          :value (precision (:cy shape 0) 2)
          :on-change (partial on-pos-change :y)}]]]

      [:span "Rotation"]
      [:div.row-flex
       [:input.slidebar
        {:type "range"
         :min 0
         :max 360
         :value (:rotation shape 0)
         :on-change on-rotation-change}]]

      [:div.row-flex
       [:div.input-element.degrees
        [:input.input-text
         {:placeholder ""
          :type "number"
          :min 0
          :max 360
          :value (precision (:rotation shape 0) 2)
          :on-change on-rotation-change
          }]]
       [:input.input-text
        {:style {:visibility "hidden"}}]]]]))
{'fraction_non_alphanumeric': 0.1467585502807555, 'fraction_numerical': 0.011485451761102604, 'mean_word_length': 1.7259130434782608, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '680969', 'n_tokens_mistral': 2635, 'n_tokens_neox': 2411, 'n_words': 631}