Skip to content

Commit

Permalink
Apply Guichan's changes from 3acee30c0bb2540b2104ee2f803d8cd2844af0b9…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Sep 12, 2024
1 parent b1f4d4d commit 8d05427
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Continue rebasing from 3acee30c0bb2540b2104ee2f803d8cd2844af0b9
* Continue rebasing from 1478f70095c523d7fcb95cc37cd770afb9cd4516
* Add a focus listener interface.
* Make focus apply synchronously.
* Graphics and input objects for DirectX.
Expand Down
9 changes: 9 additions & 0 deletions include/guisan/rectangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ namespace gcn
*/
bool isPointInRect(int x, int y) const;

/**
* Checks whether the rectangle is empty or not. A rectangle
* is considered empty when it's width or height is either
* zero or negative.
*
* @return True if the rectangle is empty, false otherwise.
*/
bool isEmpty() const;

/**
* Output operator for output.
*
Expand Down
2 changes: 1 addition & 1 deletion src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace gcn
{
// Ignore area with a negative width or height
// by simple pushing an empty clip area to the stack.
if (area.width < 0 || area.height < 0)
if (area.isEmpty())
{
ClipRectangle carea;
mClipStack.push(carea);
Expand Down
5 changes: 5 additions & 0 deletions src/rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ namespace gcn
&& y < (this->y + this->height));
}

bool Rectangle::isEmpty() const
{
return width < 0 || height < 0;
}

std::ostream& operator<<(std::ostream& out, const Rectangle& rectangle)
{
return out << "Rectangle [x = " << rectangle.x << ", y = " << rectangle.y
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/scrollarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ namespace gcn
0,
getWidth() - (mVBarVisible ? mScrollbarWidth : 0),
getHeight() - (mHBarVisible ? mScrollbarWidth : 0));
if (area.width < 0 || area.height < 0)
if (area.isEmpty())
{
return Rectangle();
}
Expand Down

0 comments on commit 8d05427

Please sign in to comment.