mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
improve window animator
This commit is contained in:
parent
132ac68121
commit
306ea9106e
@ -10,8 +10,8 @@ GTEST_ROOT = os.path.join(LFTK_ROOT, '3rd/gtest/googletest')
|
||||
BIN_DIR=os.path.join(LFTK_ROOT, 'bin')
|
||||
LIB_DIR=os.path.join(LFTK_ROOT, 'lib')
|
||||
|
||||
LCD='SDL'
|
||||
LCD='NANOVG'
|
||||
LCD='SDL'
|
||||
|
||||
os.environ['LCD'] = LCD
|
||||
os.environ['BIN_DIR'] = BIN_DIR;
|
||||
@ -46,7 +46,7 @@ elif OS_NAME == 'Linux':
|
||||
|
||||
elif OS_NAME == 'Windows':
|
||||
OS_LIBS=['SDL2', 'glad']
|
||||
OS_FLAGS='-DWIN32 -D_WIN32 -DWINDOWS /EHsc -D_CONSOLE /DEBUG /INCREMENTA -DUNICODE -D_UNICODE /Od /ZI'
|
||||
OS_FLAGS='-DWIN32 -D_WIN32 -DWINDOWS /EHsc -D_CONSOLE /DEBUG -DUNICODE -D_UNICODE /Od /ZI'
|
||||
OS_LINKFLAGS='/MACHINE:X64 /DEBUG'
|
||||
OS_LIBPATH=[LFTK_3RD_ROOT+'/SDL2-2.0.7/lib/x64']
|
||||
OS_CPPPATH=[LFTK_3RD_ROOT+'/SDL2-2.0.7/']
|
||||
|
@ -31,17 +31,18 @@ static ret_t window_animator_open_bottom_to_top_draw_curr(window_animator_t* wa)
|
||||
float_t ratio = wa->ratio;
|
||||
widget_t* win = wa->curr_win;
|
||||
float_t percent = wa->percent;
|
||||
float_t h = win->h * percent;
|
||||
float_t wm_h = win->parent->h;
|
||||
float_t y = wm_h - h;
|
||||
float_t alpha = percent;
|
||||
|
||||
#ifdef WITH_NANOVG
|
||||
float_t h = win->h * percent;
|
||||
float_t y = win->parent->h - h;
|
||||
vgcanvas_t* vg = lcd_get_vgcanvas(c->lcd);
|
||||
vgcanvas_set_global_alpha(vg, alpha);
|
||||
vgcanvas_draw_image(vg, &(wa->curr_img), win->x * ratio, win->y * ratio, win->w * ratio,
|
||||
h * ratio, win->x, y, win->w, h);
|
||||
#else
|
||||
int32_t h = win->h * percent;
|
||||
int32_t y = win->parent->h - h;
|
||||
rect_init(src, win->x * ratio, win->y * ratio, win->w * ratio, h * ratio);
|
||||
rect_init(dst, win->x, y, win->w, h);
|
||||
lcd_set_global_alpha(c->lcd, alpha * 0xff);
|
||||
|
@ -49,7 +49,6 @@ static ret_t window_animator_open_scale_draw_curr(window_animator_t* wa) {
|
||||
rect_init(dst, 0, 0, win->w * scale, win->h * scale);
|
||||
dst.x = win->x + ((win->w - dst.w) >> 1);
|
||||
dst.y = win->y + ((win->h - dst.h) >> 1);
|
||||
//log_debug("%d %d %d %d\n", dst.x, dst.y, dst.w, dst.h);
|
||||
lcd_set_global_alpha(c->lcd, alpha * 0xff);
|
||||
lcd_draw_image(c->lcd, &(wa->curr_img), &src, &dst);
|
||||
#endif
|
||||
|
@ -31,17 +31,20 @@ static ret_t window_animator_open_top_to_bottom_draw_curr(window_animator_t* wa)
|
||||
float_t ratio = wa->ratio;
|
||||
widget_t* win = wa->curr_win;
|
||||
float_t percent = wa->percent;
|
||||
float_t h = win->h * percent;
|
||||
float_t y = win->h * (1 - percent);
|
||||
float_t alpha = percent;
|
||||
|
||||
#ifdef WITH_NANOVG
|
||||
float_t h = win->h * percent;
|
||||
float_t y = win->h - h;
|
||||
vgcanvas_t* vg = lcd_get_vgcanvas(c->lcd);
|
||||
vgcanvas_set_global_alpha(vg, alpha);
|
||||
vgcanvas_draw_image(vg, &(wa->curr_img), win->x * ratio, y * ratio, win->w * ratio, h * ratio,
|
||||
win->x, 0, win->w, h);
|
||||
#else
|
||||
rect_init(src, win->x * ratio, y * ratio, win->w * ratio, h * ratio);
|
||||
int32_t h = win->h * percent;
|
||||
int32_t y = win->h - h;
|
||||
|
||||
rect_init(src, win->x * ratio, y, win->w * ratio, h);
|
||||
rect_init(dst, win->x, 0, win->w, h);
|
||||
lcd_set_global_alpha(c->lcd, alpha * 0xff);
|
||||
lcd_draw_image(c->lcd, &(wa->curr_img), &src, &dst);
|
||||
|
@ -63,6 +63,13 @@ static ret_t lcd_sdl2_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
||||
return lcd_draw_points(mem, points, nr);
|
||||
}
|
||||
|
||||
static color_t lcd_sdl2_get_point_color(lcd_t* lcd, xy_t x, xy_t y) {
|
||||
lcd_sdl2_t* sdl = (lcd_sdl2_t*)lcd;
|
||||
lcd_t* mem = (lcd_t*)(sdl->lcd_mem);
|
||||
|
||||
return lcd_get_point_color(mem, x, y);
|
||||
}
|
||||
|
||||
static ret_t lcd_sdl2_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
lcd_sdl2_t* sdl = (lcd_sdl2_t*)lcd;
|
||||
lcd_t* mem = (lcd_t*)(sdl->lcd_mem);
|
||||
@ -139,6 +146,7 @@ lcd_t* lcd_sdl2_init(SDL_Renderer* render) {
|
||||
base->draw_image = lcd_sdl2_draw_image;
|
||||
base->draw_glyph = lcd_sdl2_draw_glyph;
|
||||
base->draw_points = lcd_sdl2_draw_points;
|
||||
base->get_point_color = lcd_sdl2_get_point_color;
|
||||
base->end_frame = lcd_sdl2_end_frame;
|
||||
base->get_vgcanvas = lcd_sdl2_get_vgcanvas;
|
||||
base->take_snapshot = lcd_sdl_take_snapshot;
|
||||
|
@ -191,7 +191,7 @@ static ret_t main_loop_sdl2_create_window(main_loop_sdl2_t* l, font_manager_t* f
|
||||
SDL_CreateWindow("LFTK Simulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, 0);
|
||||
return_value_if_fail(l->sdl_window != NULL, RET_FAIL);
|
||||
|
||||
l->sdl_render = SDL_CreateRenderer(l->sdl_window, -1, 0);
|
||||
l->sdl_render = SDL_CreateRenderer(l->sdl_window, -1, SDL_RENDERER_PRESENTVSYNC|SDL_RENDERER_ACCELERATED);
|
||||
return_value_if_fail(l->sdl_render != NULL, RET_FAIL);
|
||||
|
||||
canvas_init(&(l->canvas), lcd_sdl2_init(l->sdl_render), fm);
|
||||
|
Loading…
Reference in New Issue
Block a user