From 0d9984d91b19a509b7438f339f8ade43cb49cccb Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Fri, 6 Sep 2024 19:07:03 +0200 Subject: [PATCH] Apply Guichan's changes from 3acee30c0bb2540b2104ee2f803d8cd2844af0b9 (Sept 19th 2008) http://code.google.com/p/guichan/issues/detail?id=75 --- TODO | 2 +- include/guisan/rectangle.hpp | 9 +++++++++ src/graphics.cpp | 2 +- src/rectangle.cpp | 5 +++++ src/widgets/scrollarea.cpp | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index f5ecb01..284fcf7 100644 --- a/TODO +++ b/TODO @@ -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. diff --git a/include/guisan/rectangle.hpp b/include/guisan/rectangle.hpp index 55c2042..4c45698 100644 --- a/include/guisan/rectangle.hpp +++ b/include/guisan/rectangle.hpp @@ -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. * diff --git a/src/graphics.cpp b/src/graphics.cpp index 902067f..44b7af1 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -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); diff --git a/src/rectangle.cpp b/src/rectangle.cpp index 666fafd..985041a 100644 --- a/src/rectangle.cpp +++ b/src/rectangle.cpp @@ -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 diff --git a/src/widgets/scrollarea.cpp b/src/widgets/scrollarea.cpp index 961b214..0c98ba2 100644 --- a/src/widgets/scrollarea.cpp +++ b/src/widgets/scrollarea.cpp @@ -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(); }