mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Fabric: CornerInsets: Graphical primitive for rect-corner-specific values
Summary: CornerInsets is something like EdgeInsets but about corners instead of edges. Reviewed By: fkgozali Differential Revision: D8344062 fbshipit-source-id: 9bf7a8696fba96e3124cb15e8e84093c1f4f8747
This commit is contained in:
parent
cb19621dfe
commit
e311fbb797
@ -125,5 +125,25 @@ struct EdgeInsets {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* CornerInsets
|
||||
*/
|
||||
struct CornerInsets {
|
||||
Float topLeft {0};
|
||||
Float topRight {0};
|
||||
Float bottomLeft {0};
|
||||
Float bottomRight {0};
|
||||
|
||||
bool operator ==(const CornerInsets& rhs) const {
|
||||
return
|
||||
std::tie(this->topLeft, this->topRight, this->bottomLeft, this->bottomRight) ==
|
||||
std::tie(rhs.topLeft, rhs.topRight, rhs.bottomLeft, rhs.bottomRight);
|
||||
}
|
||||
|
||||
bool operator !=(const CornerInsets& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
@ -105,6 +105,28 @@ inline void fromDynamic(const folly::dynamic &value, EdgeInsets &result) {
|
||||
abort();
|
||||
}
|
||||
|
||||
inline void fromDynamic(const folly::dynamic &value, CornerInsets &result) {
|
||||
if (value.isObject()) {
|
||||
result = CornerInsets {
|
||||
(Float)value["topLeft"].asDouble(),
|
||||
(Float)value["topRight"].asDouble(),
|
||||
(Float)value["bottomLeft"].asDouble(),
|
||||
(Float)value["bottomRight"].asDouble()
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (value.isArray()) {
|
||||
result = CornerInsets {
|
||||
(Float)value[0].asDouble(),
|
||||
(Float)value[1].asDouble(),
|
||||
(Float)value[2].asDouble(),
|
||||
(Float)value[3].asDouble()
|
||||
};
|
||||
return;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
inline std::string toString(const Point &point) {
|
||||
return "{" + folly::to<std::string>(point.x) + ", " + folly::to<std::string>(point.y) + "}";
|
||||
}
|
||||
@ -125,5 +147,13 @@ inline std::string toString(const EdgeInsets &edgeInsets) {
|
||||
folly::to<std::string>(edgeInsets.bottom) + "}";
|
||||
}
|
||||
|
||||
inline std::string toString(const CornerInsets &cornerInsets) {
|
||||
return "{" +
|
||||
folly::to<std::string>(cornerInsets.topLeft) + ", " +
|
||||
folly::to<std::string>(cornerInsets.topRight) + ", " +
|
||||
folly::to<std::string>(cornerInsets.bottomLeft) + ", " +
|
||||
folly::to<std::string>(cornerInsets.bottomRight) + "}";
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
Loading…
x
Reference in New Issue
Block a user