Module

Hylograph.Flow.Render.Tree

Package
purescript-hylograph-flow-render
Repository
afcondon/purescript-hylograph-flow-render

A layout as a HATS tree: one SVG, edges under nodes.

The tree draws a Layout (Hylograph.Flow.Render.Engine) and does not know which engine made it: every engine's layout is drawn by this one function.

An item (what holds a value) is an open box; a step (what computes) is a filled lozenge. An edge is one stroked path along its route (Route.svgPath): a ribbon as its ink says (a band as broad as it is, or a hairline down its middle), a polyline or a spline as a hairline; an edge turned back to close a cycle is dashed where it is a hairline. A port the engine placed is a small square on its node's side, open for an input and filled for an output, over the edges, so that an edge's end is seen to meet it.

The layout's direction is the root's data-direction. A node's words are set from its left side where the flow runs left to right (its edges enter and leave by its ends, and the words read along it), and about its middle where the flow runs top-down (its edges enter and leave above and below its middle); an item's swatch is along the side the flow enters by.

Everything else about an element is the caller's: its label, a short note beside the label, a class and a colour (Decoration), and whatever an Overlay knows of it (withOverlay). Clicks and the pointer's coming and going are told to the caller by element.

A closed group (Hylograph.Flow.Grouping.collapse) is a step and, where it provides anything, a summary item, and is drawn as any step and any item are. Whether it should look otherwise is the caller's to say too: withGroups changes the marks of a group's step and summary, by group.

An open group, where the layout was told of groups, is an outline under everything else: a quiet box round its members with its name in a strip at the top. The name is what takes gestures (a tab behind it, as wide as the name), told as PointedGroup, so a page can shut a group by a click on its name; the box itself takes none, and what is inside it is reached through it.

A node's inside (0.4): where the decoration draws a node's inside (Decoration.inside), the tree draws nothing of the node but that and its ports: no box, no label, no words, no swatch, no note. The inside is a HATS tree in the node's own coordinates, its box's top left at 0,0, placed by a g.flow-inside translated to the box. It is for a node the caller sized (Picture.fixed), such as a table of rows, whose inside only the caller knows how to draw; the tree still places it, keys it, and tells its gestures.

The keyboard (0.5): a mark the decoration calls a button (Decoration.button) can be reached by the Tab key and says what it is to a screen reader (tabindex="0", role="button", and the name given as its aria-label); the others are as they were. HATS tells clicks and the pointer and no keys, so pressing a button is the page's to arrange once: Hylograph.Flow.Render.Keys.pressByKeys makes Enter and Space on a focused button a click on it, which is then told as any click is.

Words: where the layout set a node's words (Picture.words), those lines are drawn, the title's and then the detail's, and the mark's label is not used; its note stands at the right of the first line. Where it did not, the mark's label is written on one line, as in 0.2.

Legibility (0.7; treeWith and its Dress, none of it drawn by tree or treeLabelled unless said):

  • a ribbon that runs against the flow carries marks of its direction along it, and no other ribbon does (Dress.marks);
  • a ribbon drawn broader than it is (Ink.Least) is dashed and has the class flow-not-to-scale in any tree, and with Dress.marks a break mark across its middle;
  • a closed group's bar shows its seams (Dress.seams, which the unfolding engine's seams gives): a line across the bar where two parts divide, and beside a part that only receives a wall on the side nothing leaves by, beside one that only gives a wall on the side nothing enters by;
  • a group's name is a heading (Dress.headings): a closed top-level group's name stands over the start of its bar, where its outline's name stands when it is open, in the same letters, so the name is in one place closed and open; and the labels of the nodes inside an open group are lighter and smaller than it;
  • a group that has several outlines (the unfolding engine's tied outlines: one for each run of its members) has its name on each and a tie drawn from each to the next.

What is drawn, for a stylesheet or a test to find:

svg.flow[data-direction=left-to-right|top-down]
  g.flow-outlines > g.flow-outline[data-group][data-depth][data-run]
                      > rect.flow-outline-box, rect.flow-outline-tab, text.flow-outline-label[.flow-group-name]
  g.flow-ties? > path.flow-tie[data-group]                      (where a group has several outlines)
  g.flow-marks? > path.flow-direction[data-edge] | path.flow-scale-break[data-edge]   (Dress.marks)
  (in a node, Dress.seams:) rect.flow-seam*, rect.flow-only[data-only=receives|gives][data-part]*
  (Dress.headings:) text.flow-label.flow-group-name on a closed top-level group; .flow-part-name on a part's label
  g.flow-edges > path.flow-edge.flow-ribbon|.flow-polyline|.flow-spline
                   .flow-band|.flow-hairline[.flow-backward][.flow-swept][data-edge][data-from][data-to]
  g.flow-nodes > g.flow-node.flow-item|.flow-step[.flow-lettered][data-key]
                   > rect.flow-box, rect.flow-swatch?, text.flow-label,
                     text.flow-label-more*, text.flow-detail*, text.flow-note?,
                     rect.flow-port.flow-port-in|.flow-port-out[data-port]*
                 | g.flow-node.flow-drawn > g.flow-inside[transform] > (the caller's),
                     rect.flow-port.flow-port-in|.flow-port-out[data-port]*

#Mark Source

type Mark = { className :: String, colour :: Maybe String, label :: String, note :: Maybe String }

A node's dress. note: a few letters beside the label (an operation, a count). className: added to the node's classes. colour: a step's fill, an item's swatch; Nothing for the ink.

#Line Source

type Line = { className :: String, colour :: Maybe String }

An edge's dress.

#Gesture Source

#Pointed Source

data Pointed

What a gesture was made on. A node is its element. An edge is a wire where it is exactly one (Both, and any edge between a drawn item and a drawn step); otherwise it is the path it stands for, with the undrawn elements it passes through. An open group's outline is its group.

Constructors

Instances

#Bands Source

data Bands

How a ribbon that is a band is drawn (0.5).

  • Stroked: one path along its centre line, stroked as broad as the ribbon is, as since 0.1. Right where a ribbon runs nearly straight along the flow. Where it slants it is too thin, and its ends are not flat on its nodes, because a stroke is broad across the line and not across the flow: a ribbon 200 pixels broad that shifts 150 across in a run of 90 bulges past both nodes.
  • Swept: the area the ribbon's span on its source sweeps to its span on its target (Route.sweptPath), filled and not stroked: flat on both nodes, and as broad across the flow all the way as the ribbon is. Its colour is then its fill, which is what a stylesheet must set. A band turned back to close a cycle, which runs both ways along the flow, is stroked either way; so is a ribbon too thin to be drawn as a band (3 pixels or less), which is a line.

Constructors

Instances

#Labels Source

data Labels

Where a node's label is written (0.6; treeLabelled).

  • Within: in its box, as since 0.1.
  • Beside least: beside its box, for a node that is a thin bar and as broad as its ribbons, no more (the unfolding engine's): after it along the flow where the picture has room and before it where it has not, left to right; over it, or under it in the first row, top-down. In the ink's colour, since it is on the paper. A node less than least pixels across the flow has no label drawn (its mark has the class flow-unlabelled): labels beside bars that touch would run into one another. And a step is then a bar with square corners, so that parts that stand with no gap between them tile.

Constructors

Instances

#Decoration Source

type Decoration wire = { bands :: Bands, button :: Pointed -> Maybe String, edge :: Edge wire -> Line, inside :: Node -> Maybe Tree, node :: Node -> Mark, notify :: Gesture -> Pointed -> Effect Unit }

inside (0.4): a node's inside, drawn by the caller in the node's own coordinates, for the nodes it draws; see the module's header. button (0.5): the marks that are buttons for the keyboard, each with the name it is announced by; Nothing for a mark that is none. bands (0.5): how a ribbon that is a band is drawn.

#plainDecoration Source

plainDecoration :: forall wire. Decoration wire

Each node under its own label, nothing else said, gestures ignored, no inside drawn by the caller, no mark a button, bands stroked.

#withOverlay Source

withOverlay :: forall a wire. Overlay a -> (a -> Mark -> Mark) -> (a -> Line -> Line) -> Decoration wire -> Decoration wire

A decoration changed by what an overlay knows: of a node, by its key; of an edge that is one wire, by the wire's.

#withGroups Source

withGroups :: forall wire. (GroupId -> Mark -> Mark) -> Decoration wire -> Decoration wire

A decoration changed for closed groups: the mark of a group's step and of its summary item, by the group. (A click on either is told as any click is, by its element; groupOf says which group that is, for a page that opens a group where it stands.)

#groupOf Source

groupOf :: ElementKey -> Maybe GroupId

The closed group an element is: its step or its summary item.

#pointedBy Source

pointedBy :: forall wire. Edge wire -> Pointed

What an edge is, for a gesture or an overlay: the wire it is, where it stands for one wire, by the identity the edge carries.

#keyName Source

keyName :: ElementKey -> String

An element's key as one string, for data-key and for HATS's keys. A closed group's step is group: and the group's id where a source's step is step: and its name, so a step and a group never share a key; likewise a closed group's summary item is summary: and the group's id where a source's item is item: and its name. Inside a wire's key the item, the step and the port are written as they read (itemLabel, stepLabel, portLabel).

#groupName Source

groupName :: GroupId -> String

A group's id as one string, for an outline's data-group.

#hairline Source

hairline :: Number

The stroke of an edge that is drawn as a line and whose route says no stroke of its own: a polyline, a spline.

#strokeOf Source

strokeOf :: Route -> Number

How wide an edge is stroked: a ribbon as its ink says, any other route as a hairline.

#directionName Source

directionName :: Direction -> String

A direction as the root's data-direction says it.

#portSide Source

portSide :: Number

The side of a port's mark: 5 pixels, centred on the port.

#tree Source

tree :: forall wire. Decoration wire -> Layout wire -> Tree

#treeLabelled Source

treeLabelled :: forall wire. Labels -> Decoration wire -> Layout wire -> Tree

The tree with each node's label written where it is told (0.6): tree is treeLabelled Within. (Not a field of Decoration, so that no decoration written out whole before 0.6 has to change.)

#Dress Source

type Dress = { headings :: Boolean, labels :: Labels, marks :: Boolean, seams :: Array Seamed }

What a tree draws beside a decoration (0.7); see the module's header. (Not fields of Decoration, so that no decoration written out whole has to change.)

#plainDress Source

plainDress :: Dress

Labels within their boxes, and nothing of 0.7's: tree's own dress.

#treeWith Source

treeWith :: forall wire. Dress -> Decoration wire -> Layout wire -> Tree

The tree, dressed (0.7): treeLabelled labels is treeWith plainDress { labels = labels }.