natiny.render.view_children

Lua
natiny.render.view_children(view)

Draws the view's children in parenting order, from inside its own natiny.view.HOOK_DRAW. A view with a draw hook draws its children only when this function is called; a view without one draws them automatically. Drawing happens at the position of the call, so a scissor opened before it and closed after it clips the whole subtree.

Parameters

Name Type Description
view number The view being drawn; the one the hook was given

view must be the non-zero handle passed to the draw hook that is currently running. Passing 0 raises a Lua error. A call outside that hook, with a different non-zero handle, or for a second time during the same hook invocation writes a diagnostic to standard error and draws nothing.

Example

Lua
natiny.view.set_hook(panel, natiny.view.HOOK_DRAW, function(self)
    local x, y, w, h = natiny.view.get_rect(self)

    natiny.render.set_color(PANEL)
    natiny.render.rectangle(x, y, w, h)

    -- the list scrolls, so nothing of it may leave the panel
    natiny.render.scissor_begin(x, y, w, h)
    natiny.render.view_children(self)
    natiny.render.scissor_end()
end)