add awtk_main

This commit is contained in:
xianjimli 2020-02-24 08:21:11 +08:00
parent fcb5dd8f22
commit ac12827b0b
13 changed files with 110 additions and 60 deletions

View File

@ -9,18 +9,17 @@ env.Library(os.path.join(LIB_DIR, 'assets'), ['assets.c']);
env['LIBS'] = ['assets'] + env['LIBS']
env['LINKFLAGS'] = env['OS_SUBSYSTEM_WINDOWS'] + env['LINKFLAGS'];
env.Program(os.path.join(BIN_DIR, 'demo1'), ['demo_main.c', 'demo1_app.c']);
env.Program(os.path.join(BIN_DIR, 'demovg'), ['demo_main.c', 'demo_vg_app.c']);
env.Program(os.path.join(BIN_DIR, 'demoui'), ['demo_ui_app.c', 'demo_main.c']);
env.Program(os.path.join(BIN_DIR, 'demotr'), ['demo_tr_app.c', 'demo_main.c']);
env.Program(os.path.join(BIN_DIR, 'demo_animator'), ['demo_animator_app.c', 'demo_main.c']);
env.Program(os.path.join(BIN_DIR, 'demo_thread'), ['demo_thread_app.c', 'demo_main.c']);
env.Program(os.path.join(BIN_DIR, 'demo_basic'), ['demo_basic.c', 'demo_main.c']);
env.Program(os.path.join(BIN_DIR, 'demo1'), ['demo1_app.c']);
env.Program(os.path.join(BIN_DIR, 'demovg'), ['demo_vg_app.c']);
env.Program(os.path.join(BIN_DIR, 'demoui'), ['demo_ui_app.c']);
env.Program(os.path.join(BIN_DIR, 'demotr'), ['demo_tr_app.c']);
env.Program(os.path.join(BIN_DIR, 'demo_basic'), ['demo_basic.c']);
env.Program(os.path.join(BIN_DIR, 'demo_thread'), ['demo_thread_app.c']);
env.Program(os.path.join(BIN_DIR, 'demo_animator'), ['demo_animator_app.c']);
env.Program(os.path.join(BIN_DIR, 'preview_ui'), ['preview_ui.c']);
env.Program(os.path.join(BIN_DIR, 'demo_desktop'), ['demo_desktop.c']);
env.Program(os.path.join(BIN_DIR, 'demo_file_browser'), ['demo_file_browser.c',
'demo_main.c']);
env.Program(os.path.join(BIN_DIR, 'demo_file_browser'), ['demo_file_browser.c']);

View File

@ -177,3 +177,11 @@ ret_t application_init() {
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -152,3 +152,10 @@ ret_t application_init() {
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -81,3 +81,11 @@ ret_t application_init() {
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -30,25 +30,13 @@ ret_t application_init(void) {
return RET_OK;
}
#if defined(WIN32)
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
#else
int main(void) {
#endif
char res_root[MAX_PATH + 1];
char app_root[MAX_PATH + 1];
path_app_root(app_root);
memset(res_root, 0x00, sizeof(res_root));
path_build(res_root, MAX_PATH, app_root, "demos", NULL);
tk_init(800, 480, APP_DESKTOP, "AWTK Demo", res_root);
system_info_set_default_font(system_info(), "default_full");
assets_init();
application_init();
tk_run();
return 0;
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#define LCD_WIDTH 800
#define LCD_HEGHT 600
#define AWTK_APP_TYPE APP_DESKTOP
#include "awtk_main.inc"

View File

@ -101,3 +101,10 @@ ret_t application_init() {
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -108,3 +108,10 @@ ret_t application_init() {
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -102,3 +102,10 @@ ret_t application_init() {
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -813,3 +813,10 @@ ret_t application_init() {
return show_preload_res_window();
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -31,10 +31,15 @@ ret_t application_init() {
widget_t* canvas = canvas_widget_create(win, 0, 0, win->w, win->h);
widget_on(canvas, EVT_PAINT, on_paint_vg, NULL);
// widget_on(canvas, EVT_PAINT, on_paint_vg_simple, NULL);
// widget_on(canvas, EVT_PAINT, on_paint_global_alpha, NULL);
timer_add(on_timer, win, 500);
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"

View File

@ -12,6 +12,6 @@
},
"android" : {
"app_name":"org.zlgopen.demoui",
"sources":["assets.c", "assets.h", "demo_main.c", "demo_ui_app.c", "vg_common.inc"]
"sources":["assets.c", "assets.h", "demo_ui_app.c", "vg_common.inc"]
}
}

View File

@ -10,6 +10,7 @@
* version 版本号。
* assets 资源所在的目录(相对于配置文件所在的目录)。
* sources 源文件列表(相对于配置文件所在的目录)。文件名支持通配符如*.c。
* includes 头文件搜索路径列表(相对于配置文件所在的目录)。
> sources 虽然是通用选项,但是不同平台,包含的源文件可能并不相同,此时应该放到具体平台之下。

60
demos/demo_main.c → src/awtk_main.inc Normal file → Executable file
View File

@ -1,7 +1,7 @@
/**
* File: demo_main.c
* File: awtk_main.c
* Author: AWTK Develop Team
* Brief: demo main
* Brief: awtk main
*
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
@ -20,14 +20,22 @@
*/
#include "awtk.h"
#include "assets.h"
#include "tkc/mem.h"
#include "tkc/fs.h"
#include "tkc/path.h"
#include "base/system_info.h"
#include "base/window_manager.h"
ret_t application_init(void);
extern ret_t assets_init();
extern ret_t application_init(void);
extern ret_t application_exit(void);
#ifndef LCD_WIDTH
#define LCD_WIDTH 320
#endif/*LCD_WIDTH*/
#ifndef LCD_HEIGHT
#define LCD_HEIGHT 480
#endif/*LCD_HEIGHT*/
#ifndef AWTK_APP_TYPE
#define AWTK_APP_TYPE APP_SIMULATOR
#endif/*AWTK_APP_TYPE*/
#ifdef USE_GUI_MAIN
int gui_app_start(int lcd_w, int lcd_h) {
@ -39,23 +47,23 @@ int main(int argc, char* argv[]) {
int32_t lcd_h = 0;
tk_init(lcd_w, lcd_h, APP_MOBILE, "", "");
system_info_set_default_font(system_info(), "default_full");
#elif defined(MOBILE_APP)
#elif defined(MOBILE_APP) || defined(ANDROID)
int SDL_main(int argc, char* argv[]) {
int32_t lcd_w = 320;
int32_t lcd_h = 480;
int32_t lcd_w = LCD_WIDTH;
int32_t lcd_h = LCD_HEIGHT;
tk_init(lcd_w, lcd_h, APP_MOBILE, "", "");
system_info_set_default_font(system_info(), "default_full");
#else
#if defined(WIN32)
#elif defined(WIN32)
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
int32_t lcd_w = 320;
int32_t lcd_h = 480;
int32_t lcd_w = LCD_WIDTH;
int32_t lcd_h = LCD_HEIGHT;
TK_ENABLE_CONSOLE();
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, NULL);
#else
int main(int argc, char* argv[]) {
int32_t lcd_w = 320;
int32_t lcd_h = 480;
int32_t lcd_w = LCD_WIDTH;
int32_t lcd_h = LCD_HEIGHT;
if (argc >= 2) {
lcd_w = tk_atoi(argv[1]);
@ -63,15 +71,10 @@ int main(int argc, char* argv[]) {
if (argc >= 3) {
lcd_h = tk_atoi(argv[2]);
}
#endif
TK_ENABLE_CONSOLE();
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, NULL);
#endif
//#define WITH_LCD_PORTRAIT 1
#if defined(USE_GUI_MAIN) && defined(WITH_LCD_PORTRAIT)
#if defined(WITH_LCD_PORTRAIT)
if (lcd_w > lcd_h) {
tk_set_lcd_orientation(LCD_ORIENTATION_90);
}
@ -87,16 +90,19 @@ int main(int argc, char* argv[]) {
system_info_set_default_font(system_info(), "default_full");
#endif /*WITH_FS_RES*/
assets_init();
tk_ext_widgets_init();
log_set_log_level(LOG_LEVEL_INFO);
log_info("Build at: %s %s\n", __DATE__, __TIME__);
assets_init();
application_init();
#ifdef ENABLE_CURSOR
window_manager_set_cursor(window_manager(), "cursor");
#endif /*ENABLE_CURSOR*/
application_init();
tk_run();
application_exit();
return 0;
}