dorne/cursetree/node.h

56 lines
1.4 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_TOOSMALL (1<<1)
/* 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_PARENT_NODE(node) (node->cindex != 0)
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);
int 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 */