summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-06 10:59:07 -0400
committerpommicket <pommicket@gmail.com>2023-08-06 10:59:07 -0400
commit413e8f4ba1c5937de40f6366a88c26f540cbb222 (patch)
tree2e4240cfd72bdd23c5ee85e5a94e97717af95a45 /util.c
parent5891bf8f920be9cfa40cc03e86c16e6406943c20 (diff)
new menu system all done
Diffstat (limited to 'util.c')
-rw-r--r--util.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/util.c b/util.c
index 2f32015..a16f7a5 100644
--- a/util.c
+++ b/util.c
@@ -925,7 +925,6 @@ bool rect_clip_to_rect(Rect *clipped, Rect clipper) {
return clipped->size.x > 0 && clipped->size.y > 0;
}
-// removes `amount` from all sides of r
Rect rect_shrink(Rect r, float amount) {
r.pos.x += amount;
r.pos.y += amount;
@@ -936,7 +935,32 @@ Rect rect_shrink(Rect r, float amount) {
return r;
}
-// adds `amount` to all sides of r
+Rect rect_shrink_left(Rect r, float amount) {
+ r.pos.x += amount;
+ r.size.x -= amount;
+ r.size.x = maxf(r.size.x, 0);
+ return r;
+}
+
+Rect rect_shrink_top(Rect r, float amount) {
+ r.pos.y += amount;
+ r.size.y -= amount;
+ r.size.y = maxf(r.size.y, 0);
+ return r;
+}
+
+Rect rect_shrink_right(Rect r, float amount) {
+ r.size.x -= amount;
+ r.size.x = maxf(r.size.x, 0);
+ return r;
+}
+
+Rect rect_shrink_bottom(Rect r, float amount) {
+ r.size.y -= amount;
+ r.size.y = maxf(r.size.y, 0);
+ return r;
+}
+
Rect rect_grow(Rect r, float amount) {
r.pos.x -= amount;
r.pos.y -= amount;