fix(scale): don't return early on main drawing when having 1 or less ticks (#10010)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify GDB constants are up-to-date / verify-gdb-consts (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build Docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled

This commit is contained in:
Carlos Diaz
2026-04-27 01:23:24 -06:00
committed by GitHub
parent 4d7458044c
commit a36662950a
4 changed files with 28 additions and 3 deletions
+9 -3
View File
@@ -1017,10 +1017,18 @@ static void scale_calculate_main_compensation(lv_obj_t * obj)
const uint32_t total_tick_count = scale->total_tick_count;
if(total_tick_count <= 1) return;
/* Not supported in round modes */
if(LV_SCALE_MODE_ROUND_OUTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) return;
/* Reset compensation when scale has 1 or less ticks on vertical and horizontal scales */
if(total_tick_count <= 1) {
/* Store initial tick width to be used in the main line drawing */
scale_store_main_line_tick_width_compensation(obj, 0U, false, 0U, 0U);
/* Store last tick width to be used in the main line drawing */
scale_store_main_line_tick_width_compensation(obj, total_tick_count, false, 0U, 0U);
}
/* Major tick style */
lv_draw_line_dsc_t major_tick_dsc;
lv_draw_line_dsc_init(&major_tick_dsc);
@@ -1075,8 +1083,6 @@ static void scale_draw_main(lv_obj_t * obj, lv_event_t * event)
lv_scale_t * scale = (lv_scale_t *)obj;
lv_layer_t * layer = lv_event_get_layer(event);
if(scale->total_tick_count <= 1) return;
if((LV_SCALE_MODE_VERTICAL_LEFT == scale->mode || LV_SCALE_MODE_VERTICAL_RIGHT == scale->mode)
|| (LV_SCALE_MODE_HORIZONTAL_BOTTOM == scale->mode || LV_SCALE_MODE_HORIZONTAL_TOP == scale->mode)) {
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

+19
View File
@@ -637,4 +637,23 @@ void test_scale_properties(void)
#endif
}
void test_scale_with_1_tick(void)
{
/* When the scale has 1 (or less) ticks, only the main part should be drawn,
* no ticks nor labels are expected to be drawn. */
lv_obj_t * lv_obj_t_id = lv_scale_create(lv_screen_active());
lv_obj_set_style_height(lv_obj_t_id, lv_pct(100), LV_PART_MAIN);
lv_obj_set_style_width(lv_obj_t_id, lv_pct(100), LV_PART_MAIN);
lv_obj_set_style_align(lv_obj_t_id, LV_ALIGN_CENTER, LV_PART_MAIN);
lv_obj_set_style_bg_opa(lv_obj_t_id, LV_OPA_TRANSP, LV_PART_MAIN);
lv_obj_set_style_radius(lv_obj_t_id, LV_RADIUS_CIRCLE, 0);
lv_scale_set_mode(lv_obj_t_id, LV_SCALE_MODE_ROUND_INNER);
lv_scale_set_range(lv_obj_t_id, 0, 100);
lv_scale_set_angle_range(lv_obj_t_id, 180);
lv_scale_set_rotation(lv_obj_t_id, 270);
lv_scale_set_total_tick_count(lv_obj_t_id, 1);
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/scale_9.png");
}
#endif