Skip to content

Commit

Permalink
libdeng2|Vector: Added a conversion method to an unsigned int vector
Browse files Browse the repository at this point in the history
Also used for a RuleRectangle::sizeui() method.
  • Loading branch information
skyjake committed Dec 9, 2013
1 parent dfbf6ed commit a8a9cef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doomsday/libdeng2/include/de/core/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class Vector2
Vector2<dint> toVector2i() const {
return Vector2<dint>(dint(x), dint(y));
}
Vector2<duint> toVector2ui() const {
return Vector2<duint>(duint(de::max(Type(0), x)), duint(de::max(Type(0), y)));
}
Type &operator [] (int index) {
DENG2_ASSERT(index >= 0 && index <= 1);
Type *ptrs[] = { &x, &y };
Expand Down
2 changes: 2 additions & 0 deletions doomsday/libdeng2/include/de/widgets/rulerectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class DENG2_PUBLIC RuleRectangle
*/
Vector2i sizei() const;

Vector2ui sizeui() const;

/**
* Returns the current rectangle as defined by the input rules.
* Values are floored to integers.
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libdeng2/src/widgets/rulerectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ Vector2i RuleRectangle::sizei() const
return Vector2i(width().valuei(), height().valuei());
}

Vector2ui RuleRectangle::sizeui() const
{
return sizei().toVector2ui();
}

Rectanglei RuleRectangle::recti() const
{
Rectanglef const r = rect();
Expand Down

0 comments on commit a8a9cef

Please sign in to comment.