aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-02 14:35:37 +0600
committerEugene Sandulenko2016-07-03 12:24:56 +0200
commit846619fd42ecb11e94958e39bd61ea29a9ff76cd (patch)
tree5667ead84b94a8b8e5c829d023e82af1186a107a
parent6de5324742fd1ceaa00d9f361638b0c0a9882999 (diff)
downloadscummvm-rg350-846619fd42ecb11e94958e39bd61ea29a9ff76cd.tar.gz
scummvm-rg350-846619fd42ecb11e94958e39bd61ea29a9ff76cd.tar.bz2
scummvm-rg350-846619fd42ecb11e94958e39bd61ea29a9ff76cd.zip
GUI: Add checks in Widget::getBossClipRect()
Prints a warning if clipping area is invalid and fixes it.
-rw-r--r--gui/object.cpp15
-rw-r--r--gui/widget.cpp25
-rw-r--r--gui/widget.h6
3 files changed, 26 insertions, 20 deletions
diff --git a/gui/object.cpp b/gui/object.cpp
index 2d9e9597f5..de66d95492 100644
--- a/gui/object.cpp
+++ b/gui/object.cpp
@@ -44,21 +44,6 @@ void GuiObject::reflowLayout() {
if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, _w, _h)) {
error("Could not load widget position for '%s'", _name.c_str());
}
-
- /*
- if (_x < 0)
- error("Widget <%s> has x < 0 (%d)", _name.c_str(), _x);
- if (_x >= g_gui.getWidth())
- error("Widget <%s> has x > %d (%d)", _name.c_str(), g_gui.getWidth(), _x);
- if (_x + _w > g_gui.getWidth())
- error("Widget <%s> has x + w > %d (%d)", _name.c_str(), g_gui.getWidth(), _x + _w);
- if (_y < 0)
- error("Widget <%s> has y < 0 (%d)", _name.c_str(), _y);
- if (_y >= g_gui.getHeight())
- error("Widget <%s> has y > %d (%d)", _name.c_str(), g_gui.getHeight(), _y);
- if (_y + _h > g_gui.getHeight())
- error("Widget <%s> has y + h > %d (%d)", _name.c_str(), g_gui.getHeight(), _y + _h);
- */
}
}
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 56b7e91455..32ca0223c5 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -53,6 +53,31 @@ void Widget::init() {
_boss->_firstWidget = this;
}
+Common::Rect Widget::getBossClipRect() const {
+ int bx = _boss->getAbsX();
+ int by = _boss->getAbsY();
+ Common::Rect result = Common::Rect(bx, by, bx + _boss->getWidth(), by + _boss->getHeight());
+ bool needsClipping = false;
+
+ //check whether clipping area is inside the screen
+ if (result.left < 0 && (needsClipping = true))
+ warning("Widget <%s> has clipping area x < 0 (%d)", _name.c_str(), result.left);
+ if (result.left >= g_gui.getWidth() && (needsClipping = true))
+ warning("Widget <%s> has clipping area x > %d (%d)", _name.c_str(), g_gui.getWidth(), result.left);
+ if (result.right > g_gui.getWidth() && (needsClipping = true))
+ warning("Widget <%s> has clipping area x + w > %d (%d)", _name.c_str(), g_gui.getWidth(), result.right);
+ if (result.top < 0 && (needsClipping = true))
+ warning("Widget <%s> has clipping area y < 0 (%d)", _name.c_str(), result.top);
+ if (result.top >= g_gui.getHeight() && (needsClipping = true))
+ warning("Widget <%s> has clipping area y > %d (%d)", _name.c_str(), g_gui.getHeight(), result.top);
+ if (result.bottom > g_gui.getHeight() && (needsClipping = true))
+ warning("Widget <%s> has clipping area y + h > %d (%d)", _name.c_str(), g_gui.getHeight(), result.bottom);
+
+ if (needsClipping)
+ result.clip(g_gui.getWidth(), g_gui.getHeight());
+ return result;
+}
+
Widget::~Widget() {
delete _next;
_next = 0;
diff --git a/gui/widget.h b/gui/widget.h
index db801fa49b..0f4b300233 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -112,11 +112,7 @@ public:
virtual int16 getAbsX() const { return _x + _boss->getChildX(); }
virtual int16 getAbsY() const { return _y + _boss->getChildY(); }
- virtual Common::Rect getBossClipRect() const {
- int px = _boss->getAbsX();
- int py = _boss->getAbsY();
- return Common::Rect(px, py, px + _boss->getWidth(), py + _boss->getHeight());
- }
+ virtual Common::Rect getBossClipRect() const;
virtual void setPos(int x, int y) { _x = x; _y = y; }
virtual void setSize(int w, int h) { _w = w; _h = h; }