(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
46
cursetree/surface.c
Normal file
46
cursetree/surface.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue