Skip to content

Commit

Permalink
fix deprecated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 13, 2024
1 parent 2621b56 commit c26370b
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 43 deletions.
2 changes: 1 addition & 1 deletion demos/demo_canvas_offline.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ret_t application_init() {
widget_t* win = window_create(NULL, 0, 0, 0, 0);
widget_t* canvas_widget = canvas_widget_create(win, 0, 0, win->w, win->h);
widget_t* button = button_create(win, 0, 0, 0, 0);
widget_set_self_layout_params(button, "c", "b", "100", "40");
widget_set_self_layout(button, "default(x=c,y=b,w=100,h=40)");
widget_on(win, EVT_DESTROY, window_on_destroy, NULL);

/* 创建离线的 canvas */
Expand Down
12 changes: 6 additions & 6 deletions demos/demo_thread_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ ret_t application_init() {
widget_t* progress_bar4 = progress_bar_create(win, 0, 0, 0, 0);

widget_set_text(label, L"Update progressbar in non GUI thread");
widget_set_self_layout_params(label, "center", "middle:-90", "80%", "30");
widget_set_self_layout(label, "default(x=center,y=middle:-90,w=80%,h=30)");

widget_set_self_layout_params(progress_bar1, "center", "middle:-60", "80%", "20");
widget_set_self_layout_params(progress_bar2, "center", "middle:-30", "80%", "20");
widget_set_self_layout_params(progress_bar3, "center", "middle:0", "80%", "20");
widget_set_self_layout_params(progress_bar4, "center", "middle:30", "80%", "20");
widget_set_self_layout(progress_bar1, "default(x=center,y=middle:-60,w=80%,h=20)");
widget_set_self_layout(progress_bar2, "default(x=center,y=middle:-30,w=80%,h=20)");
widget_set_self_layout(progress_bar3, "default(x=center,y=middle:0,w=80%,h=20)");
widget_set_self_layout(progress_bar4, "default(x=center,y=middle:30,w=80%,h=20)");

widget_set_text(close, L"close");
widget_set_self_layout_params(close, "center", "bottom:30", "50%", "30");
widget_set_self_layout(close, "default(x=center,y=bottom:30,w=50%,h=30)");

thread1 = tk_thread_create(test_thread1, progress_bar1);
tk_thread_start(thread1);
Expand Down
4 changes: 2 additions & 2 deletions demos/demo_window_animator.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ static ret_t new_window_set_param(widget_t* new_win, widget_t* curr_win) {
widget_set_prop_bool(new_win, WIDGET_PROP_DISABLE_ANIM, FALSE);
widget_set_prop_str(new_win, WIDGET_PROP_ANIM_HINT, anim);
if (tk_str_eq(anim_hint, "popup")) {
widget_set_self_layout_params(new_win, NULL, "b:20", NULL, NULL);
widget_set_self_layout(new_win, "default(y=b:20)");
} else if (tk_str_eq(anim_hint, "popdown")) {
widget_set_self_layout_params(new_win, NULL, "20", NULL, NULL);
widget_set_self_layout(new_win, "default(y=20)");
}
log_debug("%s\r\n", anim);
} else {
Expand Down
1 change: 1 addition & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

2024/12/13
* 增加EVT\_NATIVE\_WINDOW\_FOCUS\_GAINED(感谢兆坤提供补丁)
* 用widget\_set\_self\_layout替换widget\_set\_self\_layout\_params(感谢兆坤提供补丁)

2024/12/10
* 修复scroll\_bar\_d不指定max时控件内的dragger不显示的问题(感谢雨欣提供补丁)
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/dialog_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ static widget_t* dialog_create_simple_ex(widget_t* parent, xy_t x, xy_t y, wh_t

widget_set_name(title, DIALOG_CHILD_TITLE);
widget_set_tr_text(title, stitle);
widget_set_self_layout_params(title, "0", "0", "100%", "30");
widget_set_self_layout(title, "default(x=0,y=0,w=100%,h=30)");

client = dialog_client_create(widget, 0, 0, 0, 0);
goto_error_if_fail(client != NULL);
widget_set_name(client, DIALOG_CHILD_CLIENT);

widget_set_self_layout_params(client, "0", "bottom", "100%", "-30");
widget_set_self_layout(client, "default(x=0,y=bottom,w=100%,h=-30)");

return widget;
error:
Expand Down
2 changes: 1 addition & 1 deletion tests/button_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST(Button, clone) {
str_init(&str, 0);
value_set_int(&v1, 200);
ASSERT_EQ(widget_set_prop(w1, WIDGET_PROP_REPEAT, &v1), RET_OK);
widget_set_self_layout_params(w1, "1", "2", "3", "4");
widget_set_self_layout(w1, "default(x=1,y=2,w=3,h=4)");
widget_set_children_layout(w1, "default(r=0,c=0,x=10,y=10,s=10)");
widget_set_sensitive(w1, FALSE);
widget_set_floating(w1, TRUE);
Expand Down
4 changes: 2 additions & 2 deletions tests/fscript_widget_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST(FScriptWidget, layout) {
widget_t* win = window_create(NULL, 0, 0, 0, 0);
widget_t* widget = progress_bar_create(win, 0, 0, w, h);

widget_set_self_layout_params(widget, "c", "m", NULL, NULL);
widget_set_self_layout(widget, "default(x=c,y=m)");
tk_object_set_prop_pointer(obj, STR_PROP_SELF, widget);
fscript_eval(obj, "widget_layout('self')", &v);
ASSERT_EQ(widget->x, (wm->w - w) / 2);
Expand All @@ -65,7 +65,7 @@ TEST(FScriptWidget, layout) {
ASSERT_EQ(widget->h, h);

((window_base_t*)win)->need_relayout = FALSE;
widget_set_self_layout_params(widget, "c:10", "m:10", NULL, NULL);
widget_set_self_layout(widget, "default(x=c:10,y=m:10)");
tk_object_set_prop_pointer(obj, STR_PROP_SELF, widget);
fscript_eval(obj, "widget_request_relayout('self')", &v);
ASSERT_EQ(widget->x, (wm->w - w) / 2);
Expand Down
2 changes: 1 addition & 1 deletion tests/image_animation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TEST(ImageAnimation, clone) {

value_set_int(&v1, 200);
ASSERT_EQ(widget_set_prop(w1, IMAGE_ANIMATION_PROP_INTERVAL, &v1), RET_OK);
widget_set_self_layout_params(w1, "1", "2", "3", "4");
widget_set_self_layout(w1, "default(x=1,y=2,w=3,h=4)");
widget_set_children_layout(w1, "default(r=0, c=0, x=10, y=10, s=10)");
ASSERT_EQ(image_animation_cast(w1), w1);

Expand Down
2 changes: 1 addition & 1 deletion tests/scroll_view_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TEST(ScrollView, layout) {
ASSERT_EQ(scroll_view_set_virtual_w(widget, 400), RET_OK);
ASSERT_EQ(scroll_view_set_virtual_h(widget, 800), RET_OK);

widget_set_self_layout_params(button, "right", "bottom", "10%", "10%");
widget_set_self_layout(button, "default(x=right,y=bottom,w=10%,h=10%)");
widget_layout(widget);

ASSERT_EQ(button->x, 360);
Expand Down
48 changes: 24 additions & 24 deletions tests/self_layouter_default_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -674,80 +674,80 @@ TEST(SelfLayoutDefault, reinit) {
widget_destroy(w);
}

TEST(SelfLayoutDefault, set_self_layout_params) {
TEST(SelfLayoutDefault, set_self_layout) {
widget_t* win = window_create(NULL, 0, 0, 400, 300);
widget_t* btn = button_create(win, 10, 20, 30, 40);

widget_set_self_layout_params(btn, "c:100", NULL, NULL, NULL);
widget_set_self_layout(btn, "default(x=c:100)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(x=c:100)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, NULL, "b:10", NULL, NULL);
widget_set_self_layout(btn, "default(y=b:10)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(y=b:10)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, NULL, NULL, "100%", NULL);
widget_set_self_layout(btn, "default(w=100%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(w=100%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, NULL, NULL, NULL, "10%");
widget_set_self_layout(btn, "default(h=10%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(h=10%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, "c:100", "b:10", NULL, NULL);
widget_set_self_layout(btn, "default(x=c:100, y=b:10)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(x=c:100, y=b:10)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, "c:100", NULL, "100%", NULL);
widget_set_self_layout(btn, "default(x=c:100, w=100%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(x=c:100, w=100%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, "c:100", NULL, NULL, "10%");
widget_set_self_layout(btn, "default(x=c:100, h=10%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(x=c:100, h=10%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, NULL, "b:10", "100%", NULL);
widget_set_self_layout(btn, "default(y=b:10, w=100%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(y=b:10, w=100%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, NULL, "b:10", NULL, "10%");
widget_set_self_layout(btn, "default(y=b:10, h=10%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(y=b:10, h=10%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, NULL, NULL, "100%", "10%");
widget_set_self_layout(btn, "default(w=100%, h=10%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(w=100%, h=10%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, "c:100", "b:10", "100%", NULL);
widget_set_self_layout(btn, "default(x=c:100, y=b:10, w=100%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(x=c:100, y=b:10, w=100%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, "c:100", "b:10", NULL, "10%");
widget_set_self_layout(btn, "default(x=c:100, y=b:10, h=10%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(x=c:100, y=b:10, h=10%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, NULL, "b:10", "100%", "10%");
widget_set_self_layout(btn, "default(y=b:10, w=100%, h=10%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(y=b:10, w=100%, h=10%)");

self_layouter_destroy(btn->self_layout);
btn->self_layout = NULL;
widget_set_self_layout_params(btn, "c:100", NULL, "100%", "10%");
widget_set_self_layout(btn, "default(x=c:100, w=100%, h=10%)");
ASSERT_EQ(string(btn->self_layout->params.str), "default(x=c:100, w=100%, h=10%)");
}

TEST(SelfLayoutDefault, set_self_layout_params2) {
TEST(SelfLayoutDefault, set_self_layout2) {
widget_t* win = overlay_create(NULL, 0, 0, 200, 100);
widget_t* btn = button_create(win, 0, 0, 0, 0);
widget_set_self_layout(btn, "default(x=r, y=b, w=50%, h=10%)");
Expand All @@ -761,22 +761,22 @@ TEST(SelfLayoutDefault, set_self_layout_params2) {
ASSERT_EQ(widget_get_prop_int(btn, "w", 0), 100);
ASSERT_EQ(widget_get_prop_int(btn, "h", 0), 10);

widget_set_self_layout_params(btn, "c", NULL, NULL, NULL);
widget_set_self_layout(btn, "default(x=c)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "x", 0), 50);

widget_set_self_layout_params(btn, NULL, "m", NULL, NULL);
widget_set_self_layout(btn, "default(x=c,y=m)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "x", 0), 50);
ASSERT_EQ(widget_get_prop_int(btn, "y", 0), 45);

widget_set_self_layout_params(btn, NULL, NULL, "100%", NULL);
widget_set_self_layout(btn, "default(x=c,y=m,w=100%)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "x", 0), 0);
ASSERT_EQ(widget_get_prop_int(btn, "y", 0), 45);
ASSERT_EQ(widget_get_prop_int(btn, "w", 0), 200);

widget_set_self_layout_params(btn, NULL, NULL, NULL, "100%");
widget_set_self_layout(btn, "default(x=c,y=m,w=100%,h=100%)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "x", 0), 0);
ASSERT_EQ(widget_get_prop_int(btn, "y", 0), 0);
Expand All @@ -802,18 +802,18 @@ TEST(SelfLayoutDefault, set_self_layout_params2) {
ASSERT_EQ(self_layouter_get_param_int(layouter, "w_attr", 0), W_ATTR_UNDEF);
ASSERT_EQ(self_layouter_get_param_int(layouter, "h_attr", 0), W_ATTR_UNDEF);

widget_set_self_layout_params(btn, "100", NULL, NULL, NULL);
widget_set_self_layout(btn, "default(x=100)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "x", 0), 100);
widget_set_self_layout_params(btn, "c", NULL, "100", NULL);
widget_set_self_layout(btn, "default(x=c,w=100)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "x", 0), 50);
ASSERT_EQ(widget_get_prop_int(btn, "w", 0), 100);

widget_set_self_layout_params(btn, NULL, "10", NULL, NULL);
widget_set_self_layout(btn, "default(y=10)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "y", 0), 10);
widget_set_self_layout_params(btn, NULL, "m", NULL, "50");
widget_set_self_layout(btn, "default(y=m,h=50)");
ASSERT_EQ(widget_layout_self(btn), RET_OK);
ASSERT_EQ(widget_get_prop_int(btn, "y", 0), 25);
ASSERT_EQ(widget_get_prop_int(btn, "h", 0), 50);
Expand Down
2 changes: 1 addition & 1 deletion tests/switch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TEST(Switch, clone) {

value_set_int(&v1, 200);
ASSERT_EQ(widget_set_prop(w1, WIDGET_PROP_REPEAT, &v1), RET_OK);
widget_set_self_layout_params(w1, "1", "2", "3", "4");
widget_set_self_layout(w1, "default(x=1,y=2,w=3,h=4)");
widget_set_children_layout(w1, "default(r=0, c=0, x=10, y=10, s=10)");
ASSERT_EQ(switch_cast(w1), w1);

Expand Down
4 changes: 2 additions & 2 deletions tests/ui_serializer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TEST(UISerializer, layout_self) {
str_t str;
widget_t* w = button_create(NULL, 10, 20, 30, 40);

widget_set_self_layout_params(w, "right:100", "middle:10", "fill", "10%");
widget_set_self_layout(w, "default(x=right:100,y=middle:10,w=fill,h=10%)");
str_init(&str, 1024);
widget_to_xml(w, &str);

Expand All @@ -60,7 +60,7 @@ TEST(UISerializer, layout_self1) {
str_t str;
widget_t* w = button_create(NULL, 10, 20, 30, 40);

widget_set_self_layout_params(w, "center:100", "bottom:10", "fill", "10%");
widget_set_self_layout(w, "default(x=center:100,y=bottom:10,w=fill,h=10%)");
str_init(&str, 1024);
widget_to_xml(w, &str);

Expand Down

0 comments on commit c26370b

Please sign in to comment.