mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 20:18:22 +08:00
add window_close
This commit is contained in:
parent
35d4ea8f5e
commit
26c9759017
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user