dorne/cursetree/surface.c
Emile Clark-Boman 759920a9cc (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.
2025-09-13 23:45:56 +10:00

46 lines
1.3 KiB
C

#include <stdlib.h>
#include "ncrswrap.h"
#include "surface.h"
static inline struct ct_surface *__surface(struct ct_dims *const dims,
struct ct_bounds *const bounds,
WINDOW *const win) {
struct ct_surface *surface;
surface = (struct ct_surface *)malloc(sizeof(struct ct_surface));
*surface = (struct ct_surface){
.dims = dims,
.bounds = bounds,
.win = win,
.updatereq = true,
};
return surface;
}
struct ct_surface *new_surface(struct ct_dims *const dims,
struct ct_bounds *const bounds) {
WINDOW *const win = new_window(dims->x, dims->y, dims->width, dims->height);
return __surface(dims, bounds, win);
}
void destroy_surface(struct ct_surface *const surface) {
destroy_window(surface->win);
free(surface->dims);
}
void resize_surface(struct ct_surface *const surface,
struct ct_dims *const dims) {
free(surface->dims);
surface->dims = dims;
surface->updatereq = true;
resizemv_window(surface->win, dims->x, dims->y, dims->width, dims->height);
}
void rebind_surface(struct ct_surface *const surface,
struct ct_bounds *const bounds) {
free(surface->bounds);
surface->bounds = bounds;
}