dorne/cursetree/node.h

50 lines
1.2 KiB
C
Raw Normal View History

#ifndef CURSETREE_NODE_H
#define CURSETREE_NODE_H
#include "dims.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.
2025-09-13 11:21:34 +10:00
* 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)
2025-09-13 11:21:34 +10:00
enum ct_nodetype {
NODE_WINDOW,
NODE_ABSTRACT,
};
2025-09-13 11:21:34 +10:00
struct ct_node {
enum ct_nodetype type;
// union value depends on ct_node.type
union {
WINDOW *win;
struct {
2025-09-13 11:21:34 +10:00
enum ct_axis axis;
float ratio;
2025-09-13 11:21:34 +10:00
struct ct_dims *dims;
struct ct_node *child[NODE_CHILD_N];
};
};
};
/* === External Interface === */
2025-09-13 11:21:34 +10:00
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);
2025-09-13 11:21:34 +10:00
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 */