do not edit — generated by btf.
git.druid.rocksindexmilitantprogrammerastral_canvassrc/api/node.h

src/api/node.h


#ifndef NODE_H
#define NODE_H
 
#include "api/canvas.h"
 
/*
 * Internal widget tree (lib thread).
 *
 * This is the retained source of truth the renderer walks. The public
 * Widget handle is just {id, type}; Node holds parenting, geometry, and
 * type-specific payload (text, callback, …).
 *
 * Window page is the root (id 0). Style/shader apply on a node currently
 * also walks descendants so a container can push look down the hierarchy.
 *
 * App code never includes this; canvas.c talks to the tree only via jobs.
 */
 
typedef struct Node Node;
 
struct Node {
    Widget widget;           /* id + WidgetType this node represents */
    Node *parent;            /* NULL on the window page */
    Node *firstChild;        /* leftmost child; NULL if leaf */
    Node *lastChild;         /* rightmost child; attach appends here */
    Node *nextSibling;       /* next child of the same parent */
    Node *prevSibling;
 
    Position2D position;     /* relative to parent once attached */
    Size size;               /* box used for hit-test, clip, dedup */
    Style style;             /* colors / font for this node */
    int fontSize;            /* label/text size override; 0 → style.fontSize */
    void *callback;          /* button click / CANVAS_CLOSE token */
    void *userData;          /* extras / app pointer stored on the node */
    char *text;              /* heap copy of label/button/path string */
    char *shader;            /* heap copy of shader path; unused in v1 */
};
 
/* Allocate the root page (id 0) and the id→node map. Returns 0 or -1. */
int nodeGraphInit(void);
 
/* Destroy the whole tree and the id map. Safe on a never-inited graph. */
void nodeGraphDestroy(void);
 
/* Window page. NULL before init / after destroy. */
Node *nodeRoot(void);
 
/* Lookup by Widget.id. NULL if missing. */
Node *nodeFind(unsigned short id);
 
/*
 * Heap-allocate a node with widget.id / widgetType. Does not attach.
 * Registers in the id map. Caller fills position/size/text then attach.
 */
Node *nodeCreate(Widget widget);
 
/*
 * Make child a last-child of parent. Detaches child from any previous
 * parent first. Returns 0 or -1.
 */
int nodeAttach(Node *parent, Node *child);
 
/* Unlink from parent/siblings; node stays allocated and in the id map. */
void nodeDetach(Node *node);
 
/*
 * Recursively destroy children, unlink, free text/shader, free the node,
 * drop the id from the map. Does not libFreeId — the destroy job does that.
 */
void nodeDestroy(Node *node);
 
/* Copy shader onto node (and descendants, current behavior). */
void nodeApplyShader(Node *node, const char *shader);
 
/* Copy style onto node (and descendants, current behavior). */
void nodeApplyStyle(Node *node, const Style *style);
 
#endif
powered by btf.