Macaw.Frame.Writes (macaw_frame v0.1.0)

Copy Markdown View Source

What a model writes (spec/03 §5): a Frame changes the page only by emitting events, and the host applies them to the page's state.

  • Standard writes (§5.1): a model's writes/1 answers %{"selection" => :identity} where a pick of a row with a declared identity is possible, and %{"window" => :window} where a brush, a zoom or a view writes the window. union/1 is the Frame's declaration over its frames.
  • :local keys (§5.2, keys/2): named by the cell's sync group, <group>, <group>.brush, <group>.item and <group>.view, each with its domain type; none without a group. They carry domain values, never pixels.
  • Gestures as events (§5.3): a finished gesture, already in domain units, becomes a Macaw.Data.Event: "brush" and "zoom" with %{from, to} ascending, "reset" with nil, "pick" with the row's declared fields as [field, value] pairs and its declared identity, "view" with %{box: %{west, south, east, north}}. The five names are reserved (reserved/0).

A gesture is a map: kind (:brush, :zoom, :pan, :reset, :pick, :view), instance (the context's instance) and time (the holder's now), and by kind from and to (domain values), served (%{from, to}, the delivery's served window), row and schema (a pick's typed row and its slot's schema), box (a view's). This replaces visualize's Visualize.Board.Server.brush/2 and select/2 and the sync bus's payloads.

Summary

Types

An event the Frame emits.

Functions

A finished brush (§5.3): "brush" with %{from, to} ascending, nil identity.

The domain type a scale's values have on the bus: :time or :number, nil for neither.

An event of the model's frame, {:ok, event}, or :none when it cannot be built.

What a frame draws following a key of its group (§5.2): {:value, v} the crosshair at x(v) across the plot; {:brush, %{from, to}} the band between them; {:item, identity} an outline of every keyed element of scene whose row has the identity (identities maps {layer, row} to a row's identity); {:view, box} the geographic model's view moved to the box (its projection fitted to it). nil for a value the model cannot follow.

The :local keys of a sync group (§5.2): each of keys (:value with its domain type, :brush, :item, :view) under the group's name; %{} with no group.

A pick (§5.3): the row's declared fields as [field, value] pairs in declared order and its declared identity as a map of field to value; a pick of nothing (no row) is [] and nil. A row with no declared identity carries nil and its list.

The runtime's reserved event names (§5.3): a layer's declared event may not use them.

Whether a name is reserved, read by spelling.

A reset (§5.3): "reset" with nil value and identity, which clears window.

The selection write a model declares (§5.1): %{"selection" => :identity} when the design's interaction picks on this frame and a layer reads a slot with a declared identity, else %{}.

The Frame's writes declaration (§5.1): the union of its realized frames' writes/1.

A geographic view (§5.3): "view" with %{box: %{west, south, east, north}}.

A finished zoom or pan of x (§5.3, §6.4): "zoom" with the extent when it needs more detail (it reaches outside the served window or spans less than half of it), else :none: the client's transform of what is drawn.

Types

event()

@type event() :: Macaw.Data.Event.t()

An event the Frame emits.

Functions

brush(model, gesture)

@spec brush(Macaw.Frame.Coordinates.Model.t(), map()) :: {:ok, event()} | :none

A finished brush (§5.3): "brush" with %{from, to} ascending, nil identity.

domain_type(arg1)

@spec domain_type(term()) :: :time | :number | nil

The domain type a scale's values have on the bus: :time or :number, nil for neither.

event(model, gesture, name, value, identity)

@spec event(Macaw.Frame.Coordinates.Model.t(), map(), String.t(), term(), map() | nil) ::
  {:ok, event()} | :none

An event of the model's frame, {:ok, event}, or :none when it cannot be built.

follow(model, followed, opts \\ [])

What a frame draws following a key of its group (§5.2): {:value, v} the crosshair at x(v) across the plot; {:brush, %{from, to}} the band between them; {:item, identity} an outline of every keyed element of scene whose row has the identity (identities maps {layer, row} to a row's identity); {:view, box} the geographic model's view moved to the box (its projection fitted to it). nil for a value the model cannot follow.

keys(group, keys)

@spec keys(term(), term()) :: %{required(String.t()) => atom()}

The :local keys of a sync group (§5.2): each of keys (:value with its domain type, :brush, :item, :view) under the group's name; %{} with no group.

pick(model, gesture)

@spec pick(Macaw.Frame.Coordinates.Model.t(), map()) :: {:ok, event()} | :none

A pick (§5.3): the row's declared fields as [field, value] pairs in declared order and its declared identity as a map of field to value; a pick of nothing (no row) is [] and nil. A row with no declared identity carries nil and its list.

reserved()

@spec reserved() :: [String.t(), ...]

The runtime's reserved event names (§5.3): a layer's declared event may not use them.

iex> Macaw.Frame.Writes.reserved()
["brush", "zoom", "reset", "pick", "view"]

reserved?(name)

@spec reserved?(term()) :: boolean()

Whether a name is reserved, read by spelling.

reset(model, gesture)

@spec reset(Macaw.Frame.Coordinates.Model.t(), map()) :: {:ok, event()} | :none

A reset (§5.3): "reset" with nil value and identity, which clears window.

selection(model)

@spec selection(Macaw.Frame.Coordinates.Model.t()) :: %{
  optional(String.t()) => :identity
}

The selection write a model declares (§5.1): %{"selection" => :identity} when the design's interaction picks on this frame and a layer reads a slot with a declared identity, else %{}.

union(models)

@spec union(term()) :: %{required(String.t()) => :identity | :window}

The Frame's writes declaration (§5.1): the union of its realized frames' writes/1.

view(model, gesture, box)

@spec view(Macaw.Frame.Coordinates.Model.t(), map(), map()) :: {:ok, event()} | :none

A geographic view (§5.3): "view" with %{box: %{west, south, east, north}}.

zoom(model, gesture)

@spec zoom(Macaw.Frame.Coordinates.Model.t(), map()) :: {:ok, event()} | :none

A finished zoom or pan of x (§5.3, §6.4): "zoom" with the extent when it needs more detail (it reaches outside the served window or spans less than half of it), else :none: the client's transform of what is drawn.