correct placement and box model

This commit is contained in:
Alessandro Mauri 2024-11-14 23:42:20 +01:00
parent 250a0fb3b5
commit 763e9ba8d6
5 changed files with 85 additions and 42 deletions

View file

@ -52,6 +52,11 @@ enum DivLayout {
// div element
struct Div {
DivLayout layout;
bool can_scroll_x;
bool can_scroll_y;
isz vertical_scroll_bar;
isz horizontal_scroll_bar;
Rect children_bounds;
Point origin_r, origin_c;
Color color_bg;
}
@ -208,3 +213,9 @@ macro rect_intersection(Rect a, Rect b)
.h = (short)min(a.y+a.h, b.y+b.h) - (short)max(a.y, b.y),
};
}
// rect intersection not null
macro rect_collision(Rect a, Rect b)
{
return !(a.x > b.x+b.w || a.x+a.w < b.x || a.y > b.y+b.h || a.y+a.h < b.y);
}