mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
add awtk_main
This commit is contained in:
parent
fcb5dd8f22
commit
ac12827b0b
@ -9,18 +9,17 @@ env.Library(os.path.join(LIB_DIR, 'assets'), ['assets.c']);
|
|||||||
env['LIBS'] = ['assets'] + env['LIBS']
|
env['LIBS'] = ['assets'] + env['LIBS']
|
||||||
env['LINKFLAGS'] = env['OS_SUBSYSTEM_WINDOWS'] + env['LINKFLAGS'];
|
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, 'demo1'), ['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, 'demovg'), ['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, 'demoui'), ['demo_ui_app.c']);
|
||||||
env.Program(os.path.join(BIN_DIR, 'demotr'), ['demo_tr_app.c', 'demo_main.c']);
|
env.Program(os.path.join(BIN_DIR, 'demotr'), ['demo_tr_app.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_basic'), ['demo_basic.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_thread'), ['demo_thread_app.c']);
|
||||||
env.Program(os.path.join(BIN_DIR, 'demo_basic'), ['demo_basic.c', 'demo_main.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, '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_desktop'), ['demo_desktop.c']);
|
||||||
env.Program(os.path.join(BIN_DIR, 'demo_file_browser'), ['demo_file_browser.c',
|
env.Program(os.path.join(BIN_DIR, 'demo_file_browser'), ['demo_file_browser.c']);
|
||||||
'demo_main.c']);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,3 +177,11 @@ ret_t application_init() {
|
|||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
|
||||||
|
@ -152,3 +152,10 @@ ret_t application_init() {
|
|||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
@ -81,3 +81,11 @@ ret_t application_init() {
|
|||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
|
||||||
|
@ -30,25 +30,13 @@ ret_t application_init(void) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32)
|
ret_t application_exit() {
|
||||||
#include <windows.h>
|
log_debug("application_exit\n");
|
||||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
return RET_OK;
|
||||||
#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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LCD_WIDTH 800
|
||||||
|
#define LCD_HEGHT 600
|
||||||
|
#define AWTK_APP_TYPE APP_DESKTOP
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
@ -101,3 +101,10 @@ ret_t application_init() {
|
|||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
@ -108,3 +108,10 @@ ret_t application_init() {
|
|||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
@ -102,3 +102,10 @@ ret_t application_init() {
|
|||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
@ -813,3 +813,10 @@ ret_t application_init() {
|
|||||||
|
|
||||||
return show_preload_res_window();
|
return show_preload_res_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
@ -31,10 +31,15 @@ ret_t application_init() {
|
|||||||
widget_t* canvas = canvas_widget_create(win, 0, 0, win->w, win->h);
|
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, 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);
|
timer_add(on_timer, win, 500);
|
||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t application_exit() {
|
||||||
|
log_debug("application_exit\n");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "awtk_main.inc"
|
||||||
|
@ -12,6 +12,6 @@
|
|||||||
},
|
},
|
||||||
"android" : {
|
"android" : {
|
||||||
"app_name":"org.zlgopen.demoui",
|
"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"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
* version 版本号。
|
* version 版本号。
|
||||||
* assets 资源所在的目录(相对于配置文件所在的目录)。
|
* assets 资源所在的目录(相对于配置文件所在的目录)。
|
||||||
* sources 源文件列表(相对于配置文件所在的目录)。文件名支持通配符如*.c。
|
* sources 源文件列表(相对于配置文件所在的目录)。文件名支持通配符如*.c。
|
||||||
|
* includes 头文件搜索路径列表(相对于配置文件所在的目录)。
|
||||||
|
|
||||||
> sources 虽然是通用选项,但是不同平台,包含的源文件可能并不相同,此时应该放到具体平台之下。
|
> sources 虽然是通用选项,但是不同平台,包含的源文件可能并不相同,此时应该放到具体平台之下。
|
||||||
|
|
||||||
|
60
demos/demo_main.c → src/awtk_main.inc
Normal file → Executable file
60
demos/demo_main.c → src/awtk_main.inc
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* File: demo_main.c
|
* File: awtk_main.c
|
||||||
* Author: AWTK Develop Team
|
* Author: AWTK Develop Team
|
||||||
* Brief: demo main
|
* Brief: awtk main
|
||||||
*
|
*
|
||||||
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||||
*
|
*
|
||||||
@ -20,14 +20,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "awtk.h"
|
#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
|
#ifdef USE_GUI_MAIN
|
||||||
int gui_app_start(int lcd_w, int lcd_h) {
|
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;
|
int32_t lcd_h = 0;
|
||||||
tk_init(lcd_w, lcd_h, APP_MOBILE, "", "");
|
tk_init(lcd_w, lcd_h, APP_MOBILE, "", "");
|
||||||
system_info_set_default_font(system_info(), "default_full");
|
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[]) {
|
int SDL_main(int argc, char* argv[]) {
|
||||||
int32_t lcd_w = 320;
|
int32_t lcd_w = LCD_WIDTH;
|
||||||
int32_t lcd_h = 480;
|
int32_t lcd_h = LCD_HEIGHT;
|
||||||
tk_init(lcd_w, lcd_h, APP_MOBILE, "", "");
|
tk_init(lcd_w, lcd_h, APP_MOBILE, "", "");
|
||||||
system_info_set_default_font(system_info(), "default_full");
|
system_info_set_default_font(system_info(), "default_full");
|
||||||
#else
|
#elif defined(WIN32)
|
||||||
|
|
||||||
#if defined(WIN32)
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
||||||
int32_t lcd_w = 320;
|
int32_t lcd_w = LCD_WIDTH;
|
||||||
int32_t lcd_h = 480;
|
int32_t lcd_h = LCD_HEIGHT;
|
||||||
|
TK_ENABLE_CONSOLE();
|
||||||
|
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, NULL);
|
||||||
#else
|
#else
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
int32_t lcd_w = 320;
|
int32_t lcd_w = LCD_WIDTH;
|
||||||
int32_t lcd_h = 480;
|
int32_t lcd_h = LCD_HEIGHT;
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
lcd_w = tk_atoi(argv[1]);
|
lcd_w = tk_atoi(argv[1]);
|
||||||
@ -63,15 +71,10 @@ int main(int argc, char* argv[]) {
|
|||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
lcd_h = tk_atoi(argv[2]);
|
lcd_h = tk_atoi(argv[2]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
TK_ENABLE_CONSOLE();
|
|
||||||
|
|
||||||
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, NULL);
|
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define WITH_LCD_PORTRAIT 1
|
#if defined(WITH_LCD_PORTRAIT)
|
||||||
#if defined(USE_GUI_MAIN) && defined(WITH_LCD_PORTRAIT)
|
|
||||||
if (lcd_w > lcd_h) {
|
if (lcd_w > lcd_h) {
|
||||||
tk_set_lcd_orientation(LCD_ORIENTATION_90);
|
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");
|
system_info_set_default_font(system_info(), "default_full");
|
||||||
#endif /*WITH_FS_RES*/
|
#endif /*WITH_FS_RES*/
|
||||||
|
|
||||||
|
assets_init();
|
||||||
|
tk_ext_widgets_init();
|
||||||
log_set_log_level(LOG_LEVEL_INFO);
|
log_set_log_level(LOG_LEVEL_INFO);
|
||||||
log_info("Build at: %s %s\n", __DATE__, __TIME__);
|
log_info("Build at: %s %s\n", __DATE__, __TIME__);
|
||||||
assets_init();
|
|
||||||
application_init();
|
|
||||||
|
|
||||||
#ifdef ENABLE_CURSOR
|
#ifdef ENABLE_CURSOR
|
||||||
window_manager_set_cursor(window_manager(), "cursor");
|
window_manager_set_cursor(window_manager(), "cursor");
|
||||||
#endif /*ENABLE_CURSOR*/
|
#endif /*ENABLE_CURSOR*/
|
||||||
|
|
||||||
|
application_init();
|
||||||
tk_run();
|
tk_run();
|
||||||
|
application_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user