mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-03 04:27:44 +08:00
format code
This commit is contained in:
parent
6685f42933
commit
f695719134
@ -87,7 +87,7 @@ ret_t dialog_highlighter_set_system_bar_alpha(dialog_highlighter_t* h, uint8_t a
|
||||
return h->vt->set_system_bar_alpha(h, alpha);
|
||||
}
|
||||
|
||||
return RET_NOT_IMPL;
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
uint8_t dialog_highlighter_get_alpha(dialog_highlighter_t* h, float_t percent) {
|
||||
@ -97,7 +97,7 @@ uint8_t dialog_highlighter_get_alpha(dialog_highlighter_t* h, float_t percent) {
|
||||
return h->vt->get_alpha(h, percent);
|
||||
}
|
||||
|
||||
return 0x0;
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
ret_t dialog_highlighter_draw(dialog_highlighter_t* h, float_t percent) {
|
||||
|
@ -31,7 +31,8 @@ typedef struct _dialog_highlighter_t dialog_highlighter_t;
|
||||
|
||||
typedef ret_t (*dialog_highlighter_set_system_bar_alpha_t)(dialog_highlighter_t* h, uint8_t alpha);
|
||||
typedef uint8_t (*dialog_highlighter_get_alpha_t)(dialog_highlighter_t* h, float_t percent);
|
||||
typedef ret_t (*dialog_highlighter_draw_mask_t)(dialog_highlighter_t* h, canvas_t* c, float_t percent);
|
||||
typedef ret_t (*dialog_highlighter_draw_mask_t)(dialog_highlighter_t* h, canvas_t* c,
|
||||
float_t percent);
|
||||
typedef ret_t (*dialog_highlighter_prepare_t)(dialog_highlighter_t* h, canvas_t* c);
|
||||
typedef ret_t (*dialog_highlighter_draw_t)(dialog_highlighter_t* h, float_t percent);
|
||||
typedef bool_t (*dialog_highlighter_is_dynamic_t)(dialog_highlighter_t* h);
|
||||
|
@ -1675,9 +1675,9 @@ ret_t widget_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
||||
if (value_bool(v)) {
|
||||
widget_on(widget, EVT_DESTROY, widget_on_ungrab_keys, widget);
|
||||
emitter_on_with_tag(wm->global_emitter, EVT_KEY_DOWN, widget_on_grabbed_keys, widget,
|
||||
tk_pointer_to_int(widget));
|
||||
tk_pointer_to_int(widget));
|
||||
emitter_on_with_tag(wm->global_emitter, EVT_KEY_UP, widget_on_grabbed_keys, widget,
|
||||
tk_pointer_to_int(widget));
|
||||
tk_pointer_to_int(widget));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ widget_t* window_manager_init(window_manager_t* wm, const widget_vtable_t* wvt,
|
||||
wm->vt = vt;
|
||||
wm->global_emitter = emitter_create();
|
||||
widget_on(widget, EVT_DESTROY, window_manager_on_destroy, widget);
|
||||
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
5
src/dialog_highlighters/dialog_highlighter_default.c
Executable file → Normal file
5
src/dialog_highlighters/dialog_highlighter_default.c
Executable file → Normal file
@ -52,11 +52,12 @@ static ret_t dialog_highlighter_default_draw_mask_system_bar(canvas_t* c, uint8_
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t dialog_highlighter_default_draw_mask_from_percent(dialog_highlighter_t* h, canvas_t* c, float_t percent) {
|
||||
static ret_t dialog_highlighter_default_draw_mask_from_percent(dialog_highlighter_t* h, canvas_t* c,
|
||||
float_t percent) {
|
||||
dialog_highlighter_default_t* dh = (dialog_highlighter_default_t*)h;
|
||||
|
||||
return_value_if_fail(dh != NULL && c != NULL, RET_BAD_PARAMS);
|
||||
|
||||
|
||||
if (dh->start_alpha != dh->end_alpha) {
|
||||
uint8_t a = ((dh->end_alpha - dh->start_alpha) * percent) + dh->start_alpha;
|
||||
return dialog_highlighter_default_draw_mask(c, a);
|
||||
|
@ -149,8 +149,9 @@ static ret_t rich_text_on_paint_text(widget_t* widget, canvas_t* c) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static bool_t rich_text_is_need_reset_from_style(rich_text_t* rich_text, char* font_name, uint16_t font_size, color_t color, align_v_t align_v) {
|
||||
|
||||
static bool_t rich_text_is_need_reset_from_style(rich_text_t* rich_text, char* font_name,
|
||||
uint16_t font_size, color_t color,
|
||||
align_v_t align_v) {
|
||||
if (tk_str_cmp(rich_text->default_font_name, font_name) != 0) {
|
||||
return TRUE;
|
||||
}
|
||||
@ -176,17 +177,20 @@ static ret_t rich_text_ensure_render_node(widget_t* widget, canvas_t* c) {
|
||||
const char* default_font_name = style_get_str(style, STYLE_ID_FONT_NAME, NULL);
|
||||
uint16_t default_font_size = style_get_int(style, STYLE_ID_FONT_SIZE, TK_DEFAULT_FONT_SIZE);
|
||||
color_t default_color = style_get_color(style, STYLE_ID_TEXT_COLOR, color_init(0, 0, 0, 0xff));
|
||||
align_v_t default_align_v = (align_v_t)style_get_int(style, STYLE_ID_TEXT_ALIGN_V, ALIGN_V_BOTTOM);
|
||||
align_v_t default_align_v =
|
||||
(align_v_t)style_get_int(style, STYLE_ID_TEXT_ALIGN_V, ALIGN_V_BOTTOM);
|
||||
return_value_if_fail(widget != NULL && rich_text != NULL && style != NULL, RET_BAD_PARAMS);
|
||||
|
||||
rich_text->need_reset = rich_text_is_need_reset_from_style(rich_text, default_font_name, default_font_size, default_color, default_align_v);
|
||||
rich_text->need_reset = rich_text_is_need_reset_from_style(
|
||||
rich_text, default_font_name, default_font_size, default_color, default_align_v);
|
||||
|
||||
if (rich_text->need_reset) {
|
||||
str_t str;
|
||||
str_init(&str, widget->text.size * 4 + 1);
|
||||
str_from_wstr(&str, widget->text.str);
|
||||
rich_text_reset(widget);
|
||||
rich_text->node = rich_text_parse(str.str, str.size, default_font_name, default_font_size, default_color, default_align_v);
|
||||
rich_text->node = rich_text_parse(str.str, str.size, default_font_name, default_font_size,
|
||||
default_color, default_align_v);
|
||||
str_reset(&str);
|
||||
rich_text->need_reset = FALSE;
|
||||
|
||||
|
8
src/ext_widgets/rich_text/rich_text_parser.c
Executable file → Normal file
8
src/ext_widgets/rich_text/rich_text_parser.c
Executable file → Normal file
@ -160,7 +160,8 @@ static void xml_rich_text_destroy(XmlBuilder* thiz) {
|
||||
return;
|
||||
}
|
||||
|
||||
static XmlBuilder* builder_init(xml_builder_t* b, char* font_name, uint16_t font_size, color_t color, align_v_t align_v) {
|
||||
static XmlBuilder* builder_init(xml_builder_t* b, char* font_name, uint16_t font_size,
|
||||
color_t color, align_v_t align_v) {
|
||||
int32_t i = 0;
|
||||
memset(b, 0x00, sizeof(xml_builder_t));
|
||||
|
||||
@ -175,7 +176,7 @@ static XmlBuilder* builder_init(xml_builder_t* b, char* font_name, uint16_t font
|
||||
rich_text_font_t* iter = b->fonts + i;
|
||||
iter->name = font_name;
|
||||
iter->size = font_size;
|
||||
iter->color =color;
|
||||
iter->color = color;
|
||||
iter->align_v = align_v;
|
||||
}
|
||||
str_init(&(b->temp), 100);
|
||||
@ -183,7 +184,8 @@ static XmlBuilder* builder_init(xml_builder_t* b, char* font_name, uint16_t font
|
||||
return &(b->builder);
|
||||
}
|
||||
|
||||
rich_text_node_t* rich_text_parse(const char* str, uint32_t size, char* font_name, uint16_t font_size, color_t color, align_v_t align_v) {
|
||||
rich_text_node_t* rich_text_parse(const char* str, uint32_t size, char* font_name,
|
||||
uint16_t font_size, color_t color, align_v_t align_v) {
|
||||
xml_builder_t b;
|
||||
XmlParser* parser = NULL;
|
||||
rich_text_node_t* node = NULL;
|
||||
|
@ -26,7 +26,8 @@
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
rich_text_node_t* rich_text_parse(const char* str, uint32_t size, char* font_name, uint16_t font_size, color_t color, align_v_t align_v);
|
||||
rich_text_node_t* rich_text_parse(const char* str, uint32_t size, char* font_name,
|
||||
uint16_t font_size, color_t color, align_v_t align_v);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
@ -47,7 +47,7 @@ static ret_t object_destroy(object_t* obj) {
|
||||
|
||||
emitter_deinit((emitter_t*)obj);
|
||||
TKMEM_FREE(obj->name);
|
||||
|
||||
|
||||
memset(obj, 0x00, obj->vt->size);
|
||||
TKMEM_FREE(obj);
|
||||
|
||||
|
@ -367,9 +367,10 @@ static ret_t label_auto_adjust_size(widget_t* widget) {
|
||||
w = label_get_text_line_max_w(widget, c);
|
||||
}
|
||||
|
||||
return_value_if_fail(label_line_parser_init(&p, c, widget->text.str, widget->text.size,
|
||||
c->font_size, w - 2 * margin, label->line_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(
|
||||
label_line_parser_init(&p, c, widget->text.str, widget->text.size, c->font_size,
|
||||
w - 2 * margin, label->line_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
|
||||
widget->w = w;
|
||||
widget->h = line_height * p.total_lines;
|
||||
|
@ -143,18 +143,21 @@ ret_t window_manager_default_snap_curr_window(widget_t* widget, widget_t* curr_w
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t window_manager_default_snap_prev_window_draw_dialog_highlighter_and_get_alpha(widget_t* widget, canvas_t* c, uint8_t* alpha){
|
||||
static ret_t window_manager_default_snap_prev_window_draw_dialog_highlighter_and_get_alpha(
|
||||
widget_t* widget, canvas_t* c, uint8_t* alpha) {
|
||||
value_t v;
|
||||
return_value_if_fail(widget != NULL && c != NULL, FALSE);
|
||||
if (widget_get_prop(widget, WIDGET_PROP_HIGHLIGHT, &v) == RET_OK) {
|
||||
const char* args = value_str(&v);
|
||||
dialog_highlighter_factory_t* f = dialog_highlighter_factory();
|
||||
dialog_highlighter_t* dialog_highlighter = dialog_highlighter_factory_create_highlighter(f, args, widget);
|
||||
dialog_highlighter_t* dialog_highlighter =
|
||||
dialog_highlighter_factory_create_highlighter(f, args, widget);
|
||||
|
||||
if (dialog_highlighter != NULL) {
|
||||
dialog_highlighter_draw_mask(dialog_highlighter, c, 1.0f);
|
||||
*alpha = dialog_highlighter_get_alpha(dialog_highlighter, 1.0f);
|
||||
widget_off_by_func(widget, EVT_DESTROY, dialog_highlighter_on_dialog_destroy, dialog_highlighter);
|
||||
widget_off_by_func(widget, EVT_DESTROY, dialog_highlighter_on_dialog_destroy,
|
||||
dialog_highlighter);
|
||||
dialog_highlighter_destroy(dialog_highlighter);
|
||||
return RET_OK;
|
||||
}
|
||||
@ -173,7 +176,9 @@ static bool_t window_manager_default_is_dialog_highlighter(widget_t* widget) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static widget_t* window_manager_default_find_top_dialog_highlighter(widget_t* widget, widget_t* prev_win, widget_t* curr_win) {
|
||||
static widget_t* window_manager_default_find_top_dialog_highlighter(widget_t* widget,
|
||||
widget_t* prev_win,
|
||||
widget_t* curr_win) {
|
||||
int32_t i = 0;
|
||||
widget_t* dialog = NULL;
|
||||
widget_t** children = (widget_t**)(widget->children->elms);
|
||||
@ -237,7 +242,8 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w
|
||||
/* 给前面的高亮对话框叠加黑色色块 */
|
||||
if (widget_is_dialog(iter)) {
|
||||
uint8_t a = 0x0;
|
||||
window_manager_default_snap_prev_window_draw_dialog_highlighter_and_get_alpha(iter, canvas, &a);
|
||||
window_manager_default_snap_prev_window_draw_dialog_highlighter_and_get_alpha(iter,
|
||||
canvas, &a);
|
||||
if (dialog_highlighter != NULL) {
|
||||
dialog_highlighter_set_system_bar_alpha(dialog_highlighter, a);
|
||||
}
|
||||
@ -730,7 +736,8 @@ static ret_t window_manager_animate_done(widget_t* widget) {
|
||||
window_manager_dispatch_window_event(prev_win, EVT_WINDOW_TO_BACKGROUND);
|
||||
}
|
||||
if (!curr_win_is_normal_window) {
|
||||
top_dialog_highligth = window_manager_default_find_top_dialog_highlighter(widget, prev_win, curr_win_is_keyboard ? curr_win : NULL);
|
||||
top_dialog_highligth = window_manager_default_find_top_dialog_highlighter(
|
||||
widget, prev_win, curr_win_is_keyboard ? curr_win : NULL);
|
||||
}
|
||||
window_manager_dispatch_window_event(curr_win, EVT_WINDOW_OPEN);
|
||||
} else {
|
||||
@ -738,15 +745,15 @@ static ret_t window_manager_animate_done(widget_t* widget) {
|
||||
if (!curr_win_is_keyboard) {
|
||||
window_manager_animate_done_set_window_foreground(widget, prev_win, curr_win);
|
||||
}
|
||||
top_dialog_highligth = window_manager_default_find_top_dialog_highlighter(widget, prev_win, curr_win);
|
||||
|
||||
}
|
||||
top_dialog_highligth =
|
||||
window_manager_default_find_top_dialog_highlighter(widget, prev_win, curr_win);
|
||||
}
|
||||
/* 制作一张没有最后一个对话框的高亮背景贴图 */
|
||||
if (top_dialog_highligth != NULL) {
|
||||
widget_t* tmp_curr_win = wm->curr_win;
|
||||
wm->curr_win = top_dialog_highligth;
|
||||
window_manager_create_highlighter(widget, top_dialog_highligth);
|
||||
wm->curr_win = tmp_curr_win;
|
||||
widget_t* tmp_curr_win = wm->curr_win;
|
||||
wm->curr_win = top_dialog_highligth;
|
||||
window_manager_create_highlighter(widget, top_dialog_highligth);
|
||||
wm->curr_win = tmp_curr_win;
|
||||
}
|
||||
|
||||
if (wm->pending_close_window != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user