improve params checker

This commit is contained in:
xianjimli 2019-03-22 18:34:27 +08:00
parent 45b7923b30
commit 3699beb8ea
35 changed files with 134 additions and 131 deletions

View File

@ -2,7 +2,9 @@
* 2019/03/22
* 完善资源生成脚本。
* widget vtable增加inputable属性。
* 修改listview没有scrollbar时的问题(感谢陈谭提供补丁)。
* 修改listview没有scrollbar时的问题(感谢陈谭/俊杰提供补丁)。
* edit/spinbox在修改text后处理prop changed事件以更新控件状态。
* 修改参数检查的存在的问题(感谢俊杰提供补丁)
* 2019/03/21
* 增加lcd\_profile用于对绘制函数进行profile。

View File

@ -408,10 +408,12 @@ ret_t vgcanvas_draw_icon(vgcanvas_t* vg, bitmap_t* img, float_t sx, float_t sy,
float_t sh, float_t dx, float_t dy, float_t dw, float_t dh) {
float_t x = 0;
float_t y = 0;
float_t w = sw / vg->ratio;
float_t h = sh / vg->ratio;
float_t w = 0;
float_t h = 0;
return_value_if_fail(vg != NULL && img != NULL, RET_BAD_PARAMS);
w = sw / vg->ratio;
h = sh / vg->ratio;
x = (dw - w) * 0.5f + dx;
y = (dh - h) * 0.5f + dy;

View File

@ -253,7 +253,7 @@ ret_t color_component_set_color(widget_t* widget, color_t c) {
float S = 0;
float V = 0;
color_component_t* color_component = COLOR_COMPONENT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(color_component != NULL, RET_BAD_PARAMS);
color_component->c = c;
convertRGBtoHSV(c.rgba.r, c.rgba.g, c.rgba.b, &H, &S, &V);
@ -274,7 +274,7 @@ ret_t color_component_set_color(widget_t* widget, color_t c) {
static ret_t color_component_set_type(widget_t* widget, const char* type) {
color_component_t* color_component = COLOR_COMPONENT(widget);
return_value_if_fail(widget != NULL && type != NULL, RET_BAD_PARAMS);
return_value_if_fail(color_component != NULL && type != NULL, RET_BAD_PARAMS);
color_component->image.name = type;

View File

@ -30,7 +30,7 @@
static ret_t color_picker_get_prop(widget_t* widget, const char* name, value_t* v) {
color_picker_t* color_picker = COLOR_PICKER(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(color_picker != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_str(v, color_picker->value);
@ -348,7 +348,7 @@ static ret_t color_picker_update_color(widget_t* widget, color_t color) {
ret_t color_picker_set_color(widget_t* widget, const char* color) {
color_picker_t* color_picker = COLOR_PICKER(widget);
return_value_if_fail(widget != NULL && color != NULL, RET_BAD_PARAMS);
return_value_if_fail(color_picker != NULL && color != NULL, RET_BAD_PARAMS);
color_picker->init_c = color_parse(color);
color_picker_update_color(widget, color_picker->init_c);

View File

@ -56,7 +56,6 @@ static ret_t gif_image_on_paint_self(widget_t* widget, canvas_t* c) {
gif_image_t* image = GIF_IMAGE(widget);
vgcanvas_t* vg = lcd_get_vgcanvas(c->lcd);
image_base_t* image_base = IMAGE_BASE(widget);
return_value_if_fail(widget != NULL && c != NULL, RET_BAD_PARAMS);
if (image_base->image == NULL) {
return RET_OK;

View File

@ -27,7 +27,7 @@
static ret_t guage_get_prop(widget_t* widget, const char* name, value_t* v) {
guage_t* guage = GUAGE(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(guage != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_IMAGE)) {
value_set_str(v, guage->image);
@ -71,7 +71,7 @@ static ret_t guage_on_destroy(widget_t* widget) {
ret_t guage_set_image(widget_t* widget, const char* name) {
guage_t* guage = GUAGE(widget);
return_value_if_fail(widget != NULL && name != NULL, RET_BAD_PARAMS);
return_value_if_fail(guage != NULL && name != NULL, RET_BAD_PARAMS);
guage->image = tk_str_copy(guage->image, name);
@ -80,7 +80,7 @@ ret_t guage_set_image(widget_t* widget, const char* name) {
ret_t guage_set_draw_type(widget_t* widget, image_draw_type_t draw_type) {
guage_t* guage = GUAGE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(guage != NULL, RET_BAD_PARAMS);
guage->draw_type = draw_type;

View File

@ -93,7 +93,7 @@ static ret_t image_animation_on_paint_self(widget_t* widget, canvas_t* c) {
static ret_t image_animation_get_prop(widget_t* widget, const char* name, value_t* v) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, IMAGE_ANIMATION_PROP_LOOP)) {
value_set_bool(v, image_animation->loop);
@ -130,7 +130,7 @@ static ret_t image_animation_get_prop(widget_t* widget, const char* name, value_
static ret_t image_animation_set_prop(widget_t* widget, const char* name, const value_t* v) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, IMAGE_ANIMATION_PROP_LOOP)) {
return image_animation_set_loop(widget, value_bool(v));
@ -237,7 +237,7 @@ widget_t* image_animation_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t
ret_t image_animation_set_loop(widget_t* widget, bool_t loop) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
image_animation->loop = loop;
@ -246,7 +246,7 @@ ret_t image_animation_set_loop(widget_t* widget, bool_t loop) {
ret_t image_animation_set_image(widget_t* widget, const char* image) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL && image != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL && image != NULL, RET_BAD_PARAMS);
image_animation->image = tk_str_copy(image_animation->image, image);
@ -255,7 +255,7 @@ ret_t image_animation_set_image(widget_t* widget, const char* image) {
ret_t image_animation_set_interval(widget_t* widget, uint32_t interval) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
image_animation->interval = interval;
@ -264,7 +264,7 @@ ret_t image_animation_set_interval(widget_t* widget, uint32_t interval) {
ret_t image_animation_set_delay(widget_t* widget, uint32_t delay) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
image_animation->delay = delay;
@ -273,7 +273,7 @@ ret_t image_animation_set_delay(widget_t* widget, uint32_t delay) {
ret_t image_animation_set_auto_play(widget_t* widget, bool_t auto_play) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
image_animation->auto_play = auto_play;
@ -282,7 +282,7 @@ ret_t image_animation_set_auto_play(widget_t* widget, bool_t auto_play) {
ret_t image_animation_set_unload_after_paint(widget_t* widget, bool_t unload_after_paint) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
image_animation->unload_after_paint = unload_after_paint;
@ -291,7 +291,7 @@ ret_t image_animation_set_unload_after_paint(widget_t* widget, bool_t unload_aft
ret_t image_animation_set_sequence(widget_t* widget, const char* sequence) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL && sequence != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL && sequence != NULL, RET_BAD_PARAMS);
image_animation->sequence = tk_str_copy(image_animation->sequence, sequence);
@ -301,7 +301,7 @@ ret_t image_animation_set_sequence(widget_t* widget, const char* sequence) {
ret_t image_animation_set_range_sequence(widget_t* widget, uint32_t start_index,
uint32_t end_index) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
image_animation->index = start_index;
image_animation->end_index = end_index;
@ -375,7 +375,7 @@ static ret_t image_animation_on_update(const timer_info_t* info) {
ret_t image_animation_play(widget_t* widget) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
if (image_animation->timer_id == TK_INVALID_ID) {
image_animation->timer_id =
@ -387,7 +387,7 @@ ret_t image_animation_play(widget_t* widget) {
ret_t image_animation_stop(widget_t* widget) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
image_animation_pause(widget);
image_animation->index = -1;
@ -397,7 +397,7 @@ ret_t image_animation_stop(widget_t* widget) {
ret_t image_animation_pause(widget_t* widget) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL, RET_BAD_PARAMS);
if (image_animation->timer_id != TK_INVALID_ID) {
timer_remove(image_animation->timer_id);
@ -409,7 +409,7 @@ ret_t image_animation_pause(widget_t* widget) {
ret_t image_animation_set_format(widget_t* widget, const char* format) {
image_animation_t* image_animation = IMAGE_ANIMATION(widget);
return_value_if_fail(widget != NULL && format != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_animation != NULL && format != NULL, RET_BAD_PARAMS);
image_animation->format = tk_str_copy(image_animation->format, format);

View File

@ -100,7 +100,7 @@ static ret_t image_value_on_paint_self(widget_t* widget, canvas_t* c) {
static ret_t image_value_get_prop(widget_t* widget, const char* name, value_t* v) {
image_value_t* image_value = IMAGE_VALUE(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_value != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_float(v, image_value->value);
@ -158,7 +158,7 @@ widget_t* image_value_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
ret_t image_value_set_image(widget_t* widget, const char* image) {
image_value_t* image_value = IMAGE_VALUE(widget);
return_value_if_fail(widget != NULL && image != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_value != NULL && image != NULL, RET_BAD_PARAMS);
image_value->image = tk_str_copy(image_value->image, image);
@ -167,7 +167,7 @@ ret_t image_value_set_image(widget_t* widget, const char* image) {
ret_t image_value_set_format(widget_t* widget, const char* format) {
image_value_t* image_value = IMAGE_VALUE(widget);
return_value_if_fail(widget != NULL && format != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_value != NULL && format != NULL, RET_BAD_PARAMS);
image_value->format = tk_str_copy(image_value->format, format);
@ -176,7 +176,7 @@ ret_t image_value_set_format(widget_t* widget, const char* format) {
ret_t image_value_set_value(widget_t* widget, float_t value) {
image_value_t* image_value = IMAGE_VALUE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image_value != NULL, RET_BAD_PARAMS);
if (image_value->value != value) {
event_t e = event_init(EVT_VALUE_WILL_CHANGE, widget);

View File

@ -37,7 +37,7 @@ static const char* s_keyboard_properties[] = {WIDGET_PROP_ANIM_HINT, WIDGET_PROP
static ret_t keyboard_on_destroy(widget_t* widget) {
keyboard_t* keyboard = KEYBOARD(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(keyboard != NULL, RET_BAD_PARAMS);
darray_deinit(&(keyboard->action_buttons));
return window_base_on_destroy(widget);

View File

@ -87,7 +87,7 @@ static ret_t progress_circle_on_paint_self(widget_t* widget, canvas_t* c) {
ret_t progress_circle_set_value(widget_t* widget, float_t value) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL, RET_BAD_PARAMS);
if (progress_circle->value != value) {
event_t e = event_init(EVT_VALUE_WILL_CHANGE, widget);
@ -103,7 +103,7 @@ ret_t progress_circle_set_value(widget_t* widget, float_t value) {
ret_t progress_circle_set_max(widget_t* widget, uint32_t max) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL, RET_BAD_PARAMS);
progress_circle->max = max;
@ -112,7 +112,7 @@ ret_t progress_circle_set_max(widget_t* widget, uint32_t max) {
ret_t progress_circle_set_line_width(widget_t* widget, uint32_t line_width) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL, RET_BAD_PARAMS);
progress_circle->line_width = line_width;
@ -121,7 +121,7 @@ ret_t progress_circle_set_line_width(widget_t* widget, uint32_t line_width) {
ret_t progress_circle_set_start_angle(widget_t* widget, int32_t start_angle) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL, RET_BAD_PARAMS);
progress_circle->start_angle = start_angle;
@ -130,7 +130,7 @@ ret_t progress_circle_set_start_angle(widget_t* widget, int32_t start_angle) {
ret_t progress_circle_set_unit(widget_t* widget, const char* unit) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL, RET_BAD_PARAMS);
progress_circle->unit = tk_str_copy(progress_circle->unit, unit);
@ -139,7 +139,7 @@ ret_t progress_circle_set_unit(widget_t* widget, const char* unit) {
ret_t progress_circle_set_show_text(widget_t* widget, bool_t show_text) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL, RET_BAD_PARAMS);
progress_circle->show_text = show_text;
@ -148,7 +148,7 @@ ret_t progress_circle_set_show_text(widget_t* widget, bool_t show_text) {
ret_t progress_circle_set_counter_clock_wise(widget_t* widget, bool_t counter_clock_wise) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL, RET_BAD_PARAMS);
progress_circle->counter_clock_wise = counter_clock_wise;
@ -165,7 +165,7 @@ static ret_t progress_circle_on_destroy(widget_t* widget) {
static ret_t progress_circle_get_prop(widget_t* widget, const char* name, value_t* v) {
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_circle != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_float(v, progress_circle->value);

View File

@ -164,7 +164,7 @@ static ret_t rich_text_on_event(widget_t* widget, event_t* e) {
static ret_t rich_text_set_prop(widget_t* widget, const char* name, const value_t* v) {
rich_text_t* rich_text = RICH_TEXT(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(rich_text != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_TEXT)) {
return rich_text_set_text(widget, value_str(v));

View File

@ -34,7 +34,7 @@ static ret_t list_view_on_paint_self(widget_t* widget, canvas_t* c) {
static ret_t list_view_get_prop(widget_t* widget, const char* name, value_t* v) {
list_view_t* list_view = LIST_VIEW(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(list_view != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_ITEM_HEIGHT)) {
value_set_int(v, list_view->item_height);
@ -52,7 +52,7 @@ static ret_t list_view_get_prop(widget_t* widget, const char* name, value_t* v)
static ret_t list_view_set_prop(widget_t* widget, const char* name, const value_t* v) {
list_view_t* list_view = LIST_VIEW(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(list_view != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_ITEM_HEIGHT)) {
list_view->item_height = value_int(v);
@ -271,7 +271,7 @@ widget_t* list_view_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
ret_t list_view_set_item_height(widget_t* widget, int32_t item_height) {
list_view_t* list_view = LIST_VIEW(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(list_view != NULL, RET_BAD_PARAMS);
list_view->item_height = item_height;
@ -280,7 +280,7 @@ ret_t list_view_set_item_height(widget_t* widget, int32_t item_height) {
ret_t list_view_set_default_item_height(widget_t* widget, int32_t default_item_height) {
list_view_t* list_view = LIST_VIEW(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(list_view != NULL, RET_BAD_PARAMS);
list_view->default_item_height = default_item_height;
@ -289,7 +289,7 @@ ret_t list_view_set_default_item_height(widget_t* widget, int32_t default_item_h
ret_t list_view_set_auto_hide_scroll_bar(widget_t* widget, bool_t auto_hide_scroll_bar) {
list_view_t* list_view = LIST_VIEW(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(list_view != NULL, RET_BAD_PARAMS);
list_view->auto_hide_scroll_bar = auto_hide_scroll_bar;

View File

@ -346,7 +346,7 @@ static ret_t scroll_bar_create_children(widget_t* widget) {
/*share*/
ret_t scroll_bar_set_params(widget_t* widget, int32_t virtual_size, int32_t row) {
scroll_bar_t* scroll_bar = SCROLL_BAR(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_bar != NULL, RET_BAD_PARAMS);
widget->need_relayout_children = TRUE;
scroll_bar->virtual_size = virtual_size;
@ -361,7 +361,7 @@ ret_t scroll_bar_set_params(widget_t* widget, int32_t virtual_size, int32_t row)
static ret_t scroll_bar_get_prop(widget_t* widget, const char* name, value_t* v) {
scroll_bar_t* scroll_bar = SCROLL_BAR(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_bar != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_MAX)) {
value_set_int(v, scroll_bar->virtual_size);
@ -382,7 +382,7 @@ static ret_t scroll_bar_get_prop(widget_t* widget, const char* name, value_t* v)
static ret_t scroll_bar_set_prop(widget_t* widget, const char* name, const value_t* v) {
scroll_bar_t* scroll_bar = SCROLL_BAR(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_bar != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_MAX)) {
scroll_bar->virtual_size = value_int(v);
@ -447,7 +447,7 @@ static ret_t scroll_bar_on_animate_end(void* ctx, event_t* e) {
ret_t scroll_bar_scroll_to(widget_t* widget, int32_t value, int32_t duration) {
scroll_bar_t* scroll_bar = SCROLL_BAR(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_bar != NULL, RET_BAD_PARAMS);
if (scroll_bar->wa_value != NULL) {
widget_animator_destroy(scroll_bar->wa_value);
@ -507,7 +507,7 @@ static ret_t scroll_bar_update_dragger(widget_t* widget) {
ret_t scroll_bar_set_value(widget_t* widget, int32_t value) {
scroll_bar_t* scroll_bar = SCROLL_BAR(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_bar != NULL, RET_BAD_PARAMS);
if (scroll_bar->value != value) {
event_t e = event_init(EVT_VALUE_CHANGED, widget);
@ -522,7 +522,7 @@ ret_t scroll_bar_set_value(widget_t* widget, int32_t value) {
ret_t scroll_bar_set_value_only(widget_t* widget, int32_t value) {
scroll_bar_t* scroll_bar = SCROLL_BAR(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_bar != NULL, RET_BAD_PARAMS);
if (value < 0) {
value = 0;

View File

@ -145,7 +145,7 @@ ret_t scroll_view_scroll_to(widget_t* widget, int32_t xoffset_end, int32_t yoffs
int32_t xoffset = 0;
int32_t yoffset = 0;
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(scroll_view != NULL, RET_FAIL);
xoffset = scroll_view->xoffset;
yoffset = scroll_view->yoffset;
@ -359,7 +359,7 @@ static ret_t scroll_view_on_paint_children(widget_t* widget, canvas_t* c) {
static ret_t scroll_view_get_prop(widget_t* widget, const char* name, value_t* v) {
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_view != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VIRTUAL_W) || tk_str_eq(name, WIDGET_PROP_LAYOUT_W)) {
value_set_int(v, tk_max(widget->w, scroll_view->virtual_w));
@ -386,7 +386,7 @@ static ret_t scroll_view_get_prop(widget_t* widget, const char* name, value_t* v
static ret_t scroll_view_set_prop(widget_t* widget, const char* name, const value_t* v) {
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_view != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VIRTUAL_W)) {
scroll_view->virtual_w = value_int(v);
@ -445,7 +445,7 @@ widget_t* scroll_view_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
ret_t scroll_view_set_virtual_w(widget_t* widget, wh_t w) {
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_view != NULL, RET_BAD_PARAMS);
scroll_view->virtual_w = w;
@ -454,7 +454,7 @@ ret_t scroll_view_set_virtual_w(widget_t* widget, wh_t w) {
ret_t scroll_view_set_virtual_h(widget_t* widget, wh_t h) {
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(scroll_view != NULL, RET_BAD_PARAMS);
scroll_view->virtual_h = h;
@ -463,7 +463,7 @@ ret_t scroll_view_set_virtual_h(widget_t* widget, wh_t h) {
ret_t scroll_view_set_offset(widget_t* widget, int32_t xoffset, int32_t yoffset) {
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(scroll_view != NULL, RET_FAIL);
scroll_view->xoffset = xoffset;
scroll_view->yoffset = yoffset;
@ -475,7 +475,7 @@ ret_t scroll_view_set_offset(widget_t* widget, int32_t xoffset, int32_t yoffset)
ret_t scroll_view_set_xslidable(widget_t* widget, bool_t xslidable) {
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(scroll_view != NULL, RET_FAIL);
scroll_view->xslidable = xslidable;
@ -484,7 +484,7 @@ ret_t scroll_view_set_xslidable(widget_t* widget, bool_t xslidable) {
ret_t scroll_view_set_yslidable(widget_t* widget, bool_t yslidable) {
scroll_view_t* scroll_view = SCROLL_VIEW(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(scroll_view != NULL, RET_FAIL);
scroll_view->yslidable = yslidable;

View File

@ -430,7 +430,7 @@ static ret_t slide_menu_on_scroll_done(void* ctx, event_t* e) {
static ret_t slide_menu_scroll_to(widget_t* widget, int32_t xoffset_end) {
int32_t xoffset = 0;
slide_menu_t* slide_menu = SLIDE_MENU(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(slide_menu != NULL, RET_FAIL);
xoffset = slide_menu->xoffset;
if (xoffset == xoffset_end) {

View File

@ -54,7 +54,6 @@ static ret_t svg_image_on_paint_self(widget_t* widget, canvas_t* c) {
svg_image_t* svg_image = SVG_IMAGE(widget);
vgcanvas_t* vg = lcd_get_vgcanvas(c->lcd);
image_base_t* image_base = IMAGE_BASE(widget);
return_value_if_fail(widget != NULL && c != NULL && vg != NULL, RET_BAD_PARAMS);
if (image_base->image != NULL && svg_image_load_bsvg(widget) == RET_OK) {
bsvg_t bsvg;

View File

@ -69,7 +69,7 @@ static ret_t switch_on_scroll_done(void* ctx, event_t* e) {
static ret_t switch_scroll_to(widget_t* widget, int32_t xoffset_end) {
int32_t xoffset = 0;
switch_t* aswitch = SWITCH(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(aswitch != NULL, RET_FAIL);
xoffset = aswitch->xoffset;
if (xoffset == xoffset_end) {
@ -210,7 +210,7 @@ static ret_t switch_on_paint_background(widget_t* widget, canvas_t* c) {
ret_t switch_set_value(widget_t* widget, bool_t value) {
switch_t* aswitch = SWITCH(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(aswitch != NULL, RET_BAD_PARAMS);
if (aswitch->value != value) {
event_t e = event_init(EVT_VALUE_WILL_CHANGE, widget);
@ -234,7 +234,7 @@ ret_t switch_set_value(widget_t* widget, bool_t value) {
static ret_t switch_get_prop(widget_t* widget, const char* name, value_t* v) {
switch_t* aswitch = SWITCH(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(aswitch != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_bool(v, aswitch->value);
@ -257,7 +257,7 @@ static ret_t switch_get_prop(widget_t* widget, const char* name, value_t* v) {
static ret_t switch_set_prop(widget_t* widget, const char* name, const value_t* v) {
switch_t* aswitch = SWITCH(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(aswitch != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
return switch_set_value(widget, value_bool(v));

View File

@ -320,7 +320,7 @@ static ret_t text_selector_on_scroll_done(void* ctx, event_t* e) {
static ret_t text_selector_scroll_to(widget_t* widget, int32_t yoffset_end) {
int32_t yoffset = 0;
text_selector_t* text_selector = TEXT_SELECTOR(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(text_selector != NULL, RET_FAIL);
yoffset = text_selector->yoffset;
if (yoffset == yoffset_end) {

View File

@ -31,7 +31,7 @@ static ret_t time_clock_reset_time(time_clock_t* time_clock);
ret_t time_clock_set_hour(widget_t* widget, int32_t hour) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->hour = hour;
@ -40,7 +40,7 @@ ret_t time_clock_set_hour(widget_t* widget, int32_t hour) {
ret_t time_clock_set_minute(widget_t* widget, int32_t minute) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->minute = minute;
@ -49,7 +49,7 @@ ret_t time_clock_set_minute(widget_t* widget, int32_t minute) {
ret_t time_clock_set_second(widget_t* widget, int32_t second) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->second = second;
@ -58,7 +58,7 @@ ret_t time_clock_set_second(widget_t* widget, int32_t second) {
ret_t time_clock_set_hour_image(widget_t* widget, const char* hour_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->hour_image = tk_str_copy(time_clock->hour_image, hour_image);
@ -67,7 +67,7 @@ ret_t time_clock_set_hour_image(widget_t* widget, const char* hour_image) {
ret_t time_clock_set_minute_image(widget_t* widget, const char* minute_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->minute_image = tk_str_copy(time_clock->minute_image, minute_image);
@ -76,7 +76,7 @@ ret_t time_clock_set_minute_image(widget_t* widget, const char* minute_image) {
ret_t time_clock_set_second_image(widget_t* widget, const char* second_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->second_image = tk_str_copy(time_clock->second_image, second_image);
@ -85,7 +85,7 @@ ret_t time_clock_set_second_image(widget_t* widget, const char* second_image) {
ret_t time_clock_set_bg_image(widget_t* widget, const char* bg_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->bg_image = tk_str_copy(time_clock->bg_image, bg_image);
@ -94,7 +94,7 @@ ret_t time_clock_set_bg_image(widget_t* widget, const char* bg_image) {
ret_t time_clock_set_image(widget_t* widget, const char* image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL, RET_BAD_PARAMS);
time_clock->image = tk_str_copy(time_clock->image, image);
@ -103,7 +103,7 @@ ret_t time_clock_set_image(widget_t* widget, const char* image) {
static ret_t time_clock_get_prop(widget_t* widget, const char* name, value_t* v) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(time_clock != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, TIME_CLOCK_PROP_HOUR)) {
value_set_int(v, time_clock->hour);

View File

@ -128,7 +128,7 @@ static ret_t button_on_event(widget_t* widget, event_t* e) {
ret_t button_set_repeat(widget_t* widget, int32_t repeat) {
button_t* button = BUTTON(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(button != NULL, RET_BAD_PARAMS);
button->repeat = repeat;
@ -137,7 +137,7 @@ ret_t button_set_repeat(widget_t* widget, int32_t repeat) {
ret_t button_set_enable_long_press(widget_t* widget, bool_t enable_long_press) {
button_t* button = BUTTON(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(button != NULL, RET_BAD_PARAMS);
button->enable_long_press = enable_long_press;
@ -146,7 +146,7 @@ ret_t button_set_enable_long_press(widget_t* widget, bool_t enable_long_press) {
static ret_t button_get_prop(widget_t* widget, const char* name, value_t* v) {
button_t* button = BUTTON(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(button != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_REPEAT)) {
value_set_int(v, button->repeat);

View File

@ -81,7 +81,7 @@ static ret_t check_button_on_paint_self(widget_t* widget, canvas_t* c) {
static ret_t check_button_set_value_only(widget_t* widget, bool_t value) {
check_button_t* check_button = CHECK_BUTTON(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(check_button != NULL, RET_BAD_PARAMS);
if (check_button->value != value) {
event_t e = event_init(EVT_VALUE_WILL_CHANGE, widget);
@ -99,7 +99,7 @@ static ret_t check_button_set_value_only(widget_t* widget, bool_t value) {
ret_t check_button_set_value(widget_t* widget, bool_t value) {
check_button_t* check_button = CHECK_BUTTON(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(check_button != NULL, RET_BAD_PARAMS);
check_button_set_value_only(widget, value);

View File

@ -82,7 +82,7 @@ static ret_t combo_box_item_set_prop(widget_t* widget, const char* name, const v
static ret_t combo_box_item_get_prop(widget_t* widget, const char* name, value_t* v) {
combo_box_item_t* combo_box_item = COMBO_BOX_ITEM(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(combo_box_item != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_int(v, combo_box_item->value);
@ -113,7 +113,7 @@ widget_t* combo_box_item_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h
ret_t combo_box_item_set_value(widget_t* widget, int32_t value) {
combo_box_item_t* combo_box_item = COMBO_BOX_ITEM(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(combo_box_item != NULL, RET_BAD_PARAMS);
combo_box_item->value = value;
@ -122,7 +122,7 @@ ret_t combo_box_item_set_value(widget_t* widget, int32_t value) {
static ret_t combo_box_item_set_checked_only(widget_t* widget, bool_t checked) {
combo_box_item_t* combo_box_item = COMBO_BOX_ITEM(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(combo_box_item != NULL, RET_BAD_PARAMS);
if (combo_box_item->checked != checked) {
event_t e = event_init(EVT_VALUE_WILL_CHANGE, widget);

View File

@ -87,7 +87,7 @@ widget_t* dialog_create_simple(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h)
ret_t dialog_set_title(widget_t* widget, const char* title) {
dialog_t* dialog = DIALOG(widget);
return_value_if_fail(widget != NULL && title != NULL, RET_BAD_PARAMS);
return_value_if_fail(dialog != NULL && title != NULL, RET_BAD_PARAMS);
return widget_set_text_utf8(dialog->title, title);
}
@ -122,7 +122,7 @@ uint32_t dialog_modal(widget_t* widget) {
ret_t dialog_quit(widget_t* widget, uint32_t code) {
dialog_t* dialog = DIALOG(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(dialog != NULL, RET_BAD_PARAMS);
dialog->quit_code = code;
main_loop_quit(main_loop());
@ -138,14 +138,14 @@ widget_t* dialog_cast(widget_t* widget) {
widget_t* dialog_get_title(widget_t* widget) {
dialog_t* dialog = DIALOG(widget);
return_value_if_fail(widget != NULL, NULL);
return_value_if_fail(dialog != NULL, NULL);
return dialog->title;
}
widget_t* dialog_get_client(widget_t* widget) {
dialog_t* dialog = DIALOG(widget);
return_value_if_fail(widget != NULL, NULL);
return_value_if_fail(dialog != NULL, NULL);
return dialog->client;
}

View File

@ -99,7 +99,7 @@ static ret_t dragger_on_event(widget_t* widget, event_t* e) {
ret_t dragger_set_range(widget_t* widget, xy_t x_min, xy_t y_min, xy_t x_max, xy_t y_max) {
dragger_t* dragger = DRAGGER(widget);
return_value_if_fail(widget != NULL && x_min <= x_max && y_min <= y_max, RET_BAD_PARAMS);
return_value_if_fail(dragger != NULL && x_min <= x_max && y_min <= y_max, RET_BAD_PARAMS);
dragger->x_min = x_min;
dragger->x_max = x_max;
@ -111,7 +111,7 @@ ret_t dragger_set_range(widget_t* widget, xy_t x_min, xy_t y_min, xy_t x_max, xy
static ret_t dragger_get_prop(widget_t* widget, const char* name, value_t* v) {
dragger_t* dragger = DRAGGER(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(dragger != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_X_MIN)) {
value_set_int(v, dragger->x_min);
@ -132,7 +132,7 @@ static ret_t dragger_get_prop(widget_t* widget, const char* name, value_t* v) {
static ret_t dragger_set_prop(widget_t* widget, const char* name, const value_t* v) {
dragger_t* dragger = DRAGGER(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(dragger != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_X_MIN)) {
dragger->x_min = value_int(v);

View File

@ -735,7 +735,7 @@ ret_t edit_on_event(widget_t* widget, event_t* e) {
ret_t edit_set_text_limit(widget_t* widget, uint32_t min, uint32_t max) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->limit.u.t.min = min;
edit->limit.u.t.max = max;
@ -746,7 +746,7 @@ ret_t edit_set_text_limit(widget_t* widget, uint32_t min, uint32_t max) {
ret_t edit_set_int_limit(widget_t* widget, int32_t min, int32_t max, uint32_t step) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->limit.u.i.min = min;
edit->limit.u.i.max = max;
@ -758,7 +758,7 @@ ret_t edit_set_int_limit(widget_t* widget, int32_t min, int32_t max, uint32_t st
ret_t edit_set_float_limit(widget_t* widget, double min, double max, double step) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->limit.u.f.min = min;
edit->limit.u.f.max = max;
@ -770,7 +770,7 @@ ret_t edit_set_float_limit(widget_t* widget, double min, double max, double step
ret_t edit_set_readonly(widget_t* widget, bool_t readonly) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->readonly = readonly;
@ -779,7 +779,7 @@ ret_t edit_set_readonly(widget_t* widget, bool_t readonly) {
ret_t edit_set_auto_fix(widget_t* widget, bool_t auto_fix) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->auto_fix = auto_fix;
@ -788,7 +788,7 @@ ret_t edit_set_auto_fix(widget_t* widget, bool_t auto_fix) {
ret_t edit_set_input_type(widget_t* widget, input_type_t type) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->limit.type = type;
if (type == INPUT_INT || type == INPUT_UINT) {
@ -802,7 +802,7 @@ ret_t edit_set_input_type(widget_t* widget, input_type_t type) {
ret_t edit_set_input_tips(widget_t* widget, const char* tips) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL && tips != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL && tips != NULL, RET_BAD_PARAMS);
TKMEM_FREE(edit->tips);
edit->tips = tk_strdup(tips);
@ -812,9 +812,10 @@ ret_t edit_set_input_tips(widget_t* widget, const char* tips) {
ret_t edit_get_prop(widget_t* widget, const char* name, value_t* v) {
edit_t* edit = EDIT(widget);
input_type_t input_type = edit->limit.type;
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
input_type_t input_type = INPUT_TEXT;
return_value_if_fail(edit != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
input_type = edit->limit.type;
if (tk_str_eq(name, WIDGET_PROP_MIN)) {
if (input_type == INPUT_INT || input_type == INPUT_UINT) {
value_set_int(v, edit->limit.u.i.min);
@ -890,9 +891,10 @@ ret_t edit_get_prop(widget_t* widget, const char* name, value_t* v) {
ret_t edit_set_prop(widget_t* widget, const char* name, const value_t* v) {
edit_t* edit = EDIT(widget);
input_type_t input_type = edit->limit.type;
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
input_type_t input_type = INPUT_TEXT;
return_value_if_fail(edit != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
input_type = edit->limit.type;
if (tk_str_eq(name, WIDGET_PROP_MIN)) {
if (input_type == INPUT_INT || input_type == INPUT_UINT) {
edit->limit.u.i.min = value_int(v);
@ -988,7 +990,7 @@ ret_t edit_set_prop(widget_t* widget, const char* name, const value_t* v) {
ret_t edit_set_password_visible(widget_t* widget, bool_t password_visible) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->password_visible = password_visible;
@ -997,7 +999,7 @@ ret_t edit_set_password_visible(widget_t* widget, bool_t password_visible) {
ret_t edit_set_focus(widget_t* widget, bool_t focus) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
edit->focus = focus;
widget->focused = focus;

View File

@ -30,7 +30,7 @@ static ret_t image_on_paint_self(widget_t* widget, canvas_t* c) {
image_t* image = IMAGE(widget);
vgcanvas_t* vg = lcd_get_vgcanvas(c->lcd);
image_base_t* image_base = IMAGE_BASE(widget);
return_value_if_fail(widget != NULL && c != NULL, RET_BAD_PARAMS);
return_value_if_fail(image != NULL, RET_BAD_PARAMS);
if (image_base->image == NULL) {
return RET_OK;
@ -62,7 +62,7 @@ static ret_t image_on_paint_self(widget_t* widget, canvas_t* c) {
static ret_t image_get_prop(widget_t* widget, const char* name, value_t* v) {
image_t* image = IMAGE(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(image != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_DRAW_TYPE)) {
value_set_int(v, image->draw_type);
@ -122,7 +122,7 @@ widget_t* image_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
ret_t image_set_draw_type(widget_t* widget, image_draw_type_t draw_type) {
image_t* image = IMAGE(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image != NULL, RET_BAD_PARAMS);
image->draw_type = draw_type;

View File

@ -217,7 +217,7 @@ ret_t label_resize_to_content(widget_t* widget, uint32_t min_w, uint32_t max_w,
ret_t label_set_length(widget_t* widget, int32_t length) {
label_t* label = LABEL(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(label != NULL, RET_BAD_PARAMS);
label->length = length;
return widget_invalidate_force(widget, NULL);
@ -225,7 +225,7 @@ ret_t label_set_length(widget_t* widget, int32_t length) {
static ret_t label_get_prop(widget_t* widget, const char* name, value_t* v) {
label_t* label = LABEL(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(label != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_LENGTH)) {
value_set_int(v, label->length);

View File

@ -27,7 +27,7 @@
ret_t pages_set_active(widget_t* widget, uint32_t index) {
pages_t* pages = PAGES(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(pages != NULL, RET_BAD_PARAMS);
if (pages->active != index) {
event_t evt = event_init(EVT_VALUE_WILL_CHANGE, widget);
@ -71,7 +71,7 @@ static ret_t pages_on_paint_children(widget_t* widget, canvas_t* c) {
static ret_t pages_get_prop(widget_t* widget, const char* name, value_t* v) {
pages_t* pages = PAGES(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(pages != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE) || tk_str_eq(name, WIDGET_PROP_ACTIVE)) {
value_set_uint32(v, pages->active);

View File

@ -32,7 +32,7 @@
static ret_t popup_get_prop(widget_t* widget, const char* name, value_t* v) {
popup_t* popup = POPUP(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(popup != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK)) {
value_set_bool(v, popup->close_when_click);
@ -47,7 +47,7 @@ static ret_t popup_get_prop(widget_t* widget, const char* name, value_t* v) {
static ret_t popup_set_prop(widget_t* widget, const char* name, const value_t* v) {
popup_t* popup = POPUP(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(popup != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK)) {
popup->close_when_click = value_bool(v);
@ -134,7 +134,7 @@ widget_t* popup_cast(widget_t* widget) {
ret_t popup_set_close_when_click(widget_t* widget, bool_t close_when_click) {
popup_t* popup = POPUP(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(popup != NULL, RET_FAIL);
popup->close_when_click = close_when_click;
@ -143,7 +143,7 @@ ret_t popup_set_close_when_click(widget_t* widget, bool_t close_when_click) {
ret_t popup_set_close_when_click_outside(widget_t* widget, bool_t close_when_click_outside) {
popup_t* popup = POPUP(widget);
return_value_if_fail(widget != NULL, RET_FAIL);
return_value_if_fail(popup != NULL, RET_FAIL);
popup->close_when_click_outside = close_when_click_outside;

View File

@ -81,7 +81,7 @@ static ret_t progress_bar_on_paint_self(widget_t* widget, canvas_t* c) {
ret_t progress_bar_set_value(widget_t* widget, uint8_t value) {
progress_bar_t* progress_bar = PROGRESS_BAR(widget);
return_value_if_fail(widget != NULL && value <= 100, RET_BAD_PARAMS);
return_value_if_fail(progress_bar != NULL && value <= 100, RET_BAD_PARAMS);
if (progress_bar->value != value) {
event_t e = event_init(EVT_VALUE_WILL_CHANGE, widget);
@ -97,7 +97,7 @@ ret_t progress_bar_set_value(widget_t* widget, uint8_t value) {
ret_t progress_bar_set_vertical(widget_t* widget, bool_t vertical) {
progress_bar_t* progress_bar = PROGRESS_BAR(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_bar != NULL, RET_BAD_PARAMS);
progress_bar->vertical = vertical;
@ -106,7 +106,7 @@ ret_t progress_bar_set_vertical(widget_t* widget, bool_t vertical) {
ret_t progress_bar_set_show_text(widget_t* widget, bool_t show_text) {
progress_bar_t* progress_bar = PROGRESS_BAR(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_bar != NULL, RET_BAD_PARAMS);
progress_bar->show_text = show_text;
@ -115,7 +115,7 @@ ret_t progress_bar_set_show_text(widget_t* widget, bool_t show_text) {
static ret_t progress_bar_get_prop(widget_t* widget, const char* name, value_t* v) {
progress_bar_t* progress_bar = PROGRESS_BAR(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(progress_bar != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_uint8(v, progress_bar->value);

View File

@ -54,8 +54,6 @@ static ret_t slider_paint_dragger(widget_t* widget, canvas_t* c) {
style_t* style = widget->astyle;
color_t trans = color_init(0, 0, 0, 0);
return_value_if_fail(widget != NULL && c != NULL, RET_BAD_PARAMS);
slider_get_dragger_rect(widget, &r);
color = style_get_color(style, STYLE_ID_BORDER_COLOR, trans);
if (color.rgba.a) {
@ -213,7 +211,7 @@ ret_t slider_set_value_internal(widget_t* widget, uint16_t value, event_type_t e
uint16_t step = 0;
uint16_t offset = 0;
slider_t* slider = SLIDER(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(slider != NULL, RET_BAD_PARAMS);
step = slider->step;
value = tk_max(tk_min(value, slider->max), slider->min);
@ -251,7 +249,7 @@ ret_t slider_set_value(widget_t* widget, uint16_t value) {
ret_t slider_set_min(widget_t* widget, uint16_t min) {
slider_t* slider = SLIDER(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(slider != NULL, RET_BAD_PARAMS);
slider->min = min;
@ -260,7 +258,7 @@ ret_t slider_set_min(widget_t* widget, uint16_t min) {
ret_t slider_set_max(widget_t* widget, uint16_t max) {
slider_t* slider = SLIDER(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(slider != NULL, RET_BAD_PARAMS);
slider->max = max;
@ -269,7 +267,7 @@ ret_t slider_set_max(widget_t* widget, uint16_t max) {
ret_t slider_set_step(widget_t* widget, uint16_t step) {
slider_t* slider = SLIDER(widget);
return_value_if_fail(widget != NULL && step > 0, RET_BAD_PARAMS);
return_value_if_fail(slider != NULL && step > 0, RET_BAD_PARAMS);
slider->step = step;
@ -278,7 +276,7 @@ ret_t slider_set_step(widget_t* widget, uint16_t step) {
ret_t slider_set_bar_size(widget_t* widget, uint32_t bar_size) {
slider_t* slider = SLIDER(widget);
return_value_if_fail(widget != NULL && bar_size > 0, RET_BAD_PARAMS);
return_value_if_fail(slider != NULL && bar_size > 0, RET_BAD_PARAMS);
slider->bar_size = bar_size;
@ -287,7 +285,7 @@ ret_t slider_set_bar_size(widget_t* widget, uint32_t bar_size) {
ret_t slider_set_vertical(widget_t* widget, bool_t vertical) {
slider_t* slider = SLIDER(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(slider != NULL, RET_BAD_PARAMS);
slider->vertical = vertical;
@ -296,7 +294,7 @@ ret_t slider_set_vertical(widget_t* widget, bool_t vertical) {
static ret_t slider_get_prop(widget_t* widget, const char* name, value_t* v) {
slider_t* slider = SLIDER(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(slider != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_int(v, slider->value);

View File

@ -59,7 +59,7 @@ static ret_t tab_button_on_paint_self(widget_t* widget, canvas_t* c) {
static ret_t tab_button_set_value_only(widget_t* widget, bool_t value) {
tab_button_t* tab_button = TAB_BUTTON(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(tab_button != NULL, RET_BAD_PARAMS);
if (tab_button->value != value) {
event_t e = event_init(EVT_VALUE_WILL_CHANGE, widget);
@ -124,7 +124,7 @@ static int32_t tab_button_get_min_w(widget_t* widget) {
static ret_t tab_button_get_prop(widget_t* widget, const char* name, value_t* v) {
tab_button_t* tab_button = TAB_BUTTON(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(tab_button != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_VALUE)) {
value_set_bool(v, tab_button->value);

View File

@ -153,7 +153,7 @@ static ret_t tab_button_group_on_paint_end(widget_t* widget, canvas_t* c) {
static ret_t tab_button_group_get_prop(widget_t* widget, const char* name, value_t* v) {
tab_button_group_t* tab_button_group = TAB_BUTTON_GROUP(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(tab_button_group != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_COMPACT)) {
value_set_bool(v, tab_button_group->compact);
@ -165,7 +165,7 @@ static ret_t tab_button_group_get_prop(widget_t* widget, const char* name, value
static ret_t tab_button_group_set_prop(widget_t* widget, const char* name, const value_t* v) {
tab_button_group_t* tab_button_group = TAB_BUTTON_GROUP(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
return_value_if_fail(tab_button_group != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_COMPACT)) {
tab_button_group->compact = value_bool(v);

View File

@ -53,7 +53,7 @@ static ret_t window_get_prop(widget_t* widget, const char* name, value_t* v) {
ret_t window_set_fullscreen(widget_t* widget, bool_t fullscreen) {
window_t* window = WINDOW(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(window != NULL, RET_BAD_PARAMS);
if (window->fullscreen != fullscreen) {
window->fullscreen = fullscreen;

View File

@ -162,6 +162,7 @@ TEST(Edit, basic) {
TEST(Edit, cast) {
widget_t* b = edit_create(NULL, 10, 20, 30, 40);
ASSERT_EQ(b, edit_cast(b));
ASSERT_EQ((edit_t*)NULL, EDIT(NULL));
widget_destroy(b);
}