mirror of
https://github.com/zlgopen/awtk.git
synced 2025-05-08 19:44:45 +08:00
format code
This commit is contained in:
parent
4960d01fa5
commit
0273053edd
@ -87,10 +87,12 @@ static ret_t main_window_on_key_up(void* ctx, event_t* e) {
|
||||
|
||||
if (evt->key == TK_KEY_s) {
|
||||
system_info_t* info = system_info();
|
||||
window_manager_resize(window_manager(), tk_max(160, info->lcd_w / 2), tk_max(160, info->lcd_h / 2));
|
||||
window_manager_resize(window_manager(), tk_max(160, info->lcd_w / 2),
|
||||
tk_max(160, info->lcd_h / 2));
|
||||
} else if (evt->key == TK_KEY_d) {
|
||||
system_info_t* info = system_info();
|
||||
window_manager_resize(window_manager(), tk_min(1920, info->lcd_w * 2), tk_min(1920, info->lcd_h * 2));
|
||||
window_manager_resize(window_manager(), tk_min(1920, info->lcd_w * 2),
|
||||
tk_min(1920, info->lcd_h * 2));
|
||||
} else if (evt->key == TK_KEY_a) {
|
||||
native_window_t* nw = widget_get_native_window(widget_get_child(window_manager(), 0));
|
||||
native_window_set_title(nw, "AWTK Simulator");
|
||||
@ -129,7 +131,8 @@ static ret_t update_title_on_timer(const timer_info_t* info) {
|
||||
}
|
||||
|
||||
static void open_window(const char* name, widget_t* to_close) {
|
||||
bool_t is_single_main_win = widget_lookup(window_manager(), DEMOUI_MAIN_WINDOW_NAME, FALSE) == NULL;
|
||||
bool_t is_single_main_win =
|
||||
widget_lookup(window_manager(), DEMOUI_MAIN_WINDOW_NAME, FALSE) == NULL;
|
||||
widget_t* win = to_close ? window_open_and_close(name, to_close) : window_open(name);
|
||||
|
||||
if (tk_str_eq(name, DEMOUI_MAIN_WINDOW_NAME) && is_single_main_win) {
|
||||
|
@ -324,7 +324,8 @@ static float_t canvas_measure_text_default(canvas_t* c, const wchar_t* str, uint
|
||||
float_t canvas_measure_text(canvas_t* c, const wchar_t* str, uint32_t nr) {
|
||||
return_value_if_fail(c != NULL && c->lcd != NULL && str != NULL, 0);
|
||||
|
||||
if (c->last_text_length != 0 && c->last_text_nr == nr && tk_str_eq_with_len(c->last_text_str, str, nr)) {
|
||||
if (c->last_text_length != 0 && c->last_text_nr == nr &&
|
||||
tk_str_eq_with_len(c->last_text_str, str, nr)) {
|
||||
return c->last_text_length;
|
||||
} else {
|
||||
if (nr > CANVAS_MEASURE_TEXT_CACHE_MAX_LENGTH) {
|
||||
|
@ -406,7 +406,6 @@ widget_t* dialog_create_with_ok_cancel(const char* stitle, uint32_t w, uint32_t
|
||||
ret_t dialog_simple_show(const char* stitle, const char* scontent, const char* theme, bool_t has_ok,
|
||||
bool_t has_cancel);
|
||||
|
||||
|
||||
#define DIALOG(widget) ((dialog_t*)(dialog_cast(WIDGET(widget))))
|
||||
|
||||
#define DIALOG_CHILD_OK "ok"
|
||||
|
@ -366,7 +366,8 @@ model_event_t* model_event_cast(event_t* event) {
|
||||
return (model_event_t*)event;
|
||||
}
|
||||
|
||||
event_t* model_event_init(model_event_t* event, const char* name, const char* change_type, tk_object_t* model) {
|
||||
event_t* model_event_init(model_event_t* event, const char* name, const char* change_type,
|
||||
tk_object_t* model) {
|
||||
return_value_if_fail(event != NULL && name != NULL && change_type != NULL, NULL);
|
||||
event->e = event_init(EVT_MODEL_CHANGE, model);
|
||||
event->e.size = sizeof(model_event_t);
|
||||
@ -380,9 +381,7 @@ event_t* model_event_init(model_event_t* event, const char* name, const char* ch
|
||||
|
||||
system_event_t* system_event_cast(event_t* event) {
|
||||
return_value_if_fail(event != NULL, NULL);
|
||||
return_value_if_fail(
|
||||
event->type == EVT_SYSTEM,
|
||||
NULL);
|
||||
return_value_if_fail(event->type == EVT_SYSTEM, NULL);
|
||||
return_value_if_fail(event->size == sizeof(system_event_t), NULL);
|
||||
|
||||
return (system_event_t*)event;
|
||||
|
@ -536,21 +536,21 @@ typedef struct _model_event_t {
|
||||
* @annotation ["readable", "scriptable"]
|
||||
* 模型名称。
|
||||
*/
|
||||
const char* name;
|
||||
const char* name;
|
||||
|
||||
/**
|
||||
* @property {const char*} change_type
|
||||
* @annotation ["readable", "scriptable"]
|
||||
* 变化类型(update/add/remove)。
|
||||
*/
|
||||
const char* change_type;
|
||||
const char* change_type;
|
||||
|
||||
/**
|
||||
* @property {tk_object_t*} model
|
||||
* @annotation ["readable", "scriptable"]
|
||||
* 模型。
|
||||
*/
|
||||
tk_object_t* model;
|
||||
tk_object_t* model;
|
||||
} model_event_t;
|
||||
|
||||
/**
|
||||
@ -573,7 +573,8 @@ model_event_t* model_event_cast(event_t* event);
|
||||
*
|
||||
* @return {event_t*} event对象。
|
||||
*/
|
||||
event_t* model_event_init(model_event_t* event, const char* name, const char* change_type, tk_object_t* model);
|
||||
event_t* model_event_init(model_event_t* event, const char* name, const char* change_type,
|
||||
tk_object_t* model);
|
||||
/**
|
||||
* @class wheel_event_t
|
||||
* @annotation ["scriptable"]
|
||||
|
@ -170,7 +170,7 @@ ret_t mledit_set_overwrite(widget_t* widget, bool_t overwrite) {
|
||||
return_value_if_fail(mledit != NULL, RET_BAD_PARAMS);
|
||||
|
||||
mledit->overwrite = overwrite;
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -1016,7 +1016,7 @@ char* mledit_get_selected_text(widget_t* widget) {
|
||||
static void mledit_fix_state(mledit_t* mledit, uint32_t offset, uint32_t rm_num, uint32_t cursor) {
|
||||
text_edit_state_t state = {0};
|
||||
text_edit_get_state(mledit->model, &state);
|
||||
|
||||
|
||||
if (state.select_start <= offset && state.select_end >= offset) {
|
||||
state.select_start = state.select_end = 0;
|
||||
} else {
|
||||
@ -1027,7 +1027,7 @@ static void mledit_fix_state(mledit_t* mledit, uint32_t offset, uint32_t rm_num,
|
||||
state.select_start = state.select_end = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mledit->model->ignore_layout = TRUE;
|
||||
text_edit_set_select(mledit->model, state.select_start, state.select_end);
|
||||
mledit->model->ignore_layout = FALSE;
|
||||
@ -1060,13 +1060,13 @@ static ret_t mledit_insert_text_overwrite(widget_t* widget, uint32_t offset, con
|
||||
}
|
||||
|
||||
/* handle max_lines */
|
||||
for (i = (int32_t)(text->size)-1; i >= 0; --i) {
|
||||
if (i > 0 && TWINS_WCHAR_IS_LINE_BREAK(text->str[i-1], text->str[i])) {
|
||||
for (i = (int32_t)(text->size) - 1; i >= 0; --i) {
|
||||
if (i > 0 && TWINS_WCHAR_IS_LINE_BREAK(text->str[i - 1], text->str[i])) {
|
||||
++line_num;
|
||||
if (line_num > mledit->max_lines) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
--i;
|
||||
} else if (WCHAR_IS_LINE_BREAK(text->str[i])) {
|
||||
++line_num;
|
||||
@ -1076,13 +1076,13 @@ static ret_t mledit_insert_text_overwrite(widget_t* widget, uint32_t offset, con
|
||||
}
|
||||
}
|
||||
if (i >= 0) {
|
||||
rm_cnt += i+1;
|
||||
wstr_remove(text, 0, i+1);
|
||||
rm_cnt += i + 1;
|
||||
wstr_remove(text, 0, i + 1);
|
||||
}
|
||||
|
||||
/* fix select & cursor */
|
||||
mledit_fix_state(mledit, offset, rm_cnt, text->size);
|
||||
|
||||
|
||||
/* 新加入的文本 由于 max_chars 或 max_lines的限制, 实际上完全没加到文本中 */
|
||||
if (offset + newtext_len <= rm_cnt) {
|
||||
return RET_SKIP;
|
||||
|
@ -69,7 +69,9 @@ static bitmap_t* mutable_image_prepare_image(widget_t* widget, canvas_t* c) {
|
||||
|
||||
ret_t mutable_image_on_paint_self(widget_t* widget, canvas_t* canvas) {
|
||||
mutable_image_t* mutable_image = MUTABLE_IMAGE(widget);
|
||||
bitmap_t* bitmap = mutable_image->user_image != NULL ? mutable_image->user_image : mutable_image_prepare_image(widget, canvas);
|
||||
bitmap_t* bitmap = mutable_image->user_image != NULL
|
||||
? mutable_image->user_image
|
||||
: mutable_image_prepare_image(widget, canvas);
|
||||
|
||||
if (bitmap == NULL) {
|
||||
return RET_FAIL;
|
||||
|
@ -119,7 +119,7 @@ typedef struct _slide_view_t {
|
||||
*/
|
||||
uint32_t drag_threshold;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {uint32_t} animating_time
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* 动画时间(单位:毫秒)。
|
||||
|
@ -19,7 +19,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TK_TIMER_WIDGET_H
|
||||
#define TK_TIMER_WIDGET_H
|
||||
|
||||
@ -94,7 +93,6 @@ widget_t* timer_widget_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
*/
|
||||
widget_t* timer_widget_cast(widget_t* widget);
|
||||
|
||||
|
||||
/**
|
||||
* @method timer_widget_set_duration
|
||||
* 设置 时长(ms)。
|
||||
@ -106,7 +104,6 @@ widget_t* timer_widget_cast(widget_t* widget);
|
||||
*/
|
||||
ret_t timer_widget_set_duration(widget_t* widget, uint32_t duration);
|
||||
|
||||
|
||||
#define TIMER_WIDGET_PROP_DURATION "duration"
|
||||
|
||||
#define WIDGET_TYPE_TIMER_WIDGET "timer"
|
||||
|
@ -19,7 +19,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "streams/serial/serial_helper.h"
|
||||
#include "streams/serial/istream_serial.h"
|
||||
|
@ -38,7 +38,7 @@ typedef struct _tk_istream_stats_t tk_istream_stats_t;
|
||||
*/
|
||||
struct _tk_istream_stats_t {
|
||||
tk_istream_t istream;
|
||||
|
||||
|
||||
/*private*/
|
||||
tk_istream_t* impl_istream;
|
||||
int count;
|
||||
|
@ -123,7 +123,7 @@ ret_t darray_remove_index(darray_t* darray, uint32_t index) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t darray_remove_range(darray_t* darray, uint32_t start, uint32_t end) {
|
||||
ret_t darray_remove_range(darray_t* darray, uint32_t start, uint32_t end) {
|
||||
return_value_if_fail(darray != NULL && start < end && end <= darray->size, RET_BAD_PARAMS);
|
||||
|
||||
if (darray->elms != NULL) {
|
||||
|
@ -248,7 +248,7 @@ ret_t darray_remove_index(darray_t* darray, uint32_t index);
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t darray_remove_range(darray_t* darray, uint32_t start, uint32_t end);
|
||||
ret_t darray_remove_range(darray_t* darray, uint32_t start, uint32_t end);
|
||||
|
||||
/**
|
||||
* @method darray_remove_all
|
||||
|
@ -2512,8 +2512,8 @@ static ret_t func_get(fscript_t* fscript, fscript_args_t* args, value_t* result)
|
||||
return_value_if_fail(v->type == VALUE_TYPE_ID || v->type == VALUE_TYPE_STRING, RET_BAD_PARAMS);
|
||||
|
||||
if (v->type == VALUE_TYPE_STRING) {
|
||||
const char* name = value_str(v);
|
||||
ret = fscript_get_var(fscript, name, result);
|
||||
const char* name = value_str(v);
|
||||
ret = fscript_get_var(fscript, name, result);
|
||||
} else {
|
||||
if (value_id_index(v) >= 0) {
|
||||
ret = fscript_locals_get(fscript, v, result);
|
||||
@ -2537,8 +2537,8 @@ static ret_t func_set(fscript_t* fscript, fscript_args_t* args, value_t* result)
|
||||
return_value_if_fail(v->type == VALUE_TYPE_ID || v->type == VALUE_TYPE_STRING, RET_BAD_PARAMS);
|
||||
|
||||
if (v->type == VALUE_TYPE_STRING) {
|
||||
const char* name = value_str(v);
|
||||
value_set_bool(result, fscript_set_var(fscript, name, args->args + 1) == RET_OK);
|
||||
const char* name = value_str(v);
|
||||
value_set_bool(result, fscript_set_var(fscript, name, args->args + 1) == RET_OK);
|
||||
} else {
|
||||
index = value_id_index(v);
|
||||
if (index >= 0) {
|
||||
@ -2557,10 +2557,10 @@ static ret_t func_unset(fscript_t* fscript, fscript_args_t* args, value_t* resul
|
||||
value_t* v = args->args;
|
||||
FSCRIPT_FUNC_CHECK(args->size == 1, RET_BAD_PARAMS);
|
||||
return_value_if_fail(v->type == VALUE_TYPE_ID || v->type == VALUE_TYPE_STRING, RET_BAD_PARAMS);
|
||||
|
||||
|
||||
if (v->type == VALUE_TYPE_STRING) {
|
||||
const char* name = value_str(v);
|
||||
tk_object_remove_prop(fscript->obj, name);
|
||||
const char* name = value_str(v);
|
||||
tk_object_remove_prop(fscript->obj, name);
|
||||
} else {
|
||||
index = value_id_index(v);
|
||||
if (index >= 0) {
|
||||
|
@ -127,7 +127,6 @@ void tk_free(void* ptr);
|
||||
*/
|
||||
void tk_mem_dump(void);
|
||||
|
||||
|
||||
/**
|
||||
* @method tk_mem_set_on_out_of_memory
|
||||
* 设置内存耗尽时的处理函数。
|
||||
|
@ -286,7 +286,8 @@ ret_t tk_object_set_prop_pointer(tk_object_t* obj, const char* name, void* value
|
||||
return tk_object_set_prop_pointer_ex(obj, name, value, NULL);
|
||||
}
|
||||
|
||||
ret_t tk_object_set_prop_pointer_ex(tk_object_t* obj, const char* name, void* value, tk_destroy_t destroy) {
|
||||
ret_t tk_object_set_prop_pointer_ex(tk_object_t* obj, const char* name, void* value,
|
||||
tk_destroy_t destroy) {
|
||||
value_t v;
|
||||
ret_t ret = RET_OK;
|
||||
value_set_pointer_ex(&v, value, destroy);
|
||||
|
@ -377,7 +377,8 @@ ret_t tk_object_set_prop_pointer(tk_object_t* obj, const char* name, void* value
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t tk_object_set_prop_pointer_ex(tk_object_t* obj, const char* name, void* value, tk_destroy_t destroy);
|
||||
ret_t tk_object_set_prop_pointer_ex(tk_object_t* obj, const char* name, void* value,
|
||||
tk_destroy_t destroy);
|
||||
|
||||
/**
|
||||
* @method tk_object_set_prop_object
|
||||
|
@ -263,7 +263,7 @@ int32_t tk_atoi(const char* str) {
|
||||
return_value_if_fail(str != NULL, 0);
|
||||
if (IS_HEX_NUM(str)) {
|
||||
return tk_strtoi(str + 2, NULL, 16);
|
||||
}else if (str[0] == '#') {
|
||||
} else if (str[0] == '#') {
|
||||
return tk_strtoi(str + 1, NULL, 16);
|
||||
} else if (IS_BIN_NUM(str)) {
|
||||
return tk_strtoi(str + 2, NULL, 2);
|
||||
|
@ -62,7 +62,7 @@ static ret_t button_notify_pressed_changed(widget_t* widget) {
|
||||
value_t v;
|
||||
prop_change_event_t e;
|
||||
button_t* button = BUTTON(widget);
|
||||
|
||||
|
||||
e.e = event_init(EVT_PROP_CHANGED, widget);
|
||||
e.name = "pressed";
|
||||
value_set_bool(&v, button->pressed);
|
||||
|
@ -105,7 +105,7 @@ typedef struct _button_t {
|
||||
*
|
||||
*/
|
||||
uint32_t long_press_time;
|
||||
|
||||
|
||||
/**
|
||||
* @property {bool_t} pressed
|
||||
* @annotation ["set_prop","get_prop","readable","scriptable"]
|
||||
|
@ -23,9 +23,10 @@
|
||||
#include "base/layout.h"
|
||||
#include "widgets/spin_box.h"
|
||||
|
||||
#define SPIN_DEFAULT_REPEAT 300
|
||||
#define SPIN_DEFAULT_REPEAT 300
|
||||
|
||||
const char* const s_spin_box_properties[] = {TK_EDIT_PROPS, WIDGET_PROP_REPEAT, WIDGET_PROP_EASY_TOUCH_MODE, NULL};
|
||||
const char* const s_spin_box_properties[] = {TK_EDIT_PROPS, WIDGET_PROP_REPEAT,
|
||||
WIDGET_PROP_EASY_TOUCH_MODE, NULL};
|
||||
|
||||
widget_t* spin_box_create_self(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
|
@ -250,7 +250,7 @@ TEST(Button, event_fscript) {
|
||||
ASSERT_EQ(widget_dispatch(w, e), RET_STOP);
|
||||
ASSERT_EQ(widget_dispatch(w, e), RET_STOP);
|
||||
ASSERT_EQ(tk_object_get_prop_int(global, "x", 0), 123);
|
||||
|
||||
|
||||
widget_set_prop_str(w, "on:click", "print('hello\n');global.y=y;return RET_STOP");
|
||||
ASSERT_EQ(widget_dispatch(w, e), RET_STOP);
|
||||
ASSERT_EQ(tk_object_get_prop_int(global, "y", 0), 234);
|
||||
|
@ -137,7 +137,7 @@ TEST(Xml, text0) {
|
||||
str_t str;
|
||||
conf_doc_t* doc = conf_doc_load_xml("<group_box>123</group_box>");
|
||||
|
||||
ASSERT_STREQ(conf_doc_get_str(doc, "group_box."CONF_XML_TEXT, NULL), "123");
|
||||
ASSERT_STREQ(conf_doc_get_str(doc, "group_box." CONF_XML_TEXT, NULL), "123");
|
||||
str_init(&str, 100);
|
||||
conf_doc_save_xml(doc, &str);
|
||||
ASSERT_STREQ(str.str, "<group_box>123</group_box>\n");
|
||||
@ -149,7 +149,7 @@ TEST(Xml, text1) {
|
||||
str_t str;
|
||||
conf_doc_t* doc = conf_doc_load_xml("<group_box>123<abc</group_box>");
|
||||
|
||||
ASSERT_STREQ(conf_doc_get_str(doc, "group_box."CONF_XML_TEXT, NULL), "123<abc");
|
||||
ASSERT_STREQ(conf_doc_get_str(doc, "group_box." CONF_XML_TEXT, NULL), "123<abc");
|
||||
str_init(&str, 100);
|
||||
conf_doc_save_xml(doc, &str);
|
||||
ASSERT_STREQ(str.str, "<group_box>123<abc</group_box>\n");
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include "tkc/data_reader_file.h"
|
||||
|
||||
TEST(DataReaderFactory, basic) {
|
||||
char cwd[MAX_PATH+1] = {0};
|
||||
char path[MAX_PATH+1] = {0};
|
||||
char cwd[MAX_PATH + 1] = {0};
|
||||
char path[MAX_PATH + 1] = {0};
|
||||
data_reader_t* reader = NULL;
|
||||
data_reader_factory_t* f = data_reader_factory_create();
|
||||
reader = data_reader_factory_create_reader(f, "file://./tests/testdata/main.xml");
|
||||
@ -23,8 +23,8 @@ TEST(DataReaderFactory, basic) {
|
||||
|
||||
#ifdef WIN32
|
||||
path_cwd(cwd);
|
||||
path_build(path, sizeof(path)-1, cwd, "tests\\testdata\\main.xml", NULL);
|
||||
log_debug("%s\n", path);
|
||||
path_build(path, sizeof(path) - 1, cwd, "tests\\testdata\\main.xml", NULL);
|
||||
log_debug("%s\n", path);
|
||||
reader = data_reader_factory_create_reader(f, path);
|
||||
ASSERT_EQ(reader != NULL, true);
|
||||
data_reader_destroy(reader);
|
||||
|
@ -2784,19 +2784,19 @@ TEST(FScript, rets) {
|
||||
tk_object_t* obj = object_default_create();
|
||||
fscript_eval(obj, "RET_OK", &v);
|
||||
ASSERT_EQ((int)RET_OK, value_int(&v));
|
||||
|
||||
|
||||
fscript_eval(obj, "RET_FAIL", &v);
|
||||
ASSERT_EQ((int)RET_FAIL, value_int(&v));
|
||||
|
||||
|
||||
fscript_eval(obj, "RET_REMOVE", &v);
|
||||
ASSERT_EQ((int)RET_REMOVE, value_int(&v));
|
||||
|
||||
|
||||
fscript_eval(obj, "RET_REPEAT", &v);
|
||||
ASSERT_EQ((int)RET_REPEAT, value_int(&v));
|
||||
|
||||
|
||||
fscript_eval(obj, "return RET_REPEAT", &v);
|
||||
ASSERT_EQ((int)RET_REPEAT, value_int(&v));
|
||||
|
||||
|
||||
fscript_eval(obj, "return RET_NOT_FOUND", &v);
|
||||
ASSERT_EQ((int)RET_NOT_FOUND, value_int(&v));
|
||||
|
||||
@ -2835,8 +2835,8 @@ static ret_t fscript_self_hooks_set_var(fscript_t* fscript, const char* name, co
|
||||
return fscript_set_var_default(fscript, name, v);
|
||||
}
|
||||
|
||||
static ret_t fscript_self_hooks_exec_func(fscript_t* fscript, const char* name, fscript_func_call_t* iter,
|
||||
value_t* result) {
|
||||
static ret_t fscript_self_hooks_exec_func(fscript_t* fscript, const char* name,
|
||||
fscript_func_call_t* iter, value_t* result) {
|
||||
s_self_hooks_test.exec_func = TRUE;
|
||||
return fscript_exec_func_default(fscript, iter, result);
|
||||
}
|
||||
@ -2866,28 +2866,28 @@ static ret_t fscript_global_hooks_set_var(fscript_t* fscript, const char* name,
|
||||
return fscript_set_var_default(fscript, name, v);
|
||||
}
|
||||
|
||||
static ret_t fscript_global_hooks_exec_func(fscript_t* fscript, const char* name, fscript_func_call_t* iter,
|
||||
value_t* result) {
|
||||
static ret_t fscript_global_hooks_exec_func(fscript_t* fscript, const char* name,
|
||||
fscript_func_call_t* iter, value_t* result) {
|
||||
s_global_hooks_test.exec_func = TRUE;
|
||||
return fscript_exec_func_default(fscript, iter, result);
|
||||
}
|
||||
|
||||
static const fscript_hooks_t s_fscript_self_hooks = {
|
||||
NULL,
|
||||
fscript_self_hooks_on_fscript_deinit,
|
||||
fscript_self_hooks_set_var,
|
||||
fscript_self_hooks_exec_func,
|
||||
fscript_self_hooks_on_fscript_before_exec,
|
||||
fscript_self_hooks_on_fscript_after_exec,
|
||||
NULL,
|
||||
fscript_self_hooks_on_fscript_deinit,
|
||||
fscript_self_hooks_set_var,
|
||||
fscript_self_hooks_exec_func,
|
||||
fscript_self_hooks_on_fscript_before_exec,
|
||||
fscript_self_hooks_on_fscript_after_exec,
|
||||
};
|
||||
|
||||
static const fscript_hooks_t s_fscript_global_hooks = {
|
||||
fscript_global_hooks_on_fscript_init,
|
||||
fscript_global_hooks_on_fscript_deinit,
|
||||
fscript_global_hooks_set_var,
|
||||
fscript_global_hooks_exec_func,
|
||||
fscript_global_hooks_on_fscript_before_exec,
|
||||
fscript_global_hooks_on_fscript_after_exec,
|
||||
fscript_global_hooks_on_fscript_init,
|
||||
fscript_global_hooks_on_fscript_deinit,
|
||||
fscript_global_hooks_set_var,
|
||||
fscript_global_hooks_exec_func,
|
||||
fscript_global_hooks_on_fscript_before_exec,
|
||||
fscript_global_hooks_on_fscript_after_exec,
|
||||
};
|
||||
|
||||
TEST(FScript, hooks) {
|
||||
@ -2937,7 +2937,6 @@ TEST(FScript, hooks) {
|
||||
ASSERT_EQ(s_global_hooks_test.exec_func, TRUE);
|
||||
ASSERT_EQ(s_global_hooks_test.set_var, TRUE);
|
||||
|
||||
|
||||
value_reset(&v);
|
||||
TK_OBJECT_UNREF(obj);
|
||||
}
|
||||
@ -2948,11 +2947,11 @@ TEST(FScript, set_get_unset) {
|
||||
fscript_eval(obj, "set('a',3);get('a')", &v);
|
||||
ASSERT_EQ(3, value_int(&v));
|
||||
value_reset(&v);
|
||||
|
||||
|
||||
fscript_eval(obj, "set(a,3);get(a)", &v);
|
||||
ASSERT_EQ(3, value_int(&v));
|
||||
value_reset(&v);
|
||||
|
||||
|
||||
fscript_eval(obj, "set(a,3);get(a);unset('a');get('a')", &v);
|
||||
ASSERT_EQ(0, value_int(&v));
|
||||
value_reset(&v);
|
||||
|
@ -209,7 +209,7 @@ TEST(MLEdit, insert_text_overwrite) {
|
||||
ASSERT_EQ(mledit_insert_text(e, 0, "0\n"), RET_SKIP);
|
||||
widget_get_text_utf8(e, get_text, sizeof(get_text));
|
||||
ASSERT_STREQ(get_text, "1\n2\n3\n4\n5");
|
||||
|
||||
|
||||
memset(get_text, 0, sizeof(get_text));
|
||||
mledit_set_max_lines(e, 7);
|
||||
widget_set_text_utf8(e, str);
|
||||
|
@ -758,7 +758,7 @@ TEST(ObjectArray, push_and_remove) {
|
||||
ASSERT_EQ(OBJECT_ARRAY(obj)->size, 3);
|
||||
ASSERT_EQ(object_array_get(obj, 0, &v), RET_OK);
|
||||
ASSERT_EQ(value_int(&v), 20);
|
||||
|
||||
|
||||
value_set_int(&v, 30);
|
||||
ASSERT_EQ(object_array_remove_value(obj, &v), RET_OK);
|
||||
ASSERT_EQ(OBJECT_ARRAY(obj)->size, 2);
|
||||
|
@ -144,7 +144,9 @@ TEST(Path, normalize) {
|
||||
ASSERT_EQ(string(result), normalPath("/c"));
|
||||
|
||||
#ifdef WIN32
|
||||
ASSERT_EQ(path_normalize("D:\\aaaa\\aaaaaaaaaaaaaaaaaaaaa\\.\\bin\\demo.exe/../../data/test.c", result, sizeof(result)), RET_OK);
|
||||
ASSERT_EQ(path_normalize("D:\\aaaa\\aaaaaaaaaaaaaaaaaaaaa\\.\\bin\\demo.exe/../../data/test.c",
|
||||
result, sizeof(result)),
|
||||
RET_OK);
|
||||
ASSERT_STREQ(result, "D:\\aaaa\\aaaaaaaaaaaaaaaaaaaaa\\data\\test.c");
|
||||
#endif
|
||||
}
|
||||
|
@ -34,7 +34,12 @@ TEST(SpinBox, to_xml) {
|
||||
str_init(&str, 1024);
|
||||
ASSERT_EQ(widget_to_xml(w1, &str), RET_OK);
|
||||
ASSERT_EQ(string(str.str),
|
||||
string("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<spin_box x=\"10\" y=\"20\" w=\"30\" h=\"40\" focusable=\"true\" min=\"0\" max=\"1024\" step=\"1.000000\" input_type=\"1\" readonly=\"false\" cancelable=\"false\" auto_fix=\"false\" left_margin=\"2\" right_margin=\"2\" top_margin=\"2\" bottom_margin=\"2\" action_text=\"done\" password_visible=\"false\" repeat=\"300\" easy_touch_mode=\"false\">\n</spin_box>\n"));
|
||||
string("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<spin_box x=\"10\" "
|
||||
"y=\"20\" w=\"30\" h=\"40\" focusable=\"true\" min=\"0\" max=\"1024\" "
|
||||
"step=\"1.000000\" input_type=\"1\" readonly=\"false\" cancelable=\"false\" "
|
||||
"auto_fix=\"false\" left_margin=\"2\" right_margin=\"2\" top_margin=\"2\" "
|
||||
"bottom_margin=\"2\" action_text=\"done\" password_visible=\"false\" "
|
||||
"repeat=\"300\" easy_touch_mode=\"false\">\n</spin_box>\n"));
|
||||
|
||||
str_reset(&str);
|
||||
widget_destroy(w1);
|
||||
|
@ -73,11 +73,11 @@ TEST(Str, set_with_len) {
|
||||
|
||||
ASSERT_EQ(str_set_with_len(s, "hello world", 5), RET_OK);
|
||||
ASSERT_EQ(str_eq(s, "hello"), TRUE);
|
||||
|
||||
|
||||
ASSERT_EQ(str_set_with_len(s, &c, 1), RET_OK);
|
||||
ASSERT_EQ(s->size, 1);
|
||||
ASSERT_EQ(str_eq(s, "a"), TRUE);
|
||||
|
||||
|
||||
c = '\0';
|
||||
ASSERT_EQ(str_set_with_len(s, &c, 1), RET_OK);
|
||||
ASSERT_EQ(s->size, 0);
|
||||
|
@ -1338,7 +1338,7 @@ TEST(Widget, set_text) {
|
||||
w->dirty = FALSE;
|
||||
ASSERT_EQ(widget_set_text_utf8_ex(w, "ok", FALSE), RET_OK);
|
||||
ASSERT_EQ(w->dirty, TRUE);
|
||||
|
||||
|
||||
w->dirty = FALSE;
|
||||
ASSERT_EQ(widget_set_tr_text(w, "ok"), RET_OK);
|
||||
ASSERT_EQ(w->dirty, TRUE);
|
||||
|
@ -199,7 +199,7 @@ TEST(Window, copy) {
|
||||
static ret_t on_model_changed(void* ctx, event_t* e) {
|
||||
model_event_t* evt = model_event_cast(e);
|
||||
str_t* str = (str_t*)ctx;
|
||||
str_append_more(str, evt->name, ",", evt->change_type, ";", NULL);
|
||||
str_append_more(str, evt->name, ",", evt->change_type, ";", NULL);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@ -208,7 +208,7 @@ TEST(Window, model_change) {
|
||||
str_t str;
|
||||
widget_t* w1 = window_create(NULL, 10, 20, 30, 40);
|
||||
widget_t* w2 = window_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
|
||||
str_init(&str, 100);
|
||||
widget_on(w1, EVT_MODEL_CHANGE, on_model_changed, &str);
|
||||
widget_on(w2, EVT_MODEL_CHANGE, on_model_changed, &str);
|
||||
|
@ -2130,8 +2130,8 @@ static uint8_t* image_dither_convert_2_to_4(uint8_t* src, uint32_t w, uint32_t h
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static void image_dither_image_blend_bg_color(uint8_t* data, uint32_t w, uint32_t h, uint32_t bpp, color_t bg_color) {
|
||||
static void image_dither_image_blend_bg_color(uint8_t* data, uint32_t w, uint32_t h, uint32_t bpp,
|
||||
color_t bg_color) {
|
||||
if (bpp == 4) {
|
||||
uint32_t y = 0, x = 0;
|
||||
uint8_t* src = data;
|
||||
@ -2155,7 +2155,8 @@ static void image_dither_image_blend_bg_color(uint8_t* data, uint32_t w, uint32_
|
||||
}
|
||||
|
||||
ret_t image_dither_load_image(const uint8_t* buff, uint32_t buff_size, bitmap_t* image,
|
||||
bitmap_format_t bitmap_format, lcd_orientation_t o, color_t bg_color) {
|
||||
bitmap_format_t bitmap_format, lcd_orientation_t o,
|
||||
color_t bg_color) {
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
int n = 0;
|
||||
|
@ -151,8 +151,10 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
platform_prepare();
|
||||
|
||||
if (argc < 4) {
|
||||
printf("Usage: %S in_filename out_filename (png|res|data) (bgra|rgba|bgr|rgb|bgr565|rgb565) (bg_color) (theme) (orientation) \n",
|
||||
argv[0]);
|
||||
printf(
|
||||
"Usage: %S in_filename out_filename (png|res|data) (bgra|rgba|bgr|rgb|bgr565|rgb565) "
|
||||
"(bg_color) (theme) (orientation) \n",
|
||||
argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -177,7 +179,8 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
str_from_wstr(&str_color, argv[5]);
|
||||
bg_color = color_parse(str_color.str);
|
||||
str_reset(&str_color);
|
||||
printf("bg_color(rbga):(%d, %d, %d, %d)", bg_color.rgba.r, bg_color.rgba.g, bg_color.rgba.b, bg_color.rgba.a);
|
||||
printf("bg_color(rbga):(%d, %d, %d, %d)", bg_color.rgba.r, bg_color.rgba.g, bg_color.rgba.b,
|
||||
bg_color.rgba.a);
|
||||
if (bg_color.rgba.a != 0xFF) {
|
||||
printf(", bg_color must opaque!, so fail \r\n");
|
||||
return 0;
|
||||
@ -216,7 +219,8 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
str_from_wstr(&in_file, argv[1]);
|
||||
str_from_wstr(&out_file, argv[2]);
|
||||
|
||||
gen_one(&in_file, &out_file, theme_name.str, output_format, image_format, lcd_orientation, bg_color);
|
||||
gen_one(&in_file, &out_file, theme_name.str, output_format, image_format, lcd_orientation,
|
||||
bg_color);
|
||||
|
||||
str_reset(&in_file);
|
||||
str_reset(&out_file);
|
||||
|
Loading…
x
Reference in New Issue
Block a user