dorne/cursetree/node.h

66 lines
1.8 KiB
C

#ifndef CURSETREE_NODE_H
#define CURSETREE_NODE_H
#include "dims.h"
#include "limits.h"
#include "surface.h"
#ifndef __NCURSES_H
typedef struct _win_st WINDOW;
#endif /* __NCURSES_H */
#define NODE_INIT_CHILDREN 4
#define NODE_CHILDREN_GROWTH 1.5
#define CINDEX_MAX (UCHAR_MAX)
#define NFLAG_EMPTY (0)
#define NFLAG_RESIZE (1 << 0)
#define NFLAG_SMALL (1 << 1)
#define NFLAG_SMALLCHILD (1 << 2)
#define NFLAG_LARGE (1 << 3)
/* Child Index */
typedef unsigned char cindex;
struct ct_node {
struct ct_surface *surface;
unsigned char flags;
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;
};
/* === External Interface === */
#define IS_ROOT_NODE(node) (node->parent == NULL)
#define IS_PARENT_NODE(node) (node->cindex != 0)
struct ct_node *__node(struct ct_dims *const dims,
struct ct_bounds *const bounds,
struct ct_node *const parent);
struct ct_node *new_node(struct ct_bounds *const bounds,
struct ct_node *const parent);
void __destroy_node(struct ct_node *const node);
int resize_node(struct ct_node *const node, struct ct_dims *dims);
int insert_child_node(struct ct_node *const parent, struct ct_node *const child,
const cindex i);
int append_child_node(struct ct_node *const parent,
struct ct_node *const child);
struct ct_node *remove_child_node(struct ct_node *const parent,
const cindex i);
int destroy_child_node(struct ct_node *const parent, const cindex i);
void collapse_node(struct ct_node **const node, const int i,
const bool preserve_bounds);
#endif /* CURSETREE_NODE_H */