View Source Garnish.Renderer behaviour (garnish v0.1.2)
Logic to render a view tree.
This API is still under development.
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.
Types
@type child_tag() ::
:bar
| :chart
| :column
| :label
| :overlay
| :panel
| :row
| :sparkline
| :table
| :table_cell
| :table_row
| :text
| :tree
| :tree_node
@type root_element() :: %Garnish.Renderer.Element{ attributes: term(), children: [child_element()], tag: :view }
Callbacks
@callback render( Garnish.Renderer.Canvas.t(), Garnish.Renderer.Element.t(), (Garnish.Renderer.Canvas.t(), Garnish.Renderer.Element.t() -> Garnish.Renderer.Canvas.t()) ) :: Garnish.Renderer.Canvas.t()
Functions
@spec render(Garnish.Renderer.Canvas.t(), root_element()) :: {:ok, Garnish.Renderer.Canvas.t()} | {:error, term()}
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.
@spec render_tree( Garnish.Renderer.Canvas.t(), Garnish.Renderer.Element.t() | [Garnish.Renderer.Element.t()] ) :: Garnish.Renderer.Canvas.t()
@spec validate_tree(Garnish.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.