Ratatouille v0.5.1 Ratatouille.Renderer behaviour View Source

Logic to render a view tree.

This API is still under development.

Link to this section Summary

Functions

Renders a view tree to canvas, given a canvas and a root element (an element with the :view tag).

Validates the hierarchy of a view tree given the root element.

Link to this section Types

Link to this type

child_element()

View Source
child_element() :: %Ratatouille.Renderer.Element{
  attributes: term(),
  children: term(),
  tag: child_tag()
}
Link to this type

child_tag()

View Source
child_tag() ::
  :bar
  | :chart
  | :column
  | :label
  | :overlay
  | :panel
  | :row
  | :sparkline
  | :table
  | :table_cell
  | :table_row
  | :text
  | :tree
  | :tree_node
Link to this type

root_element()

View Source
root_element() :: %Ratatouille.Renderer.Element{
  attributes: term(),
  children: [child_element()],
  tag: :view
}

Link to this section Functions

Renders a view tree to canvas, given a canvas and a root element (an element with the :view tag).

The tree is rendered by recursively rendering each element in the hierarchy. The canvas serves as both the accumulator for rendered cells at each stage and as the box representing available space for rendering, which shrinks as this space is consumed.

Link to this function

render_tree(canvas, elements)

View Source
render_tree(
  Ratatouille.Renderer.Canvas.t(),
  Ratatouille.Renderer.Element.t() | [Ratatouille.Renderer.Element.t()]
) :: Ratatouille.Renderer.Canvas.t()
Link to this function

validate_tree(element)

View Source
validate_tree(Ratatouille.Renderer.Element.t()) :: :ok | {:error, String.t()}

Validates the hierarchy of a view tree given the root element.

Used by the render/2 function to prevent strange errors that may otherwise occur when processing invalid view trees.

Link to this section Callbacks

Link to this callback

render(arg1, arg2, function)

View Source
render(
  Ratatouille.Renderer.Canvas.t(),
  Ratatouille.Renderer.Element.t(),
  (Ratatouille.Renderer.Canvas.t(), Ratatouille.Renderer.Element.t() ->
     Ratatouille.Renderer.Canvas.t())
) :: Ratatouille.Renderer.Canvas.t()