bug fixes + general X axis splitting!

This commit is contained in:
Emile Clark-Boman 2025-09-16 21:30:14 +10:00
parent 5e99b09f8a
commit dce97e6b3e
6 changed files with 69 additions and 33 deletions

View file

@ -1,5 +1,6 @@
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -119,7 +120,7 @@ int resize_node(struct ct_node *const node, struct ct_dims *dims) {
assert(node->axis == AXIS_Y);
axm_free = dims->height;
axm_size = dims->height;
/* DEBUG: WARNING :DEBUG */
// dims_axm_pos_offset = offsetof(struct ct_dims, y);
// dims_axm_size_offset = offsetof(struct ct_dims, height);
@ -138,7 +139,7 @@ int resize_node(struct ct_node *const node, struct ct_dims *dims) {
// *(int *)(node->child[i]->surface->bounds + bounds_axm_max_offset);
cspdims[i].min = node->child[i]->surface->bounds->wmin;
cspdims[i].max = node->child[i]->surface->bounds->wmax;
if (node->child[i]->surface->bounds->type == BOUND_RELATIVE) {
cspdims[i].min *= axm_size;
cspdims[i].max *= axm_size;
@ -236,9 +237,9 @@ int insert_child_node(struct ct_node *const parent, struct ct_node *const child,
return 2;
else if (parent->cindex == parent->csize) {
// grow child array size and clamp maximum
parent->csize *= NODE_CHILDREN_GROWTH;
if (parent->csize > CINDEX_MAX)
parent->csize = CINDEX_MAX;
cindex new_csize = parent->csize * NODE_CHILDREN_GROWTH;
// check overflow
parent->csize = (parent->csize <= new_csize) ? new_csize : CINDEX_MAX;
parent->child =
reallocarray(parent->child, parent->csize, sizeof(struct ct_node *));