popup support highlight

This commit is contained in:
lixianjing 2023-05-30 17:43:17 +08:00
parent 49f6c2334a
commit a91821aa2a
4 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2023/05/30
* popup恢复支持高亮(感谢智明提供补丁)。
2023/05/29
* main\_loop\_dispatch\_events支持分发EVT\_KEY\_LONG\_PRESS
* event\_from\_name增加窗口被切换到前台、后台事件用于给窗口绑定(感谢兆坤提供补丁)

View File

@ -4718,6 +4718,12 @@ bool_t widget_is_popup(widget_t* widget) {
return widget->vt->is_window && tk_str_eq(widget->vt->type, WIDGET_TYPE_POPUP);
}
bool_t widget_is_support_highlighter(widget_t* widget) {
return_value_if_fail(widget != NULL && widget->vt != NULL, FALSE);
return widget->vt->is_window && (tk_str_eq(widget->vt->type, WIDGET_TYPE_POPUP) || tk_str_eq(widget->vt->type, WIDGET_TYPE_DIALOG));
}
bool_t widget_is_overlay(widget_t* widget) {
return_value_if_fail(widget != NULL && widget->vt != NULL, FALSE);

View File

@ -1027,6 +1027,16 @@ ret_t widget_get_window_theme(widget_t* widget, theme_t** win_theme, theme_t** d
*/
bool_t widget_is_style_exist(widget_t* widget, const char* style_name, const char* state_name);
/**
* @method widget_is_support_highlighter
* widget是否支持高亮
* @annotation ["scriptable"]
* @param {widget_t*} widget
*
* @return {bool_t} TRUE FALSE
*/
bool_t widget_is_support_highlighter(widget_t* widget);
/**
* @method widget_use_style
* style

View File

@ -344,7 +344,7 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w
if (iter != wm->curr_win) {
rect_t iter_rect = rect_init(iter->x, iter->y, iter->w, iter->h);
/* 给前面的高亮对话框叠加黑色色块 */
if (widget_is_dialog(iter)) {
if (widget_is_support_highlighter(iter)) {
uint8_t a = 0x0;
if (window_manager_default_snap_prev_window_draw_dialog_highlighter_and_get_alpha(iter, canvas, &a) == RET_OK) {
/* 计算最终叠加后的透明度值 */
@ -432,7 +432,7 @@ static ret_t window_manager_default_create_dialog_highlighter(widget_t* widget,
wm->dialog_highlighter = dialog_highlighter = NULL;
}
if (dialog_highlighter == NULL && (widget_is_dialog(curr_win) || widget_is_popup(curr_win)) &&
if (dialog_highlighter == NULL && widget_is_support_highlighter(curr_win) &&
curr_highlight != NULL) {
dialog_highlighter_factory_t* f = dialog_highlighter_factory();
dialog_highlighter = dialog_highlighter_factory_create_highlighter(f, curr_highlight, curr_win);
@ -450,8 +450,8 @@ static ret_t window_manager_default_create_dialog_highlighter(widget_t* widget,
/* 把 dialog_highlighter 给键盘窗口使用 */
dialog_highlighter->used_by_others = TRUE;
}
/* 因为当 dialog 的窗口销毁的时候会释放 dialog_highlighter 局部, 防止非 dialog 的窗口使用 dialog_highlighter 高亮贴图。 */
else if (dialog_highlighter != NULL && !widget_is_dialog(curr_win)) {
/* 因为当支持高亮的窗口销毁的时候会释放 dialog_highlighter 局部, 防止非 dialog 的窗口使用 dialog_highlighter 高亮贴图。 */
else if (dialog_highlighter != NULL && !widget_is_support_highlighter(curr_win)) {
wm->dialog_highlighter = NULL;
}
@ -979,7 +979,7 @@ static bool_t window_manager_default_is_dialog_highlighter(widget_t* widget) {
value_t v;
return_value_if_fail(widget != NULL, FALSE);
if (widget_is_dialog(widget) && widget_get_prop(widget, WIDGET_PROP_HIGHLIGHT, &v) == RET_OK) {
if (widget_is_support_highlighter(widget) && widget_get_prop(widget, WIDGET_PROP_HIGHLIGHT, &v) == RET_OK) {
return TRUE;
}