예제 #1
0
파일: LCUI_Graph.c 프로젝트: fshunj/LCUI
LCUI_API int Graph_Quote( LCUI_Graph *des, LCUI_Graph *src, LCUI_Rect area )
{
	if( !src || !des ) {
		return -1;
	}
	//printf("Graph_Quote(), before, area: %d,%d,%d,%d\n",
	//	area.x, area.y, area.width, area.height);
	area = LCUIRect_ValidArea(Size(src->w, src->h), area);
	//printf("Graph_Quote(), after, area: %d,%d,%d,%d\n",
	//	area.x, area.y, area.width, area.height);
	if(!LCUIRect_IsValid( area )) { 
		des->src = NULL;
		des->x = 0;
		des->y = 0;
		des->w = 0;
		des->h= 0;
		des->alpha = 255;
		des->quote = FALSE;
		return -1;
	} 
	des->src = src;
	des->x = area.x;
	des->y = area.y;
	des->w = area.width;
	des->h = area.height;
	des->alpha = 255;
	des->quote = TRUE;
	return 0;
}
예제 #2
0
static int 
__GraphLayer_GetLayers(
	LCUI_GraphLayer *root_glayer,
	LCUI_GraphLayer *glayer, 
	LCUI_Rect rect, LCUI_Queue *queue )
{
	int i, total;
	LCUI_Pos pos;
	LCUI_Rect tmp;
	LCUI_GraphLayer *child; 
	LCUI_Queue *child_list;

	if( !glayer ) {
		//_DEBUG_MSG("!glayer\n");
		return -1;
	}
	if( !glayer->visible ) {
		//_DEBUG_MSG("!glayer_visible\n");
		return 1;
	}
	child_list = &glayer->child;
	/* 从底到顶遍历子部件 */
	total = Queue_GetTotal( child_list );
	//_DEBUG_MSG( "root: %p, cur: %p, child total: %d\n",
	//		root_glayer, glayer, total );
	/* 从尾到首,从底到顶,遍历图层 */
	for( i=total-1; i>=0; --i ) {
		child = (LCUI_GraphLayer*)Queue_Get( child_list, i );
		/* 忽略无效或不可见的图层 */
		if( !child || !child->visible ) {
			continue;
		}
		/* 获取子图层的有效区域及全局坐标 */
		tmp = GraphLayer_GetValidRect( root_glayer, child );
		pos = GraphLayer_GetGlobalPos( root_glayer, child );
		//_DEBUG_MSG( "child: %p, pos: %d,%d, valid rect: %d,%d, %d, %d\n", 
		//	child, pos.x, pos.y, tmp.x, tmp.y, tmp.width, tmp.height);
		//Graph_PrintInfo( &child->graph );
		/* 有效区域加上子部件的全局坐标 */
		tmp.x += pos.x;
		tmp.y += pos.y;
		/* 判断区域是否有效 */
		if( !LCUIRect_IsValid(tmp) ) {
			continue;
		}
		/* 若该有效区域与目标区域重叠,则记录子部件,并进行递归 */
		if( LCUIRect_Overlay(tmp, rect) ) {
			Queue_AddPointer( queue, child );
			__GraphLayer_GetLayers(	root_glayer, 
						child, rect, queue );
		}
	}
	return 0;
}