summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-11 23:46:13 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-11 23:46:13 +0300
commitd36cabcc327d586a13d30c53c579927a4837e4a3 (patch)
treef25ce540ecad8a9a046c35bf29aae68ceac930b2 /src/ui/util.c
parent25417c357d46f3ba65d7ac1ef460d52ccea41a9b (diff)
Integer range utilities
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 9aa634bc..0af33138 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -62,6 +62,19 @@ int keyMods_Sym(int kmods) {
62 return kmods; 62 return kmods;
63} 63}
64 64
65iRangei intersect_Rangei(iRangei a, iRangei b) {
66 if (a.end < b.start || a.start > b.end) {
67 return (iRangei){ 0, 0 };
68 }
69 return (iRangei){ iMax(a.start, b.start), iMin(a.end, b.end) };
70}
71
72iRangei union_Rangei(iRangei a, iRangei b) {
73 if (isEmpty_Rangei(a)) return b;
74 if (isEmpty_Rangei(b)) return a;
75 return (iRangei){ iMin(a.start, b.start), iMax(a.end, b.end) };
76}
77
65/*-----------------------------------------------------------------------------------------------*/ 78/*-----------------------------------------------------------------------------------------------*/
66 79
67void init_Click(iClick *d, iAnyObject *widget, int button) { 80void init_Click(iClick *d, iAnyObject *widget, int button) {