fix(flex): fix rounding may leave unused space on track with flex_grow (#9217)
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 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
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
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
Close stale issues and PRs / stale (push) Has been cancelled
@@ -67,6 +67,11 @@ static lv_obj_t * get_next_item(lv_obj_t * cont, bool rev, int32_t * item_id);
|
||||
static int32_t lv_obj_get_width_with_margin(const lv_obj_t * obj);
|
||||
static int32_t lv_obj_get_height_with_margin(const lv_obj_t * obj);
|
||||
|
||||
static inline int32_t div_round_closest(int32_t dividend, int32_t divisor)
|
||||
{
|
||||
return (dividend + divisor / 2) / divisor;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
@@ -363,13 +368,11 @@ static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, i
|
||||
grow_max_size -= t->grow_dsc[i].final_size;
|
||||
}
|
||||
}
|
||||
int32_t grow_unit;
|
||||
|
||||
for(i = 0; i < t->grow_item_cnt; i++) {
|
||||
if(t->grow_dsc[i].clamped == 0) {
|
||||
LV_ASSERT(grow_value_sum != 0);
|
||||
grow_unit = grow_max_size / grow_value_sum;
|
||||
int32_t size = grow_unit * t->grow_dsc[i].grow_value;
|
||||
int32_t size = div_round_closest(grow_max_size * t->grow_dsc[i].grow_value, grow_value_sum);
|
||||
int32_t size_clamp = LV_CLAMP(t->grow_dsc[i].min_size, size, t->grow_dsc[i].max_size);
|
||||
|
||||
if(size_clamp != size) {
|
||||
|
||||
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 700 B |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 700 B |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 9.6 KiB |
@@ -0,0 +1,69 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static lv_obj_t * active_screen = NULL;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
active_screen = lv_screen_active();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(active_screen);
|
||||
}
|
||||
|
||||
static void simple_style(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_set_style_pad_row(obj, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_column(obj, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_all(obj, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_radius(obj, 0, LV_PART_MAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that various flex tracks containing fixed and growing items are
|
||||
* always completely filled, no red background visible.
|
||||
*/
|
||||
void test_grid_fr(void)
|
||||
{
|
||||
simple_style(active_screen);
|
||||
|
||||
lv_obj_t * container = lv_obj_create(active_screen);
|
||||
simple_style(container);
|
||||
lv_obj_set_style_bg_color(container, lv_palette_main(LV_PALETTE_RED), LV_PART_MAIN);
|
||||
lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_size(container, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_center(container);
|
||||
|
||||
for(int32_t grow_1 = 1; grow_1 <= 3; grow_1++) {
|
||||
for(int32_t grow_2 = 1; grow_2 <= 3; grow_2++) {
|
||||
for(int32_t fixed = 20; fixed <= 24; fixed++) {
|
||||
lv_obj_t * child_grow_1 = lv_obj_create(container);
|
||||
simple_style(child_grow_1);
|
||||
lv_obj_set_style_bg_color(child_grow_1, lv_palette_main(LV_PALETTE_BLUE), LV_PART_MAIN);
|
||||
lv_obj_set_size(child_grow_1, 1, 10);
|
||||
lv_obj_set_flex_grow(child_grow_1, grow_1);
|
||||
lv_obj_add_flag(child_grow_1, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
|
||||
|
||||
lv_obj_t * child_grow_2 = lv_obj_create(container);
|
||||
simple_style(child_grow_2);
|
||||
lv_obj_set_style_bg_color(child_grow_2, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN);
|
||||
lv_obj_set_size(child_grow_2, 1, 10);
|
||||
lv_obj_set_flex_grow(child_grow_2, grow_2);
|
||||
|
||||
lv_obj_t * child_fixed = lv_obj_create(container);
|
||||
simple_style(child_fixed);
|
||||
lv_obj_set_style_bg_color(child_fixed, lv_palette_main(LV_PALETTE_BLUE), LV_PART_MAIN);
|
||||
lv_obj_set_size(child_fixed, fixed, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("flex_grow.png");
|
||||
}
|
||||
|
||||
#endif
|
||||