From 75bb270bb95c528d0b8d04a80ab55456c4bb1cf8 Mon Sep 17 00:00:00 2001 From: Liu Date: Thu, 16 May 2024 00:12:03 +0800 Subject: [PATCH] feat: replace custom bool type with bool type in stdbool.h --- include/LCUI/common.h | 11 ---- lib/css/include/css/types.h | 1 + lib/css/src/value.c | 2 +- lib/pandagl/include/pandagl/canvas.h | 10 +-- lib/pandagl/include/pandagl/rect.h | 10 +-- lib/pandagl/include/pandagl/text.h | 32 ++++----- lib/pandagl/include/pandagl/types.h | 11 ++-- lib/pandagl/src/boxshadow.c | 18 ++--- lib/pandagl/src/canvas.c | 4 +- lib/pandagl/src/font/library.c | 2 +- lib/pandagl/src/image/jpeg.c | 2 +- lib/pandagl/src/rect.c | 10 +-- lib/pandagl/src/text/style_tag.c | 8 +-- lib/pandagl/src/text/text.c | 12 ++-- lib/pandagl/src/tile.c | 2 +- lib/pandagl/src/zoom.c | 4 +- lib/platform/README.md | 4 +- lib/thread/src/pthread.c | 2 +- lib/thread/src/windows.c | 10 +-- lib/ui-cursor/src/cursor.c | 6 +- lib/ui-router/src/link.c | 6 +- lib/ui-router/src/location.c | 6 +- lib/ui-router/src/matcher.c | 12 ++-- lib/ui-router/src/router.c | 4 +- lib/ui-router/src/strmap.c | 6 +- lib/ui-router/src/utils.c | 12 ++-- lib/ui-router/src/view.c | 2 +- lib/ui-router/tests/test.c | 98 ++++++++++++++-------------- lib/ui-widgets/src/anchor.c | 6 +- lib/ui-widgets/src/canvas.c | 4 +- lib/ui-widgets/src/scrollbar.c | 46 ++++++------- lib/ui-widgets/src/textcaret.c | 6 +- lib/ui-widgets/src/textinput.c | 26 ++++---- lib/ui-widgets/src/textstyle.c | 14 ++-- lib/ui/README.md | 6 +- lib/worker/src/worker.c | 10 +-- src/lcui.c | 8 +-- src/lcui_settings.c | 2 +- src/lcui_ui.c | 2 +- tests/cases/test_block_layout.c | 8 +-- tests/cases/test_clipboard.c | 4 +- tests/cases/test_mainloop.c | 6 +- tests/cases/test_scrollbar.c | 8 +-- tests/cases/test_settings.c | 8 +-- tests/cases/test_text_resize.c | 24 +++---- tests/cases/test_textinput.c | 24 +++---- tests/cases/test_thread.c | 10 +-- tests/cases/test_widget_event.c | 42 ++++++------ tests/cases/test_widget_opacity.c | 14 ++-- tests/cases/test_widget_rect.c | 18 ++--- tests/cases/test_xml_parser.c | 18 ++--- tests/test_fill_rect_with_rgba.c | 2 +- tests/test_mix_rect_with_opacity.c | 2 +- tests/test_paint_border.c | 4 +- tests/test_paint_boxshadow.c | 4 +- tests/test_render.c | 6 +- tests/test_string_render.c | 2 +- tests/test_touch.c | 8 +-- tests/test_widget_render.c | 2 +- 59 files changed, 320 insertions(+), 331 deletions(-) diff --git a/include/LCUI/common.h b/include/LCUI/common.h index 4f158a963..94796f347 100644 --- a/include/LCUI/common.h +++ b/include/LCUI/common.h @@ -63,15 +63,4 @@ logger_log(LOGGER_LEVEL_DEBUG, __FILE__ ":%d: %s(): " format, \ __LINE__, __FUNCTION__, ##__VA_ARGS__) -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -typedef unsigned char LCUI_BOOL; -typedef unsigned char uchar_t; - #endif diff --git a/lib/css/include/css/types.h b/lib/css/include/css/types.h index 08ed7c8db..02b9dc88e 100644 --- a/lib/css/include/css/types.h +++ b/lib/css/include/css/types.h @@ -12,6 +12,7 @@ #ifndef LIBCSS_INCLUDE_CSS_DEF_H #define LIBCSS_INCLUDE_CSS_DEF_H +#include #include #include diff --git a/lib/css/src/value.c b/lib/css/src/value.c index e9ce83ad1..aba05d23e 100644 --- a/lib/css/src/value.c +++ b/lib/css/src/value.c @@ -115,7 +115,7 @@ static bool css_valdef_has_children(css_valdef_t *valdef) default: break; } - return FALSE; + return false; } void css_valdef_destroy(css_valdef_t *valdef) diff --git a/lib/pandagl/include/pandagl/canvas.h b/lib/pandagl/include/pandagl/canvas.h index 7a8c6a333..762455d9a 100644 --- a/lib/pandagl/include/pandagl/canvas.h +++ b/lib/pandagl/include/pandagl/canvas.h @@ -67,7 +67,7 @@ PD_INLINE const pd_canvas_t *pd_canvas_get_quote_source_readonly( PD_PUBLIC void pd_canvas_init(pd_canvas_t *canvas); -PD_PUBLIC pd_bool_t pd_canvas_is_valid(const pd_canvas_t *canvas); +PD_PUBLIC bool pd_canvas_is_valid(const pd_canvas_t *canvas); PD_PUBLIC int pd_canvas_quote(pd_canvas_t *self, pd_canvas_t *source, const pd_rect_t *rect); @@ -91,7 +91,7 @@ PD_PUBLIC int pd_canvas_cut(const pd_canvas_t *canvas, pd_rect_t rect, PD_PUBLIC void pd_canvas_copy(pd_canvas_t *des, const pd_canvas_t *src); PD_PUBLIC int pd_canvas_mix(pd_canvas_t *back, const pd_canvas_t *fore, int left, - int top, pd_bool_t with_alpha); + int top, bool with_alpha); PD_PUBLIC int pd_canvas_fill_rect(pd_canvas_t *canvas, pd_color_t color, pd_rect_t rect); @@ -103,17 +103,17 @@ PD_INLINE int pd_canvas_fill(pd_canvas_t *canvas, pd_color_t color) } PD_PUBLIC int pd_canvas_tile(pd_canvas_t *buff, const pd_canvas_t *canvas, - pd_bool_t replace, pd_bool_t with_alpha); + bool replace, bool with_alpha); PD_PUBLIC int pd_canvas_veri_flip(const pd_canvas_t *canvas, pd_canvas_t *buff); PD_PUBLIC int pd_canvas_horiz_flip(const pd_canvas_t *canvas, pd_canvas_t *buff); PD_PUBLIC int pd_canvas_zoom(const pd_canvas_t *canvas, pd_canvas_t *buff, - pd_bool_t keep_scale, int width, int height); + bool keep_scale, int width, int height); PD_PUBLIC int pd_canvas_zoom_bilinear(const pd_canvas_t *canvas, - pd_canvas_t *buff, pd_bool_t keep_scale, + pd_canvas_t *buff, bool keep_scale, int width, int height); PD_END_DECLS diff --git a/lib/pandagl/include/pandagl/rect.h b/lib/pandagl/include/pandagl/rect.h index ea9f6513d..6b0eb82b5 100644 --- a/lib/pandagl/include/pandagl/rect.h +++ b/lib/pandagl/include/pandagl/rect.h @@ -18,7 +18,7 @@ PD_BEGIN_DECLS -PD_INLINE pd_bool_t pd_rect_is_include(pd_rect_t *a, pd_rect_t *b) +PD_INLINE bool pd_rect_is_include(pd_rect_t *a, pd_rect_t *b) { return (b->x >= a->x && b->x + b->width <= a->x + a->width && b->y >= a->y && b->y + b->height <= a->y + a->height); @@ -29,11 +29,11 @@ PD_PUBLIC pd_rect_t pd_rect_crop(const pd_rect_t *rect, int container_width, int container_height); /** 将矩形区域纠正在容器有效区域内 */ -PD_PUBLIC pd_bool_t pd_rect_correct(pd_rect_t *rect, int container_width, +PD_PUBLIC bool pd_rect_correct(pd_rect_t *rect, int container_width, int container_height); /** 检测矩形是否遮盖另一个矩形 */ -PD_PUBLIC pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b); +PD_PUBLIC bool pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b); /** * 获取两个矩形中的重叠矩形 @@ -42,13 +42,13 @@ PD_PUBLIC pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b); * @param[out] out 矩形A和B重叠处的矩形 * @returns 如果两个矩形重叠,则返回PD_TRUE,否则返回PD_FALSE */ -PD_PUBLIC pd_bool_t pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b, +PD_PUBLIC bool pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b, pd_rect_t *overlapping_rect); PD_PUBLIC void pd_rect_split(pd_rect_t *base, pd_rect_t *target, pd_rect_t rects[4]); -PD_INLINE pd_bool_t pd_rect_is_equal(const pd_rect_t *a, const pd_rect_t *b) +PD_INLINE bool pd_rect_is_equal(const pd_rect_t *a, const pd_rect_t *b) { return a->x == b->x && a->y == b->y && a->width == b->width && a->height == b->height; diff --git a/lib/pandagl/include/pandagl/text.h b/lib/pandagl/include/pandagl/text.h index f36cf541a..00bfe8875 100644 --- a/lib/pandagl/include/pandagl/text.h +++ b/lib/pandagl/include/pandagl/text.h @@ -20,12 +20,12 @@ PD_BEGIN_DECLS typedef struct pd_text_style_t { - pd_bool_t has_family : 1; - pd_bool_t has_style : 1; - pd_bool_t has_weight : 1; - pd_bool_t has_back_color : 1; - pd_bool_t has_fore_color : 1; - pd_bool_t has_pixel_size : 1; + bool has_family : 1; + bool has_style : 1; + bool has_weight : 1; + bool has_back_color : 1; + bool has_fore_color : 1; + bool has_pixel_size : 1; int style; int weight; @@ -109,19 +109,19 @@ typedef struct pd_text_t { int line_height; pd_text_align_t text_align; pd_word_break_t word_break; - pd_bool_t mulitiline_enabled; - pd_bool_t autowrap_enabled; - pd_bool_t style_tag_enabled; + bool mulitiline_enabled; + bool autowrap_enabled; + bool style_tag_enabled; list_t dirty_rects; list_t styles; pd_text_style_t default_style; pd_text_line_t **lines; int lines_length; struct { - pd_bool_t update_bitmap; - pd_bool_t update_typeset; + bool update_bitmap; + bool update_typeset; int typeset_start_line; - pd_bool_t redraw_all; + bool redraw_all; } task; } pd_text_t; @@ -141,7 +141,7 @@ PD_PUBLIC void pd_text_set_typeset_task(pd_text_t *layer, int start_row); PD_PUBLIC void pd_text_set_align(pd_text_t *layer, int align); /** 设置坐标偏移量 */ -PD_PUBLIC pd_bool_t pd_text_set_offset(pd_text_t *layer, int offset_x, +PD_PUBLIC bool pd_text_set_offset(pd_text_t *layer, int offset_x, int offset_y); PD_PUBLIC pd_text_t *pd_text_create(void); @@ -195,7 +195,7 @@ PD_PUBLIC int pd_text_set_fixed_size(pd_text_t *layer, int width, int height); PD_PUBLIC int pd_text_set_max_size(pd_text_t *layer, int width, int height); /** 设置是否启用多行文本模式 */ -PD_PUBLIC void pd_text_set_multiline(pd_text_t *layer, pd_bool_t enabled); +PD_PUBLIC void pd_text_set_multiline(pd_text_t *layer, bool enabled); /** 删除文本光标的当前坐标右边的文本 */ PD_PUBLIC int pd_text_delete(pd_text_t *layer, int n_char); @@ -204,13 +204,13 @@ PD_PUBLIC int pd_text_delete(pd_text_t *layer, int n_char); PD_PUBLIC int pd_text_backspace(pd_text_t *layer, int n_char); /** 设置是否启用自动换行模式 */ -PD_PUBLIC void pd_text_set_autowrap(pd_text_t *layer, pd_bool_t autowrap); +PD_PUBLIC void pd_text_set_autowrap(pd_text_t *layer, bool autowrap); /** 设置单词内断行模式 */ PD_PUBLIC void pd_text_set_word_break(pd_text_t *layer, pd_word_break_t mode); /** 设置是否使用样式标签 */ -PD_PUBLIC void pd_text_set_style_tag(pd_text_t *layer, pd_bool_t enabled); +PD_PUBLIC void pd_text_set_style_tag(pd_text_t *layer, bool enabled); /** 重新载入各个文字的字体位图 */ PD_PUBLIC void pd_text_reload_bitmap(pd_text_t *layer); diff --git a/lib/pandagl/include/pandagl/types.h b/lib/pandagl/include/pandagl/types.h index e399bbff8..7717eb385 100644 --- a/lib/pandagl/include/pandagl/types.h +++ b/lib/pandagl/include/pandagl/types.h @@ -13,10 +13,9 @@ #define LIB_PANDAGL_INCLUDE_PANDAGL_TPYES_H #include +#include #include -typedef unsigned char pd_bool_t; - #define PD_FALSE 0 #define PD_TRUE 1 @@ -65,7 +64,7 @@ typedef struct pd_canvas_t pd_canvas_t; typedef struct pd_canvas_quote_t { int top; int left; - pd_bool_t is_valid; + bool is_valid; pd_canvas_t *source; } pd_canvas_quote_t; @@ -88,14 +87,14 @@ struct pd_canvas_t { typedef struct pd_context_t { pd_rect_t rect; /**< 需要绘制的区域 */ pd_canvas_t canvas; /**< 绘制后的位图缓存(可称为:画布) */ - pd_bool_t with_alpha; /**< 绘制时是否需要处理 alpha 通道 */ + bool with_alpha; /**< 绘制时是否需要处理 alpha 通道 */ } pd_context_t; typedef struct pd_background_t { pd_canvas_t *image; pd_color_t color; - pd_bool_t repeat_x; - pd_bool_t repeat_y; + bool repeat_x; + bool repeat_y; int x; int y; int width; diff --git a/lib/pandagl/src/boxshadow.c b/lib/pandagl/src/boxshadow.c index 0a4b69b85..086034403 100644 --- a/lib/pandagl/src/boxshadow.c +++ b/lib/pandagl/src/boxshadow.c @@ -140,7 +140,7 @@ void pd_get_boxshadow_canvas_rect(const pd_boxshadow_t *shadow, canvas_rect->y; } -static pd_bool_t pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx) { int x, y; int right; @@ -181,7 +181,7 @@ static pd_bool_t pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx) return PD_TRUE; } -static pd_bool_t pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx) { int x, y; int left; @@ -222,7 +222,7 @@ static pd_bool_t pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx) return PD_TRUE; } -static pd_bool_t pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx) { int x, y; int bottom; @@ -263,7 +263,7 @@ static pd_bool_t pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx) return PD_TRUE; } -static pd_bool_t pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx) { int x, y; int top; @@ -303,7 +303,7 @@ static pd_bool_t pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx) return PD_TRUE; } -static pd_bool_t pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx, +static bool pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx, const pd_rect_t *circle_rect, double center_x, double center_y, int radius) @@ -373,7 +373,7 @@ static pd_bool_t pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx, return PD_TRUE; } -static pd_bool_t pd_paint_boxshadow_top_left_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_top_left_blur(pd_boxshadow_context_t *ctx) { int radius; pd_rect_t rect; @@ -388,7 +388,7 @@ static pd_bool_t pd_paint_boxshadow_top_left_blur(pd_boxshadow_context_t *ctx) rect.height, radius); } -static pd_bool_t pd_paint_boxshadow_top_right_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_top_right_blur(pd_boxshadow_context_t *ctx) { int radius; pd_rect_t rect; @@ -403,7 +403,7 @@ static pd_bool_t pd_paint_boxshadow_top_right_blur(pd_boxshadow_context_t *ctx) radius); } -static pd_bool_t pd_paint_boxshadow_bottom_left_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_bottom_left_blur(pd_boxshadow_context_t *ctx) { int radius; pd_rect_t rect; @@ -418,7 +418,7 @@ static pd_bool_t pd_paint_boxshadow_bottom_left_blur(pd_boxshadow_context_t *ctx radius); } -static pd_bool_t pd_paint_boxshadow_bottom_right_blur(pd_boxshadow_context_t *ctx) +static bool pd_paint_boxshadow_bottom_right_blur(pd_boxshadow_context_t *ctx) { int radius; pd_rect_t rect; diff --git a/lib/pandagl/src/canvas.c b/lib/pandagl/src/canvas.c index 51f237815..c66f131fa 100644 --- a/lib/pandagl/src/canvas.c +++ b/lib/pandagl/src/canvas.c @@ -27,7 +27,7 @@ void pd_canvas_init(pd_canvas_t *canvas) canvas->bytes_per_row = 0; } -pd_bool_t pd_canvas_is_valid(const pd_canvas_t *canvas) +bool pd_canvas_is_valid(const pd_canvas_t *canvas) { if (!canvas) { return PD_FALSE; @@ -378,7 +378,7 @@ static void pd_canvas_mix_argb2rgb(pd_canvas_t *des, pd_rect_t des_rect, } int pd_canvas_mix(pd_canvas_t *back, const pd_canvas_t *fore, int left, int top, - pd_bool_t with_alpha) + bool with_alpha) { pd_canvas_t w_slot; pd_rect_t r_rect, w_rect; diff --git a/lib/pandagl/src/font/library.c b/lib/pandagl/src/font/library.c index bf992a959..e909b147d 100644 --- a/lib/pandagl/src/font/library.c +++ b/lib/pandagl/src/font/library.c @@ -52,7 +52,7 @@ typedef struct font_family_node_t { static struct font_library_module_t { int count; /**< 计数器,主要用于为字体信息生成标识号 */ int font_cache_num; /**< 字体信息缓存区的数量 */ - pd_bool_t active; /**< 标记,指示数据库是否初始化 */ + bool active; /**< 标记,指示数据库是否初始化 */ dict_t *font_families; /**< 字族信息库,以字族名称索引字体信息 */ dict_type_t font_families_type; /**< 字族信息库的字典类型数据 */ rbtree_t bitmap_cache; /**< 字体位图缓存区 */ diff --git a/lib/pandagl/src/image/jpeg.c b/lib/pandagl/src/image/jpeg.c index 446cd0635..eaf5cc1c3 100644 --- a/lib/pandagl/src/image/jpeg.c +++ b/lib/pandagl/src/image/jpeg.c @@ -34,7 +34,7 @@ typedef struct pd_jpeg_reader_t { struct jpeg_decompress_struct cinfo; jmp_buf env; pd_jpeg_error_t err; - pd_bool_t start_of_file; + bool start_of_file; pd_image_reader_t *base; unsigned char buffer[BUFFER_SIZE]; } pd_jpeg_reader_t; diff --git a/lib/pandagl/src/rect.c b/lib/pandagl/src/rect.c index 783025757..531d8505e 100644 --- a/lib/pandagl/src/rect.c +++ b/lib/pandagl/src/rect.c @@ -42,10 +42,10 @@ pd_rect_t pd_rect_crop(const pd_rect_t *rect, int container_width, return cropped_rect; } -pd_bool_t pd_rect_correct(pd_rect_t *rect, int container_width, +bool pd_rect_correct(pd_rect_t *rect, int container_width, int container_height) { - pd_bool_t overflow = PD_FALSE; + bool overflow = PD_FALSE; if (rect->x < 0) { overflow = PD_TRUE; @@ -77,7 +77,7 @@ pd_bool_t pd_rect_correct(pd_rect_t *rect, int container_width, return overflow; } -pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b) +bool pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b) { if (a->x > b->x) { if (b->x + b->width <= a->x) { @@ -100,7 +100,7 @@ pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b) return PD_TRUE; } -pd_bool_t pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b, +bool pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b, pd_rect_t *overlapping_rect) { if (a->x > b->x) { @@ -286,7 +286,7 @@ int pd_rects_remove(list_t *list, pd_rect_t *rect) { int i; - pd_bool_t deletable; + bool deletable; pd_rect_t *p, child_rects[4]; list_t extra_list; diff --git a/lib/pandagl/src/text/style_tag.c b/lib/pandagl/src/text/style_tag.c index f77beadea..bc6242ab3 100644 --- a/lib/pandagl/src/text/style_tag.c +++ b/lib/pandagl/src/text/style_tag.c @@ -42,7 +42,7 @@ pd_text_style_t *pd_style_tags_get_text_style(list_t *tags) list_node_t *node; pd_style_tag_t *tag; pd_text_style_t *style; - pd_bool_t found_tags[PD_TEXT_STYLE_TYPE_TOTAL_NUM] = { 0 }; + bool found_tags[PD_TEXT_STYLE_TYPE_TOTAL_NUM] = { 0 }; if (tags->length <= 0) { return NULL; @@ -170,7 +170,7 @@ const wchar_t *pd_scan_style_open_tag(const wchar_t *wstr, wchar_t *name, int max_name_len, wchar_t *data) { size_t i, j, len; - pd_bool_t end_name = FALSE; + bool end_name = false; len = wcslen(wstr); if (wstr[0] != '<') { @@ -181,7 +181,7 @@ const wchar_t *pd_scan_style_open_tag(const wchar_t *wstr, wchar_t *name, if (wstr[i] == ' ') { /* 如果上个字符不是空格,说明标签名已经结束 */ if (i > 0 && wstr[i - 1] != ' ') { - end_name = TRUE; + end_name = true; } /* 标签名首部和尾部可包含空格 */ if (j == 0 || max_name_len == 0 || @@ -287,7 +287,7 @@ static const wchar_t *pd_scan_style_tag_by_name(const wchar_t *wstr, return wstr + i; } -static pd_bool_t pd_parse_color(const char *str, pd_color_t *value) +static bool pd_parse_color(const char *str, pd_color_t *value) { size_t len = strlen(str); int r, g, b; diff --git a/lib/pandagl/src/text/text.c b/lib/pandagl/src/text/text.c index c3723b92d..5bad93c9a 100644 --- a/lib/pandagl/src/text/text.c +++ b/lib/pandagl/src/text/text.c @@ -570,7 +570,7 @@ static void pd_text_typeset_line(pd_text_t *text, int line_num) pd_char_t *txtchar; pd_text_line_t *line = text->lines[line_num]; - pd_bool_t autowrap = + bool autowrap = max_width > 0 && text->autowrap_enabled && text->mulitiline_enabled; for (col = 0; col < line->length; ++col) { @@ -665,7 +665,7 @@ static int pd_text_process(pd_text_t *text, const wchar_t *wstr, list_t tmp_tags; const wchar_t *p; int cur_col, cur_line, start_line, ins_x, ins_y; - pd_bool_t need_typeset, rect_has_added; + bool need_typeset, rect_has_added; pd_text_style_t *style = NULL; if (!wstr) { @@ -866,7 +866,7 @@ int pd_text_set_max_size(pd_text_t *text, int width, int height) } /** 设置是否启用多行文本模式 */ -void pd_text_set_multiline(pd_text_t *text, pd_bool_t enabled) +void pd_text_set_multiline(pd_text_t *text, bool enabled) { if (text->mulitiline_enabled != enabled) { text->mulitiline_enabled = enabled; @@ -1054,7 +1054,7 @@ int pd_text_backspace(pd_text_t *text, int n_char) return 0; } -void pd_text_set_autowrap(pd_text_t *text, pd_bool_t autowrap) +void pd_text_set_autowrap(pd_text_t *text, bool autowrap) { if (text->autowrap_enabled != autowrap) { text->autowrap_enabled = autowrap; @@ -1071,7 +1071,7 @@ void pd_text_set_word_break(pd_text_t *text, pd_word_break_t word_break) } /** 设置是否使用样式标签 */ -void pd_text_set_style_tag(pd_text_t *text, pd_bool_t enabled) +void pd_text_set_style_tag(pd_text_t *text, bool enabled) { text->style_tag_enabled = enabled; } @@ -1255,7 +1255,7 @@ void pd_text_set_line_height(pd_text_t *text, int height) text->task.typeset_start_line = 0; } -pd_bool_t pd_text_set_offset(pd_text_t *text, int offset_x, int offset_y) +bool pd_text_set_offset(pd_text_t *text, int offset_x, int offset_y) { if (text->new_offset_x != offset_x || text->new_offset_y != offset_y) { text->new_offset_x = offset_x; diff --git a/lib/pandagl/src/tile.c b/lib/pandagl/src/tile.c index 581dda2a9..ebd9b78bf 100644 --- a/lib/pandagl/src/tile.c +++ b/lib/pandagl/src/tile.c @@ -12,7 +12,7 @@ #include int pd_canvas_tile(pd_canvas_t *buff, const pd_canvas_t *canvas, - pd_bool_t replace, pd_bool_t with_alpha) + bool replace, bool with_alpha) { int ret = 0; unsigned x, y; diff --git a/lib/pandagl/src/zoom.c b/lib/pandagl/src/zoom.c index e68b2d48c..db9ffa20c 100644 --- a/lib/pandagl/src/zoom.c +++ b/lib/pandagl/src/zoom.c @@ -19,7 +19,7 @@ static uint8_t canvas_bilinear_resampling_core(uint8_t a, uint8_t b, uint8_t c, } int pd_canvas_zoom(const pd_canvas_t *canvas, pd_canvas_t *buff, - pd_bool_t keep_scale, int width, int height) + bool keep_scale, int width, int height) { pd_rect_t rect; int x, y, src_x, src_y; @@ -90,7 +90,7 @@ int pd_canvas_zoom(const pd_canvas_t *canvas, pd_canvas_t *buff, } int pd_canvas_zoom_bilinear(const pd_canvas_t *canvas, pd_canvas_t *buff, - pd_bool_t keep_scale, int width, int height) + bool keep_scale, int width, int height) { pd_rect_t rect; pd_color_t a, b, c, d, t_color; diff --git a/lib/platform/README.md b/lib/platform/README.md index 5a7eeaf93..d00e13a75 100644 --- a/lib/platform/README.md +++ b/lib/platform/README.md @@ -77,7 +77,7 @@ void on_window_paint(app_event_t *e, void *arg) // 开始绘制,创建绘制上下文 paint = app_window_begin_paint(e->window, &e->paint.rect); // 自定义绘制窗口内容,例如填充白色: - pd_canvas_fill_rect(&paint->canvas, RGB(255, 255, 255), NULL, TRUE); + pd_canvas_fill_rect(&paint->canvas, RGB(255, 255, 255), NULL, true); // 结束绘制,销毁绘制上下文 app_window_end_paint(e->window, paint); } @@ -125,7 +125,7 @@ int main(int argc, char *argv) // 设置每秒 60 tick timer.target_elapsed_time = 1000 / 60; - timer.is_fixed_time_step = TRUE; + timer.is_fixed_time_step = true; step_timer_init(&timer); while (frames <= 240) { step_timer_tick(&timer, on_tick, &frames); diff --git a/lib/thread/src/pthread.c b/lib/thread/src/pthread.c index fbbe9770b..6c2fc17df 100644 --- a/lib/thread/src/pthread.c +++ b/lib/thread/src/pthread.c @@ -199,7 +199,7 @@ int thread_create(thread_t *tid, void (*func)(void *), void *arg) if (!thread_manager.active) { list_create(&thread_manager.threads); thread_mutex_init(&thread_manager.mutex); - thread_manager.active = TRUE; + thread_manager.active = true; } thread = malloc(sizeof(thread_info_t)); if (!thread) { diff --git a/lib/thread/src/windows.c b/lib/thread/src/windows.c index fa8a971da..1ca511cae 100644 --- a/lib/thread/src/windows.c +++ b/lib/thread/src/windows.c @@ -45,7 +45,7 @@ int thread_cond_init(thread_cond_t *cond) { HANDLE handle; - handle = CreateEvent(NULL, FALSE, FALSE, NULL); + handle = CreateEvent(NULL, false, false, NULL); if (handle == 0) { return -1; } @@ -140,7 +140,7 @@ int thread_mutex_init(thread_mutex_t *mutex) if (!*mutex) { return -1; } - (*mutex)->handle = CreateMutex(NULL, FALSE, NULL); + (*mutex)->handle = CreateMutex(NULL, false, NULL); return 0; } @@ -178,7 +178,7 @@ int thread_mutex_lock(thread_mutex_t *mutex) /* Unlock the mutex */ int thread_mutex_unlock(thread_mutex_t *mutex) { - if (ReleaseMutex((*mutex)->handle) == FALSE) { + if (ReleaseMutex((*mutex)->handle) == false) { return -1; } return 0; @@ -199,7 +199,7 @@ int thread_create(thread_t *tid, void (*func)(void *), void *arg) if (!thread_manager.active) { list_create(&thread_manager.threads); thread_mutex_init(&thread_manager.mutex); - thread_manager.active = TRUE; + thread_manager.active = true; } thread = malloc(sizeof(thread_info_t)); if (!thread) { @@ -304,7 +304,7 @@ int thread_join(thread_t tid, void **retval) thread_mutex_unlock(&thread_manager.mutex); return -1; } - thread->has_waiter = TRUE; + thread->has_waiter = true; thread_mutex_unlock(&thread_manager.mutex); do { code = 0; diff --git a/lib/ui-cursor/src/cursor.c b/lib/ui-cursor/src/cursor.c index f09d94da4..e98069a71 100644 --- a/lib/ui-cursor/src/cursor.c +++ b/lib/ui-cursor/src/cursor.c @@ -156,14 +156,14 @@ bool ui_cursor_is_visible(void) void ui_cursor_show(void) { - ui_cursor.visible = TRUE; + ui_cursor.visible = true; ui_cursor_refresh(); } void ui_cursor_hide(void) { ui_cursor_refresh(); - ui_cursor.visible = FALSE; + ui_cursor.visible = false; } void ui_cursor_set_position(int x, int y) @@ -203,7 +203,7 @@ int ui_cursor_paint(app_window_t *w, app_window_paint_t* paint) // TODO: 转换为窗口客户区内的坐标 x = ui_cursor.x - paint->rect.x; y = ui_cursor.y - paint->rect.y; - return pd_canvas_mix(&paint->canvas, &ui_cursor.image, x, y, FALSE); + return pd_canvas_mix(&paint->canvas, &ui_cursor.image, x, y, false); } void ui_cursor_init(void) diff --git a/lib/ui-router/src/link.c b/lib/ui-router/src/link.c index c54c77bb6..195b96e31 100644 --- a/lib/ui-router/src/link.c +++ b/lib/ui-router/src/link.c @@ -39,7 +39,7 @@ static void ui_router_link_on_route_update(void *w, const router_route_t *to, return; } link = ui_widget_get_data(w, ui_router_link_proto); - resolved = router_resolve(link->router, link->to, FALSE); + resolved = router_resolve(link->router, link->to, false); route = router_resolved_get_route(resolved); // https://github.com/vuejs/vue-router/blob/65de048ee9f0ebf899ae99c82b71ad397727e55d/src/components/link.js#L65 is_same_route = router_is_same_route(to, route); @@ -141,8 +141,8 @@ static void ui_router_link_on_init(ui_widget_t *w) link->active_class = strdup("router-link-active"); link->exact_active_class = strdup("router-link-exact-active"); link->to = NULL; - link->replace = FALSE; - link->exact = FALSE; + link->replace = false; + link->exact = false; link->router = NULL; link->watcher = NULL; ui_widget_on(w, "ready", ui_router_link_on_ready, NULL); diff --git a/lib/ui-router/src/location.c b/lib/ui-router/src/location.c index 2c2726f6c..8d1da71cf 100644 --- a/lib/ui-router/src/location.c +++ b/lib/ui-router/src/location.c @@ -22,7 +22,7 @@ router_location_t *router_location_create(const char *name, const char *path) location->hash = NULL; location->query = NULL; location->params = NULL; - location->normalized = FALSE; + location->normalized = false; return location; } @@ -101,7 +101,7 @@ static router_location_t *router_location_from_path( strmap_extend(query, raw->query); location->query = query; location->hash = hash; - location->normalized = TRUE; + location->normalized = true; router_mem_free(query_str); return location; } @@ -121,7 +121,7 @@ router_location_t *router_location_normalize(const router_location_t *raw, } if (!raw->path && raw->params && current) { location = router_location_duplicate(raw); - location->normalized = TRUE; + location->normalized = true; params = strmap_create(); strmap_extend(params, current->params); strmap_extend(params, raw->params); diff --git a/lib/ui-router/src/matcher.c b/lib/ui-router/src/matcher.c index c21cdc4d3..a11183715 100644 --- a/lib/ui-router/src/matcher.c +++ b/lib/ui-router/src/matcher.c @@ -56,7 +56,7 @@ router_route_record_t *router_matcher_add_route_record( list_node_t *node; record = router_route_record_create(); - record->path = router_path_resolve(config->path, base_path, TRUE); + record->path = router_path_resolve(config->path, base_path, true); strmap_extend(record->components, config->components); if (config->name) { if (dict_fetch_value(matcher->name_map, config->name)) { @@ -107,8 +107,8 @@ bool router_matcher_match_route(router_route_record_t *record, const char *path, size_t record_nodes_count; size_t path_match_len = 0; size_t path_match_i = 0; - bool matched = TRUE; - bool match_all = FALSE; + bool matched = true; + bool match_all = false; nodes_count = strsplit(path, "/", &nodes); record_nodes_count = strsplit(record->path, "/", &record_nodes); @@ -124,7 +124,7 @@ bool router_matcher_match_route(router_route_record_t *record, const char *path, "[router] %s", "the asterisk should be at the end\n"); } - match_all = TRUE; + match_all = true; } if (match_all) { if (path_match_len > 0) { @@ -145,7 +145,7 @@ bool router_matcher_match_route(router_route_record_t *record, const char *path, } else if (record_nodes[j][0] == ':') { strmap_set(params, record_nodes[j] + 1, nodes[i]); } else if (strcmp(record_nodes[j], nodes[i]) != 0) { - matched = FALSE; + matched = false; break; } ++j; @@ -236,7 +236,7 @@ router_route_t *router_matcher_match(router_matcher_t *matcher, router_location_t *location; location = - router_location_normalize(raw_location, current_route, FALSE); + router_location_normalize(raw_location, current_route, false); if (location->name) { route = router_matcher_match_by_name(matcher, location, current_route); diff --git a/lib/ui-router/src/router.c b/lib/ui-router/src/router.c index 7d9e4c3af..9921d241c 100644 --- a/lib/ui-router/src/router.c +++ b/lib/ui-router/src/router.c @@ -129,7 +129,7 @@ void router_push(router_t *router, router_location_t *location) { router_resolved_t *resolved; - resolved = router_resolve(router, location, FALSE); + resolved = router_resolve(router, location, false); router_history_push(router->history, resolved->route); resolved->route = NULL; router_resolved_destroy(resolved); @@ -139,7 +139,7 @@ void router_replace(router_t *router, router_location_t *location) { router_resolved_t *resolved; - resolved = router_resolve(router, location, FALSE); + resolved = router_resolve(router, location, false); router_history_replace(router->history, resolved->route); resolved->route = NULL; router_resolved_destroy(resolved); diff --git a/lib/ui-router/src/strmap.c b/lib/ui-router/src/strmap.c index 04a6b61b1..44776a296 100644 --- a/lib/ui-router/src/strmap.c +++ b/lib/ui-router/src/strmap.c @@ -130,17 +130,17 @@ bool strmap_includes(strmap_t *a, strmap_t *b) value = strmap_get(a, item->key); if (!value || strcmp(value, item->value) != 0) { strmap_destroy_iterator(iter); - return FALSE; + return false; } } strmap_destroy_iterator(iter); - return TRUE; + return true; } bool strmap_equal(strmap_t *a, strmap_t *b) { if (dict_size(a->dict) != dict_size(b->dict)) { - return FALSE; + return false; } return strmap_includes(a, b); } diff --git a/lib/ui-router/src/utils.c b/lib/ui-router/src/utils.c index 133fdeda7..2a79149ff 100644 --- a/lib/ui-router/src/utils.c +++ b/lib/ui-router/src/utils.c @@ -257,7 +257,7 @@ bool router_path_starts_with(const char *path, const char *subpath) while (*p && *q) { if (*p != *q) { - return FALSE; + return false; } p++; q++; @@ -268,19 +268,19 @@ bool router_path_starts_with(const char *path, const char *subpath) if (*q == '/' && !*(q + 1)) { q++; } else { - return FALSE; + return false; } } if (q - subpath > 0) { // path: "path/to/a/b/c" // subpath: "path/to/" if (*(q - 1) == '/') { - return TRUE; + return true; } // path: "path/to/a/b/c" // subpath: "path/to" if (*p == '/') { - return TRUE; + return true; } } return *p == *q; @@ -291,7 +291,7 @@ bool router_path_starts_with(const char *path, const char *subpath) bool router_is_same_route(const router_route_t *a, const router_route_t *b) { if (!b) { - return FALSE; + return false; } if (a->path && b->path) { return router_path_compare(a->path, b->path) == 0 && @@ -304,7 +304,7 @@ bool router_is_same_route(const router_route_t *a, const router_route_t *b) strmap_equal(a->query, b->query) && strmap_equal(a->params, b->params); } - return FALSE; + return false; } // https://github.com/vuejs/vue-router/blob/65de048ee9f0ebf899ae99c82b71ad397727e55d/src/util/route.js#L115 diff --git a/lib/ui-router/src/view.c b/lib/ui-router/src/view.c index 5703b93fb..39aa200e8 100644 --- a/lib/ui-router/src/view.c +++ b/lib/ui-router/src/view.c @@ -128,7 +128,7 @@ static void ui_router_view_on_init(ui_widget_t *w) view->watcher = NULL; dict_init_string_copy_key_type(&view->cache_dict_type); view->cache = dict_create(&view->cache_dict_type, NULL); - view->keep_alive = FALSE; + view->keep_alive = false; ui_widget_on(w, "ready", ui_router_view_on_ready, NULL); } diff --git a/lib/ui-router/tests/test.c b/lib/ui-router/tests/test.c index bbb84cb16..658cf56a8 100644 --- a/lib/ui-router/tests/test.c +++ b/lib/ui-router/tests/test.c @@ -24,7 +24,7 @@ void test_router_location(void) char *path; raw = router_location_create(NULL, "/search?type=issue&order=desc"); - location = router_location_normalize(raw, NULL, FALSE); + location = router_location_normalize(raw, NULL, false); str = strmap_get(location->query, "type"); ctest_equal_str("location.query.type", str, "issue"); @@ -39,7 +39,7 @@ void test_router_location(void) router_location_destroy(location); raw = router_location_create(NULL, "/search?type=issue#pagination"); - location = router_location_normalize(raw, NULL, FALSE); + location = router_location_normalize(raw, NULL, false); str = location->hash; ctest_equal_str("location.hash", str, "#pagination"); @@ -55,7 +55,7 @@ void test_router_location(void) raw = router_location_create(NULL, NULL); router_location_set_param(raw, "user", "foo"); router_location_set_param(raw, "repo", "bar"); - location = router_location_normalize(raw, route, FALSE); + location = router_location_normalize(raw, route, false); ctest_equal_str( "normalize({ params: { user: 'foo', repo: 'bar' } }).path", router_location_get_path(location), "/repos/foo/bar/issues"); @@ -65,7 +65,7 @@ void test_router_location(void) raw = router_location_create(NULL, NULL); router_location_set_param(raw, "user", "root"); router_location_set_param(raw, "repo", "example"); - location = router_location_normalize(raw, route, FALSE); + location = router_location_normalize(raw, route, false); ctest_equal_str( "normalize({ params: { user: 'root', repo: 'example' } }).path", router_location_get_path(location), "/repos/root/example/issues"); @@ -75,7 +75,7 @@ void test_router_location(void) raw = router_location_create(NULL, NULL); router_location_set_query(raw, "q", "bug"); router_location_set_query(raw, "state", "closed"); - location = router_location_normalize(raw, route, FALSE); + location = router_location_normalize(raw, route, false); path = router_location_stringify(location); ctest_equal_str( "stringify(normalize({ query: { q: 'bug', state: 'closed' } }))", @@ -87,7 +87,7 @@ void test_router_location(void) raw = router_location_create(NULL, NULL); router_location_set_query(raw, "order", "desc"); router_location_set_query(raw, "assignee", "root"); - location = router_location_normalize(raw, route, FALSE); + location = router_location_normalize(raw, route, false); path = router_location_stringify(location); ctest_equal_str("stringify(normalize({ query: { order: 'desc', " "assignee: 'root' } }))", @@ -110,7 +110,7 @@ void test_router_route(void) "/user/profile?tab=repos&order=desc&q=test#pagination"; raw = router_location_create(NULL, full_path); - location = router_location_normalize(raw, NULL, FALSE); + location = router_location_normalize(raw, NULL, false); route = router_route_create(NULL, location); ctest_equal_str("route.path", router_route_get_path(route), @@ -206,7 +206,7 @@ void test_router_matcher(void) router_config_destroy(config); location = router_location_create(NULL, "/users/root"); - resolved = router_resolve(router, location, FALSE); + resolved = router_resolve(router, location, false); router_location_destroy(location); route = router_resolved_get_route(resolved); str = router_route_get_param(route, "username"); @@ -215,8 +215,8 @@ void test_router_matcher(void) router_resolved_destroy(resolved); location = router_location_create("user#posts", NULL); - resolved = router_resolve(router, location, FALSE); - ctest_equal_bool("match({ name: 'user#posts' })", !resolved, FALSE); + resolved = router_resolve(router, location, false); + ctest_equal_bool("match({ name: 'user#posts' })", !resolved, false); router_location_destroy(location); router_resolved_destroy(resolved); @@ -224,8 +224,8 @@ void test_router_matcher(void) router_push(router, location); router_location_destroy(location); location = router_location_create("user#posts", NULL); - resolved = router_resolve(router, location, FALSE); - ctest_equal_bool("match({ name: 'user#posts' })", !!resolved, TRUE); + resolved = router_resolve(router, location, false); + ctest_equal_bool("match({ name: 'user#posts' })", !!resolved, true); route = router_resolved_get_route(resolved); str = router_route_get_param(route, "username"); ctest_equal_str("match({ name: 'user#posts' }).route.params.username", @@ -236,12 +236,12 @@ void test_router_matcher(void) router_resolved_destroy(resolved); location = router_location_create(NULL, "/users/root/posts"); - resolved = router_resolve(router, location, FALSE); + resolved = router_resolve(router, location, false); router_location_destroy(location); route = router_resolved_get_route(resolved); record = router_route_get_matched_record(route, 0); ctest_equal_bool("match('/users/root/posts').route.matched[0] != null", - !!record, TRUE); + !!record, true); ctest_equal_str( "match('/users/root/posts').route.matched[0].components.default", record ? router_route_record_get_component(record, NULL) : NULL, @@ -249,7 +249,7 @@ void test_router_matcher(void) route = router_resolved_get_route(resolved); record = router_route_get_matched_record(route, 1); ctest_equal_bool("match('/users/root/posts').route.matched[1] != null", - !!record, TRUE); + !!record, true); ctest_equal_str( "match('/users/root/posts').route.matched[1].components.default", record ? router_route_record_get_component(record, NULL) : NULL, @@ -257,13 +257,13 @@ void test_router_matcher(void) router_resolved_destroy(resolved); location = router_location_create(NULL, "/other/path/to/file"); - resolved = router_resolve(router, location, FALSE); + resolved = router_resolve(router, location, false); router_location_destroy(location); route = router_resolved_get_route(resolved); record = router_route_get_matched_record(route, 0); ctest_equal_bool( "match('/other/path/to/file').route.matched[0] != null", !!record, - TRUE); + true); ctest_equal_str( "match('/other/path/to/file').route.matched[0].components.default", record ? router_route_record_get_component(record, NULL) : NULL, @@ -275,7 +275,7 @@ void test_router_matcher(void) router_resolved_destroy(resolved); location = router_location_create(NULL, "/files/path/to/file"); - resolved = router_resolve(router, location, FALSE); + resolved = router_resolve(router, location, false); router_location_destroy(location); route = router_resolved_get_route(resolved); record = router_route_get_matched_record(route, 0); @@ -312,93 +312,93 @@ void test_router_utils(void) ctest_equal_bool( "isObjectEqual({ id: '404', name: 'git' }, { id: '404', name: " "'git' })", - strmap_equal(a, b), TRUE); + strmap_equal(a, b), true); strmap_set(b, "id", "200"); ctest_equal_bool( "isObjectEqual({ id: '404', name: 'git' }, { id: '200', name: " "'git' })", - strmap_equal(a, b), FALSE); + strmap_equal(a, b), false); strmap_delete(b, "id"); ctest_equal_bool( "isObjectIncludes({ id: '404', name: 'git' }, { name: 'git' })", - strmap_includes(a, b), TRUE); + strmap_includes(a, b), true); strmap_delete(a, "name"); ctest_equal_bool("isObjectIncludes({ id: '404' }, { name: '200' })", - strmap_includes(a, b), FALSE); + strmap_includes(a, b), false); strmap_delete(a, "id"); strmap_delete(b, "name"); - ctest_equal_bool("isObjectEqual({}, {})", strmap_equal(a, b), TRUE); + ctest_equal_bool("isObjectEqual({}, {})", strmap_equal(a, b), true); ctest_equal_int("string.compare('', '')", router_string_compare("", ""), 0); ctest_equal_bool("string.compare(null, 'a') != 0", - router_string_compare(NULL, "a") != 0, TRUE); + router_string_compare(NULL, "a") != 0, true); ctest_equal_int("string.compare(null, null)", router_string_compare(NULL, NULL), 0); strmap_destroy(a); strmap_destroy(b); - str = router_path_resolve("", NULL, TRUE); + str = router_path_resolve("", NULL, true); ctest_equal_str("path.resolve('', null, true) == '/'", str, "/"); free(str); - str = router_path_resolve("", "/root", TRUE); + str = router_path_resolve("", "/root", true); ctest_equal_str("path.resolve('', '/root', true)", str, "/root"); free(str); - str = router_path_resolve("hello/../world/./", NULL, TRUE); + str = router_path_resolve("hello/../world/./", NULL, true); ctest_equal_str("path.resolve('hello/../world/./', null, true)", str, "/world"); free(str); - str = router_path_resolve("/root/path", "base/path", TRUE); + str = router_path_resolve("/root/path", "base/path", true); ctest_equal_str("path.resolve('/root/path', 'base/path', true)", str, "/root/path"); free(str); - str = router_path_resolve("../../profile", "base/path/to/file", TRUE); + str = router_path_resolve("../../profile", "base/path/to/file", true); ctest_equal_str( "path.resolve('../../profile', 'base/path/to/file', true)", str, "/base/path/profile"); free(str); - str = router_path_resolve("profile", "base/file", FALSE); + str = router_path_resolve("profile", "base/file", false); ctest_equal_str("path.resolve('profile', 'base/profile', false)", str, "/base/profile"); free(str); - str = router_path_resolve("/profile", "base/file", FALSE); + str = router_path_resolve("/profile", "base/file", false); ctest_equal_str("path.resolve('/profile', 'base/profile', false)", str, "/profile"); free(str); ctest_equal_bool("path.compare('/a/b', '/a/b/')", - router_path_compare("/a/b", "/a/b/"), TRUE); + router_path_compare("/a/b", "/a/b/"), true); ctest_equal_bool("path.compare('/a/b/', '/a/b/')", - router_path_compare("/a/b/", "/a/b"), TRUE); + router_path_compare("/a/b/", "/a/b"), true); ctest_equal_bool("path.compare('', '')", - router_path_compare("", "") == 0, TRUE); + router_path_compare("", "") == 0, true); ctest_equal_bool("path.compare('a', '')", - router_path_compare("a", "") != 0, TRUE); + router_path_compare("a", "") != 0, true); ctest_equal_bool("path.compare('', 'b')", - router_path_compare("", "b") != 0, TRUE); + router_path_compare("", "b") != 0, true); ctest_equal_bool("path.compare('a', 'b')", - router_path_compare("a", "b") != 0, TRUE); + router_path_compare("a", "b") != 0, true); ctest_equal_bool( "path.startsWith('/profile/events', '/profile/event')", router_path_starts_with("/profile/events", "/profile/event"), - FALSE); + false); ctest_equal_bool( "path.startsWith('/profile/events', '/profile/')", - router_path_starts_with("/profile/events", "/profile/"), TRUE); + router_path_starts_with("/profile/events", "/profile/"), true); ctest_equal_bool("path.startsWith('/profile', '/profile/')", router_path_starts_with("/profile", "/profile/"), - TRUE); + true); ctest_equal_bool("path.startsWith('/profile/', '/profile')", router_path_starts_with("/profile/", "/profile"), - TRUE); + true); p = str = "/:username/:repo/settings"; p = router_path_parse_key(p, key, &key_len); @@ -622,44 +622,44 @@ void test_router_components(void) // ui_update(); matched_widget = ui_router_view_get_matched_widget(view); ctest_equal_bool("[/foo] widget should load widget", - strcmp(matched_widget->type, "foo") == 0, TRUE); + strcmp(matched_widget->type, "foo") == 0, true); ctest_equal_bool( "[/foo] linkFoo should has active classes", (ui_widget_has_class(link_foo, "router-link-active") && ui_widget_has_class(link_foo, "router-link-exact-active")), - TRUE); + true); ui_widget_emit_event(link_bar, e, NULL); matched_widget = ui_router_view_get_matched_widget(view); ctest_equal_bool("[/bar] widget should load widget", - strcmp(matched_widget->type, "bar") == 0, TRUE); + strcmp(matched_widget->type, "bar") == 0, true); ctest_equal_bool( "[/bar] linkFoo should not has active classes", (!ui_widget_has_class(link_foo, "router-link-exact-active") && !ui_widget_has_class(link_foo, "router-link-active")), - TRUE); + true); ui_widget_emit_event(link_foobar, e, NULL); matched_widget = ui_router_view_get_matched_widget(view); ctest_equal_bool( "[/foo/bar] widget should load widget", - strcmp(matched_widget->type, "foobar") == 0, TRUE); + strcmp(matched_widget->type, "foobar") == 0, true); ctest_equal_bool( "[/foo/bar] linkFooBar should has active classes", (ui_widget_has_class(link_foobar, "router-link-exact-active") && ui_widget_has_class(link_foobar, "router-link-active")), - TRUE); + true); ctest_equal_bool( "[/foo/bar] linkFoo should only has the exact active class", (!ui_widget_has_class(link_foo, "router-link-exact-active") && ui_widget_has_class(link_foo, "router-link-active")), - TRUE); + true); ui_widget_set_attr(link_foo, "exact", "exact"); ui_widget_emit_event(link_foobar, e, NULL); ctest_equal_bool( "[/foo/bar] linkFoo should not has any active classes (exact)", (!ui_widget_has_class(link_foo, "router-link-exact-active") && !ui_widget_has_class(link_foo, "router-link-active")), - TRUE); + true); ui_destroy(); router_destroy(router); diff --git a/lib/ui-widgets/src/anchor.c b/lib/ui-widgets/src/anchor.c index 7519148ae..10d291d28 100644 --- a/lib/ui-widgets/src/anchor.c +++ b/lib/ui-widgets/src/anchor.c @@ -91,7 +91,7 @@ static void ui_anchor_on_load(ui_widget_t* w, ui_event_t* e, void* arg) ui_widget_append(target, loader->pack); ui_widget_unwrap(loader->pack); ui_event_init(&ev, "loaded.anchor"); - ev.cancel_bubble = TRUE; + ev.cancel_bubble = true; ev.target = loader->widget; ui_widget_emit_event(root, ev, loader->key); } @@ -125,7 +125,7 @@ static void xml_loader_load(xml_loader_t* loader) } ui_event_init(&e, "load.anchor"); e.target = loader->widget; - e.cancel_bubble = TRUE; + e.cancel_bubble = true; loader->pack = pack; ui_post_event(&e, loader, (ui_event_arg_destructor_t)xml_loader_destroy); @@ -175,7 +175,7 @@ void ui_anchor_open(ui_widget_t* w) return; } ui_event_init(&e, "startload.anchor"); - e.cancel_bubble = TRUE; + e.cancel_bubble = true; ui_post_event(&e, loader, NULL); } diff --git a/lib/ui-widgets/src/canvas.c b/lib/ui-widgets/src/canvas.c index 2be342685..1cc360e1a 100644 --- a/lib/ui-widgets/src/canvas.c +++ b/lib/ui-widgets/src/canvas.c @@ -57,7 +57,7 @@ static void ui_canvas_on_destroy(ui_widget_t *w) canvas = ui_widget_add_data(w, ui_canvas.proto, sizeof(ui_canvas_t)); for (list_each(node, &canvas->contexts)) { ctx = node->data; - ctx->available = FALSE; + ctx->available = false; } list_destroy_without_node(&canvas->contexts, NULL); pd_canvas_destroy(&canvas->buffer); @@ -137,7 +137,7 @@ ui_canvas_context_t *ui_canvas_get_context(ui_widget_t *w) ctx = malloc(sizeof(ui_canvas_context_t)); ctx->canvas = w; - ctx->available = TRUE; + ctx->available = true; ctx->buffer = canvas->buffer; ctx->width = ctx->buffer.width; ctx->height = ctx->buffer.height; diff --git a/lib/ui-widgets/src/scrollbar.c b/lib/ui-widgets/src/scrollbar.c index d1b10ed74..be104976c 100644 --- a/lib/ui-widgets/src/scrollbar.c +++ b/lib/ui-widgets/src/scrollbar.c @@ -156,7 +156,7 @@ static void ui_scrollbar_on_scrolling(void *arg) } } lcui_destroy_timer(effect->timer); - effect->is_running = FALSE; + effect->is_running = false; effect->timer = -1; } @@ -168,14 +168,14 @@ static void ui_scroll_effect_init(ui_scroll_effect_t *effect) effect->timestamp = 0; effect->speed = 0; effect->speed_delta = 320; - effect->is_running = FALSE; + effect->is_running = false; effect->interval = 1000 / EFFECT_FRAMES; } static void ui_scroll_effect_update(ui_scroll_effect_t *effect, float pos) { effect->speed = 0; - effect->is_running = FALSE; + effect->is_running = false; effect->start_pos = pos; effect->timestamp = get_time_ms(); } @@ -205,7 +205,7 @@ static void ui_scrollbar_start_scrolling(ui_widget_t *w) if (effect->is_running) { return; } - effect->is_running = TRUE; + effect->is_running = true; if (effect->timer > 0) { lcui_destroy_timer(effect->timer); } @@ -258,7 +258,7 @@ static void ui_scrollbar_thumb_on_mousemove(ui_widget_t *thumb, ui_event_t *e, if (scrollbar->pos != layer_pos) { ui_event_t e; ui_event_init(&e, "scroll"); - e.cancel_bubble = TRUE; + e.cancel_bubble = true; ui_widget_emit_event(target, e, &layer_pos); } scrollbar->pos = layer_pos; @@ -275,7 +275,7 @@ static void ui_scrollbar_thumb_on_mouseup(ui_widget_t *thumb, ui_event_t *e, ui_widget_off(thumb, "mousemove", ui_scrollbar_thumb_on_mousemove, w); ui_widget_off(thumb, "mouseup", ui_scrollbar_thumb_on_mouseup, w); ui_widget_release_mouse_capture(thumb); - scrollbar->is_dragging = FALSE; + scrollbar->is_dragging = false; } static void Ui_scrollbar_thumb_on_mousedown(ui_widget_t *thumb, ui_event_t *e, @@ -291,7 +291,7 @@ static void Ui_scrollbar_thumb_on_mousedown(ui_widget_t *thumb, ui_event_t *e, scrollbar->thumb_y = thumb->canvas_box.y; scrollbar->mouse_x = e->mouse.x; scrollbar->mouse_y = e->mouse.y; - scrollbar->is_dragging = TRUE; + scrollbar->is_dragging = true; ui_widget_set_mouse_capture(thumb); ui_widget_on(thumb, "mousemove", ui_scrollbar_thumb_on_mousemove, w); ui_widget_on(thumb, "mouseup", ui_scrollbar_thumb_on_mouseup, w); @@ -398,7 +398,7 @@ static void ui_scrollbar_on_container_wheel(ui_widget_t *container, /* If the position of the scroll bar is changed, then prevent * the event bubbling, to avoid change the parent scroll bars */ if (pos != ui_scrollbar_set_position(w, new_pos)) { - e->cancel_bubble = TRUE; + e->cancel_bubble = true; } } @@ -441,14 +441,14 @@ static void ui_scrollbar_on_container_touch(ui_widget_t *container, case UI_EVENT_TOUCHDOWN: scrollbar->distance = 0; scrollbar->effect.speed = 0; - scrollbar->effect.is_running = FALSE; + scrollbar->effect.is_running = false; scrollbar->old_pos = scrollbar->pos; if (scrollbar->is_dragging) { return; } scrollbar->mouse_x = point->x; scrollbar->mouse_y = point->y; - scrollbar->is_draggable = TRUE; + scrollbar->is_draggable = true; break; case UI_EVENT_TOUCHUP: ui_widget_release_touch_capture(container, -1); @@ -457,14 +457,14 @@ static void ui_scrollbar_on_container_touch(ui_widget_t *container, ui_scrollbar_start_scrolling(w); } scrollbar->touch_point_id = -1; - scrollbar->is_dragging = FALSE; - ui_widget_block_event(container, FALSE); + scrollbar->is_dragging = false; + ui_widget_block_event(container, false); break; case UI_EVENT_TOUCHMOVE: if (!scrollbar->is_draggable) { break; } - e->cancel_bubble = TRUE; + e->cancel_bubble = true; pos = scrollbar->old_pos; if (scrollbar->direction == UI_SCROLLBAR_HORIZONTAL) { pos -= point->x - scrollbar->mouse_x; @@ -490,15 +490,15 @@ static void ui_scrollbar_on_container_touch(ui_widget_t *container, * mark current drag action should be ignore */ if (scrollbar->is_draggable && scrollbar->old_pos == scrollbar->pos) { - scrollbar->is_dragging = FALSE; - scrollbar->is_draggable = FALSE; - e->cancel_bubble = FALSE; + scrollbar->is_dragging = false; + scrollbar->is_draggable = false; + e->cancel_bubble = false; break; } /* start drag action and block all events of container */ - scrollbar->is_dragging = TRUE; + scrollbar->is_dragging = true; ui_clear_event_target(NULL); - ui_widget_block_event(container, TRUE); + ui_widget_block_event(container, true); ui_widget_set_touch_capture(container, point->id); default: break; @@ -528,12 +528,12 @@ static void ui_scrollbar_on_container_set_scroll(ui_widget_t *container, { float *pos = arg; ui_scrollbar_set_position(e->data, *pos); - e->cancel_bubble = TRUE; + e->cancel_bubble = true; } static void ui_scrollbar_observe(ui_widget_t *w) { - ui_mutation_observer_init_t options = { .properties = TRUE }; + ui_mutation_observer_init_t options = { .properties = true }; ui_scrollbar_t *scrollbar = ui_widget_get_data(w, ui_scrollbar_proto); if (scrollbar->container) { @@ -664,7 +664,7 @@ float ui_scrollbar_set_position(ui_widget_t *w, float pos) if (scrollbar->pos != pos) { ui_event_t e; ui_event_init(&e, "scroll"); - e.cancel_bubble = TRUE; + e.cancel_bubble = true; ui_widget_emit_event(content, e, &new_pos); } scrollbar->pos = pos; @@ -721,8 +721,8 @@ static void ui_scrollbar_on_init(ui_widget_t *w) self = ui_widget_add_data(w, ui_scrollbar_proto, sizeof(ui_scrollbar_t)); self->direction = UI_SCROLLBAR_VERTICAL; - self->is_dragging = FALSE; - self->is_draggable = FALSE; + self->is_dragging = false; + self->is_draggable = false; self->scroll_step = 64; self->target = NULL; self->container = NULL; diff --git a/lib/ui-widgets/src/textcaret.c b/lib/ui-widgets/src/textcaret.c index 4401b7fe3..a14711fda 100644 --- a/lib/ui-widgets/src/textcaret.c +++ b/lib/ui-widgets/src/textcaret.c @@ -96,10 +96,10 @@ static void ui_textcaret_on_init(ui_widget_t *widget) caret = ui_widget_add_data(widget, ui_textcaret_proto, sizeof(ui_textcaret_t)); caret->task = malloc(sizeof(ui_textcaret_task_t)); - caret->task->active = TRUE; + caret->task->active = true; caret->task->widget = widget; caret->blink_interval = 500; - caret->visible = FALSE; + caret->visible = false; caret->timer_id = lcui_set_interval(caret->blink_interval, ui_textcaret_on_blink, caret->task); } @@ -118,7 +118,7 @@ static void ui_textcaret_on_destroy(ui_widget_t *widget) ui_textcaret_t *caret; caret = ui_widget_get_data(widget, ui_textcaret_proto); - caret->task->active = FALSE; + caret->task->active = false; if (lcui_destroy_timer(caret->timer_id) != -1) { free(caret->task); caret->task = NULL; diff --git a/lib/ui-widgets/src/textinput.c b/lib/ui-widgets/src/textinput.c index 2a5912ddc..895cf8de2 100644 --- a/lib/ui-widgets/src/textinput.c +++ b/lib/ui-widgets/src/textinput.c @@ -150,7 +150,7 @@ static void ui_textinput_update_caret(ui_widget_t *widget) offset_x = y_iround((x - caret_x) * scale); offset_y = y_iround((y - caret_y) * scale); if (pd_text_set_offset(edit->layer, offset_x, offset_y)) { - edit->tasks[TASK_UPDATE] = TRUE; + edit->tasks[TASK_UPDATE] = true; ui_widget_request_update(widget); } x += widget->computed_style.padding_left; @@ -325,7 +325,7 @@ static void textinput_update_textlayer(ui_widget_t *w) if (edit->password_char) { pd_text_set_style(edit->layer_mask, &style); } - style.has_fore_color = TRUE; + style.has_fore_color = true; style.fore_color = PLACEHOLDER_COLOR; pd_text_set_style(edit->layer_placeholder, &style); pd_text_style_destroy(&style); @@ -488,7 +488,7 @@ void ui_textinput_clear_text(ui_widget_t *widget) } pd_text_empty(edit->layer_source); pd_style_tags_clear(&edit->text_tags); - edit->tasks[TASK_UPDATE] = TRUE; + edit->tasks[TASK_UPDATE] = true; ui_widget_request_update(widget); thread_mutex_unlock(&edit->mutex); ui_widget_mark_dirty_rect(widget, NULL, UI_BOX_TYPE_PADDING_BOX); @@ -611,7 +611,7 @@ static void ui_textinput_on_focus(ui_widget_t *widget, ui_event_t *e, void *arg) ui_textinput_t *edit; edit = ui_widget_get_data(widget, ui_textinput_proto); - ui_textcaret_set_visible(edit->caret, TRUE); + ui_textcaret_set_visible(edit->caret, true); ui_textinput_update_caret(widget); } @@ -620,7 +620,7 @@ static void ui_textinput_on_blur(ui_widget_t *widget, ui_event_t *e, void *arg) ui_textinput_t *edit; edit = ui_widget_get_data(widget, ui_textinput_proto); - ui_textcaret_set_visible(edit->caret, FALSE); + ui_textcaret_set_visible(edit->caret, false); /* In single-line editing mode, we should reset the caret position to * the head, otherwise it will mistakenly think that only the last part * is entered after inputting long text. */ @@ -696,7 +696,7 @@ static void ui_textinput_on_keydown(ui_widget_t *widget, ui_event_t *e, cur_col = edit->layer->insert_x; rows = pd_text_get_lines_length(edit->layer); cols = pd_text_get_line_length(edit->layer, cur_row); - e->cancel_bubble = TRUE; + e->cancel_bubble = true; switch (e->key.code) { case KEY_HOME: cur_col = 0; @@ -870,11 +870,11 @@ static void ui_textinput_on_init(ui_widget_t *w) edit = ui_widget_add_data(w, ui_textinput_proto, sizeof(ui_textinput_t)); - edit->is_read_only = FALSE; + edit->is_read_only = false; edit->password_char = 0; edit->allow_input_char = NULL; - edit->placeholder_visible = FALSE; - edit->is_multiline_mode = FALSE; + edit->placeholder_visible = false; + edit->is_multiline_mode = false; edit->layer_mask = pd_text_create(); edit->layer_source = pd_text_create(); edit->layer_placeholder = pd_text_create(); @@ -885,10 +885,10 @@ static void ui_textinput_on_init(ui_widget_t *w) memset(edit->tasks, 0, sizeof(edit->tasks)); list_create(&edit->text_blocks); list_create(&edit->text_tags); - ui_textinput_enable_multiline(w, FALSE); - pd_text_set_autowrap(edit->layer, TRUE); - pd_text_set_autowrap(edit->layer_mask, TRUE); - pd_text_set_style_tag(edit->layer, FALSE); + ui_textinput_enable_multiline(w, false); + pd_text_set_autowrap(edit->layer, true); + pd_text_set_autowrap(edit->layer_mask, true); + pd_text_set_style_tag(edit->layer, false); ui_widget_on(w, "textinput", ui_textinput_on_textinput, NULL); ui_widget_on(w, "mousedown", ui_textinput_on_mousedown, NULL); ui_widget_on(w, "mouseup", ui_textinput_on_mouseup, NULL); diff --git a/lib/ui-widgets/src/textstyle.c b/lib/ui-widgets/src/textstyle.c index fafc5d626..bc6fe8592 100644 --- a/lib/ui-widgets/src/textstyle.c +++ b/lib/ui-widgets/src/textstyle.c @@ -15,12 +15,12 @@ void convert_font_style_to_text_style(ui_text_style_t *fs, pd_text_style_t *ts) { size_t len; ts->font_ids = NULL; - ts->has_style = TRUE; - ts->has_weight = TRUE; - ts->has_family = FALSE; - ts->has_back_color = FALSE; - ts->has_pixel_size = TRUE; - ts->has_fore_color = TRUE; + ts->has_style = true; + ts->has_weight = true; + ts->has_family = false; + ts->has_back_color = false; + ts->has_pixel_size = true; + ts->has_fore_color = true; ts->fore_color = fs->color; ts->pixel_size = fs->font_size; ts->weight = fs->font_weight; @@ -30,6 +30,6 @@ void convert_font_style_to_text_style(ui_text_style_t *fs, pd_text_style_t *ts) ; ts->font_ids = malloc(sizeof(int) * ++len); memcpy(ts->font_ids, fs->font_ids, len * sizeof(int)); - ts->has_family = TRUE; + ts->has_family = true; } } diff --git a/lib/ui/README.md b/lib/ui/README.md index f9cf41c62..c883492cf 100644 --- a/lib/ui/README.md +++ b/lib/ui/README.md @@ -87,11 +87,11 @@ void example(void) ... // 监听属性变化 - options.properties = TRUE; + options.properties = true; // 监听子组件的变化 - options.child_list = TRUE; + options.child_list = true; // 监听子树的变化 - options.subtree = TRUE; + options.subtree = true; // 监听组件 ui_mutation_observer_observe(observer, widget, options); diff --git a/lib/worker/src/worker.c b/lib/worker/src/worker.c index 80d328f28..6027545a6 100644 --- a/lib/worker/src/worker.c +++ b/lib/worker/src/worker.c @@ -48,7 +48,7 @@ worker_t *worker_create(void) thread_mutex_init(&worker->mutex); thread_cond_init(&worker->cond); list_create(&worker->tasks); - worker->active = FALSE; + worker->active = false; worker->thread = 0; return worker; } @@ -87,12 +87,12 @@ bool worker_run_task(worker_t *worker) task = worker_get_task(worker); thread_mutex_unlock(&worker->mutex); if (!task) { - return FALSE; + return false; } worker_task_run(task); worker_task_destroy(task); free(task); - return TRUE; + return true; } static void worker_on_destroy_task(void *arg) @@ -139,7 +139,7 @@ int worker_run_async(worker_t *worker) if (worker->thread != 0) { return -EEXIST; } - worker->active = TRUE; + worker->active = true; thread_create(&worker->thread, worker_thread, worker); return 0; } @@ -150,7 +150,7 @@ void worker_destroy(worker_t *worker) if (worker->active) { thread_mutex_lock(&worker->mutex); - worker->active = FALSE; + worker->active = false; thread_cond_signal(&worker->cond); thread_mutex_unlock(&worker->mutex); thread_join(thread, NULL); diff --git a/src/lcui.c b/src/lcui.c index 75a0f135f..b1b3dfdad 100644 --- a/src/lcui.c +++ b/src/lcui.c @@ -40,10 +40,10 @@ const char *lcui_get_version(void) bool lcui_post_task(worker_task_t *task) { if (!lcui_app.main_worker) { - return FALSE; + return false; } worker_post_task(lcui_app.main_worker, task); - return TRUE; + return true; } bool lcui_post_simple_task(worker_callback_t callback, void *arg1, void *arg2) @@ -79,9 +79,9 @@ void lcui_set_frame_rate_cap(unsigned rate_cap) { if (rate_cap > 0) { lcui_app.timer.target_elapsed_time = 1000 / rate_cap; - lcui_app.timer.is_fixed_time_step = TRUE; + lcui_app.timer.is_fixed_time_step = true; } else { - lcui_app.timer.is_fixed_time_step = FALSE; + lcui_app.timer.is_fixed_time_step = false; } } diff --git a/src/lcui_settings.c b/src/lcui_settings.c index 4394d8231..d1962c9d5 100644 --- a/src/lcui_settings.c +++ b/src/lcui_settings.c @@ -41,7 +41,7 @@ void lcui_reset_settings(void) lcui_settings_t settings = { .frame_rate_cap = LCUI_MAX_FRAMES_PER_SEC, .parallel_rendering_threads = 4, - .paint_flashing = FALSE + .paint_flashing = false }; lcui_apply_settings(&settings); } diff --git a/src/lcui_ui.c b/src/lcui_ui.c index b91158f93..8f80ce13c 100644 --- a/src/lcui_ui.c +++ b/src/lcui_ui.c @@ -255,7 +255,7 @@ void lcui_set_ui_display_mode(lcui_display_mode_t mode) app_window_set_fullscreen(wnd, true); break; case LCUI_DISPLAY_MODE_SEAMLESS: - options.child_list = TRUE; + options.child_list = true; lcui_ui.observer = ui_mutation_observer_create(lcui_on_ui_mutation, NULL); ui_mutation_observer_observe(lcui_ui.observer, ui_root(), diff --git a/tests/cases/test_block_layout.c b/tests/cases/test_block_layout.c index 6a17f18a2..54e044ec1 100644 --- a/tests/cases/test_block_layout.c +++ b/tests/cases/test_block_layout.c @@ -19,9 +19,9 @@ static void test_dropdown(void) w = ui_get_widget("test-dropdown-menu"); ctest_equal_bool("$('#test-dropdown-menu')[0].border_box.height < 200", - w->border_box.width < 200, TRUE); + w->border_box.width < 200, true); ctest_equal_bool("$('#test-dropdown-menu')[0].border_box.width > 100", - w->border_box.width > 100, TRUE); + w->border_box.width > 100, true); ctest_equal_int("$('#test-dropdown-menu')[0].border_box.height", (int)w->border_box.height, 142); @@ -93,7 +93,7 @@ static void test_auto_size(void) ctest_equal_int("$('#test-text-auto-size')[0].border_box.y", (int)w->border_box.y, 5 + 50); ctest_equal_bool("$('#test-text-auto-size')[0].border_box.width <= 758", - w->border_box.width < 758.f, TRUE); + w->border_box.width < 758.f, true); ctest_equal_int("$('#test-text-auto-size')[0].border_box.height", (int)w->border_box.height, 50); @@ -433,7 +433,7 @@ static void test_block_layout_1280(void) w = ui_get_widget("test-text-auto-size"); ctest_equal_bool("$('#test-text-auto-size')[0].width < 140px", - w->border_box.width < 170, TRUE); + w->border_box.width < 170, true); ctest_equal_int("$('#test-text-auto-size')[0].height", (int)w->border_box.height, 31); diff --git a/tests/cases/test_clipboard.c b/tests/cases/test_clipboard.c index 74a5983ad..d85186be5 100644 --- a/tests/cases/test_clipboard.c +++ b/tests/cases/test_clipboard.c @@ -20,7 +20,7 @@ static void paste_text(void *arg) ev.type = APP_EVENT_KEYDOWN; ev.key.code = KEY_V; - ev.key.ctrl_key = TRUE; + ev.key.ctrl_key = true; ui_set_focus(w); app_post_event(&ev); } @@ -31,7 +31,7 @@ static void on_text1_focused(ui_widget_t *w, ui_event_t *e, void *arg) ev.type = APP_EVENT_KEYDOWN; ev.key.code = KEY_C; - ev.key.ctrl_key = TRUE; + ev.key.ctrl_key = true; app_post_event(&ev); lcui_set_timeout(100, paste_text, e->data); } diff --git a/tests/cases/test_mainloop.c b/tests/cases/test_mainloop.c index 728f8a16b..11f5db08d 100644 --- a/tests/cases/test_mainloop.c +++ b/tests/cases/test_mainloop.c @@ -52,7 +52,7 @@ static void ObserverThread(void *arg) for (i = 0; i < 20 && !*exited; ++i) { sleep_ms(100); } - ctest_equal_bool("main loop should exit within 2000ms", *exited, TRUE); + ctest_equal_bool("main loop should exit within 2000ms", *exited, true); if (!*exited) { exit(-ctest_finish()); return; @@ -64,7 +64,7 @@ void test_mainloop(void) { thread_t tid; ui_widget_t *btn; - LCUI_BOOL exited = FALSE; + LCUI_BOOL exited = false; lcui_init(); btn = ui_create_widget("button"); @@ -76,6 +76,6 @@ void test_mainloop(void) /* Trigger the click event after the first frame is updated */ lcui_set_timeout(50, OnTriggerBtnClick, btn); lcui_main(); - exited = TRUE; + exited = true; thread_join(tid, NULL); } diff --git a/tests/cases/test_scrollbar.c b/tests/cases/test_scrollbar.c index bdf15e441..8508b9d04 100644 --- a/tests/cases/test_scrollbar.c +++ b/tests/cases/test_scrollbar.c @@ -132,7 +132,7 @@ void test_scrollbar(void) ctest_equal_bool("content should be moved to the left", content->computed_style.left < left && top == content->computed_style.top, - TRUE); + true); left = content->computed_style.left; top = content->computed_style.top; @@ -151,7 +151,7 @@ void test_scrollbar(void) ctest_equal_bool("content should be moved to the right", content->computed_style.left > left && top == content->computed_style.top, - TRUE); + true); left = content->computed_style.left; top = content->computed_style.top; @@ -178,7 +178,7 @@ void test_scrollbar(void) ctest_equal_bool("content should be moved to the top", content->computed_style.left == left && top > content->computed_style.top, - TRUE); + true); left = content->computed_style.left; top = content->computed_style.top; @@ -197,7 +197,7 @@ void test_scrollbar(void) ctest_equal_bool("the content should have scrolled to the bottom", content->computed_style.left == left && top < content->computed_style.top, - TRUE); + true); lcui_quit(); lcui_main(); diff --git a/tests/cases/test_settings.c b/tests/cases/test_settings.c index 56d4b14a5..528fe710a 100644 --- a/tests/cases/test_settings.c +++ b/tests/cases/test_settings.c @@ -21,7 +21,7 @@ static void check_settings_frame_rate_cap(void *arg) sprintf(str, "should work when frame cap is %u (actual %u)", fps_limit, fps); - ctest_equal_bool(str, fps <= fps_limit + 2 && fps > fps_limit / 2, TRUE); + ctest_equal_bool(str, fps <= fps_limit + 2 && fps > fps_limit / 2, true); lcui_quit(); } @@ -36,7 +36,7 @@ static void test_default_settings(void) ctest_equal_int("check default frame rate cap", settings.frame_rate_cap, 120); ctest_equal_int("check default parallel rendering threads", settings.parallel_rendering_threads, 4); - ctest_equal_bool("check default paint flashing", settings.paint_flashing, FALSE); + ctest_equal_bool("check default paint flashing", settings.paint_flashing, false); lcui_quit(); lcui_main(); } @@ -47,7 +47,7 @@ static void test_apply_settings(void) settings.frame_rate_cap = 60; settings.parallel_rendering_threads = 2; - settings.paint_flashing = TRUE; + settings.paint_flashing = true; lcui_init(); lcui_apply_settings(&settings); @@ -55,7 +55,7 @@ static void test_apply_settings(void) ctest_equal_int("check frame rate cap", settings.frame_rate_cap, 60); ctest_equal_int("check parallel rendering threads", settings.parallel_rendering_threads, 2); - ctest_equal_bool("check paint flashing", settings.paint_flashing, TRUE); + ctest_equal_bool("check paint flashing", settings.paint_flashing, true); settings.frame_rate_cap = -1; settings.parallel_rendering_threads = -1; diff --git a/tests/cases/test_text_resize.c b/tests/cases/test_text_resize.c index 99ba890b1..d9c33bf95 100644 --- a/tests/cases/test_text_resize.c +++ b/tests/cases/test_text_resize.c @@ -87,13 +87,13 @@ static void check_text_set_content(void) ui_update(); ctest_equal_bool("check block width", - self.block->border_box.width == 122.0f, TRUE); + self.block->border_box.width == 122.0f, true); ctest_equal_bool("check block height", - self.block->border_box.height > 140.0f, TRUE); + self.block->border_box.height > 140.0f, true); ctest_equal_bool("check inline block width", - self.inline_block->border_box.width > 520.0f, TRUE); + self.inline_block->border_box.width > 520.0f, true); ctest_equal_bool("check inline block height", - self.inline_block->border_box.height < 45.0f, TRUE); + self.inline_block->border_box.height < 45.0f, true); } static void test_text_set_short_content_css(void *arg) @@ -107,13 +107,13 @@ static void check_text_set_short_content_css(void) ui_update(); ctest_equal_bool("check block width", - self.block->border_box.width == 122.0f, TRUE); + self.block->border_box.width == 122.0f, true); ctest_equal_bool("check block height", - self.block->border_box.height < 45.0f, TRUE); + self.block->border_box.height < 45.0f, true); ctest_equal_bool("check inline block width", - self.inline_block->border_box.width < 70.0f, TRUE); + self.inline_block->border_box.width < 70.0f, true); ctest_equal_bool("check inline block height", - self.inline_block->border_box.height < 45.0f, TRUE); + self.inline_block->border_box.height < 45.0f, true); } static void test_text_set_long_content_css(void *arg) @@ -129,13 +129,13 @@ static void check_text_set_long_content_css(void) ui_update(); ctest_equal_bool("check block width", - self.block->border_box.width == 122.0f, TRUE); + self.block->border_box.width == 122.0f, true); ctest_equal_bool("check block height", - self.block->border_box.height > 60.0f, TRUE); + self.block->border_box.height > 60.0f, true); ctest_equal_bool("check inline block width", - self.inline_block->border_box.width > 250.0f, TRUE); + self.inline_block->border_box.width > 250.0f, true); ctest_equal_bool("check inline block height", - self.inline_block->border_box.height < 45.0f, TRUE); + self.inline_block->border_box.height < 45.0f, true); } void test_text_resize(void) diff --git a/tests/cases/test_textinput.c b/tests/cases/test_textinput.c index 8fa59494c..8ae62b378 100644 --- a/tests/cases/test_textinput.c +++ b/tests/cases/test_textinput.c @@ -24,29 +24,29 @@ void test_textinput(void) ui_textinput_set_text_w(w, L"hello"); ui_widget_update(w); ctest_equal_bool("check TextEdit_GetLength after ui_textinput_set_text_w", - ui_textinput_get_text_length(w) == wcslen(L"hello"), TRUE); + ui_textinput_get_text_length(w) == wcslen(L"hello"), true); ctest_equal_bool("check ui_textinput_get_text_w after ui_textinput_set_text_w", - ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello"), TRUE); + ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello"), true); ctest_equal_bool("check string retrieved from ui_textinput_get_text_w", - wcscmp(L"hello", wcs) == 0, TRUE); + wcscmp(L"hello", wcs) == 0, true); ui_widget_set_text(w, "hello"); ui_widget_update(w); ctest_equal_bool("check TextEdit_GetLength after ui_textinput_set_text", - ui_textinput_get_text_length(w) == wcslen(L"hello"), TRUE); + ui_textinput_get_text_length(w) == wcslen(L"hello"), true); ctest_equal_bool("check ui_textinput_get_text_w after ui_textinput_set_text", - ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello"), TRUE); + ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello"), true); ctest_equal_bool("check string retrieved from ui_textinput_get_text_w", - wcscmp(L"hello", wcs) == 0, TRUE); + wcscmp(L"hello", wcs) == 0, true); ui_textinput_append_text_w(w, L"world"); ui_widget_update(w); ctest_equal_bool("check TextEdit_GetLength after ui_textinput_append_text_w", - ui_textinput_get_text_length(w) == wcslen(L"helloworld"), TRUE); + ui_textinput_get_text_length(w) == wcslen(L"helloworld"), true); ctest_equal_bool("check ui_textinput_get_text_w after ui_textinput_append_text_w", - ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"helloworld"), TRUE); + ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"helloworld"), true); ctest_equal_bool("check string retrieved from ui_textinput_get_text_w", - wcscmp(L"helloworld", wcs) == 0, TRUE); + wcscmp(L"helloworld", wcs) == 0, true); ui_textinput_move_caret(w, 0, 5); ui_textinput_insert_text_w(w, L", "); @@ -55,12 +55,12 @@ void test_textinput(void) ui_textinput_insert_text_w(w, L"!"); ui_widget_update(w); ctest_equal_bool("check TextEdit_GetLength after inserting text", - ui_textinput_get_text_length(w) == wcslen(L"hello, world!"), TRUE); + ui_textinput_get_text_length(w) == wcslen(L"hello, world!"), true); ctest_equal_bool("check ui_textinput_get_text_w after inserting text", ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello, world!"), - TRUE); + true); ctest_equal_bool("check string retrieved from ui_textinput_get_text_w", - wcscmp(L"hello, world!", wcs) == 0, TRUE); + wcscmp(L"hello, world!", wcs) == 0, true); ui_widget_destroy(w); lcui_quit(); lcui_main(); diff --git a/tests/cases/test_thread.c b/tests/cases/test_thread.c index 0049a5a65..84384907c 100644 --- a/tests/cases/test_thread.c +++ b/tests/cases/test_thread.c @@ -28,8 +28,8 @@ static void TestWorker_Thread(void *arg) { TestWorker worker = arg; - worker->cancel = FALSE; - worker->active = TRUE; + worker->cancel = false; + worker->active = true; worker->data_count = 0; thread_mutex_lock(&worker->mutex); while (!worker->cancel && worker->data_count < 20) { @@ -40,7 +40,7 @@ static void TestWorker_Thread(void *arg) } thread_mutex_unlock(&worker->mutex); logger_debug("count: %d\n", worker->data_count); - worker->active = FALSE; + worker->active = false; thread_exit(NULL); } @@ -61,7 +61,7 @@ static void TestWorker_Init(TestWorker worker) static void TestWorker_Destroy(TestWorker worker) { thread_mutex_lock(&worker->mutex); - worker->cancel = TRUE; + worker->cancel = true; thread_cond_signal(&worker->cond); thread_mutex_unlock(&worker->mutex); thread_join(worker->thread, NULL); @@ -90,5 +90,5 @@ void test_thread(void) sleep_ms(100); TestWorker_Destroy(&worker); ctest_equal_int("check worker data count", worker.data_count, 7); - ctest_equal_bool("check worker is no longer active", worker.active, FALSE); + ctest_equal_bool("check worker is no longer active", worker.active, false); } diff --git a/tests/cases/test_widget_event.c b/tests/cases/test_widget_event.c index f677e3e03..5e3bb7505 100644 --- a/tests/cases/test_widget_event.c +++ b/tests/cases/test_widget_event.c @@ -38,33 +38,33 @@ void test_widget_mouse_event(void) ui_dispatch_event(&ev); ui_update(); ctest_equal_bool("mousemove(150, 150): root.hasStatus('hover') == true", - ui_widget_has_status(root, "hover"), TRUE); + ui_widget_has_status(root, "hover"), true); ctest_equal_bool("mousemove(150, 150): parent.hasStatus('hover') == false", - ui_widget_has_status(parent, "hover"), FALSE); + ui_widget_has_status(parent, "hover"), false); ctest_equal_bool("mousemove(150, 150): child.hasStatus('hover') == false", - ui_widget_has_status(child, "hover"), FALSE); + ui_widget_has_status(child, "hover"), false); ev.mouse.x = 80; ev.mouse.y = 80; ui_dispatch_event(&ev); ui_update(); ctest_equal_bool("mousemove(80, 80): root.hasStatus('hover') == true", - ui_widget_has_status(root, "hover"), TRUE); + ui_widget_has_status(root, "hover"), true); ctest_equal_bool("mousemove(80, 80): parent.hasStatus('hover') == true", - ui_widget_has_status(parent, "hover"), TRUE); + ui_widget_has_status(parent, "hover"), true); ctest_equal_bool("mousemove(80, 80): child.hasStatus('hover') == false", - ui_widget_has_status(child, "hover"), FALSE); + ui_widget_has_status(child, "hover"), false); ev.mouse.x = 40; ev.mouse.y = 40; ui_dispatch_event(&ev); ui_update(); ctest_equal_bool("mousemove(40, 40): root.hasStatus('hover') == true", - ui_widget_has_status(root, "hover"), TRUE); + ui_widget_has_status(root, "hover"), true); ctest_equal_bool("mousemove(40, 40): parent.hasStatus('hover') == true", - ui_widget_has_status(parent, "hover"), TRUE); + ui_widget_has_status(parent, "hover"), true); ctest_equal_bool("mousemove(40, 40): child.hasStatus('hover') == true", - ui_widget_has_status(child, "hover"), TRUE); + ui_widget_has_status(child, "hover"), true); ev.type = UI_EVENT_MOUSEDOWN; ev.mouse.x = 40; @@ -73,21 +73,21 @@ void test_widget_mouse_event(void) ui_dispatch_event(&ev); ui_update(); ctest_equal_bool("mousedown(40, 40): root.hasStatus('active') == true", - ui_widget_has_status(root, "active"), TRUE); + ui_widget_has_status(root, "active"), true); ctest_equal_bool("mousedown(40, 40): parent.hasStatus('active') == true", - ui_widget_has_status(parent, "active"), TRUE); + ui_widget_has_status(parent, "active"), true); ctest_equal_bool("mousedown(40, 40): child.hasStatus('active') == true", - ui_widget_has_status(child, "active"), TRUE); + ui_widget_has_status(child, "active"), true); ev.type = UI_EVENT_MOUSEUP; ui_dispatch_event(&ev); ui_update(); ctest_equal_bool("mouseup(40, 40): root.hasStatus('active') == false", - ui_widget_has_status(root, "active"), FALSE); + ui_widget_has_status(root, "active"), false); ctest_equal_bool("mouseup(40, 40): parent.hasStatus('active') == false", - ui_widget_has_status(parent, "active"), FALSE); + ui_widget_has_status(parent, "active"), false); ctest_equal_bool("mouseup(40, 40): child.hasStatus('active') == false", - ui_widget_has_status(child, "active"), FALSE); + ui_widget_has_status(child, "active"), false); ev.type = UI_EVENT_MOUSEMOVE; ev.mouse.x = 80; @@ -95,22 +95,22 @@ void test_widget_mouse_event(void) ui_dispatch_event(&ev); ui_update(); ctest_equal_bool("mousemove(80, 80): root.hasStatus('hover') == true", - ui_widget_has_status(root, "hover"), TRUE); + ui_widget_has_status(root, "hover"), true); ctest_equal_bool("mousemove(80, 80): parent.hasStatus('hover') == true", - ui_widget_has_status(parent, "hover"), TRUE); + ui_widget_has_status(parent, "hover"), true); ctest_equal_bool("mousemove(80, 80): child.hasStatus('hover') == false", - ui_widget_has_status(child, "hover"), FALSE); + ui_widget_has_status(child, "hover"), false); ev.mouse.x = 150; ev.mouse.y = 150; ui_dispatch_event(&ev); ui_update(); ctest_equal_bool("mousemove(150, 150): root.hasStatus('hover') == true", - ui_widget_has_status(root, "hover"), TRUE); + ui_widget_has_status(root, "hover"), true); ctest_equal_bool("mousemove(150, 150): parent.hasStatus('hover') == false", - ui_widget_has_status(parent, "hover"), FALSE); + ui_widget_has_status(parent, "hover"), false); ctest_equal_bool("mousemove(150, 150): child.hasStatus('hover') == false", - ui_widget_has_status(child, "hover"), FALSE); + ui_widget_has_status(child, "hover"), false); lcui_quit(); lcui_main(); diff --git a/tests/cases/test_widget_opacity.c b/tests/cases/test_widget_opacity.c index 5fe10055d..b37719567 100644 --- a/tests/cases/test_widget_opacity.c +++ b/tests/cases/test_widget_opacity.c @@ -59,7 +59,7 @@ static void check_widget_opactiy(void) pd_canvas_create(&canvas, rect.width, rect.height); pd_canvas_fill(&canvas, bgcolor); - paint.with_alpha = FALSE; + paint.with_alpha = false; paint.rect.width = 400; paint.rect.height = 256; paint.rect.x = paint.rect.y = 0; @@ -78,14 +78,14 @@ static void check_widget_opactiy(void) pd_blend_pixel(&expected_color, &parent_bcolor, (int)(PARENT_OPACITY * 255)); ctest_equal_bool("check parent border color", check_color(expected_color, color), - TRUE); + true); expected_color = bgcolor; color = pd_canvas_get_pixel(&canvas, 30, 30); pd_blend_pixel(&expected_color, &parent_bgcolor, (int)(PARENT_OPACITY * 255)); ctest_equal_bool("check parent background color", - check_color(expected_color, color), TRUE); + check_color(expected_color, color), true); tmp = parent_bgcolor; expected_color = bgcolor; @@ -93,7 +93,7 @@ static void check_widget_opactiy(void) pd_blend_pixel(&tmp, &child_bgcolor, (int)(CHILD_OPACITY * 255)); pd_blend_pixel(&expected_color, &tmp, (int)(PARENT_OPACITY * 255)); ctest_equal_bool("check child 1 background color", - check_color(expected_color, color), TRUE); + check_color(expected_color, color), true); tmp = parent_bgcolor; expected_color = bgcolor; @@ -101,18 +101,18 @@ static void check_widget_opactiy(void) pd_blend_pixel(&tmp, &child_footer_bgcolor, (int)(CHILD_OPACITY * 255)); pd_blend_pixel(&expected_color, &tmp, (int)(PARENT_OPACITY * 255)); ctest_equal_bool("check child 1 footer background color", - check_color(expected_color, color), TRUE); + check_color(expected_color, color), true); expected_color = bgcolor; color = pd_canvas_get_pixel(&canvas, 220, 90); pd_blend_pixel(&expected_color, &child_bgcolor, (int)(PARENT_OPACITY * 255)); ctest_equal_bool("check child 2 background color", - check_color(expected_color, color), TRUE); + check_color(expected_color, color), true); expected_color = child_footer_bgcolor; color = pd_canvas_get_pixel(&canvas, 220, 120); ctest_equal_bool("check child 2 footer background color", - check_color(expected_color, color), TRUE); + check_color(expected_color, color), true); pd_canvas_destroy(&canvas); } diff --git a/tests/cases/test_widget_rect.c b/tests/cases/test_widget_rect.c index 39748d1b9..f0da794d7 100644 --- a/tests/cases/test_widget_rect.c +++ b/tests/cases/test_widget_rect.c @@ -51,7 +51,7 @@ void test_widget_rect(void) ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("app.trigger({ type: 'mousemove', x: 150, y: 150}), " "root.getDirtyRects().length == 0", - rects.length == 0, TRUE); + rects.length == 0, true); e.mouse.x = 80; e.mouse.y = 80; @@ -60,7 +60,7 @@ void test_widget_rect(void) ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("app.trigger({ type: 'mousemove', x: 80, y: 80 }), " "root.getDirtyRects().length == 1", - rects.length == 1, TRUE); + rects.length == 1, true); expected_rect.x = 0; expected_rect.y = 0; @@ -79,7 +79,7 @@ void test_widget_rect(void) ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("app.trigger({ type: 'mousemove', x: 40, y: 40 }), " "root.getDirtyRects().length == 0", - rects.length == 0, TRUE); + rects.length == 0, true); e.type = UI_EVENT_MOUSEDOWN; e.mouse.x = 40; @@ -90,7 +90,7 @@ void test_widget_rect(void) ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("app.trigger({ type: 'mousedown', x: 40, y: 40 }), " "root.getDirtyRects().length == 1", - rects.length == 1, TRUE); + rects.length == 1, true); if (rects.length == 1) { rect = *(pd_rect_t *)list_get(&rects, 0); } @@ -103,7 +103,7 @@ void test_widget_rect(void) ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("app.trigger({ type: 'mouseup', x: 40, y: 40 }), " "root.getDirtyRects().length == 1", - rects.length == 1, TRUE); + rects.length == 1, true); if (rects.length == 1) { rect = *(pd_rect_t *)list_get(&rects, 0); } @@ -118,7 +118,7 @@ void test_widget_rect(void) ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("app.trigger({ type: 'mousemove', x: 80, y: 80 }), " "root.getDirtyRects().length == 0", - rects.length == 0, TRUE); + rects.length == 0, true); e.mouse.x = 150; e.mouse.y = 150; @@ -128,7 +128,7 @@ void test_widget_rect(void) ctest_equal_bool("app.trigger({ type: 'mousemove', x: 150, y: 150 }), " "root.getDirtyRects().length == 1", - rects.length == 1, TRUE); + rects.length == 1, true); if (rects.length == 1) { rect = *(pd_rect_t *)list_get(&rects, 0); } @@ -143,7 +143,7 @@ void test_widget_rect(void) ui_update(); ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("child.destroy(), root.getDirtyRects().length == 1", - rects.length == 1, TRUE); + rects.length == 1, true); if (rects.length == 1) { rect = *(pd_rect_t *)list_get(&rects, 0); } @@ -158,7 +158,7 @@ void test_widget_rect(void) ui_update(); ui_widget_get_dirty_rects(root, &rects); ctest_equal_bool("parent.destroy(), root.getDirtyRects().length == 1", - rects.length == 1, TRUE); + rects.length == 1, true); if (rects.length == 1) { rect = *(pd_rect_t *)list_get(&rects, 0); } diff --git a/tests/cases/test_xml_parser.c b/tests/cases/test_xml_parser.c index 336195672..b8f91d8a1 100644 --- a/tests/cases/test_xml_parser.c +++ b/tests/cases/test_xml_parser.c @@ -17,13 +17,13 @@ static void check_widget_attribute(void) ui_widget_t* w; w = ui_get_widget("test-attr-disabled-1"); - ctest_equal_bool("check element-1 is disabled", w->disabled, TRUE); + ctest_equal_bool("check element-1 is disabled", w->disabled, true); w = ui_get_widget("test-attr-disabled-2"); - ctest_equal_bool("check element-2 is disabled", w->disabled, TRUE); + ctest_equal_bool("check element-2 is disabled", w->disabled, true); w = ui_get_widget("test-attr-disabled-3"); - ctest_equal_bool("check element-3 is disabled", w->disabled, TRUE); + ctest_equal_bool("check element-3 is disabled", w->disabled, true); w = ui_get_widget("test-attr-disabled-4"); - ctest_equal_bool("check element-4 is normal", w->disabled, FALSE); + ctest_equal_bool("check element-4 is normal", w->disabled, false); } static void check_widget_loaded_from_nested_xml(void) @@ -31,13 +31,13 @@ static void check_widget_loaded_from_nested_xml(void) ui_widget_t* w; w = ui_get_widget("test-nested-1"); - ctest_equal_bool("check test-nested-1 should exist", w != NULL, TRUE); + ctest_equal_bool("check test-nested-1 should exist", w != NULL, true); w = ui_get_widget("test-nested-2"); - ctest_equal_bool("check test-nested-2 should exist", w != NULL, TRUE); + ctest_equal_bool("check test-nested-2 should exist", w != NULL, true); w = ui_get_widget("test-nested-3"); - ctest_equal_bool("check test-nested-3 should exist", w != NULL, TRUE); + ctest_equal_bool("check test-nested-3 should exist", w != NULL, true); w = ui_get_widget("test-nested-4"); - ctest_equal_bool("check test-nested-4 should exist", w != NULL, TRUE); + ctest_equal_bool("check test-nested-4 should exist", w != NULL, true); } void test_xml_parser(void) @@ -47,7 +47,7 @@ void test_xml_parser(void) ui_init(); ctest_equal_bool("load XML file", (pack = ui_load_xml_file("test_xml_parser.xml")) != NULL, - TRUE); + true); if (!pack) { lcui_destroy(); return; diff --git a/tests/test_fill_rect_with_rgba.c b/tests/test_fill_rect_with_rgba.c index 87564cfc1..64084919d 100644 --- a/tests/test_fill_rect_with_rgba.c +++ b/tests/test_fill_rect_with_rgba.c @@ -46,7 +46,7 @@ int main(void) color.alpha = (unsigned char)(255 * (i + 1) / 10.0); pd_canvas_fill(&fore_canvas, color); for (j = 0; j < 4; ++j) { - pd_canvas_mix(&canvas, &fore_canvas, 5 + i * 15, 5 + j * 40, TRUE); + pd_canvas_mix(&canvas, &fore_canvas, 5 + i * 15, 5 + j * 40, true); } } pd_write_png_file("test_fill_rect_with_rgba.png", &canvas); diff --git a/tests/test_mix_rect_with_opacity.c b/tests/test_mix_rect_with_opacity.c index 1695d98da..ab095ee7f 100644 --- a/tests/test_mix_rect_with_opacity.c +++ b/tests/test_mix_rect_with_opacity.c @@ -47,7 +47,7 @@ int main(void) pd_canvas_fill(&fore_canvas, pd_rgb(255, 255, 255)); // 将前景图混合到背景图中 pd_canvas_mix(&canvas, &fore_canvas, 75 - size / 2, 75 - size / 2, - FALSE); + false); } pd_write_png_file("test_mix_rect_with_opacity.png", &canvas); pd_canvas_destroy(&fore_canvas); diff --git a/tests/test_paint_border.c b/tests/test_paint_border.c index 0e57e349a..132224399 100644 --- a/tests/test_paint_border.c +++ b/tests/test_paint_border.c @@ -87,11 +87,11 @@ int main(void) // 创建绘制上下文 paint = pd_context_create(&layer, &layer_rect); - paint->with_alpha = TRUE; + paint->with_alpha = true; paint_background(paint, &bg_box); paint_border(paint, &border_box); pd_canvas_mix(&canvas, &layer, (canvas.width - layer_rect.width) / 2, - (canvas.height - layer_rect.height) / 2, FALSE); + (canvas.height - layer_rect.height) / 2, false); pd_write_png_file("test_paint_border.png", &canvas); pd_canvas_destroy(&canvas); return 0; diff --git a/tests/test_paint_boxshadow.c b/tests/test_paint_boxshadow.c index b3e9324ed..ae37ff265 100644 --- a/tests/test_paint_boxshadow.c +++ b/tests/test_paint_boxshadow.c @@ -115,7 +115,7 @@ int main(void) // 基于临时绘制层创建绘制上下文 ctx = pd_context_create(&layer, &layer_rect); - ctx->with_alpha = TRUE; + ctx->with_alpha = true; // 将背景区域和边框区域的坐标转换成相对于阴影区域 bg_box.x -= shadow_box.x; bg_box.y -= shadow_box.y; @@ -127,7 +127,7 @@ int main(void) border_box.height); // 将临时绘制层混合到画布中 - pd_canvas_mix(&canvas, &layer, shadow_box.x, shadow_box.y, FALSE); + pd_canvas_mix(&canvas, &layer, shadow_box.x, shadow_box.y, false); pd_write_png_file("test_paint_boxshadow.png", &canvas); pd_canvas_destroy(&canvas); return 0; diff --git a/tests/test_render.c b/tests/test_render.c index cc18f76c1..3a023fb8b 100644 --- a/tests/test_render.c +++ b/tests/test_render.c @@ -112,9 +112,9 @@ void InitBackground(void) color.value); ui_widget_append(self.box, w); } - rules.cache_children_style = TRUE; - rules.ignore_classes_change = TRUE; - rules.ignore_status_change = TRUE; + rules.cache_children_style = true; + rules.ignore_classes_change = true; + rules.ignore_status_change = true; rules.max_update_children_count = -1; rules.max_render_children_count = 0; ui_widget_generate_hash(self.box); diff --git a/tests/test_string_render.c b/tests/test_string_render.c index f92c7afc8..7442f598b 100644 --- a/tests/test_string_render.c +++ b/tests/test_string_render.c @@ -32,7 +32,7 @@ int main(void) /* 设置文本的字体大小 */ pd_text_style_Init(&txtstyle); txtstyle.pixel_size = 24; - txtstyle.has_pixel_size = TRUE; + txtstyle.has_pixel_size = true; /* 设置文本图层的固定尺寸、文本样式、文本内容、对齐方式 */ pd_text_set_fixed_size(txt, 320, 240); diff --git a/tests/test_touch.c b/tests/test_touch.c index f4a61cc3e..30285e6c8 100644 --- a/tests/test_touch.c +++ b/tests/test_touch.c @@ -48,7 +48,7 @@ static void OnTouchWidget(ui_widget_t *w, ui_event_t *e, void *arg) /* 当触点释放后销毁部件及绑定记录 */ ui_widget_release_touch_capture(w, -1); list_unlink(&touch_bindings, &binding->node); - binding->is_valid = FALSE; + binding->is_valid = false; ui_widget_remove(w); free(binding); break; @@ -68,14 +68,14 @@ static void OnTouch(app_event_t *e, void *arg) for (i = 0; i < e->touch.n_points; ++i) { TouchPointBinding binding; - LCUI_BOOL is_existed = FALSE; + LCUI_BOOL is_existed = false; point = &e->touch.points[i]; _DEBUG_MSG("point: %d\n", point->id); /* 检查该触点是否已经被绑定 */ for (list_each(node, &touch_bindings)) { binding = node->data; if (binding->point_id == point->id) { - is_existed = TRUE; + is_existed = true; } } if (is_existed) { @@ -86,7 +86,7 @@ static void OnTouch(app_event_t *e, void *arg) binding = malloc(sizeof(TouchPointBindingRec)); binding->point_id = point->id; binding->node.data = binding; - binding->is_valid = TRUE; + binding->is_valid = true; binding->widget = w; ui_widget_resize(w, 64, 64); ui_widget_move(w, point->x - 32.0f, point->y - 32.0f); diff --git a/tests/test_widget_render.c b/tests/test_widget_render.c index bb5776baf..83387fcfa 100644 --- a/tests/test_widget_render.c +++ b/tests/test_widget_render.c @@ -32,7 +32,7 @@ int main(void) pd_canvas_fill(&canvas, pd_rgb(240, 240, 240)); /* 初始化一个绘制实例,绘制区域为整个画板 */ - paint.with_alpha = FALSE; + paint.with_alpha = false; paint.rect.width = 320; paint.rect.height = 320; paint.rect.x = paint.rect.y = 0;