finish bulk of tree.* implementation

This commit is contained in:
Emile Clark-Boman 2025-09-11 17:41:14 +10:00
parent 669f620a6a
commit 8c4f288a97
4 changed files with 181 additions and 43 deletions

View file

@ -1,16 +1,19 @@
#ifndef DORNE_TREE_H
#define DORNE_TREE_H
# ifndef __NCURSES_H
#ifndef __NCURSES_H
typedef struct _win_st WINDOW;
# endif /* __NCURSES_H */
#endif /* __NCURSES_H */
#define NODE_CHILD_N 2
/* MACRO:
* Get widnow node start x,y coordinates, width, & height.
* void NODEDIMS(struct crs_node *node, struct crs_nodedims dims);
*/
#define NODEDIMS(node, dims) (getbegyx(dims.y, dims.x); getmaxyx(dims.y, dims.x))
#define GET_WNODEDIMS(dims, node) \
(getbegyx((node)->win, dims.y, dims.x)); \
getmaxyx((node)->win, dims.y, dims.x)
enum crs_nodetype {
NODE_WINDOW,
@ -35,24 +38,24 @@ struct crs_node {
union {
WINDOW *win;
struct {
enum crs_axis axis;
float ratio;
struct crs_nodedims *dims;
struct crs_node *child[NODE_CHILD_N];
};
};
};
struct crs_tree {
WINDOW *stdscr;
struct crs_node *root;
};
/* === External Interface === */
// struct crs_node *init_node_window(void);
// struct crs_node *init_node_abstract(void);
// void destroy_node(struct crs_node *node);
int init_tree(struct crs_tree **const tree);
void destroy_tree(struct crs_tree *const tree);
void resize_tree(struct crs_tree *const tree, struct crs_nodedims *const dims);
int init_tree(struct crs_tree **tree);
void update_tree(struct crs_tree *tree);
void destroy_tree(struct crs_tree *tree);
void bifurcate_window_node(struct crs_node **node, const enum crs_axis axis,
const int invert_axis, const float ratio);
#endif /* DORNE_TREE_H */