From daf6f84ccdf817f7088aa527b4b37c2cca91c052 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sat, 27 Jan 2024 13:41:14 +0100 Subject: gfx: Add return value to *_sort functions --- src/gui/src/bar.c | 22 ++++++++++++++++++---- src/gui/src/button_sprite.c | 9 +++++++-- src/gui/src/button_type1.c | 8 +++++++- src/gui/src/line_edit.c | 24 ++++++++++++++++++++---- src/gui/src/rounded_rect.c | 14 ++++++++++++-- 5 files changed, 64 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/src/bar.c b/src/gui/src/bar.c index 25446e0..bd38cd6 100644 --- a/src/gui/src/bar.c +++ b/src/gui/src/bar.c @@ -15,8 +15,13 @@ static int render_topleft(const struct gui_bar *const b, const short x, s->x = x; s->y = y; - sprite_sort(s); - return 0; + + const int ret = sprite_sort(s); + + if (ret) + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + + return ret; } static int render_topright(const struct gui_bar *const b, const short x, @@ -29,7 +34,12 @@ static int render_topright(const struct gui_bar *const b, const short x, s->x = x + b->w - s->w; s->y = y; - sprite_sort(s); + + const int ret = sprite_sort(s); + + if (ret) + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + return 0; } @@ -66,7 +76,11 @@ static int render_topmid(const struct gui_bar *const b, const short x, else m->w = mid_w; - sprite_sort(m); + if (sprite_sort(m)) + { + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + return -1; + } } return 0; diff --git a/src/gui/src/button_sprite.c b/src/gui/src/button_sprite.c index 5bdc1b0..c98bdea 100644 --- a/src/gui/src/button_sprite.c +++ b/src/gui/src/button_sprite.c @@ -13,8 +13,13 @@ int gui_button_render_sprite(const struct gui_button *const b) return -1; gui_coords(&b->common, &s->x, &s->y); - sprite_sort(s); - return 0; + + const int ret = sprite_sort(s); + + if (ret) + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + + return ret; } void gui_button_get_dim_sprite(const struct gui_button *const b, diff --git a/src/gui/src/button_type1.c b/src/gui/src/button_type1.c index f07f2f3..da59d8b 100644 --- a/src/gui/src/button_type1.c +++ b/src/gui/src/button_type1.c @@ -19,7 +19,13 @@ static int render_left(const struct gui_button *const b, s->x = *x; s->y = y; - sprite_sort(s); + + if (sprite_sort(s)) + { + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + return -1; + } + *x = s->x + s->w; return 0; } diff --git a/src/gui/src/line_edit.c b/src/gui/src/line_edit.c index df52fd0..a7d56c8 100644 --- a/src/gui/src/line_edit.c +++ b/src/gui/src/line_edit.c @@ -26,7 +26,13 @@ static int render_left(const struct gui_line_edit *const l, s->x = *x; s->y = y; - sprite_sort(s); + + if (sprite_sort(s)) + { + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + return -1; + } + *x = s->x + s->w; return 0; } @@ -66,7 +72,12 @@ static int render_mid(const struct gui_line_edit *const l, else m->w = mid_w; - sprite_sort(m); + if (sprite_sort(m)) + { + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + return -1; + } + *x += m->w; } } @@ -85,8 +96,13 @@ static int render_right(const short x, const short y) s->x = x; s->y = y; - sprite_sort(s); - return 0; + + const int ret = sprite_sort(s); + + if (ret) + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + + return ret; } static int render(const struct gui_common *const g) diff --git a/src/gui/src/rounded_rect.c b/src/gui/src/rounded_rect.c index b60a05a..4ae3780 100644 --- a/src/gui/src/rounded_rect.c +++ b/src/gui/src/rounded_rect.c @@ -19,7 +19,12 @@ static int render_top(const struct gui_rounded_rect *const r, left->x = x; left->y = y; - sprite_sort(left); + + if (sprite_sort(left)) + { + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + return -1; + } } { @@ -33,7 +38,12 @@ static int render_top(const struct gui_rounded_rect *const r, right->x = x + r->w - ref->w; right->y = y; - sprite_sort(right); + + if (sprite_sort(right)) + { + fprintf(stderr, "%s: sprite_sort failed\n", __func__); + return -1; + } } return 0; -- cgit v1.2.3