mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-04 03:15:59 -04:00
Add Point and Rect setters
While here, fix Rect::GetX2 and Rect::GetY2 off-by-one errors
This commit is contained in:
parent
14819ba188
commit
802322ef1b
@ -76,9 +76,19 @@ int Point::GetX() const {
|
|||||||
return point_->x;
|
return point_->x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Point::SetX(int x) {
|
||||||
|
assert(!IsNull());
|
||||||
|
point_->x = x;
|
||||||
|
}
|
||||||
|
|
||||||
int Point::GetY() const {
|
int Point::GetY() const {
|
||||||
assert(!IsNull());
|
assert(!IsNull());
|
||||||
return point_->y;
|
return point_->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Point::SetY(int y) {
|
||||||
|
assert(!IsNull());
|
||||||
|
point_->y = y;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,10 @@ public:
|
|||||||
bool IsNull() const;
|
bool IsNull() const;
|
||||||
|
|
||||||
int GetX() const;
|
int GetX() const;
|
||||||
|
void SetX(int x);
|
||||||
|
|
||||||
int GetY() const;
|
int GetY() const;
|
||||||
|
void SetY(int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,29 +86,59 @@ int Rect::GetX() const {
|
|||||||
return rect_->x;
|
return rect_->x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rect::SetX(int x) {
|
||||||
|
assert(!IsNull());
|
||||||
|
rect_->x = x;
|
||||||
|
}
|
||||||
|
|
||||||
int Rect::GetY() const {
|
int Rect::GetY() const {
|
||||||
assert(!IsNull());
|
assert(!IsNull());
|
||||||
return rect_->y;
|
return rect_->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rect::SetY(int y) {
|
||||||
|
assert(!IsNull());
|
||||||
|
rect_->y = y;
|
||||||
|
}
|
||||||
|
|
||||||
int Rect::GetW() const {
|
int Rect::GetW() const {
|
||||||
assert(!IsNull());
|
assert(!IsNull());
|
||||||
return rect_->w;
|
return rect_->w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rect::SetW(int w) {
|
||||||
|
assert(!IsNull());
|
||||||
|
rect_->w = w;
|
||||||
|
}
|
||||||
|
|
||||||
int Rect::GetH() const {
|
int Rect::GetH() const {
|
||||||
assert(!IsNull());
|
assert(!IsNull());
|
||||||
return rect_->h;
|
return rect_->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rect::SetH(int h) {
|
||||||
|
assert(!IsNull());
|
||||||
|
rect_->h = h;
|
||||||
|
}
|
||||||
|
|
||||||
int Rect::GetX2() const {
|
int Rect::GetX2() const {
|
||||||
assert(!IsNull());
|
assert(!IsNull());
|
||||||
return rect_->x + rect_->w;
|
return rect_->x + rect_->w - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rect::SetX2(int x2) {
|
||||||
|
assert(!IsNull());
|
||||||
|
rect_->w = x2 - rect_->x + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Rect::GetY2() const {
|
int Rect::GetY2() const {
|
||||||
assert(!IsNull());
|
assert(!IsNull());
|
||||||
return rect_->y + rect_->h;
|
return rect_->y + rect_->h - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rect::SetY2(int y2) {
|
||||||
|
assert(!IsNull());
|
||||||
|
rect_->h = y2 - rect_->y + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,22 @@ public:
|
|||||||
bool IsNull() const;
|
bool IsNull() const;
|
||||||
|
|
||||||
int GetX() const;
|
int GetX() const;
|
||||||
|
void SetX(int x);
|
||||||
|
|
||||||
int GetY() const;
|
int GetY() const;
|
||||||
|
void SetY(int y);
|
||||||
|
|
||||||
int GetW() const;
|
int GetW() const;
|
||||||
|
void SetW(int w);
|
||||||
|
|
||||||
int GetH() const;
|
int GetH() const;
|
||||||
|
void SetH(int h);
|
||||||
|
|
||||||
int GetX2() const;
|
int GetX2() const;
|
||||||
|
void SetX2(int x2);
|
||||||
|
|
||||||
int GetY2() const;
|
int GetY2() const;
|
||||||
|
void SetY2(int y2);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user