[ui] Add some basic math ops for view_pos_t

Just add and subtract, but I got tired of having to write two lines of
code for such.
This commit is contained in:
Bill Currie 2024-01-06 19:38:20 +09:00
parent 082d00b6c3
commit aa5dc657fd

View file

@ -138,6 +138,9 @@ typedef void (*view_move_f) (view_t view, view_pos_t abs);
#define VIEWINLINE GNU89INLINE inline
VIEWINLINE view_pos_t VP_add (view_pos_t a, view_pos_t b);
VIEWINLINE view_pos_t VP_sub (view_pos_t a, view_pos_t b);
VIEWINLINE view_t View_FromEntity (ecs_system_t viewsys, uint32_t ent);
view_t View_New (ecs_system_t viewsys, view_t parent);
view_t View_AddToEntity (uint32_t ent, ecs_system_t viewsys, view_t parent,
@ -185,6 +188,24 @@ VIEWINLINE void View_SetOnMove (view_t view, view_move_f onmove);
#define VIEWINLINE VISIBLE
#endif
VIEWINLINE view_pos_t
VP_add (view_pos_t a, view_pos_t b)
{
return (view_pos_t) {
.x = a.x + b.x,
.y = a.y + b.y,
};
}
VIEWINLINE view_pos_t
VP_sub (view_pos_t a, view_pos_t b)
{
return (view_pos_t) {
.x = a.x - b.x,
.y = a.y - b.y,
};
}
VIEWINLINE
view_t
View_FromEntity (ecs_system_t viewsys, uint32_t ent)