mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 19:49:11 +08:00
format code
This commit is contained in:
parent
c28ad0d4e8
commit
371c5e857b
@ -130,8 +130,9 @@ static ret_t update_title_on_timer(const timer_info_t* info) {
|
||||
return RET_REPEAT;
|
||||
}
|
||||
|
||||
static ret_t popup_move_to_foreground(void* ctx, event_t* e){
|
||||
window_manager_switch_to(window_manager(), window_manager_get_top_main_window(window_manager()), ctx, FALSE);
|
||||
static ret_t popup_move_to_foreground(void* ctx, event_t* e) {
|
||||
window_manager_switch_to(window_manager(), window_manager_get_top_main_window(window_manager()),
|
||||
ctx, FALSE);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -203,7 +204,7 @@ static ret_t on_paint_linear_gradient(void* ctx, event_t* e) {
|
||||
vgcanvas_translate(vg, 0, r.y + r.h);
|
||||
vgcanvas_rect(vg, r.x, r.y, r.w, r.h);
|
||||
ecolor = color_init(0, 0, 0xff, 0xff);
|
||||
vgcanvas_set_fill_linear_gradient(vg, r.x + r.w*0.6, r.y, r.x + r.w*0.4, r.y, scolor, ecolor);
|
||||
vgcanvas_set_fill_linear_gradient(vg, r.x + r.w * 0.6, r.y, r.x + r.w * 0.4, r.y, scolor, ecolor);
|
||||
vgcanvas_fill(vg);
|
||||
|
||||
vgcanvas_translate(vg, -(r.x + r.w), 0);
|
||||
|
@ -35,7 +35,8 @@ ret_t locale_info_set(locale_info_t* locale_info) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static locale_info_t* locale_info_init(locale_info_t* locale_info, const char* language, const char* country, assets_manager_t* am) {
|
||||
static locale_info_t* locale_info_init(locale_info_t* locale_info, const char* language,
|
||||
const char* country, assets_manager_t* am) {
|
||||
return_value_if_fail(locale_info != NULL, NULL);
|
||||
|
||||
locale_info->assets_manager = am;
|
||||
@ -45,7 +46,8 @@ static locale_info_t* locale_info_init(locale_info_t* locale_info, const char* l
|
||||
return locale_info;
|
||||
}
|
||||
|
||||
static locale_info_t* locale_info_create_internal(const char* language, const char* country, assets_manager_t* am) {
|
||||
static locale_info_t* locale_info_create_internal(const char* language, const char* country,
|
||||
assets_manager_t* am) {
|
||||
locale_info_t* locale_info = TKMEM_ZALLOC(locale_info_t);
|
||||
return locale_info_init(locale_info, language, country, am);
|
||||
}
|
||||
|
@ -311,7 +311,9 @@ typedef struct _widget_animator_t widget_animator_t;
|
||||
#define TK_PARENT_VTABLE(vt) NULL, .get_parent_vt = TK_GET_PARENT_VTABLE(vt)
|
||||
#define TK_DECL_VTABLE(vt) \
|
||||
extern const widget_vtable_t g_##vt##_vtable; \
|
||||
const widget_vtable_t* vt##_get_widget_vtable(void) { return &g_##vt##_vtable; } \
|
||||
const widget_vtable_t* vt##_get_widget_vtable(void) { \
|
||||
return &g_##vt##_vtable; \
|
||||
} \
|
||||
const widget_vtable_t g_##vt##_vtable
|
||||
#define TK_EXTERN_VTABLE(vt) const widget_vtable_t* vt##_get_widget_vtable(void);
|
||||
|
||||
|
@ -327,4 +327,3 @@ TK_DECL_VTABLE(widget) = {.size = sizeof(widget_t),
|
||||
.set_prop = widget_set_prop_default,
|
||||
.find_target = widget_find_target_default,
|
||||
.on_destroy = widget_on_destroy_default};
|
||||
|
||||
|
@ -54,14 +54,11 @@ static ret_t line_number_do_paint_self(widget_t* widget, canvas_t* c) {
|
||||
if (style_is_valid(style)) {
|
||||
uint32_t line_index = 0;
|
||||
color_t trans = color_init(0, 0, 0, 0);
|
||||
widget_prepare_text_style_ex(widget, c, trans, NULL, TK_DEFAULT_FONT_SIZE,
|
||||
ALIGN_H_RIGHT, ALIGN_V_TOP);
|
||||
color_t active_bg =
|
||||
style_get_color(style, LINE_NUMBER_STYLE_ACTIVE_LINE_BG_COLOR, trans);
|
||||
color_t highlight_bg =
|
||||
style_get_color(style, LINE_NUMBER_STYLE_HIGHLIGHT_LINE_BG_COLOR, trans);
|
||||
const char* highlight_shape =
|
||||
style_get_str(style, LINE_NUMBER_STYLE_HIGHLIGHT_LINE_SHAPE,
|
||||
widget_prepare_text_style_ex(widget, c, trans, NULL, TK_DEFAULT_FONT_SIZE, ALIGN_H_RIGHT,
|
||||
ALIGN_V_TOP);
|
||||
color_t active_bg = style_get_color(style, LINE_NUMBER_STYLE_ACTIVE_LINE_BG_COLOR, trans);
|
||||
color_t highlight_bg = style_get_color(style, LINE_NUMBER_STYLE_HIGHLIGHT_LINE_BG_COLOR, trans);
|
||||
const char* highlight_shape = style_get_str(style, LINE_NUMBER_STYLE_HIGHLIGHT_LINE_SHAPE,
|
||||
LINE_NUMBER_STYLE_HIGHLIGHT_LINE_SHAPE_CIRCLE);
|
||||
|
||||
while (1) {
|
||||
@ -89,10 +86,10 @@ static ret_t line_number_do_paint_self(widget_t* widget, canvas_t* c) {
|
||||
canvas_set_fill_color(c, highlight_bg);
|
||||
if (highlight_shape[0] == 'c') {
|
||||
rect_t save_r = r;
|
||||
int32_t size = tk_min(r.w, r.h)/2;
|
||||
int32_t dx = (r.w - size)/2;
|
||||
int32_t dy = (r.h - size)/2;
|
||||
int32_t rr = size/2;
|
||||
int32_t size = tk_min(r.w, r.h) / 2;
|
||||
int32_t dx = (r.w - size) / 2;
|
||||
int32_t dy = (r.h - size) / 2;
|
||||
int32_t rr = size / 2;
|
||||
|
||||
r.x += dx;
|
||||
r.y += dy;
|
||||
|
@ -955,7 +955,8 @@ static ret_t mledit_on_scroll_bar_value_changed(void* ctx, event_t* e) {
|
||||
return_value_if_fail(vscroll_bar != NULL && scroll_bar != NULL, RET_BAD_PARAMS);
|
||||
|
||||
value = widget_get_value(vscroll_bar);
|
||||
value = (int64_t)(scroll_bar->virtual_size - vscroll_bar->h) * (int64_t)value / scroll_bar->virtual_size;
|
||||
value = (int64_t)(scroll_bar->virtual_size - vscroll_bar->h) * (int64_t)value /
|
||||
scroll_bar->virtual_size;
|
||||
|
||||
if (mledit->overwrite && mledit->max_chars == 0 && mledit->max_lines != 0) {
|
||||
if (value == scroll_bar->virtual_size - vscroll_bar->h) {
|
||||
|
@ -179,7 +179,7 @@ static ret_t list_view_on_event(widget_t* widget, event_t* e) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EVT_KEY_UP :
|
||||
case EVT_KEY_UP:
|
||||
case EVT_POINTER_UP: {
|
||||
pointer_event_t* evt = (pointer_event_t*)e;
|
||||
list_view_on_pointer_up(list_view, evt);
|
||||
|
@ -933,7 +933,8 @@ static ret_t slide_view_set_active_animate(widget_t* widget, uint32_t active) {
|
||||
}
|
||||
old_active = slide_view->active;
|
||||
|
||||
if ((old_active < active && !(slide_view->loop && old_active == 0 && active == widget->children->size - 1)) ||
|
||||
if ((old_active < active &&
|
||||
!(slide_view->loop && old_active == 0 && active == widget->children->size - 1)) ||
|
||||
(slide_view->loop && active == 0 && old_active == widget->children->size - 1)) {
|
||||
slide_view->prev = widget_get_child(widget, old_active);
|
||||
slide_view->next = widget_get_child(widget, active);
|
||||
|
@ -212,7 +212,8 @@ static ret_t main_loop_sdl2_dispatch_window_event(main_loop_simple_t* loop, SDL_
|
||||
native_window_info_t info;
|
||||
event_t e = event_init(EVT_NATIVE_WINDOW_RESIZED, NULL);
|
||||
SDL_Window* win = SDL_GetWindowFromID(event->window.windowID);
|
||||
native_window_t* native_window = (native_window_t*)widget_get_prop_pointer(window_manager(), WIDGET_PROP_NATIVE_WINDOW);
|
||||
native_window_t* native_window =
|
||||
(native_window_t*)widget_get_prop_pointer(window_manager(), WIDGET_PROP_NATIVE_WINDOW);
|
||||
native_window_get_info(native_window, &info);
|
||||
system_info_set_lcd_w(system_info(), info.w);
|
||||
system_info_set_lcd_h(system_info(), info.h);
|
||||
|
@ -1181,7 +1181,7 @@ static ret_t fscript_parser_parse_id_or_number(fscript_parser_t* parser, token_t
|
||||
if (tk_isxdigit(c) || tk_isdigit(c) || tk_isalpha(c) || c == '.' || c == '_' || c == '[' ||
|
||||
c == ']' || c == '#') {
|
||||
str_append_char(str, c);
|
||||
} else if(tk_isspace(c)) {
|
||||
} else if (tk_isspace(c)) {
|
||||
break;
|
||||
} else {
|
||||
int32_t n = tk_utf8_get_bytes_of_leading((uint8_t)c);
|
||||
|
@ -973,7 +973,8 @@ ret_t tk_object_set_prop_uint64(tk_object_t* obj, const char* name, uint64_t val
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t tk_object_to_json(tk_object_t* obj, str_t* json, uint32_t indent, uint32_t level, bool_t oneline);
|
||||
ret_t tk_object_to_json(tk_object_t* obj, str_t* json, uint32_t indent, uint32_t level,
|
||||
bool_t oneline);
|
||||
|
||||
/**
|
||||
* @method tk_object_get_child_object
|
||||
|
@ -59,7 +59,7 @@ wchar_t* wcs_cpy(wchar_t* s1, const wchar_t* s2) {
|
||||
return s1;
|
||||
}
|
||||
|
||||
int wcs_ncmp(const wchar_t *s1, const wchar_t *s2, uint32_t n) {
|
||||
int wcs_ncmp(const wchar_t* s1, const wchar_t* s2, uint32_t n) {
|
||||
wchar_t c1 = L'\0';
|
||||
wchar_t c2 = L'\0';
|
||||
return_value_if_fail(s1 != NULL && s2 != NULL, -1);
|
||||
|
@ -58,7 +58,8 @@ static ret_t check_button_on_event(widget_t* widget, event_t* e) {
|
||||
pointer_event_t* evt = (pointer_event_t*)e;
|
||||
if (check_button->pressed && widget_is_point_in(widget, evt->x, evt->y, FALSE)) {
|
||||
pointer_event_t click;
|
||||
ret = widget_dispatch(widget, pointer_event_init(&click, EVT_CLICK, widget, evt->x, evt->y));
|
||||
ret =
|
||||
widget_dispatch(widget, pointer_event_init(&click, EVT_CLICK, widget, evt->x, evt->y));
|
||||
}
|
||||
|
||||
check_button->pressed = FALSE;
|
||||
|
@ -599,7 +599,8 @@ ret_t combo_box_combobox_popup_on_close_func(void* ctx, event_t* e) {
|
||||
combo_box_t* combo_box = COMBO_BOX(ctx);
|
||||
return_value_if_fail(combo_box != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_off_by_func(window_manager(), EVT_WIDGET_WILL_RESTACK_CHILD, combo_box_popup_restack, combo_box);
|
||||
widget_off_by_func(window_manager(), EVT_WIDGET_WILL_RESTACK_CHILD, combo_box_popup_restack,
|
||||
combo_box);
|
||||
combo_box->combobox_popup = NULL;
|
||||
|
||||
return RET_OK;
|
||||
|
@ -147,7 +147,8 @@ widget_t* digit_clock_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
digit_clock_update_time(widget);
|
||||
widget_add_timer(widget, digit_clock_on_timer, 1000);
|
||||
wstr_init(&(digit_clock->last_time), 32);
|
||||
digit_clock->local_changed_event_id = locale_info_on(locale_info(), EVT_LOCALE_CHANGED, digit_clock_on_display_time, widget);
|
||||
digit_clock->local_changed_event_id =
|
||||
locale_info_on(locale_info(), EVT_LOCALE_CHANGED, digit_clock_on_display_time, widget);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
@ -3152,6 +3152,5 @@ TEST(FScript, id1) {
|
||||
ASSERT_EQ(value_int(&v), 3);
|
||||
value_reset(&v);
|
||||
|
||||
|
||||
TK_OBJECT_UNREF(obj);
|
||||
}
|
||||
|
@ -693,7 +693,9 @@ TEST(ObjectDefault, to_json1) {
|
||||
|
||||
str_clear(&str);
|
||||
tk_object_to_json(obj, &str, 2, 0, FALSE);
|
||||
ASSERT_STREQ(str.str, "{\n \"age\": \"100\",\n \"detail\": {\n \"city\": \"sz\"\n },\n \"name\": \"jim\"\n}");
|
||||
ASSERT_STREQ(str.str,
|
||||
"{\n \"age\": \"100\",\n \"detail\": {\n \"city\": \"sz\"\n },\n "
|
||||
"\"name\": \"jim\"\n}");
|
||||
|
||||
str_reset(&str);
|
||||
TK_OBJECT_UNREF(obj);
|
||||
|
Loading…
Reference in New Issue
Block a user