From 1e67642f3e5d4ea6791a157533b954c5e90ee161 Mon Sep 17 00:00:00 2001 From: xianjimli Date: Fri, 7 Aug 2020 17:46:16 +0800 Subject: [PATCH] improve candidates --- docs/changes.md | 3 +++ src/ext_widgets/keyboard/candidates.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changes.md b/docs/changes.md index 8001a75b2..734fc6123 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,8 @@ # 最新动态 +* 2020/08/07 + * 候选字控件 (candidate) 支持设置 margin style。 + * 2020/08/06 * 完善离线 lcd(感谢智明提供补丁)。 * 完善 slist (感谢智明提供补丁)。 diff --git a/src/ext_widgets/keyboard/candidates.c b/src/ext_widgets/keyboard/candidates.c index df5f2c958..8f7eb5db5 100644 --- a/src/ext_widgets/keyboard/candidates.c +++ b/src/ext_widgets/keyboard/candidates.c @@ -138,12 +138,13 @@ static ret_t candidates_relayout_children(widget_t* widget) { style_t* style = children[0]->astyle; canvas_t* c = widget_get_canvas(widget); const char* font = system_info_fix_font_name(NULL); + int32_t child_margin = style_get_int(style, STYLE_ID_MARGIN, 0); uint16_t font_size = style_get_int(style, STYLE_ID_FONT_SIZE, TK_DEFAULT_FONT_SIZE); canvas_set_font(c, font, font_size); for (i = 0; i < nr; i++) { iter = children[i]; - child_w = candidates_calc_child_width(c, iter); + child_w = candidates_calc_child_width(c, iter) + child_margin* 2; if (iter->text.size) { widget_set_visible(iter, TRUE, FALSE); } else {