From 62fb41733628bed2feee7c827b25c6f7fd85a18a Mon Sep 17 00:00:00 2001 From: xianjimli Date: Mon, 19 Aug 2019 18:10:46 +0800 Subject: [PATCH] add some cumstom macros --- src/awtk_global.c | 47 ++++++++++++++++++++++++-------- src/base/types_def.h | 9 +++++++ src/base/widget.c | 28 ++++++++++++++++++++ src/base/widget_factory.c | 56 ++++++++++++++++++++++----------------- 4 files changed, 104 insertions(+), 36 deletions(-) diff --git a/src/awtk_global.c b/src/awtk_global.c index ece26d611..ee21f30b5 100644 --- a/src/awtk_global.c +++ b/src/awtk_global.c @@ -134,7 +134,9 @@ ret_t tk_init_internal(void) { return_value_if_fail(timer_init(time_now_ms) == RET_OK, RET_FAIL); return_value_if_fail(idle_manager_set(idle_manager_create()) == RET_OK, RET_FAIL); +#ifndef WITHOUT_INPUT_METHOD return_value_if_fail(input_method_set(input_method_create()) == RET_OK, RET_FAIL); +#endif/*WITHOUT_INPUT_METHOD*/ return_value_if_fail(widget_factory_set(widget_factory_create()) == RET_OK, RET_FAIL); return_value_if_fail(theme_set(theme_create(NULL)) == RET_OK, RET_FAIL); @@ -142,26 +144,38 @@ ret_t tk_init_internal(void) { return_value_if_fail(locale_info_set(locale_info_create(NULL, NULL)) == RET_OK, RET_FAIL); return_value_if_fail(font_manager_set(font_manager_create(font_loader)) == RET_OK, RET_FAIL); return_value_if_fail(image_manager_set(image_manager_create()) == RET_OK, RET_FAIL); +#ifndef WITHOUT_WINDOW_ANIMATORS return_value_if_fail(window_animator_factory_set(window_animator_factory_create()) == RET_OK, RET_FAIL); + window_animator_register_builtins(); +#endif/*WITHOUT_WIDGET_ANIMATORS*/ + +#ifndef WITHOUT_DIALOG_HIGHLIGHTER return_value_if_fail( dialog_highlighter_factory_set(dialog_highlighter_factory_create()) == RET_OK, RET_FAIL); +#endif/*WITHOUT_DIALOG_HIGHLIGHTER*/ + +#ifndef WITHOUT_LAYOUT return_value_if_fail(children_layouter_factory_set(children_layouter_factory_create()) == RET_OK, RET_FAIL); return_value_if_fail(self_layouter_factory_set(self_layouter_factory_create()) == RET_OK, RET_FAIL); - return_value_if_fail(widget_animator_manager_set(widget_animator_manager_create()) == RET_OK, - RET_FAIL); + + self_layouter_register_builtins(); + children_layouter_register_builtins(); +#endif/*WITHOUT_LAYOUT*/ + return_value_if_fail(window_manager_set(window_manager_create()) == RET_OK, RET_FAIL); return_value_if_fail(clip_board_set(clip_board_create()) == RET_OK, RET_FAIL); -#ifdef WITH_WINDOW_ANIMATORS - window_animator_register_builtins(); - dialog_highlighter_register_builtins(); -#endif /*WITH_WINDOW_ANIMATORS*/ +#ifndef WITHOUT_WIDGET_ANIMATORS + return_value_if_fail(widget_animator_manager_set(widget_animator_manager_create()) == RET_OK, + RET_FAIL); +#endif/*WITHOUT_WIDGET_ANIMATORS*/ - self_layouter_register_builtins(); - children_layouter_register_builtins(); +#ifndef WITHOUT_DIALOG_HIGHLIGHTER + dialog_highlighter_register_builtins(); +#endif/*WITHOUT_DIALOG_HIGHLIGHTER*/ tk_mem_set_on_out_of_memory(awtk_mem_on_out_of_memory, NULL); @@ -184,17 +198,28 @@ ret_t tk_deinit_internal(void) { clip_board_destroy(clip_board()); clip_board_set(NULL); +#ifndef WITHOUT_WINDOW_ANIMATORS window_animator_factory_destroy(window_animator_factory()); window_animator_factory_set(NULL); +#endif/*WITHOUT_WINDOW_ANIMATORS*/ + +#ifndef WITHOUT_WIDGET_ANIMATORS + widget_animator_manager_destroy(widget_animator_manager()); + widget_animator_manager_set(NULL); +#endif/*WITHOUT_WIDGET_ANIMATORS*/ +#ifndef WITHOUT_DIALOG_HIGHLIGHTER dialog_highlighter_factory_destroy(dialog_highlighter_factory()); dialog_highlighter_factory_set(NULL); +#endif/*WITHOUT_DIALOG_HIGHLIGHTER*/ +#ifndef WITHOUT_LAYOUT children_layouter_factory_destroy(children_layouter_factory()); children_layouter_factory_set(NULL); children_layouter_factory_destroy(children_layouter_factory()); children_layouter_factory_set(NULL); +#endif/*WITHOUT_LAYOUT*/ image_manager_destroy(image_manager()); image_manager_set(NULL); @@ -202,9 +227,6 @@ ret_t tk_deinit_internal(void) { widget_destroy(window_manager()); window_manager_set(NULL); - widget_animator_manager_destroy(widget_animator_manager()); - widget_animator_manager_set(NULL); - idle_manager_destroy(idle_manager()); idle_manager_set(NULL); @@ -214,8 +236,10 @@ ret_t tk_deinit_internal(void) { widget_factory_destroy(widget_factory()); widget_factory_set(NULL); +#ifndef WITHOUT_INPUT_METHOD input_method_destroy(input_method()); input_method_set(NULL); +#endif/*WITHOUT_INPUT_METHOD*/ theme_destroy(theme()); theme_set(NULL); @@ -286,3 +310,4 @@ int32_t tk_get_pointer_y(void) { bool_t tk_is_pointer_pressed(void) { return window_manager_get_pointer_pressed(window_manager()); } + diff --git a/src/base/types_def.h b/src/base/types_def.h index 5ecb54437..04d22b920 100644 --- a/src/base/types_def.h +++ b/src/base/types_def.h @@ -324,4 +324,13 @@ typedef struct _system_info_t system_info_t; #define WITH_BITMAP_FONT 1 #endif /*WITH_LCD_MONO*/ +#ifdef AWTK_LITE +#define WITHOUT_LAYOUT 1 +#define WITHOUT_EXT_WIDGETS 1 +#define WITHOUT_INPUT_METHOD 1 +#define WITHOUT_WINDOW_ANIMATORS +#define WITHOUT_WIDGET_ANIMATORS 1 +#define WITHOUT_DIALOG_HIGHLIGHTER 1 +#endif/*AWTK_LITE*/ + #endif /*TK_TYPES_DEF_H*/ diff --git a/src/base/widget.c b/src/base/widget.c index faee094de..c54ff003a 100644 --- a/src/base/widget.c +++ b/src/base/widget.c @@ -358,6 +358,7 @@ ret_t widget_set_cursor(widget_t* widget, const char* cursor) { return widget_set_prop_str(wm, WIDGET_PROP_CURSOR, cursor); } +#ifndef WITHOUT_WINDOW_ANIMATORS ret_t widget_set_animation(widget_t* widget, const char* animation) { return_value_if_fail(widget != NULL && animation != NULL, RET_BAD_PARAMS); @@ -418,6 +419,32 @@ ret_t widget_stop_animator(widget_t* widget, const char* name) { ret_t widget_destroy_animator(widget_t* widget, const char* name) { return widget_animator_manager_remove_all(widget_animator_manager(), widget, name); } +#else +ret_t widget_start_animator(widget_t* widget, const char* name) { + return RET_OK; +} +ret_t widget_create_animator(widget_t* widget, const char* animation) { + return RET_OK; +} +ret_t widget_set_animation(widget_t* widget, const char* animation) { + return RET_OK; +} +ret_t widget_set_animator_time_scale(widget_t* widget, const char* name, float_t time_scale) { + return RET_OK; +} +ret_t widget_pause_animator(widget_t* widget, const char* name) { + return RET_OK; +} +widget_animator_t* widget_find_animator(widget_t* widget, const char* name) { + return NULL; +} +ret_t widget_stop_animator(widget_t* widget, const char* name) { + return RET_OK; +} +ret_t widget_destroy_animator(widget_t* widget, const char* name) { + return RET_OK; +} +#endif/*WITHOUT_WIDGET_ANIMATORS*/ ret_t widget_set_enable(widget_t* widget, bool_t enable) { return_value_if_fail(widget != NULL, RET_BAD_PARAMS); @@ -3001,3 +3028,4 @@ bool_t widget_is_dialog(widget_t* widget) { bool_t widget_is_popup(widget_t* widget) { return tk_str_eq(widget->vt->type, WIDGET_TYPE_POPUP); } + diff --git a/src/base/widget_factory.c b/src/base/widget_factory.c index 697f5c57c..8a440743b 100644 --- a/src/base/widget_factory.c +++ b/src/base/widget_factory.c @@ -28,36 +28,39 @@ #include "base/widget_factory.h" #ifndef AWTK_NOGUI -#include "widgets/row.h" -#include "widgets/grid.h" -#include "widgets/view.h" #include "widgets/image.h" #include "widgets/label.h" -#include "widgets/overlay.h" #include "widgets/button.h" #include "widgets/slider.h" -#include "widgets/edit.h" #include "widgets/pages.h" #include "widgets/popup.h" -#include "widgets/column.h" -#include "widgets/app_bar.h" -#include "widgets/dragger.h" -#include "widgets/grid_item.h" -#include "widgets/system_bar.h" -#include "widgets/tab_button.h" -#include "widgets/tab_control.h" #include "widgets/button_group.h" -#include "widgets/tab_button_group.h" -#include "widgets/spin_box.h" #include "widgets/group_box.h" #include "widgets/dialog_title.h" #include "widgets/dialog_client.h" #include "widgets/check_button.h" #include "widgets/progress_bar.h" -#include "widgets/combo_box.h" #include "widgets/color_tile.h" -#include "widgets/combo_box_item.h" + +#ifndef AWTK_LITE +#include "widgets/system_bar.h" #include "widgets/calibration_win.h" +#include "widgets/dragger.h" +#include "widgets/tab_button.h" +#include "widgets/tab_control.h" +#include "widgets/row.h" +#include "widgets/grid.h" +#include "widgets/view.h" +#include "widgets/overlay.h" +#include "widgets/edit.h" +#include "widgets/column.h" +#include "widgets/app_bar.h" +#include "widgets/grid_item.h" +#include "widgets/combo_box.h" +#include "widgets/combo_box_item.h" +#include "widgets/tab_button_group.h" +#include "widgets/spin_box.h" +#endif/*AWTK_LITE*/ #endif /*AWTK_NOGUI*/ static widget_factory_t* widget_factory_init(widget_factory_t* factory); @@ -79,35 +82,37 @@ static const creator_item_t s_builtin_creators[] = { #ifndef AWTK_NOGUI {WIDGET_TYPE_DIALOG_TITLE, dialog_title_create}, {WIDGET_TYPE_DIALOG_CLIENT, dialog_client_create}, - {WIDGET_TYPE_OVERLAY, overlay_create}, {WIDGET_TYPE_IMAGE, image_create}, {WIDGET_TYPE_BUTTON, button_create}, {WIDGET_TYPE_LABEL, label_create}, - {WIDGET_TYPE_EDIT, edit_create}, {WIDGET_TYPE_PROGRESS_BAR, progress_bar_create}, {WIDGET_TYPE_SLIDER, slider_create}, - {WIDGET_TYPE_GROUP_BOX, group_box_create}, - {WIDGET_TYPE_VIEW, view_create}, {WIDGET_TYPE_CHECK_BUTTON, check_button_create}, {WIDGET_TYPE_RADIO_BUTTON, check_button_create_radio}, {WIDGET_TYPE_PAGES, pages_create}, + {WIDGET_TYPE_BUTTON_GROUP, button_group_create}, + {WIDGET_TYPE_POPUP, popup_create}, + {WIDGET_TYPE_COLOR_TILE, color_tile_create}, + {WIDGET_TYPE_GROUP_BOX, group_box_create}, +#ifndef AWTK_LITE + {WIDGET_TYPE_SYSTEM_BAR, system_bar_create}, + {WIDGET_TYPE_CALIBRATION_WIN, calibration_win_create}, + {WIDGET_TYPE_VIEW, view_create}, + {WIDGET_TYPE_OVERLAY, overlay_create}, + {WIDGET_TYPE_EDIT, edit_create}, {WIDGET_TYPE_TAB_CONTROL, tab_control_create}, {WIDGET_TYPE_TAB_BUTTON, tab_button_create}, {WIDGET_TYPE_TAB_BUTTON_GROUP, tab_button_group_create}, - {WIDGET_TYPE_BUTTON_GROUP, button_group_create}, {WIDGET_TYPE_SPIN_BOX, spin_box_create}, {WIDGET_TYPE_DRAGGER, dragger_create}, {WIDGET_TYPE_COMBO_BOX, combo_box_create}, {WIDGET_TYPE_COMBO_BOX_ITEM, combo_box_item_create}, - {WIDGET_TYPE_POPUP, popup_create}, {WIDGET_TYPE_GRID, grid_create}, {WIDGET_TYPE_GRID_ITEM, grid_item_create}, {WIDGET_TYPE_ROW, row_create}, {WIDGET_TYPE_COLUMN, column_create}, {WIDGET_TYPE_APP_BAR, app_bar_create}, - {WIDGET_TYPE_SYSTEM_BAR, system_bar_create}, - {WIDGET_TYPE_CALIBRATION_WIN, calibration_win_create}, - {WIDGET_TYPE_COLOR_TILE, color_tile_create} +#endif/*AWTK_LITE*/ #endif /**AWTK_NOGUI*/ }; @@ -200,3 +205,4 @@ ret_t widget_factory_destroy(widget_factory_t* factory) { return RET_OK; } +