diff --git a/dist/index.html b/dist/index.html index 8ff5c753..2e83ca9b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -29,13 +29,14 @@ .css-place.focused { fill: lightblue; } - .css-place-label { - font-size: 0.075em; + .css-place-name-label, .css-transition-name-label { + fill: rgb(100,100,100); + } + .css-place-label{ fill: rgb(100,100,100); } .css-arc-label { display: none; /* TODO development */ - font-size: 0.1em; fill: rgb(200,200,200); } .css-arc { diff --git a/src/Config.purs b/src/Config.purs index b0863a1a..8f16531f 100644 --- a/src/Config.purs +++ b/src/Config.purs @@ -3,6 +3,12 @@ module Config where import Prelude import Svg.Attributes (Duration, seconds) +fontSize :: Number +fontSize = 0.1 + +tokenPadding :: Number +tokenPadding = placeRadius * 0.2 + placeRadius :: Number placeRadius = 4.0 * tokenRadius diff --git a/src/PetrinetView.purs b/src/PetrinetView.purs index 406a58c2..632f7a99 100644 --- a/src/PetrinetView.purs +++ b/src/PetrinetView.purs @@ -213,7 +213,7 @@ ui initialState' = , HE.onClick (HE.input_ (FocusTransition tid)) , HE.onDoubleClick (HE.input_ (if isEnabled then FireTransition tid else FocusTransition tid)) ] - (svgPreArcs <> svgPostArcs <> [svgTransitionRect trPos tid]) + (svgPreArcs <> svgPostArcs <> [svgTransitionRect trPos tid] <> [svgTransitionLabel trPos tid]) -- TODO simplify, especially (src, dest) order given isPost mkPostArc :: ∀ tid a. Show tid => tid -> Vec2D -> PlaceMarkingF pid Tokens -> Maybe (ArcModel tid) @@ -225,13 +225,22 @@ ui initialState' = -------------------------------------------------------------------------------- svgTransitionRect :: ∀ a tid. Show tid => Vec2D -> tid -> HTML a ((QueryF pid tid) Unit) - svgTransitionRect pos tid = SE.rect - [ SA.class_ "css-transition-rect" - , SA.width transitionWidth - , SA.height transitionHeight - , SA.x (pos.x - transitionWidth / 2.0) - , SA.y (pos.y - transitionHeight / 2.0) - ] + svgTransitionRect point tid = + SE.rect [ SA.class_ "css-transition-rect" + , SA.width transitionWidth + , SA.height transitionHeight + , SA.x (point.x - transitionWidth / 2.0) + , SA.y (point.y - transitionHeight / 2.0) + ] + + svgTransitionLabel :: ∀ a tid. Show tid => Vec2D -> tid -> HTML a ((QueryF pid tid) Unit) + svgTransitionLabel point tid = + SE.text [ SA.class_ "css-transition-name-label" + , SA.x (point.x + 1.5 * placeRadius) + , SA.y (point.y + 4.0 * fontSize) + , SA.font_size (SA.FontSizeLength $ Em fontSize) + ] + [ HH.text $ mkTransitionIdStr tid ] svgArc :: ∀ a pid tid. Show tid => ArcModel tid -> HTML a ((QueryF pid tid) Unit) svgArc arc = @@ -246,7 +255,7 @@ ui initialState' = [ SA.class_ "css-arc-label" , SA.x arc.src.x , SA.y arc.src.y - , SA.font_size (FontSizeLength $ Px 2.0) + , SA.font_size (FontSizeLength $ Em fontSize) -- TODO add SVG.textPath prop, refer to the svg path using xlink:href="#" ] [ HH.text arc.htmlId ] @@ -313,10 +322,16 @@ ui initialState' = , SA.cy point.y ] , svgTokens tokens point + , SE.text [ SA.class_ "css-place-name-label" + , SA.x (point.x + placeRadius + placeRadius / 2.0) + , SA.y (point.y + 4.0 * fontSize) + , SA.font_size (SA.FontSizeLength $ Em fontSize) + ] + [ HH.text label ] , SE.text [ SA.class_ "css-place-label" - , SA.x (point.x + 0.2 * placeRadius) - , SA.y (point.y - 0.2 * placeRadius) - , SA.font_size (SA.FontSizeLength (SA.Px 2.0)) + , SA.x (point.x + tokenPadding) + , SA.y (point.y - tokenPadding) + , SA.font_size (SA.FontSizeLength $ Em fontSize) ] [ HH.text $ if tokens == 0 || tokens == 1 then "" else show tokens ] ]