From c8fa50eb01dcff404fe710f3d0de009b1e50fc34 Mon Sep 17 00:00:00 2001 From: Liu Chao Date: Mon, 22 Oct 2012 22:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9D=90=E6=A0=87=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=9C=89=E6=95=88=E6=80=A7=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/misc/rect.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/misc/rect.c b/src/misc/rect.c index c42f18cd..b6e34807 100644 --- a/src/misc/rect.c +++ b/src/misc/rect.c @@ -127,11 +127,20 @@ LCUI_Rect Get_Valid_Area(LCUI_Size container, LCUI_Rect rect) rect.y = 0; } - if (rect.x + rect.width > container.w) - rect.width = container.w - rect.x; - if (rect.y + rect.height > container.h) - rect.height = container.h - rect.y; - + if (rect.x + rect.width > container.w) { + if(rect.x < container.w) { + rect.width = container.w - rect.x; + } else { + rect.width = 0; + } + } + if (rect.y + rect.height > container.h) { + if(rect.y < container.h) { + rect.height = container.h - rect.y; + } else { + rect.height = 0; + } + } return rect; }