improve layout param

This commit is contained in:
lixianjing 2023-05-30 17:48:33 +08:00
parent a91821aa2a
commit 769858a914
2 changed files with 16 additions and 11 deletions

View File

@ -2,6 +2,7 @@
2023/05/30
* popup恢复支持高亮(感谢智明提供补丁)。
* 修复在linux上面设置layout\_params出错的问题(感谢智明提供补丁)。
2023/05/29
* main\_loop\_dispatch\_events支持分发EVT\_KEY\_LONG\_PRESS

View File

@ -166,38 +166,42 @@ ret_t widget_set_children_layout(widget_t* widget, const char* params) {
ret_t widget_set_self_layout_params(widget_t* widget, const char* x, const char* y, const char* w,
const char* h) {
bool_t one = FALSE;
char params[128] = {0};
if (widget->self_layout == NULL) {
tk_strcpy(params, "default(");
ret_t ret;
str_t params;
str_init(&params, 128);
str_append(&params, "default(");
if (x != NULL) {
one = TRUE;
tk_snprintf(params, sizeof(params) - 1, "%sx=%s", params, x);
str_append_format(&params, 128, "x=%s", x);
}
if (y != NULL) {
if (one) {
tk_snprintf(params, sizeof(params) - 1, "%s, ", params);
str_append(&params, ", ");
}
one = TRUE;
tk_snprintf(params, sizeof(params) - 1, "%sy=%s", params, y);
str_append_format(&params, 128, "y=%s", y);
}
if (w != NULL) {
if (one) {
tk_snprintf(params, sizeof(params) - 1, "%s, ", params);
str_append(&params, ", ");
}
one = TRUE;
tk_snprintf(params, sizeof(params) - 1, "%sw=%s", params, w);
str_append_format(&params, 128, "w=%s", w);
}
if (h != NULL) {
if (one) {
tk_snprintf(params, sizeof(params) - 1, "%s, ", params);
str_append(&params, ", ");
}
one = TRUE;
tk_snprintf(params, sizeof(params) - 1, "%sh=%s", params, h);
str_append_format(&params, 128, "h=%s", h);
}
if (one) {
tk_snprintf(params, sizeof(params) - 1, "%s)", params);
str_append(&params, ")");
}
return widget_set_self_layout(widget, params);
ret = widget_set_self_layout(widget, params.str);
str_reset(&params);
return ret;
} else {
value_t v;
if (x != NULL) {