Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Guichan's changes from 3acee30c0bb2540b2104ee2f803d8cd2844af0b9… #73

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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