Make the workspace canvas bigger and center the drawing layout.

This commit is contained in:
Andrey Antukh 2016-02-15 22:59:08 +02:00
parent 6d8ae401f3
commit 6235e9c86e
3 changed files with 35 additions and 15 deletions

View file

@ -63,23 +63,31 @@
(when left-sidebar? (when left-sidebar?
(left-sidebar)) (left-sidebar))
[:section.workspace-content [:section.workspace-content {:class classes :on-scroll on-scroll}
;; Pages management lightbox ;; Pages management lightbox
;; (pagesmngr) ;; (pagesmngr)
;; Canvas ;; Rules
[:section.workspace-canvas {:class classes :on-scroll on-scroll} (h-rule left-sidebar?)
;; Rules (v-rule left-sidebar?)
(h-rule left-sidebar?)
(v-rule left-sidebar?)
(when (and (:selected workspace) (coordinates)
;; Canvas
[:section.workspace-canvas
{:class classes
:ref "workspace-canvas"}
#_(when (and (:selected workspace)
(= (count (:selected workspace)) 1)) (= (count (:selected workspace)) 1))
(let [shape-id (first (:selected workspace)) (let [shape-id (first (:selected workspace))
shape (l/focus-atom (l/in [:shapes-by-id shape-id]) st/state)] shape (l/focus-atom (l/in [:shapes-by-id shape-id]) st/state)]
(element-opts shape))) (element-opts shape)))
(coordinates)
(viewport)]] [:section.viewport-container
{:ref "viewport-container"
:width wb/viewport-width
:height wb/viewport-height}
(viewport)]]]
(colorpalette) (colorpalette)
@ -94,6 +102,17 @@
(rs/emit! (dw/initialize projectid pageid)) (rs/emit! (dw/initialize projectid pageid))
own)) own))
(defn- workspace-did-mount
[own]
;; FIXME: this is a hack. I don't know why I need setup
;; scroll to both elements, but it does not works without
;; that horrible hack.
(let [el1 (mx/get-ref-dom own "viewport-container")
el2 (mx/get-ref-dom own "workspace-canvas")]
(set! (.-scrollLeft el1) 600)
(set! (.-scrollLeft el2) 600)
own))
(defn- workspace-transfer-state (defn- workspace-transfer-state
[old-state state] [old-state state]
(let [[projectid pageid] (:rum/props state)] (let [[projectid pageid] (:rum/props state)]
@ -104,6 +123,7 @@
(mx/component (mx/component
{:render workspace-render {:render workspace-render
:will-mount workspace-will-mount :will-mount workspace-will-mount
:did-mount workspace-did-mount
:transfer-state workspace-transfer-state :transfer-state workspace-transfer-state
:name "workspace" :name "workspace"
:mixins [mx/static rum/reactive wshortcuts/mixin]})) :mixins [mx/static rum/reactive wshortcuts/mixin]}))

View file

@ -121,8 +121,8 @@
;; Constants ;; Constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def viewport-height 2048) (def viewport-width 4069)
(def viewport-width 2048) (def viewport-height 2048)
(def document-start-x 50) (def document-start-x 630)
(def document-start-y 50) (def document-start-y 30)

View file

@ -200,8 +200,8 @@
(dom/stop-propagation event) (dom/stop-propagation event)
(wb/emit-interaction! :nothing))] (wb/emit-interaction! :nothing))]
(html (html
[:svg.viewport {:width wb/viewport-height [:svg.viewport {:width wb/viewport-width
:height wb/viewport-width :height wb/viewport-height
:class (when drawing? "drawing") :class (when drawing? "drawing")
:on-mouse-down on-mouse-down :on-mouse-down on-mouse-down
:on-mouse-up on-mouse-up} :on-mouse-up on-mouse-up}