Macaw.Frame.Budget (macaw_frame v0.1.0)

Copy Markdown View Source

The Frame's budget/3 and budget/4 (spec/05 §2): each slot's rows from the pixels its layers are drawn in, copied from visualize's Visualize.Board.Budget.slot/5 (its feeds/5 and slots/6, a board's pooling, are the host's here and not carried over).

  • The layers that read the slot are those whose data names it, as the slot itself or as a source of their steps (a graph's nodes), each drawn in its frame; a layer's plot width w is its frame's plot at the given size, read from the compiled document's frames without drawing, rounded up to whole pixels and at least 1 (§2.1).
  • Each layer needs rows by its kind at w, its kind's budget hint (Macaw.Frame.Layer.Budget, §2.2), and the slot's budget is the largest need.
  • A slot no layer reads by rows, or one a layer reads whole (a sum, a bin, a stack, a layout) is nil, which the host reads at its ceiling.
  • A document's own budget wins (§2.3): n rows for every slot, {:per_px, k} ceil(k × w) over the widest plot of the slot's layers, at least 1. The host's ceiling still clamps both (§2.4): that is the host's, never the Frame's.
  • Device pixels (§2.5): budget/4 is handed the instance's context, and w is the plot width times context.ratio, rounded up, so a line in a 500-pixel plot on a 2× display asks 4 × 1000 rows. macaw_component 0.12 carries the ratio (Macaw.Frame.Contract), so §2.5's fallback is the host's alone: a host calling budget/3 reads ratio 1, CSS pixels.

It reads the bindable parameters' and variables' current values in the settings, so a margin a variable gives is read at its value (§2.1). It compiles the document's frames and layers and applies nothing to data; its cost is pinned by test/macaw/frame/data_budget_test.exs.

Summary

Functions

The rows the Frame asks for slot at size, in CSS pixels (spec/05 §2.1): a positive integer, or nil for a slot read at the host's ceiling. Settings whose document does not compile, and a slot the document does not declare, answer nil.

The rows the Frame asks for slot at size in context (spec/05 §2.1, §2.5): as budget/4, every plot width counted in device pixels by context.ratio. A number in place of the context is the ratio itself.

Functions

budget(slot, settings, size, registry)

@spec budget(term(), term(), term(), map()) :: pos_integer() | nil

The rows the Frame asks for slot at size, in CSS pixels (spec/05 §2.1): a positive integer, or nil for a slot read at the host's ceiling. Settings whose document does not compile, and a slot the document does not declare, answer nil.

budget(slot, settings, size, context_or_ratio, registry)

@spec budget(term(), term(), term(), Macaw.Component.Context.t() | number(), map()) ::
  pos_integer() | nil

The rows the Frame asks for slot at size in context (spec/05 §2.1, §2.5): as budget/4, every plot width counted in device pixels by context.ratio. A number in place of the context is the ratio itself.