From cb593b35ead6b95b311ebfbc6ac76d0a575355c8 Mon Sep 17 00:00:00 2001 From: Benign X <1341398182@qq.com> Date: Wed, 28 May 2025 16:42:14 +0800 Subject: [PATCH] chore(arc_label): documentation, formatting, redundant code fixes --- examples/widgets/arc_label/index.rst | 2 +- .../arc_label/lv_example_arc_label_1.c | 2 +- lv_conf_template.h | 1 + src/lv_conf_internal.h | 1 + src/widgets/arc_label/lv_arc_label.c | 7 ++--- src/widgets/arc_label/lv_arc_label.h | 26 +++++++++---------- tests/src/test_cases/widgets/test_arc_label.c | 2 +- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/examples/widgets/arc_label/index.rst b/examples/widgets/arc_label/index.rst index 250988e361..5cdc217bf2 100644 --- a/examples/widgets/arc_label/index.rst +++ b/examples/widgets/arc_label/index.rst @@ -1,5 +1,5 @@ Simple Arc Label ----------- +---------------- .. lv_example:: widgets/arc_label/lv_example_arc_label_1 :language: c diff --git a/examples/widgets/arc_label/lv_example_arc_label_1.c b/examples/widgets/arc_label/lv_example_arc_label_1.c index 0585ca60ea..13c30c48d5 100644 --- a/examples/widgets/arc_label/lv_example_arc_label_1.c +++ b/examples/widgets/arc_label/lv_example_arc_label_1.c @@ -2,7 +2,7 @@ #if LV_USE_ARC_LABEL && LV_BUILD_EXAMPLES -const char * ARC_LABEL_TEXT = +static const char * ARC_LABEL_TEXT = "I'm on an #FA7C45 ARC#! Centered with #12c2E9 C##8B68E8 O##c471ed L##B654E5 O##C84AB2 R##DB417A F##f64659 U##ff8888 L# feature!\n"; void lv_example_arc_label_1(void) diff --git a/lv_conf_template.h b/lv_conf_template.h index 7616ce0b37..1c0ce4fe66 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -699,6 +699,7 @@ * - lv_dropdown_t : Options set to "Option 1", "Option 2", "Option 3", else no values are set. * - lv_roller_t : Options set to "Option 1", "Option 2", "Option 3", "Option 4", "Option 5", else no values are set. * - lv_label_t : Text set to "Text", else empty string. + * - lv_arc_label_t : Text set to "Arced Text", else empty string. * */ #define LV_WIDGETS_HAS_DEFAULT_VALUE 1 diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index daac562f60..e4e6bb2569 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -2030,6 +2030,7 @@ * - lv_dropdown_t : Options set to "Option 1", "Option 2", "Option 3", else no values are set. * - lv_roller_t : Options set to "Option 1", "Option 2", "Option 3", "Option 4", "Option 5", else no values are set. * - lv_label_t : Text set to "Text", else empty string. + * - lv_arc_label_t : Text set to "Arced Text", else empty string. * */ #ifndef LV_WIDGETS_HAS_DEFAULT_VALUE #ifdef LV_KCONFIG_PRESENT diff --git a/src/widgets/arc_label/lv_arc_label.c b/src/widgets/arc_label/lv_arc_label.c index 50c77efeef..ca67535129 100644 --- a/src/widgets/arc_label/lv_arc_label.c +++ b/src/widgets/arc_label/lv_arc_label.c @@ -137,7 +137,6 @@ void lv_arc_label_set_text_fmt(lv_obj_t * obj, const char * fmt, ...) LV_ASSERT_OBJ(obj, MY_CLASS); LV_ASSERT_NULL(fmt); - lv_obj_invalidate(obj); lv_arc_label_t * arc_label = (lv_arc_label_t *)obj; /*If text is NULL then refresh*/ @@ -346,11 +345,9 @@ static void lv_arc_label_constructor(const lv_obj_class_t * class_p, lv_obj_t * arc->dir = LV_ARC_LABEL_DIR_CLOCKWISE; arc->recolor = false; - lv_obj_remove_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_arc_label_set_text(obj, LV_ARC_LABEL_DEFAULT_TEXT); + lv_arc_label_set_text_static(obj, LV_ARC_LABEL_DEFAULT_TEXT); - lv_obj_remove_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN | LV_OBJ_FLAG_SCROLLABLE); + lv_obj_remove_flag(obj, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLL_CHAIN | LV_OBJ_FLAG_SCROLLABLE); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/arc_label/lv_arc_label.h b/src/widgets/arc_label/lv_arc_label.h index 2b5cb8e0a0..558a8a3339 100644 --- a/src/widgets/arc_label/lv_arc_label.h +++ b/src/widgets/arc_label/lv_arc_label.h @@ -51,9 +51,9 @@ LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_arc_label_class; **********************/ /** - * Create an arc object - * @param parent pointer to an object, it will be the parent of the new arc - * @return pointer to the created arc + * Create an arc label object + * @param parent pointer to an object, it will be the parent of the new arc label + * @return pointer to the created arc label */ lv_obj_t * lv_arc_label_create(lv_obj_t * parent); @@ -98,35 +98,35 @@ void lv_arc_label_set_text_static(lv_obj_t * obj, const char * text); /** * Set the start angle of an arc. 0 deg: right, 90 bottom, etc. - * @param obj pointer to an arc object + * @param obj pointer to an arc label object * @param start the start angle. (if `LV_USE_FLOAT` is enabled it can be fractional too.) */ void lv_arc_label_set_angle_start(lv_obj_t * obj, lv_value_precise_t start); /** * Set the end angle of an arc. 0 deg: right, 90 bottom, etc. - * @param obj pointer to an arc object + * @param obj pointer to an arc label object * @param size the angle size (if `LV_USE_FLOAT` is enabled it can be fractional too.) */ void lv_arc_label_set_angle_size(lv_obj_t * obj, lv_value_precise_t size); /** * Set the rotation for the whole arc - * @param obj pointer to an arc object + * @param obj pointer to an arc label object * @param offset rotation angle */ void lv_arc_label_set_offset(lv_obj_t * obj, int32_t offset); /** * Set the type of arc. - * @param obj pointer to arc object + * @param obj pointer to and arc label object * @param dir arc label's direction */ void lv_arc_label_set_dir(lv_obj_t * obj, lv_arc_label_dir_t dir); /** * Enable the recoloring by in-line commands - * @param obj pointer to a label object + * @param obj pointer to an arc label object * @param en true: enable recoloring, false: disable * Example: "This is a #ff0000 red# word" */ @@ -174,21 +174,21 @@ void lv_arc_label_set_text_horizontal_align(lv_obj_t * obj, lv_arc_label_text_al /** * Get the start angle of an arc label. - * @param obj pointer to an arc object + * @param obj pointer to an arc label object * @return the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.) */ lv_value_precise_t lv_arc_label_get_angle_start(lv_obj_t * obj); /** * Get the angle size of an arc label. - * @param obj pointer to an arc object + * @param obj pointer to an arc label object * @return the end angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.) */ lv_value_precise_t lv_arc_label_get_angle_size(lv_obj_t * obj); /** - * Get whether the arc is type or not. - * @param obj pointer to an arc object + * Get whether the arc label is type or not. + * @param obj pointer to an arc label object * @return arc label's direction */ lv_arc_label_dir_t lv_arc_label_get_dir(const lv_obj_t * obj); @@ -205,7 +205,7 @@ bool lv_arc_label_get_recolor(lv_obj_t * obj); /** * Get the text of the arc label. - * @param obj pointer to an arc object + * @param obj pointer to an arc label object * @return the radius of the arc label */ uint32_t lv_arc_label_get_radius(lv_obj_t * obj); diff --git a/tests/src/test_cases/widgets/test_arc_label.c b/tests/src/test_cases/widgets/test_arc_label.c index 4b2b27882a..12e9d547f0 100644 --- a/tests/src/test_cases/widgets/test_arc_label.c +++ b/tests/src/test_cases/widgets/test_arc_label.c @@ -16,7 +16,7 @@ #define EXT_NAME ".lp32.png" #endif -const char * ARC_LABEL_TEXT = +static const char * ARC_LABEL_TEXT = "I'm on an #FA7C45 ARC#! Centered with #12c2E9 C##8B68E8 O##c471ed L##B654E5 O##C84AB2 R##DB417A F##f64659 U##ff8888 L# 特性! \n"; static lv_font_t * font;