refactor cursetree into node.c & tree.c
This commit is contained in:
parent
daaaaf979c
commit
2d76f8221e
6 changed files with 288 additions and 304 deletions
|
|
@ -1,63 +1,10 @@
|
|||
#ifndef CURSETREE_CURSETREE_H
|
||||
#define CURSETREE_CURSETREE_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;
|
||||
};
|
||||
#include "tree.h"
|
||||
|
||||
/* === 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 /* CURSETREE_CURSETREE_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue