mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
format code
This commit is contained in:
parent
a105fc1193
commit
8aaef10b5c
@ -113,7 +113,7 @@ dialog_highlighter_t* dialog_highlighter_factory_create_highlighter(
|
||||
return h;
|
||||
#else
|
||||
return NULL;
|
||||
#endif/*WITHOUT_DIALOG_HIGHLIGHTER*/
|
||||
#endif /*WITHOUT_DIALOG_HIGHLIGHTER*/
|
||||
}
|
||||
|
||||
ret_t dialog_highlighter_factory_set(dialog_highlighter_factory_t* factory) {
|
||||
|
@ -97,7 +97,7 @@ static ret_t style_const_apply_props(style_t* s, widget_t* widget) {
|
||||
if (focusable != NULL) {
|
||||
widget->focusable = *focusable == 'T' || *focusable == 't';
|
||||
}
|
||||
|
||||
|
||||
if (feedback != NULL) {
|
||||
widget->feedback = *feedback == 'T' || *feedback == 't';
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ typedef struct _system_info_t system_info_t;
|
||||
|
||||
#ifdef WITHOUT_WINDOW_ANIMATOR_CACHE
|
||||
#define WITHOUT_DIALOG_HIGHLIGHTER 1
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
|
||||
/**
|
||||
* @enum bitmap_format_t
|
||||
|
2
src/base/window_animator.h
Executable file → Normal file
2
src/base/window_animator.h
Executable file → Normal file
@ -136,7 +136,7 @@ struct _window_animator_t {
|
||||
#ifndef WITHOUT_WINDOW_ANIMATOR_CACHE
|
||||
bitmap_t prev_img;
|
||||
bitmap_t curr_img;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
bool_t open;
|
||||
float_t ratio;
|
||||
float_t percent;
|
||||
|
@ -239,7 +239,7 @@ typedef struct _window_base_t {
|
||||
* 单例。如果窗口存在,先关闭再打开。
|
||||
*/
|
||||
bool_t single_instance;
|
||||
|
||||
|
||||
/**
|
||||
* @property {bool_t} strongly_focus
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
|
@ -184,11 +184,10 @@ ret_t gif_image_stop(widget_t* widget) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
TK_DECL_VTABLE(gif_image) = {.size = sizeof(gif_image_t),
|
||||
.type = WIDGET_TYPE_GIF_IMAGE,
|
||||
.space_key_to_activate = TRUE,
|
||||
.return_key_to_activate = TRUE,
|
||||
.space_key_to_activate = TRUE,
|
||||
.return_key_to_activate = TRUE,
|
||||
.clone_properties = s_gif_image_properties,
|
||||
.persistent_properties = s_gif_image_properties,
|
||||
.parent = TK_PARENT_VTABLE(image_base),
|
||||
|
@ -64,7 +64,8 @@ ret_t stb_load_image(int32_t subtype, const uint8_t* buff, uint32_t buff_size, b
|
||||
if (subtype != ASSET_TYPE_IMAGE_GIF) {
|
||||
uint8_t* data = NULL;
|
||||
int out_channel_order;
|
||||
uint8_t* stb_data = stbi_load_from_memory_ex(buff, buff_size, &w, &h, &n, &out_channel_order, 0);
|
||||
uint8_t* stb_data =
|
||||
stbi_load_from_memory_ex(buff, buff_size, &w, &h, &n, &out_channel_order, 0);
|
||||
return_value_if_fail(stb_data != NULL, RET_FAIL);
|
||||
|
||||
if (n == 2) {
|
||||
@ -74,11 +75,11 @@ ret_t stb_load_image(int32_t subtype, const uint8_t* buff, uint32_t buff_size, b
|
||||
data = stb_data;
|
||||
}
|
||||
#ifdef WITH_LCD_MONO
|
||||
if (out_channel_order == STBI_ORDER_RGB) {
|
||||
ret = bitmap_init_from_rgba(image, w, h, BITMAP_FMT_MONO, data, n);
|
||||
} else {
|
||||
ret = bitmap_init_from_bgra(image, w, h, BITMAP_FMT_MONO, data, n);
|
||||
}
|
||||
if (out_channel_order == STBI_ORDER_RGB) {
|
||||
ret = bitmap_init_from_rgba(image, w, h, BITMAP_FMT_MONO, data, n);
|
||||
} else {
|
||||
ret = bitmap_init_from_bgra(image, w, h, BITMAP_FMT_MONO, data, n);
|
||||
}
|
||||
#else
|
||||
if (out_channel_order == STBI_ORDER_RGB) {
|
||||
if (enable_bgr565 && rgba_data_is_opaque(data, w, h, n)) {
|
||||
|
@ -474,7 +474,7 @@ static native_window_t* native_window_create_internal(const char* title, uint32_
|
||||
if (system_info()->app_type == APP_DESKTOP) {
|
||||
flags |= SDL_WINDOW_RESIZABLE;
|
||||
}
|
||||
#endif/*NATIVE_WINDOW_NOT_RESIZABLE*/
|
||||
#endif /*NATIVE_WINDOW_NOT_RESIZABLE*/
|
||||
|
||||
#ifndef WITH_NANOVG_SOFT
|
||||
flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
@ -1087,9 +1087,9 @@ static bool_t widget_has_uint_min_max(widget_t* widget) {
|
||||
return_value_if_fail(edit != NULL, FALSE);
|
||||
|
||||
input_type = edit->input_type;
|
||||
|
||||
return input_type == INPUT_TEXT || input_type == INPUT_ASCII || input_type == INPUT_PASSWORD
|
||||
|| input_type == INPUT_EMAIL || input_type == INPUT_UINT;
|
||||
|
||||
return input_type == INPUT_TEXT || input_type == INPUT_ASCII || input_type == INPUT_PASSWORD ||
|
||||
input_type == INPUT_EMAIL || input_type == INPUT_UINT;
|
||||
}
|
||||
|
||||
ret_t edit_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||
|
@ -22,20 +22,19 @@
|
||||
#include "window_animators/window_animator_center_scale.h"
|
||||
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
#define START_PERCENT 0.5f
|
||||
#define START_PERCENT 0.5f
|
||||
#else
|
||||
#define START_PERCENT 0.9f
|
||||
#define START_PERCENT 0.9f
|
||||
#endif
|
||||
|
||||
static ret_t window_animator_center_scale_update_percent(window_animator_t* wa) {
|
||||
|
||||
if (wa->open) {
|
||||
wa->percent = START_PERCENT + (1-START_PERCENT) * wa->easing(wa->time_percent);
|
||||
wa->percent = START_PERCENT + (1 - START_PERCENT) * wa->easing(wa->time_percent);
|
||||
if (wa->easing(wa->time_percent) == 0) {
|
||||
wa->percent = 0;
|
||||
}
|
||||
} else {
|
||||
wa->percent = 1.0f - (1-START_PERCENT) * wa->easing(wa->time_percent);
|
||||
wa->percent = 1.0f - (1 - START_PERCENT) * wa->easing(wa->time_percent);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
@ -64,9 +63,9 @@ static ret_t window_animator_center_scale_draw_curr(window_animator_t* wa) {
|
||||
#else
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
vgcanvas_t* vg = canvas_get_vgcanvas(c);
|
||||
float x = win->x + (win->w/2);
|
||||
float y = win->y + (win->h/2);
|
||||
float alpha = 1-(1-scale) / (1 - START_PERCENT);
|
||||
float x = win->x + (win->w / 2);
|
||||
float y = win->y + (win->h / 2);
|
||||
float alpha = 1 - (1 - scale) / (1 - START_PERCENT);
|
||||
|
||||
vgcanvas_save(vg);
|
||||
vgcanvas_translate(vg, x, y);
|
||||
@ -79,9 +78,9 @@ static ret_t window_animator_center_scale_draw_curr(window_animator_t* wa) {
|
||||
#else
|
||||
assert(!"not supported");
|
||||
return RET_FAIL;
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
#endif /*WITH_NANOVG_GPU*/
|
||||
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
static const window_animator_vtable_t s_window_animator_center_scale_vt = {
|
||||
|
@ -46,12 +46,12 @@ ret_t window_animator_to_bottom_draw_curr(window_animator_t* wa) {
|
||||
|
||||
return lcd_draw_image(c->lcd, &(wa->curr_img), rect_scale(&src, wa->ratio), &dst);
|
||||
#else
|
||||
int32_t y = -win->h * (1-percent);
|
||||
int32_t y = -win->h * (1 - percent);
|
||||
canvas_translate(c, 0, y);
|
||||
widget_paint(win, c);
|
||||
canvas_untranslate(c, 0, y);
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
ret_t window_animator_to_top_draw_curr(window_animator_t* wa) {
|
||||
@ -71,12 +71,12 @@ ret_t window_animator_to_top_draw_curr(window_animator_t* wa) {
|
||||
|
||||
return lcd_draw_image(c->lcd, &(wa->curr_img), rect_scale(&src, wa->ratio), &dst);
|
||||
#else
|
||||
int32_t y = win->h * (1-percent);
|
||||
int32_t y = win->h * (1 - percent);
|
||||
canvas_translate(c, 0, y);
|
||||
widget_paint(win, c);
|
||||
canvas_untranslate(c, 0, y);
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
ret_t window_animator_to_left_draw_curr(window_animator_t* wa) {
|
||||
@ -96,13 +96,13 @@ ret_t window_animator_to_left_draw_curr(window_animator_t* wa) {
|
||||
|
||||
return lcd_draw_image(c->lcd, &(wa->curr_img), rect_scale(&src, wa->ratio), &dst);
|
||||
#else
|
||||
int32_t x = -win->w * (1-percent);
|
||||
int32_t x = -win->w * (1 - percent);
|
||||
|
||||
canvas_translate(c, x, 0);
|
||||
widget_paint(win, c);
|
||||
canvas_untranslate(c, x, 0);
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
ret_t window_animator_to_right_draw_curr(window_animator_t* wa) {
|
||||
@ -121,13 +121,13 @@ ret_t window_animator_to_right_draw_curr(window_animator_t* wa) {
|
||||
|
||||
return lcd_draw_image(c->lcd, &(wa->curr_img), rect_scale(&src, wa->ratio), &dst);
|
||||
#else
|
||||
int32_t x = win->w * (1-percent);
|
||||
int32_t x = win->w * (1 - percent);
|
||||
|
||||
canvas_translate(c, x, 0);
|
||||
widget_paint(win, c);
|
||||
canvas_untranslate(c, x, 0);
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
static ret_t window_animator_paint_system_bar(window_animator_t* wa);
|
||||
@ -141,7 +141,7 @@ static ret_t window_animator_open_destroy(window_animator_t* wa) {
|
||||
bitmap_destroy(&(wa->prev_img));
|
||||
}
|
||||
bitmap_destroy(&(wa->curr_img));
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
|
||||
memset(wa, 0x00, sizeof(window_animator_t));
|
||||
TKMEM_FREE(wa);
|
||||
@ -234,7 +234,7 @@ ret_t window_animator_prepare(window_animator_t* wa, canvas_t* c, widget_t* prev
|
||||
window_manager_snap_prev_window(wm, prev_win, &(wa->prev_img));
|
||||
window_manager_snap_curr_window(wm, curr_win, &(wa->curr_img));
|
||||
wa->dialog_highlighter = window_manager_get_dialog_highlighter(wm);
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@ -316,7 +316,7 @@ ret_t window_animator_overlap_default_draw_prev(window_animator_t* wa) {
|
||||
#else
|
||||
widget_paint(win, c);
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
ret_t window_animator_begin_frame(window_animator_t* wa) {
|
||||
@ -336,6 +336,6 @@ ret_t window_animator_end_frame(window_animator_t* wa) {
|
||||
if (tk_str_eq(wa->vt->type, WINDOW_ANIMATOR_VTRANSLATE)) {
|
||||
window_animator_paint_system_bar(wa);
|
||||
}
|
||||
|
||||
|
||||
return canvas_end_frame(wa->canvas);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ static ret_t window_animator_fade_draw_curr(window_animator_t* wa) {
|
||||
lcd_set_global_alpha(c->lcd, global_alpha);
|
||||
|
||||
return widget_paint(win, c);
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
static const window_animator_vtable_t s_window_animator_fade_vt = {
|
||||
|
@ -49,7 +49,7 @@ static ret_t window_animator_htranslate_draw_prev(window_animator_t* wa) {
|
||||
widget_paint(win, c);
|
||||
canvas_untranslate(c, -x, 0);
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
static ret_t window_animator_htranslate_draw_curr(window_animator_t* wa) {
|
||||
@ -70,7 +70,7 @@ static ret_t window_animator_htranslate_draw_curr(window_animator_t* wa) {
|
||||
canvas_untranslate(c, x, 0);
|
||||
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
static const window_animator_vtable_t s_window_animator_htranslate_vt = {
|
||||
|
@ -50,7 +50,7 @@ static ret_t window_animator_vtranslate_draw_prev(window_animator_t* wa) {
|
||||
widget_paint(win, c);
|
||||
canvas_untranslate(c, 0, -y);
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
static ret_t window_animator_vtranslate_draw_curr(window_animator_t* wa) {
|
||||
@ -66,13 +66,13 @@ static ret_t window_animator_vtranslate_draw_curr(window_animator_t* wa) {
|
||||
|
||||
return lcd_draw_image(c->lcd, &(wa->curr_img), rect_scale(&src, wa->ratio), &dst);
|
||||
#else
|
||||
y = win->h * (1-percent);
|
||||
y = win->h * (1 - percent);
|
||||
canvas_translate(c, 0, y);
|
||||
widget_paint(win, c);
|
||||
canvas_untranslate(c, 0, y);
|
||||
|
||||
return RET_OK;
|
||||
#endif/*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
#endif /*WITHOUT_WINDOW_ANIMATOR_CACHE*/
|
||||
}
|
||||
|
||||
static const window_animator_vtable_t s_window_animator_vtranslate_vt = {
|
||||
|
@ -137,7 +137,8 @@ ret_t window_manager_default_snap_curr_window(widget_t* widget, widget_t* curr_w
|
||||
r = rect_init(curr_win->x, curr_win->y, curr_win->w, curr_win->h);
|
||||
|
||||
canvas_save(c);
|
||||
canvas = canvas_offline_create(canvas_get_width(c), canvas_get_height(c), lcd_get_desired_bitmap_format(c->lcd));
|
||||
canvas = canvas_offline_create(canvas_get_width(c), canvas_get_height(c),
|
||||
lcd_get_desired_bitmap_format(c->lcd));
|
||||
canvas_offline_begin_draw(canvas);
|
||||
canvas_set_clip_rect(canvas, &r);
|
||||
ENSURE(widget_on_paint_background(widget, canvas) == RET_OK);
|
||||
@ -203,7 +204,8 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w
|
||||
r = rect_init(prev_win->x, prev_win->y, prev_win->w, prev_win->h);
|
||||
|
||||
canvas_save(c);
|
||||
canvas = canvas_offline_create(canvas_get_width(c), canvas_get_height(c), lcd_get_desired_bitmap_format(c->lcd));
|
||||
canvas = canvas_offline_create(canvas_get_width(c), canvas_get_height(c),
|
||||
lcd_get_desired_bitmap_format(c->lcd));
|
||||
canvas_offline_begin_draw(canvas);
|
||||
canvas_set_clip_rect(canvas, &r);
|
||||
ENSURE(widget_on_paint_background(widget, canvas) == RET_OK);
|
||||
|
@ -185,7 +185,9 @@ TEST(Button, to_xml) {
|
||||
widget_set_text_utf8(w1, "<>&\"");
|
||||
widget_to_xml(w1, &str);
|
||||
log_debug("w1:%s\n", str.str);
|
||||
ASSERT_STREQ(str.str, "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<button x=\"10\" y=\"20\" w=\"30\" h=\"40\" text=\"<>&"\">\n</button>\n");
|
||||
ASSERT_STREQ(str.str,
|
||||
"<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<button x=\"10\" "
|
||||
"y=\"20\" w=\"30\" h=\"40\" text=\"<>&"\">\n</button>\n");
|
||||
widget_destroy(w1);
|
||||
|
||||
str_reset(&str);
|
||||
|
@ -30,7 +30,7 @@ TEST(GuagePointer, set_angle) {
|
||||
EXPECT_TRUE(gauge_pointer_set_angle(gauge_pointer, -10) == RET_OK);
|
||||
|
||||
EXPECT_TRUE(gauge_pointer_set_angle(gauge_pointer, 370) == RET_OK);
|
||||
|
||||
|
||||
EXPECT_TRUE(gauge_pointer_set_angle(gauge_pointer, 10.5) == RET_OK);
|
||||
EXPECT_TRUE(gauge_pointer_tmp->angle == 10.5);
|
||||
|
||||
|
@ -38,7 +38,7 @@ TEST(GifImage, state) {
|
||||
|
||||
gif_image_play(img);
|
||||
ASSERT_EQ(GIF_IMAGE(img)->running, TRUE);
|
||||
|
||||
|
||||
gif_image_pause(img);
|
||||
ASSERT_EQ(GIF_IMAGE(img)->running, FALSE);
|
||||
|
||||
|
@ -1330,7 +1330,7 @@ TEST(Widget, is_focusable) {
|
||||
ASSERT_EQ(widget_is_focusable(w), FALSE);
|
||||
widget_set_enable(w, TRUE);
|
||||
ASSERT_EQ(widget_is_focusable(w), TRUE);
|
||||
|
||||
|
||||
widget_set_sensitive(w, FALSE);
|
||||
ASSERT_EQ(widget_is_focusable(w), FALSE);
|
||||
widget_set_sensitive(w, TRUE);
|
||||
@ -1388,4 +1388,3 @@ TEST(Widget, update_style4) {
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
|
@ -122,11 +122,11 @@ TEST(Window, focused_widget) {
|
||||
widget_t* b = button_create(w, 0, 0, 60, 30);
|
||||
widget_set_focusable(b, TRUE);
|
||||
widget_set_name(b, "b1");
|
||||
|
||||
|
||||
b = button_create(w, 0, 30, 60, 30);
|
||||
widget_set_focusable(b, TRUE);
|
||||
widget_set_name(b, "b2");
|
||||
|
||||
|
||||
b = button_create(w, 0, 30, 60, 30);
|
||||
widget_set_focusable(b, TRUE);
|
||||
widget_set_name(b, "b3");
|
||||
|
Loading…
Reference in New Issue
Block a user