mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 12:08:16 +08:00
refactor
This commit is contained in:
parent
af283bb539
commit
02d40de07c
@ -90,7 +90,7 @@ static ret_t main_loop_nanovg_create_window(main_loop_simple_t* l) {
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
canvas_init(&(l->canvas), lcd_nanovg_init(LOOP_SDL_WINDOW(l)), font_manager());
|
||||
canvas_init(&(l->base.canvas), lcd_nanovg_init(LOOP_SDL_WINDOW(l)), font_manager());
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ static ret_t main_loop_raw_init_canvas(main_loop_simple_t* loop) {
|
||||
lcd_t* lcd = platform_create_lcd(loop->w, loop->h);
|
||||
|
||||
return_value_if_fail(lcd != NULL, RET_OOM);
|
||||
canvas_init(&(loop->canvas), lcd, font_manager());
|
||||
canvas_init(&(loop->base.canvas), lcd, font_manager());
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ ret_t main_loop_post_key_event(main_loop_t* l, bool_t pressed, uint8_t key) {
|
||||
|
||||
static ret_t main_loop_dispatch_events(main_loop_simple_t* loop) {
|
||||
event_queue_req_t r;
|
||||
widget_t* widget = loop->wm;
|
||||
widget_t* widget = loop->base.wm;
|
||||
|
||||
while (main_loop_simple_recv_event(loop, &r) == RET_OK) {
|
||||
switch (r.event.type) {
|
||||
@ -161,7 +161,7 @@ static ret_t main_loop_simple_run(main_loop_t* l) {
|
||||
main_loop_dispatch_events(loop);
|
||||
idle_dispatch();
|
||||
|
||||
window_manager_paint(loop->wm, &(loop->canvas));
|
||||
window_manager_paint(loop->base.wm, &(loop->base.canvas));
|
||||
main_loop_sleep(l);
|
||||
}
|
||||
|
||||
@ -176,8 +176,8 @@ main_loop_simple_t* main_loop_simple_init(int w, int h) {
|
||||
|
||||
loop->w = w;
|
||||
loop->h = h;
|
||||
loop->wm = window_manager();
|
||||
return_value_if_fail(loop->wm != NULL, NULL);
|
||||
loop->base.wm = window_manager();
|
||||
return_value_if_fail(loop->base.wm != NULL, NULL);
|
||||
|
||||
loop->queue = event_queue_create(20);
|
||||
return_value_if_fail(loop->queue != NULL, NULL);
|
||||
@ -188,7 +188,7 @@ main_loop_simple_t* main_loop_simple_init(int w, int h) {
|
||||
loop->base.run = main_loop_simple_run;
|
||||
loop->base.queue_event = main_loop_simple_queue_event;
|
||||
|
||||
window_manager_resize(loop->wm, w, h);
|
||||
window_manager_resize(loop->base.wm, w, h);
|
||||
main_loop_set((main_loop_t*)loop);
|
||||
|
||||
return loop;
|
||||
|
@ -40,9 +40,7 @@ typedef ret_t (*main_loop_dispatch_input_t)(main_loop_simple_t* loop);
|
||||
|
||||
struct _main_loop_simple_t {
|
||||
main_loop_t base;
|
||||
canvas_t canvas;
|
||||
event_queue_t* queue;
|
||||
widget_t* wm;
|
||||
|
||||
wh_t w;
|
||||
wh_t h;
|
||||
|
@ -2,7 +2,7 @@
|
||||
static ret_t main_loop_sdl2_dispatch_key_event(main_loop_simple_t* loop, SDL_Event* sdl_event) {
|
||||
key_event_t event;
|
||||
int type = sdl_event->type;
|
||||
widget_t* widget = loop->wm;
|
||||
widget_t* widget = loop->base.wm;
|
||||
|
||||
event.e.time = time_now_ms();
|
||||
event.key = sdl_event->key.keysym.sym;
|
||||
@ -27,7 +27,7 @@ static ret_t main_loop_sdl2_dispatch_key_event(main_loop_simple_t* loop, SDL_Eve
|
||||
static ret_t main_loop_sdl2_dispatch_mouse_event(main_loop_simple_t* loop, SDL_Event* sdl_event) {
|
||||
pointer_event_t event;
|
||||
int type = sdl_event->type;
|
||||
widget_t* widget = loop->wm;
|
||||
widget_t* widget = loop->base.wm;
|
||||
|
||||
event.e.time = time_now_ms();
|
||||
switch (type) {
|
||||
|
Loading…
Reference in New Issue
Block a user