mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
improve layout param
This commit is contained in:
parent
a91821aa2a
commit
769858a914
@ -2,6 +2,7 @@
|
||||
|
||||
2023/05/30
|
||||
* popup恢复支持高亮(感谢智明提供补丁)。
|
||||
* 修复在linux上面设置layout\_params出错的问题(感谢智明提供补丁)。
|
||||
|
||||
2023/05/29
|
||||
* main\_loop\_dispatch\_events支持分发EVT\_KEY\_LONG\_PRESS
|
||||
|
@ -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(¶ms, 128);
|
||||
str_append(¶ms, "default(");
|
||||
if (x != NULL) {
|
||||
one = TRUE;
|
||||
tk_snprintf(params, sizeof(params) - 1, "%sx=%s", params, x);
|
||||
str_append_format(¶ms, 128, "x=%s", x);
|
||||
}
|
||||
if (y != NULL) {
|
||||
if (one) {
|
||||
tk_snprintf(params, sizeof(params) - 1, "%s, ", params);
|
||||
str_append(¶ms, ", ");
|
||||
}
|
||||
one = TRUE;
|
||||
tk_snprintf(params, sizeof(params) - 1, "%sy=%s", params, y);
|
||||
str_append_format(¶ms, 128, "y=%s", y);
|
||||
}
|
||||
if (w != NULL) {
|
||||
if (one) {
|
||||
tk_snprintf(params, sizeof(params) - 1, "%s, ", params);
|
||||
str_append(¶ms, ", ");
|
||||
}
|
||||
one = TRUE;
|
||||
tk_snprintf(params, sizeof(params) - 1, "%sw=%s", params, w);
|
||||
str_append_format(¶ms, 128, "w=%s", w);
|
||||
}
|
||||
if (h != NULL) {
|
||||
if (one) {
|
||||
tk_snprintf(params, sizeof(params) - 1, "%s, ", params);
|
||||
str_append(¶ms, ", ");
|
||||
}
|
||||
one = TRUE;
|
||||
tk_snprintf(params, sizeof(params) - 1, "%sh=%s", params, h);
|
||||
str_append_format(¶ms, 128, "h=%s", h);
|
||||
}
|
||||
if (one) {
|
||||
tk_snprintf(params, sizeof(params) - 1, "%s)", params);
|
||||
str_append(¶ms, ")");
|
||||
}
|
||||
return widget_set_self_layout(widget, params);
|
||||
ret = widget_set_self_layout(widget, params.str);
|
||||
str_reset(¶ms);
|
||||
return ret;
|
||||
} else {
|
||||
value_t v;
|
||||
if (x != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user