forked from autopilot-rs/autopy-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
69 lines (51 loc) · 1.15 KB
/
types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#ifndef TYPES_H
#define TYPES_H
#include "os.h"
#include "inline_keywords.h" /* For H_INLINE */
#include <stddef.h>
/* Some generic, cross-platform types. */
struct _MMPoint {
size_t x;
size_t y;
};
typedef struct _MMPoint MMPoint;
struct _MMSize {
size_t width;
size_t height;
};
typedef struct _MMSize MMSize;
struct _MMRect {
MMPoint origin;
MMSize size;
};
typedef struct _MMRect MMRect;
H_INLINE MMPoint MMPointMake(size_t x, size_t y)
{
MMPoint point;
point.x = x;
point.y = y;
return point;
}
H_INLINE MMSize MMSizeMake(size_t width, size_t height)
{
MMSize size;
size.width = width;
size.height = height;
return size;
}
H_INLINE MMRect MMRectMake(size_t x, size_t y, size_t width, size_t height)
{
MMRect rect;
rect.origin = MMPointMake(x, y);
rect.size = MMSizeMake(width, height);
return rect;
}
#define MMPointZero MMPointMake(0, 0)
#if defined(IS_MACOSX)
#define CGPointFromMMPoint(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
#define MMPointFromCGPoint(p) MMPointMake((size_t)(p).x, (size_t)(p).y)
#elif defined(IS_WINDOWS)
#define MMPointFromPOINT(p) MMPointMake((size_t)p.x, (size_t)p.y)
#endif
#endif /* TYPES_H */