63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
#ifndef DORNE_TREE_H
|
|
#define DORNE_TREE_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 crs_node *node, struct crs_nodedims dims);
|
|
*/
|
|
#define GET_WNODEDIMS(dims, node) \
|
|
(getbegyx((node)->win, dims.y, dims.x)); \
|
|
getmaxyx((node)->win, dims.y, dims.x)
|
|
|
|
enum crs_nodetype {
|
|
NODE_WINDOW,
|
|
NODE_ABSTRACT,
|
|
};
|
|
|
|
/* Stores a node's starting x,y coordinates, width, & height.
|
|
* NOTE: Intended for interfunction communication.
|
|
*/
|
|
struct crs_nodedims {
|
|
int x, y, width, height;
|
|
};
|
|
|
|
enum crs_axis {
|
|
AXIS_X,
|
|
AXIS_Y,
|
|
};
|
|
|
|
struct crs_node {
|
|
enum crs_nodetype type;
|
|
// union value depends on crs_node.type
|
|
union {
|
|
WINDOW *win;
|
|
struct {
|
|
enum crs_axis axis;
|
|
float ratio;
|
|
struct crs_nodedims *dims;
|
|
struct crs_node *child[NODE_CHILD_N];
|
|
};
|
|
};
|
|
};
|
|
|
|
struct crs_tree {
|
|
struct crs_node *root;
|
|
};
|
|
|
|
/* === External Interface === */
|
|
int ct_init(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);
|
|
void ct_update(struct crs_tree *const tree);
|
|
|
|
void bifurcate_window_node(struct crs_node **const node,
|
|
const enum crs_axis axis, const int invert_axis,
|
|
const float ratio);
|
|
|
|
#endif /* DORNE_TREE_H */
|