Exemplo n.º 1
0
static void check_widget_rect( LCUI_SysEvent ev, void *arg )
{
	int ret = 0;
	LCUI_RectF rectf;
	LCUI_Rect rect, old_rect;
	LCUI_Rect *paint_rect = &ev->paint.rect;

	rectf.x = self.x;
	rectf.y = self.y;
	rectf.width = WIDGET_WIDTH;
	rectf.height = WIDGET_WIDTH;
	LCUIMetrics_ComputeRectActual( &old_rect, &rectf );
	LCUIMetrics_ComputeRectActual( &rect, &self.widget->box.canvas );
	LCUIRect_MergeRect( &rect, &rect, &old_rect );
	CHECK2( check_rect_correct( &rect, paint_rect ) );
	if( ret != 0 ) {
		TEST_LOG( "[%d] correct: (%d, %d, %d, %d),"
			  " actual: (%d, %d, %d, %d)\n", self.step,
			  rect.x, rect.y, rect.width, rect.height,
			  paint_rect->x, paint_rect->y,
			  paint_rect->width, paint_rect->height );
	} else {
		self.pass += 1;
	}
	self.count += 1;
	self.x = self.widget->x;
	self.y = self.widget->y;
	LCUI_PostSimpleTask( test_move_widget, NULL, NULL );
}
Exemplo n.º 2
0
static size_t WidgetRenderer_RenderChildren( LCUI_WidgetRenderer that )
{
	size_t count = 0;
	LCUI_Widget child;
	LinkedListNode *node;
	LCUI_RectF rect;
	LCUI_PaintContextRec paint;
	LCUI_WidgetRenderer renderer;
	LCUI_Rect actual_rect, paint_rect;

	/* 按照显示顺序,从底到顶,递归遍历子级部件 */
	for( LinkedList_EachReverse( node, &that->target->children_show ) ) {
		child = node->data;
		if( !child->computed_style.visible ||
		    child->state != WSTATE_NORMAL ) {
			continue;
		}
		rect.width = child->box.graph.width;
		rect.height = child->box.graph.height;
		rect.x = that->x + child->box.graph.x + that->content_left;
		rect.y = that->y + child->box.graph.y + that->content_top;
		/* 栅格化部件区域,即:转换为相对于根级部件的实际区域 */
		LCUIMetrics_ComputeRectActual( &actual_rect, &rect );
		if( !LCUIRect_GetOverlayRect( &that->content_rect,
					      &actual_rect,
					      &paint_rect ) ) {
			continue;
		}
		if( !LCUIRect_GetOverlayRect( &that->root_paint->rect,
					      &paint_rect,
					      &paint_rect ) ) {
			continue;
		}
		if( that->has_content_graph ) {
			paint.with_alpha = TRUE;
		} else {
			paint.with_alpha = that->paint->with_alpha;
		}
		paint.rect = paint_rect;
		/* 转换绘制区域坐标为相对于自身图层区域 */
		paint.rect.x -= actual_rect.x;
		paint.rect.y -= actual_rect.y;
		/* 转换绘制区域坐标为相对于部件内容区域,作为子部件的绘制区域 */
		paint_rect.x -= that->root_paint->rect.x;
		paint_rect.y -= that->root_paint->rect.y;
		Graph_Quote( &paint.canvas, &that->root_paint->canvas,
			     &paint_rect );
		renderer = WidgetRenderer( child, &paint, that );
		count += WidgetRenderer_Render( renderer );
		WidgetRenderer_Delete( renderer );
	}
	return count;
}
Exemplo n.º 3
0
static LCUI_WidgetRenderer WidgetRenderer( LCUI_Widget w,
					   LCUI_PaintContext paint,
					   LCUI_WidgetRenderer parent )
{
	LCUI_RectF rect;
	ASSIGN( that, LCUI_WidgetRenderer );

	that->target = w;
	that->paint = paint;
	that->is_cover_border = FALSE;
	that->has_self_graph = FALSE;
	that->has_layer_graph = FALSE;
	that->has_content_graph = FALSE;
	if( parent ) {
		that->root_paint = parent->root_paint;
		that->x = parent->x + parent->content_left + w->box.graph.x;
		that->y = parent->y + parent->content_top + w->box.graph.y;
	} else {
		that->x = that->y = 0;
		that->root_paint = that->paint;
	}
	/* 若部件本身是透明的 */
	if( w->computed_style.opacity < 1.0 ) {
		that->has_self_graph = TRUE;
		that->has_content_graph = TRUE;
		that->has_layer_graph = TRUE;
	} else {
		/* 若使用了圆角边框,则判断当前脏矩形区域是否在圆角边框内
		...
		if( ... ) {
			that->has_content_graph = TRUE;
			that->is_cover_border = TRUE;
		}
		*/
	}
	Graph_Init( &that->self_graph );
	Graph_Init( &that->layer_graph );
	Graph_Init( &that->content_graph );
	that->layer_graph.color_type = COLOR_TYPE_ARGB;
	that->can_render_self = Widget_IsPaintable( w );
	if( that->can_render_self ) {
		that->self_graph.color_type = COLOR_TYPE_ARGB;
		Graph_Create( &that->self_graph,
			      that->paint->rect.width,
			      that->paint->rect.height );
	}
	/* 获取内容框相对于图层的间距 */
	that->content_left = w->box.padding.x - w->box.graph.x;
	that->content_top = w->box.padding.y - w->box.graph.y;
	/* 获取内容区域,相对于根级部件 */
	rect.x = that->x + that->content_left;
	rect.y = that->y + that->content_top;
	rect.width = w->box.padding.width;
	rect.height = w->box.padding.height;
	/* 栅格化内容区域 */
	LCUIMetrics_ComputeRectActual( &that->content_rect, &rect );
	rect.x -= that->x;
	rect.y -= that->y;
	LCUIMetrics_ComputeRectActual( &that->content_paint_rect, &rect );
	/* 获取内容区域中实际需要绘制的区域 */
	that->can_render_centent = LCUIRect_GetOverlayRect(
		&that->content_paint_rect, &that->paint->rect,
		&that->content_paint_rect
	);
	/* 转换坐标为相对于绘制区域 */
	that->content_paint_rect.x -= that->paint->rect.x;
	that->content_paint_rect.y -= that->paint->rect.y;
	if( !that->can_render_centent ) {
		return that;
	}
	/* 若需要部件内容区的位图缓存 */
	if( that->has_content_graph ) {
		that->content_graph.color_type = COLOR_TYPE_ARGB;
		Graph_Create( &that->content_graph, that->content_paint_rect.width,
			      that->content_paint_rect.height );
	}
	return that;
}
Exemplo n.º 4
0
void RectToInvalidArea( const LCUI_Rect *rect, LCUI_Rect *area )
{
	LCUI_RectF rectf;
	LCUIRect_ToRectF( rect, &rectf, 1.0f );
	LCUIMetrics_ComputeRectActual( area, &rectf );
}
Exemplo n.º 5
0
void RectFToInvalidArea( const LCUI_RectF *rect, LCUI_Rect *area )
{
	LCUIMetrics_ComputeRectActual( area, rect );
}