Raxol.Core.Renderer.View (Raxol v0.2.0)

View Source

Defines the view system for Raxol components.

Provides:

  • Box model layout (content, padding, border, margin)
  • Flexible layouts (grid, flex)
  • Rich text rendering
  • Borders and shadows

Summary

Functions

Creates an absolutely positioned view.

Creates a border around a view.

Creates a box view for layout.

Creates a fixed position view (relative to viewport).

Creates a flex container.

Creates a grid container.

Calculates the layout for a view tree. Returns a list of positioned views ready for rendering.

Creates a new view with the given type and options.

Creates a scrollable view.

Creates a shadow effect.

Creates a text view.

Types

border_style()

@type border_style() :: :none | :single | :double | :rounded | :bold | :dashed

color()

@type color() :: Raxol.Core.Renderer.Color.color()

layout_type()

@type layout_type() :: :flex | :grid | :flow | :absolute

margin()

@type margin() :: padding()

padding()

position()

@type position() :: {non_neg_integer(), non_neg_integer()}

position_type()

@type position_type() :: :relative | :absolute | :fixed

size()

@type size() :: {non_neg_integer(), non_neg_integer()}

style()

@type style() :: [atom()]

view()

@type view() :: %{
  type: atom(),
  position: position() | nil,
  position_type: position_type(),
  z_index: z_index(),
  size: size() | nil,
  style: style(),
  fg: color() | nil,
  bg: color() | nil,
  border: border_style(),
  padding: padding(),
  margin: margin(),
  children: [view()],
  content: term()
}

z_index()

@type z_index() :: integer()

Functions

absolute(opts \\ [], list)

Creates an absolutely positioned view.

border(style \\ :single, opts \\ [], list)

Creates a border around a view.

box(opts \\ [])

Creates a box view for layout.

fixed(opts \\ [], list)

Creates a fixed position view (relative to viewport).

flex(opts \\ [], list)

Creates a flex container.

grid(opts \\ [], list)

Creates a grid container.

layout(view, available_size)

Calculates the layout for a view tree. Returns a list of positioned views ready for rendering.

new(type, opts \\ [])

Creates a new view with the given type and options.

scroll(opts \\ [], list)

Creates a scrollable view.

shadow(opts \\ [], list)

Creates a shadow effect.

text(content, opts \\ [])

Creates a text view.