got nonbinary partitioning working yippie

This commit is contained in:
Emile Clark-Boman 2025-09-15 19:26:04 +10:00
parent 6b5bcff1a4
commit 330755591b
6 changed files with 170 additions and 57 deletions

View file

@ -4,6 +4,7 @@
#include <string.h>
#include "dims.h"
#include "util.h"
struct ct_dims *new_dims(int x, int y, int width, int height) {
struct ct_dims *dims;
@ -42,19 +43,17 @@ static struct ct_bounds *__bounds(const enum ct_boundtype type, const int wmin,
return bounds;
}
static inline void clamp(int *const val, const int min, const int max,
static inline void __clamp(int *const val, const int min, const int max,
const int do_ceiling) {
if (*val == __BOUND_UNLIMITED)
*val = do_ceiling ? max : min;
else if (*val > max)
*val = max;
else if (*val < min)
*val = min;
else
*val = clampi(*val, min, max);
}
#define CLAMP_ABS(val, is_max) \
(clamp(&val, __BOUND_ABS_MIN, __BOUND_ABS_MAX, is_max))
(__clamp(&val, __BOUND_ABS_MIN, __BOUND_ABS_MAX, is_max))
#define CLAMP_REL(val, is_max) \
(clamp(&val, __BOUND_REL_MIN, __BOUND_REL_MAX, is_max))
(__clamp(&val, __BOUND_REL_MIN, __BOUND_REL_MAX, is_max))
struct ct_bounds *bounds_none(void) {
return __bounds(BOUND_NONE, __BOUND_ABS_MIN, __BOUND_ABS_MAX, __BOUND_ABS_MIN,