添加坐标位置有效性判断

This commit is contained in:
Liu Chao
2012-10-22 22:09:32 +08:00
parent ad45a5d10c
commit c8fa50eb01
+14 -5
View File
@@ -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;
}