add window_close

This commit is contained in:
xianjimli 2018-04-21 07:42:22 +08:00
parent 35d4ea8f5e
commit 26c9759017
4 changed files with 36 additions and 5 deletions

View File

@ -81,3 +81,10 @@ widget_t* window_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
return widget; return widget;
} }
ret_t window_close(widget_t* widget) {
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return window_manager_remove_child(widget->parent, widget);
}

View File

@ -61,6 +61,16 @@ widget_t* window_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
* @return {widget_t*} * @return {widget_t*}
*/ */
/**
* @method window_close
* @deconstructor
*
* @param {widget_t*} parent window对象
*
* @return {ret_t} RET_OK表示成功
*/
ret_t window_close(widget_t* parent);
#define WINDOW(widget) ((window_t*)(widget)) #define WINDOW(widget) ((window_t*)(widget))
END_C_DECLS END_C_DECLS

View File

@ -52,10 +52,15 @@ typedef enum _window_animator_type_t {
*/ */
WINDOW_ANIMATOR_CENTER_SCALE, WINDOW_ANIMATOR_CENTER_SCALE,
/** /**
* @const WINDOW_ANIMATOR_BOTTOM_POPUP * @const WINDOW_ANIMATOR_TOP_TOP_BOTTOM
* *
*/ */
WINDOW_ANIMATOR_BOTTOM_POPUP, WINDOW_ANIMATOR_TOP_TOP_BOTTOM,
/**
* @const WINDOW_ANIMATOR_BOTTOM_TO_TOP
*
*/
WINDOW_ANIMATOR_BOTTOM_TO_TOP,
/** /**
* @const WINDOW_ANIMATOR_HTRANSLATE * @const WINDOW_ANIMATOR_HTRANSLATE
* *
@ -66,6 +71,7 @@ typedef enum _window_animator_type_t {
* *
*/ */
WINDOW_ANIMATOR_VTRANSLATE, WINDOW_ANIMATOR_VTRANSLATE,
WINDOW_ANIMATOR_NR WINDOW_ANIMATOR_NR
} window_animator_type_t; } window_animator_type_t;

View File

@ -44,7 +44,7 @@ static widget_t* window_manager_find_prev_window(widget_t* widget) {
return NULL; return NULL;
} }
static ret_t window_manager_check_if_need_open_animation(idle_info_t* info) { static ret_t window_manager_check_if_need_open_animation(const idle_info_t* info) {
value_t anim_hint; value_t anim_hint;
widget_t* prev_win = NULL; widget_t* prev_win = NULL;
widget_t* curr_win = WIDGETP(info->ctx); widget_t* curr_win = WIDGETP(info->ctx);
@ -140,12 +140,20 @@ ret_t window_manager_add_child(widget_t* wm, widget_t* window) {
return widget_add_child(wm, window); return widget_add_child(wm, window);
} }
static ret_t window_manager_idle_destroy_window(const idle_info_t* info) {
widget_t* win = WIDGETP(info->ctx);
widget_destroy(win);
return RET_OK;
}
ret_t window_manager_remove_child(widget_t* wm, widget_t* window) { ret_t window_manager_remove_child(widget_t* wm, widget_t* window) {
ret_t ret = RET_OK; ret_t ret = RET_OK;
return_value_if_fail(wm != NULL && window != NULL, RET_BAD_PARAMS); return_value_if_fail(wm != NULL && window != NULL, RET_BAD_PARAMS);
if (window_manager_check_if_need_close_animation(WINDOW_MANAGER(wm), window) != RET_OK) { if (window_manager_check_if_need_close_animation(WINDOW_MANAGER(wm), window) != RET_OK) {
widget_destroy(window); window_manager_remove_child_real(wm, window);
idle_add(window_manager_idle_destroy_window, window);
} }
return ret; return ret;