Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions src/Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 27 additions & 12 deletions src/PetrinetView.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation oopsie

, 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 =
Expand All @@ -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="#<arc id here>"
]
[ HH.text arc.htmlId ]
Expand Down Expand Up @@ -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 ]
]
Expand Down