Adding tooltip to all shapes creation

This commit is contained in:
Jesús Espino 2016-12-22 10:29:34 +01:00
parent 0f21d11fd3
commit 1181c01f55
3 changed files with 22 additions and 4 deletions

View file

@ -50,7 +50,7 @@
background-color: $color-dark-bg; background-color: $color-dark-bg;
border-radius: $br-small; border-radius: $br-small;
color: $color-white; color: $color-white;
font-size: $fs14; font-size: $fs12;
padding: 3px 8px; padding: 3px 8px;
transition: none; transition: none;
text-align: center; text-align: center;

View file

@ -47,14 +47,16 @@
{:project project {:project project
:page page :page page
:selected #{} :selected #{}
:drawing nil}) :drawing nil
:tooltip nil})
(assoc state :workspace (assoc state :workspace
{:project project {:project project
:zoom 1 :zoom 1
:page page :page page
:flags #{:sitemap :drawtools :layers :element-options} :flags #{:sitemap :drawtools :layers :element-options}
:selected #{} :selected #{}
:drawing nil}))) :drawing nil
:tooltip nil})))
ptk/WatchEvent ptk/WatchEvent
(watch [_ state s] (watch [_ state s]

View file

@ -55,6 +55,20 @@
[:span {:alt "y"} [:span {:alt "y"}
(str "Y: " (:y coords "-"))]])) (str "Y: " (:y coords "-"))]]))
;; --- Cursor tooltip
(defn- get-shape-tooltip
"Return the shape tooltip text"
[shape]
(case (:type shape)
:icon "Click to place the Icon"
:image "Click to place the Image"
:rect "Drag to draw a Box"
:text "Drag to draw a Text Box"
:path "Click to draw a Path"
:circle "Drag to draw a Circle"
nil))
(mx/defc cursor-tooltip (mx/defc cursor-tooltip
{:mixins [mx/reactive mx/static]} {:mixins [mx/reactive mx/static]}
[tooltip] [tooltip]
@ -164,7 +178,9 @@
page (mx/react wb/page-ref) page (mx/react wb/page-ref)
flags (:flags workspace) flags (:flags workspace)
drawing? (:drawing workspace) drawing? (:drawing workspace)
tooltip (:tooltip workspace) tooltip (if (:tooltip workspace)
(:tooltip workspace)
(get-shape-tooltip drawing?))
zoom (or (:zoom workspace) 1)] zoom (or (:zoom workspace) 1)]
(letfn [(on-mouse-down [event] (letfn [(on-mouse-down [event]
(dom/stop-propagation event) (dom/stop-propagation event)