mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
add int32_t types support
This commit is contained in:
parent
6b94d024dc
commit
a3da8915b9
51
base/types.h
51
base/types.h
@ -5,6 +5,7 @@
|
||||
#include "os.h"
|
||||
#include "inline_keywords.h" /* For H_INLINE */
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Some generic, cross-platform types. */
|
||||
|
||||
@ -15,6 +16,13 @@ struct _MMPoint {
|
||||
|
||||
typedef struct _MMPoint MMPoint;
|
||||
|
||||
struct _MMSignedPoint {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
};
|
||||
|
||||
typedef struct _MMSignedPoint MMSignedPoint;
|
||||
|
||||
struct _MMSize {
|
||||
size_t width;
|
||||
size_t height;
|
||||
@ -22,6 +30,14 @@ struct _MMSize {
|
||||
|
||||
typedef struct _MMSize MMSize;
|
||||
|
||||
struct _MMSignedSize {
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
};
|
||||
|
||||
typedef struct _MMSignedSize MMSignedSize;
|
||||
|
||||
|
||||
struct _MMRect {
|
||||
MMPoint origin;
|
||||
MMSize size;
|
||||
@ -29,6 +45,13 @@ struct _MMRect {
|
||||
|
||||
typedef struct _MMRect MMRect;
|
||||
|
||||
struct _MMSignedRect {
|
||||
MMSignedPoint origin;
|
||||
MMSignedSize size;
|
||||
};
|
||||
|
||||
typedef struct _MMSignedRect MMSignedRect;
|
||||
|
||||
H_INLINE MMPoint MMPointMake(size_t x, size_t y)
|
||||
{
|
||||
MMPoint point;
|
||||
@ -37,6 +60,14 @@ H_INLINE MMPoint MMPointMake(size_t x, size_t y)
|
||||
return point;
|
||||
}
|
||||
|
||||
H_INLINE MMSignedPoint MMSignedPointMake(int32_t x, int32_t y)
|
||||
{
|
||||
MMSignedPoint point;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
return point;
|
||||
}
|
||||
|
||||
H_INLINE MMSize MMSizeMake(size_t width, size_t height)
|
||||
{
|
||||
MMSize size;
|
||||
@ -45,6 +76,14 @@ H_INLINE MMSize MMSizeMake(size_t width, size_t height)
|
||||
return size;
|
||||
}
|
||||
|
||||
H_INLINE MMSignedSize MMSignedSizeMake(int32_t w, int32_t h)
|
||||
{
|
||||
MMSignedSize size;
|
||||
size.w = w;
|
||||
size.h = h;
|
||||
return size;
|
||||
}
|
||||
|
||||
H_INLINE MMRect MMRectMake(size_t x, size_t y, size_t width, size_t height)
|
||||
{
|
||||
MMRect rect;
|
||||
@ -53,6 +92,15 @@ H_INLINE MMRect MMRectMake(size_t x, size_t y, size_t width, size_t height)
|
||||
return rect;
|
||||
}
|
||||
|
||||
H_INLINE MMSignedRect MMSignedRectMake(int32_t x, int32_t y, int32_t w, int32_t h)
|
||||
{
|
||||
MMSignedRect rect;
|
||||
rect.origin = MMSignedPointMake(x, y);
|
||||
rect.size = MMSignedSizeMake(w, h);
|
||||
return rect;
|
||||
}
|
||||
|
||||
//
|
||||
#define MMPointZero MMPointMake(0, 0)
|
||||
|
||||
#if defined(IS_MACOSX)
|
||||
@ -60,6 +108,9 @@ H_INLINE MMRect MMRectMake(size_t x, size_t y, size_t width, size_t height)
|
||||
#define CGPointFromMMPoint(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
|
||||
#define MMPointFromCGPoint(p) MMPointMake((size_t)(p).x, (size_t)(p).y)
|
||||
|
||||
#define CGPointFromMMSignedPoint(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
|
||||
#define MMSignedPointFromCGPoint(p) MMPointMake((int32_t)(p).x, (int32_t)(p).y)
|
||||
|
||||
#elif defined(IS_WINDOWS)
|
||||
|
||||
#define MMPointFromPOINT(p) MMPointMake((size_t)p.x, (size_t)p.y)
|
||||
|
Loading…
Reference in New Issue
Block a user