解决部件无法显示、部件client图层高度计算错误的问题

This commit is contained in:
Liu Chao
2013-01-18 21:30:59 +08:00
parent 85f63ee6e6
commit 262c287317
6 changed files with 49 additions and 29 deletions
+17 -1
View File
@@ -68,6 +68,7 @@ int GraphLayer_AddChild( LCUI_GraphLayer *des_ctnr,
{
int i, total;
LCUI_GraphLayer *tmp_child;
/* 容器图层必须有效 */
if( !des_ctnr ) {
return -1;
@@ -342,9 +343,11 @@ __GraphLayer_GetLayers(
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;
@@ -363,6 +366,7 @@ __GraphLayer_GetLayers(
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);
//Print_Graph_Info( &child->graph );
tmp.x += pos.x;
tmp.y += pos.y;
if( !Rect_Valid(tmp) ) {
@@ -382,6 +386,8 @@ int GraphLayer_GetLayers(
LCUI_GraphLayer *glayer,
LCUI_Rect rect, LCUI_Queue *queue )
{
//_DEBUG_MSG("rect: %d,%d,%d,%d\n",
//rect.x, rect.y, rect.width, rect.height);
return __GraphLayer_GetLayers( glayer, glayer, rect, queue );
}
@@ -467,13 +473,23 @@ skip_loop:
Graph_Cut (&ctnr->graph, rect, graph_buff );
}
for(i=0; i<total; ++i) {
glayer = Queue_Get( &glayerQ, i );
glayer = Queue_Get( &glayerQ, i );
//_DEBUG_MSG("%p = Queue_Get( %p, %d )\n", glayer, &glayerQ, i);
if( !glayer ) {
continue;
}
pos = GraphLayer_GetGlobalPos( ctnr, glayer );
valid_area = GraphLayer_GetValidRect( ctnr, glayer );
Quote_Graph( &tmp_graph, &glayer->graph, valid_area );
//_DEBUG_MSG("valid area: %d,%d,%d,%d, pos: %d,%d, size: %d,%d\n",
// valid_area.x, valid_area.y, valid_area.width, valid_area.height,
// pos.x, pos.y, glayer->graph.width, glayer->graph.height
// );
/* 获取相对坐标 */
pos.x = pos.x - rect.x + valid_area.x;
pos.y = pos.y - rect.y + valid_area.y;
//_DEBUG_MSG("mix pos: %d,%d\n", pos.x, pos.y);
/* 如果该图层没有继承父图层的透明度 */
if( !glayer->inherit_alpha ) {
Graph_Mix( graph_buff, &tmp_graph, pos );
+16 -10
View File
@@ -693,14 +693,14 @@ int Widget_InvalidArea ( LCUI_Widget *widget, LCUI_Rect rect )
LCUI_Sys.need_sync_area = TRUE;
}
/* 以“写”模式使用该队列 */
//Queue_Using( &widget->invalid_area, RWLOCK_WRITE );
Queue_Using( &widget->invalid_area, RWLOCK_WRITE );
/* 保存至队列中 */
if(0 != Queue_Add( &widget->invalid_area, &rect ) ) {
//Queue_End_Use( &widget->invalid_area );
Queue_End_Use( &widget->invalid_area );
return -1;
}
/* 使用结束 */
//Queue_End_Use( &widget->invalid_area );
Queue_End_Use( &widget->invalid_area );
return 0;
}
@@ -1150,8 +1150,13 @@ LCUI_Widget *Create_Widget( const char *widget_type )
GraphLayer_AddChild( LCUI_Sys.root_glayer, widget.main_glayer );
/* 继承主图层的透明度 */
GraphLayer_InerntAlpha( widget.client_glayer, TRUE );
/* 部件图形设为有alpha通道 */
/* 设定图层属性 */
widget.main_glayer->graph.have_alpha = TRUE;
widget.client_glayer->graph.have_alpha = TRUE;
//widget.client_glayer->graph.is_opaque = FALSE;
//widget.client_glayer->graph.not_visible = TRUE;
/* 显示图层 */
GraphLayer_Show( widget.client_glayer );
Graph_Init( &widget.background_image ); /* 初始化背景图数据 */
RectQueue_Init( &widget.invalid_area ); /* 初始化无效区域记录 */
@@ -1163,7 +1168,7 @@ LCUI_Widget *Create_Widget( const char *widget_type )
/* 最后,将该部件数据添加至部件队列中 */
pos = Queue_Add(&LCUI_Sys.widget_list, &widget);
p = (LCUI_Widget*)Queue_Get(&LCUI_Sys.widget_list, pos);
p = Queue_Get(&LCUI_Sys.widget_list, pos);
if( !widget_type ) {
return p;
@@ -1503,6 +1508,7 @@ void Exec_Move_Widget( LCUI_Widget *widget, LCUI_Pos pos )
/* 否则,直接改坐标 */
widget->pos = pos;
}
GraphLayer_SetPos( widget->main_glayer, pos.x, pos.y );
}
void Exec_Hide_Widget(LCUI_Widget *widget)
@@ -1623,12 +1629,13 @@ void Exec_Resize_Widget(LCUI_Widget *widget, LCUI_Size size)
} else {
widget->size = size;
}
//_DEBUG_MSG("size: %d, %d\n", size.w, size.h);
GraphLayer_Resize( widget->main_glayer, size.w, size.h );
/* 调整客户区图层尺寸 */
size.w -= (widget->padding.left + widget->padding.right);
size.h -= (widget->padding.top + widget->padding.bottom);
GraphLayer_Resize( widget->main_glayer, size.w, size.h );
//_DEBUG_MSG("size: %d, %d\n", size.w, size.h);
GraphLayer_Resize( widget->client_glayer, size.w, size.h );
/* 获取改变部件尺寸时需要调用的函数 */
func_resize = Get_WidgetFunc_By_ID( widget->type_id, FUNC_TYPE_RESIZE );
@@ -1667,10 +1674,9 @@ void Exec_Update_Widget(LCUI_Widget *widget)
func_update = Get_WidgetFunc_By_ID( widget->type_id, FUNC_TYPE_UPDATE );
GraphLayer_SetPos( widget->client_glayer,
widget->padding.left, widget->padding.top );
size.w = widget->size.w;
size = widget->size;
size.w -= (widget->padding.left + widget->padding.right);
size.h = widget->size.h;
size.h = (widget->padding.top + widget->padding.bottom);
size.h -= (widget->padding.top + widget->padding.bottom);
GraphLayer_Resize( widget->client_glayer, size.w, size.h );
func_update( widget );
}
+1 -1
View File
@@ -210,9 +210,9 @@ void LCUI_Font_Init(LCUI_Font *font)
//font->space = 1;
//font->linegap = 0;
font->status = KILLED;
#ifdef USE_FREETYPE
//font->load_flags = FT_LOAD_RENDER | FT_LOAD_NO_BITMAP | FT_LOAD_FORCE_AUTOHINT;
//font->load_flags = FT_LOAD_RENDER | FT_LOAD_MONOCHROME;
#ifdef USE_FREETYPE
font->load_flags = FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT;
font->render_mode = FT_RENDER_MODE_MONO;
#else
+2
View File
@@ -256,6 +256,8 @@ int Screen_Init()
graph = GraphLayer_GetSelfGraph( LCUI_Sys.root_glayer );
/* 保存当前屏幕内容,以便退出LCUI后还原 */
Get_Screen_Graph( graph );
/* 显示根图层 */
GraphLayer_Show( LCUI_Sys.root_glayer );
return 0;
}
+2 -8
View File
@@ -197,16 +197,10 @@ Handle_Refresh_Area( void )
* 最终的局部刷新区域数据添加至屏幕刷新区域队列中,等
* 待LCUI来处理。
**/
{
/* 如果flag标志的值为IS_TRUE */
{
if ( LCUI_Sys.need_sync_area ) {
/* 转移部件内记录的区域至主记录中 */
/* 同步部件内记录的区域至主记录中 */
Widget_SyncInvalidArea( NULL );
/*
* 复位标志,这是为了避免每次进入本函数时都要进入递归,并对各
* 个部件的矩形数据进行移动,因为这是浪费时间,降低了程序的效
* 率
* */
LCUI_Sys.need_sync_area = FALSE;
}
}
+11 -9
View File
@@ -124,23 +124,25 @@ void *change_fonttype()
int main(int argc, char *argv[])
{
thread_t t;
//thread_t t;
setenv( "LCUI_FONTFILE", "../fonts/simsun.ttc", TRUE );
LCUI_Init(argc, argv);
window = Create_Widget("window");
text = Create_Widget("label");
filename = scan_fontfile("../fonts/", &total_files);
//filename = scan_fontfile("../fonts/", &total_files);
Resize_Widget(window, Size(320, 240));
Set_Window_Title_Text( window, "测试simsun.ttc" );
Label_Text( text,
"<size=25px><color=0,0,0>abcdefghijklmn</color>\n"
"<color=165,42,42>opqrstuvwxyz</color>\n"
"<color=30,144,255>ABCDEFGHIJKLMN</color>\n"
"<color=0,75,65>OPQRSTUVWXYZ</color>\n"
"<color=255,0,0>1234567890.:,;(*!?)</color>\n"
"<color=0,215,0>中国创造,慧及全球!</color></size>");
"<size=10px>10px: 汉字,abcdefghijklmn,opqrstuvwxyz</size>\n"
"<size=11px>11px: 汉字,abcdefghijklmn,opqrstuvwxyz</size>\n"
"<size=12px>12px: 汉字,ABCDEFGHIJKLMN,OPQRSTUVWXYZ</size>\n"
"<size=14px>14px: 汉字,ABCDEFGHIJKLMN,OPQRSTUVWXYZ</size>\n"
"<size=16px>16px: 汉字,1234567890.:,;(*!?)</size>\n"
"<size=18px>18px: 中国创造,慧及全球!</size>");
Set_Widget_Align(text, ALIGN_MIDDLE_CENTER, Pos(0,0));
Window_Client_Area_Add(window, text);
Show_Widget(text);
Show_Widget(window);
LCUI_Thread_Create(&t, NULL, change_fonttype, NULL);
//LCUI_Thread_Create(&t, NULL, change_fonttype, NULL);
return LCUI_Main();
}