2018-03-19 02:04:13 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-04-10 19:45:33 +00:00
|
|
|
#include <tuple>
|
|
|
|
|
2018-03-19 02:04:25 +00:00
|
|
|
#include <CoreGraphics/CGBase.h>
|
|
|
|
|
2018-03-19 02:04:13 +00:00
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exact type of float numbers which ideally should match a type behing
|
2018-03-19 02:04:25 +00:00
|
|
|
* platform- and chip-architecture-specific float type.
|
|
|
|
*/
|
|
|
|
using Float = CGFloat;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Large positive number signifies that the `Float` values is `undefined`.
|
2018-03-19 02:04:13 +00:00
|
|
|
*/
|
2018-03-19 02:04:25 +00:00
|
|
|
const Float kFloatUndefined = CGFLOAT_MAX;
|
2018-03-19 02:04:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Point
|
|
|
|
*/
|
|
|
|
struct Point {
|
|
|
|
Float x {0};
|
|
|
|
Float y {0};
|
|
|
|
|
|
|
|
Point& operator += (const Point& rhs) {
|
|
|
|
x += rhs.x;
|
|
|
|
y += rhs.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend Point operator + (Point lhs, const Point& rhs) {
|
|
|
|
return lhs += rhs;
|
|
|
|
}
|
2018-03-19 23:51:29 +00:00
|
|
|
|
|
|
|
bool operator ==(const Point& rhs) const {
|
|
|
|
return
|
|
|
|
std::tie(this->x, this->y) ==
|
|
|
|
std::tie(rhs.x, rhs.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator !=(const Point& rhs) const {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
2018-03-19 02:04:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Size
|
|
|
|
*/
|
|
|
|
struct Size {
|
|
|
|
Float width {0};
|
|
|
|
Float height {0};
|
2018-03-19 23:51:29 +00:00
|
|
|
|
|
|
|
bool operator ==(const Size& rhs) const {
|
|
|
|
return
|
|
|
|
std::tie(this->width, this->height) ==
|
|
|
|
std::tie(rhs.width, rhs.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator !=(const Size& rhs) const {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
2018-03-19 02:04:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rect: Point and Size
|
|
|
|
*/
|
|
|
|
struct Rect {
|
|
|
|
Point origin {0, 0};
|
|
|
|
Size size {0, 0};
|
2018-03-19 23:51:29 +00:00
|
|
|
|
|
|
|
bool operator ==(const Rect& rhs) const {
|
|
|
|
return
|
|
|
|
std::tie(this->origin, this->size) ==
|
|
|
|
std::tie(rhs.origin, rhs.size);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator !=(const Rect& rhs) const {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
2018-03-19 02:04:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* EdgeInsets
|
|
|
|
*/
|
|
|
|
struct EdgeInsets {
|
|
|
|
Float left {0};
|
2018-03-19 23:51:29 +00:00
|
|
|
Float top {0};
|
2018-03-19 02:04:13 +00:00
|
|
|
Float right {0};
|
2018-03-19 23:51:29 +00:00
|
|
|
Float bottom {0};
|
|
|
|
|
|
|
|
bool operator ==(const EdgeInsets& rhs) const {
|
|
|
|
return
|
|
|
|
std::tie(this->left, this->top, this->right, this->bottom) ==
|
|
|
|
std::tie(rhs.left, rhs.top, rhs.right, rhs.bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator !=(const EdgeInsets& rhs) const {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
2018-03-19 02:04:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|