Add Coords constructor to Map and CoordsRange

This commit is contained in:
Tulio Leao 2020-06-30 09:12:14 -03:00
parent 701f7f6d67
commit 70e245a1c3
1 changed files with 13 additions and 3 deletions

View File

@ -636,8 +636,13 @@ template<class T> struct CoordsRange
CoordsRange() = default; CoordsRange() = default;
CoordsRange(int32_t left, int32_t top, int32_t right, int32_t bottom) CoordsRange(int32_t left, int32_t top, int32_t right, int32_t bottom)
: LeftTop(left, top) : CoordsRange({ left, top }, { right, bottom })
, RightBottom(right, bottom) {
}
CoordsRange(const T& leftTop, const T& rightBottom)
: LeftTop(leftTop)
, RightBottom(rightBottom)
{ {
} }
}; };
@ -650,7 +655,12 @@ struct MapRange : public CoordsRange<CoordsXY>
{ {
using CoordsRange::CoordsRange; using CoordsRange::CoordsRange;
MapRange(int32_t left, int32_t top, int32_t right, int32_t bottom) MapRange(int32_t left, int32_t top, int32_t right, int32_t bottom)
: CoordsRange<CoordsXY>(left, top, right, bottom) : MapRange({ left, top }, { right, bottom })
{
}
MapRange(const CoordsXY& leftTop, const CoordsXY& rightBottom)
: CoordsRange<CoordsXY>(leftTop, rightBottom)
{ {
// Make sure it's a rectangle // Make sure it's a rectangle
assert(std::abs(GetLeft() - GetRight()) > 0); assert(std::abs(GetLeft() - GetRight()) > 0);