#ifndef CURSETREE_NODE_H #define CURSETREE_NODE_H #include "dims.h" # ifndef __NCURSES_H typedef struct _win_st WINDOW; # endif /* __NCURSES_H */ #define NODE_CHILD_N 2 /* MACRO: * Get widnow node start x,y coordinates, width, & height. * void NODEDIMS(struct ct_node *node, struct ct_dims dims); */ #define GET_WNODEDIMS(dims, node) \ (getbegyx((node)->win, dims.y, dims.x)); \ getmaxyx((node)->win, dims.y, dims.x) enum ct_nodetype { NODE_WINDOW, NODE_ABSTRACT, }; struct ct_node { enum ct_nodetype type; // union value depends on ct_node.type union { WINDOW *win; struct { enum ct_axis axis; float ratio; struct ct_dims *dims; struct ct_node *child[NODE_CHILD_N]; }; }; }; /* === External Interface === */ struct ct_node *init_window_node(WINDOW *const win); void destroy_node(struct ct_node *const node); void resize_node(struct ct_node *const node, struct ct_dims *const new_dims); void bifurcate_window_node(struct ct_node **const node, const enum ct_axis axis, const int invert_axis, const float ratio); #endif /* CURSETREE_NODE_H */