From aa5dc657fd1aec8a963a4d91f522152743639e4b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 6 Jan 2024 19:38:20 +0900 Subject: [PATCH] [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. --- include/QF/ui/view.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/QF/ui/view.h b/include/QF/ui/view.h index 6efe73747..ce8d5e161 100644 --- a/include/QF/ui/view.h +++ b/include/QF/ui/view.h @@ -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)