From a24660404199592687ed2e18c60d2f0930f14a5d Mon Sep 17 00:00:00 2001 From: anheiqq Date: Tue, 24 Sep 2024 04:07:12 +0800 Subject: [PATCH] fix(textarea): fix placeholder text cannot be centered (#6879) --- src/widgets/textarea/lv_textarea.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/widgets/textarea/lv_textarea.c b/src/widgets/textarea/lv_textarea.c index 02f1b1614..1958371b3 100644 --- a/src/widgets/textarea/lv_textarea.c +++ b/src/widgets/textarea/lv_textarea.c @@ -1403,11 +1403,16 @@ static void draw_placeholder(lv_event_t * e) if(ta->one_line) ph_dsc.flag |= LV_TEXT_FLAG_EXPAND; int32_t left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); + int32_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); int32_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); + int32_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); int32_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN); lv_area_t ph_coords; lv_area_copy(&ph_coords, &obj->coords); - lv_area_move(&ph_coords, left + border_width, top + border_width); + ph_coords.x1 += left + border_width; + ph_coords.x2 -= right + border_width; + ph_coords.y1 += top + border_width; + ph_coords.y2 -= bottom + border_width; ph_dsc.text = ta->placeholder_txt; lv_draw_label(layer, &ph_dsc, &ph_coords); }