void Widget_UpdateVisibility(LCUI_Widget w) { LCUI_Style s = &w->style->sheet[key_visibility]; LCUI_BOOL visible = w->computed_style.visible; if (w->computed_style.display == SV_NONE) { w->computed_style.visible = FALSE; } else if (s->is_valid && s->type == LCUI_STYPE_STRING && strcmp(s->val_string, "hidden") == 0) { w->computed_style.visible = FALSE; } else { w->computed_style.visible = TRUE; } if (visible == w->computed_style.visible) { return; } if (w->parent) { Widget_InvalidateArea(w, NULL, SV_GRAPH_BOX); } visible = w->computed_style.visible; if (visible) { Widget_PostSurfaceEvent(w, LCUI_WEVENT_SHOW, TRUE); } else { Widget_PostSurfaceEvent(w, LCUI_WEVENT_HIDE, TRUE); } }
static void Widget_AddToTrash(LCUI_Widget w) { w->state = LCUI_WSTATE_DELETED; if (Widget_Unlink(w) != 0) { return; } LinkedList_AppendNode(&LCUIWidget.trash, &w->node); Widget_PostSurfaceEvent(w, LCUI_WEVENT_UNLINK, TRUE); }
static void Widget_SendResizeEvent(LCUI_Widget w) { LCUI_WidgetEventRec e; e.target = w; e.data = NULL; e.type = LCUI_WEVENT_RESIZE; e.cancel_bubble = TRUE; Widget_TriggerEvent(w, &e, NULL); Widget_AddTask(w, LCUI_WTASK_REFRESH); Widget_PostSurfaceEvent(w, LCUI_WEVENT_RESIZE, FALSE); }
void Widget_AddToTrash( LCUI_Widget w ) { LCUI_WidgetEventRec e = { 0 }; e.type = WET_REMOVE; w->state = WSTATE_DELETED; Widget_TriggerEvent( w, &e, NULL ); if( !w->parent ) { return; } LinkedList_Unlink( &w->parent->children, &w->node ); LinkedList_Unlink( &w->parent->children_show, &w->node_show ); LinkedList_AppendNode( &self.trash, &w->node ); Widget_PostSurfaceEvent( w, WET_REMOVE, TRUE ); }
static void HandleSetTitle(LCUI_Widget w) { Widget_PostSurfaceEvent(w, LCUI_WEVENT_TITLE, TRUE); }
static void HandleSetTitle( LCUI_Widget w ) { Widget_PostSurfaceEvent( w, WET_TITLE ); }
void Widget_UpdatePosition(LCUI_Widget w) { LCUI_RectF rect; int position = ComputeStyleOption(w, key_position, SV_STATIC); int valign = ComputeStyleOption(w, key_vertical_align, SV_TOP); w->computed_style.vertical_align = valign; w->computed_style.left = ComputeXMetric(w, key_left); w->computed_style.right = ComputeXMetric(w, key_right); w->computed_style.top = ComputeYMetric(w, key_top); w->computed_style.bottom = ComputeYMetric(w, key_bottom); if (w->parent && w->computed_style.position != position) { w->computed_style.position = position; Widget_UpdateLayout(w->parent); Widget_ClearComputedSize(w); Widget_UpdateChildrenSize(w); /* 当部件尺寸是按百分比动态计算的时候需要重新计算尺寸 */ if (Widget_CheckStyleType(w, key_width, scale) || Widget_CheckStyleType(w, key_height, scale)) { Widget_UpdateSize(w); } } w->computed_style.position = position; Widget_UpdateZIndex(w); rect = w->box.canvas; w->x = w->origin_x; w->y = w->origin_y; switch (position) { case SV_ABSOLUTE: w->x = w->y = 0; if (!Widget_HasAutoStyle(w, key_left)) { w->x = w->computed_style.left; } else if (!Widget_HasAutoStyle(w, key_right)) { if (w->parent) { w->x = w->parent->box.border.width; w->x -= w->width; } w->x -= w->computed_style.right; } if (!Widget_HasAutoStyle(w, key_top)) { w->y = w->computed_style.top; } else if (!Widget_HasAutoStyle(w, key_bottom)) { if (w->parent) { w->y = w->parent->box.border.height; w->y -= w->height; } w->y -= w->computed_style.bottom; } break; case SV_RELATIVE: if (!Widget_HasAutoStyle(w, key_left)) { w->x += w->computed_style.left; } else if (!Widget_HasAutoStyle(w, key_right)) { w->x -= w->computed_style.right; } if (!Widget_HasAutoStyle(w, key_top)) { w->y += w->computed_style.top; } else if (!Widget_HasAutoStyle(w, key_bottom)) { w->y -= w->computed_style.bottom; } default: if (w->parent) { w->x += w->parent->padding.left; w->y += w->parent->padding.top; } break; } switch (valign) { case SV_MIDDLE: if (!w->parent) { break; } w->y += (w->parent->box.content.height - w->height) / 2; break; case SV_BOTTOM: if (!w->parent) { break; } w->y += w->parent->box.content.height - w->height; case SV_TOP: default: break; } w->box.outer.x = w->x; w->box.outer.y = w->y; w->x += w->margin.left; w->y += w->margin.top; /* 以x、y为基础 */ w->box.padding.x = w->x; w->box.padding.y = w->y; w->box.border.x = w->x; w->box.border.y = w->y; w->box.canvas.x = w->x; w->box.canvas.y = w->y; /* 计算各个框的坐标 */ w->box.padding.x += w->computed_style.border.left.width; w->box.padding.y += w->computed_style.border.top.width; w->box.content.x = w->box.padding.x + w->padding.left; w->box.content.y = w->box.padding.y + w->padding.top; w->box.canvas.x -= Widget_GetBoxShadowOffsetX(w); w->box.canvas.y -= Widget_GetBoxShadowOffsetY(w); if (w->parent) { /* 标记移动前后的区域 */ Widget_InvalidateArea(w, NULL, SV_GRAPH_BOX); Widget_InvalidateArea(w->parent, &rect, SV_PADDING_BOX); } /* 检测是否为顶级部件并做相应处理 */ Widget_PostSurfaceEvent(w, LCUI_WEVENT_MOVE, TRUE); }
void Widget_UpdateSizeWithSurface(LCUI_Widget w) { Widget_UpdateSize(w); Widget_PostSurfaceEvent(w, LCUI_WEVENT_RESIZE, TRUE); }