(UNDER CONSTRUCTION) cursetree is now a non-binary tree yippiegit add .
also abstracted ncurses WINDOW into the ct_surface structure. and added ct_bounds to complement ct_dims.
This commit is contained in:
parent
b04f0b4aa3
commit
759920a9cc
9 changed files with 476 additions and 193 deletions
|
|
@ -2,48 +2,52 @@
|
|||
#define CURSETREE_NODE_H
|
||||
|
||||
#include "dims.h"
|
||||
#include "limits.h"
|
||||
#include "surface.h"
|
||||
|
||||
# ifndef __NCURSES_H
|
||||
#ifndef __NCURSES_H
|
||||
typedef struct _win_st WINDOW;
|
||||
# endif /* __NCURSES_H */
|
||||
#endif /* __NCURSES_H */
|
||||
|
||||
#define NODE_CHILD_N 2
|
||||
#define NODE_INIT_CHILDREN 4
|
||||
#define NODE_CHILDREN_GROWTH 1.5
|
||||
#define CINDEX_MAX UCHAR_MAX
|
||||
|
||||
/* 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,
|
||||
};
|
||||
/* Child Index */
|
||||
typedef unsigned char cindex;
|
||||
|
||||
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];
|
||||
};
|
||||
};
|
||||
struct ct_surface *surface;
|
||||
|
||||
struct ct_node *parent;
|
||||
enum ct_axis axis;
|
||||
struct ct_node **child;
|
||||
cindex csize, cindex;
|
||||
/* child imposed minimum bounds */
|
||||
struct {
|
||||
int wmin_abs;
|
||||
int hmin_abs;
|
||||
int wmin_rel;
|
||||
int hmin_rel;
|
||||
} cbounds;
|
||||
|
||||
float ratio;
|
||||
};
|
||||
|
||||
/* === 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);
|
||||
#define IS_PARENT_NODE(node) (node->cindex != 0)
|
||||
|
||||
void bifurcate_window_node(struct ct_node **const node,
|
||||
const enum ct_axis axis, const int invert_axis,
|
||||
const float ratio);
|
||||
struct ct_node *new_node(struct ct_dims *const dims,
|
||||
struct ct_bounds *const bounds,
|
||||
struct ct_node *const parent);
|
||||
void destroy_node(struct ct_node *const node);
|
||||
void resize_node(struct ct_node *const node, struct ct_dims *const new_dims);
|
||||
|
||||
void collapse_node(struct ct_node **const node, const int i,
|
||||
const bool preserve_bounds);
|
||||
|
||||
// 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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue