Skip to documentation
SLOP

tiny.ui.layout.input

Reference tiny.ui layout input

Defined in layout.

API (5)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callslayoutinput
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callerslayout.Stylescountlayout.Inputindexed
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callslayout.Inputindexedlayout.Stylescount
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.ui.src.layout.input.Inputgetlayout.Stylesrecord
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/ui/src/layout/input.zig

zig
const std = @import("std");const arrange = @import("arrange");const abi = @import("../abi/root.zig");const style = @import("../style/root.zig");const tree = @import("../tree/root.zig");pub const Styles = union(enum) {    records: []const style.Record,    engine: *const style.Engine,    pub fn count(self: Styles) usize {        return switch (self) {            .records => |records| records.len,            .engine => |engine| engine.count,        };    }    pub fn record(self: Styles, index: u32) *const style.Record {        return switch (self) {            .records => |records| &records[index],            .engine => |engine| engine.record(index),        };    }};pub const Input = struct {    view: tree.View,    styles: Styles,    rects: []arrange.Rect,    pub fn indexed(self: *Input) arrange.IndexedInput {        std.debug.assert(self.view.nodes.len <= std.math.maxInt(u32));        std.debug.assert(self.styles.count() >= self.view.nodes.len);        std.debug.assert(self.rects.len >= self.view.nodes.len);        return .{            .context = self,            .count = @intCast(self.view.nodes.len),            .get = get,            .descendants = descendants,            .is_leaf = isLeaf,            .rects = self.rects,        };    }    fn get(context: ?*anyopaque, index: u32) arrange.Node {        const self: *const Input = @ptrCast(@alignCast(context.?));        const node = self.view.nodes[index];        const record = self.styles.record(index);        var result = arrange.Node{            .id = index,            .style = record.layout,            .size = record.dimensions,            .measure_token = if (node.text != abi.text_absent) index else null,            .clip_x = abi.holds(node.flags, .clip) or abi.holds(node.flags, .scroll_x),            .clip_y = abi.holds(node.flags, .clip) or abi.holds(node.flags, .scroll_y),        };        if (abi.holds(node.flags, .solved)) {            const solved = self.solvedRoot(index);            const rect = self.view.solvedRectsOf(solved)[0];            result.size = .{ .width = rect.width, .height = rect.height };            result.style.constraints = .{};            result.style.flex_basis = null;            result.style.flex_grow = 0;            result.style.flex_shrink = 0;            result.measure_token = null;        }        return result;    }    fn descendants(context: ?*anyopaque, index: u32) u32 {        const self: *const Input = @ptrCast(@alignCast(context.?));        return self.view.nodes[index].subtree_count;    }    fn isLeaf(context: ?*anyopaque, index: u32) bool {        const self: *const Input = @ptrCast(@alignCast(context.?));        return abi.holds(self.view.nodes[index].flags, .solved);    }    fn solvedRoot(self: *const Input, index: u32) abi.SolvedRoot {        var first: usize = 0;        var last: usize = self.view.solved_roots.len;        while (first < last) {            const middle = first + (last - first) / 2;            const root = self.view.solved_roots[middle];            if (root.node < index) {                first = middle + 1;            } else {                last = middle;            }        }        std.debug.assert(first < self.view.solved_roots.len);        std.debug.assert(self.view.solved_roots[first].node == index);        return self.view.solved_roots[first];    }};

Source: lib/ui/src/layout/root.zig:1

zig
pub const input = @import("input.zig");

Audit

Definitions6
Public names11
Members5
Version26.7.0
Revisiondaab053ee433