mirror of
https://github.com/lvgl/lvgl.git
synced 2026-09-27 18:34:13 +08:00
fix(flex): use min size when item is set to grow and parent is LV_SIZE_CONTENT (#8806)
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
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
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: André <andre_miguel_costa@hotmail.com>
This commit is contained in:
co-authored by
cubic-dev-ai[bot]
André
parent
af25d9f0f1
commit
a5b1045918
@@ -204,6 +204,30 @@ You can force Flex to put an item into a new line with
|
||||
Learn more about `CSS Flexbox`_.
|
||||
|
||||
|
||||
Edge cases and notes
|
||||
--------------------
|
||||
|
||||
The following behaviors clarify interactions between flex grow, wrapping and size constraints:
|
||||
|
||||
- Grow with LV_SIZE_CONTENT parent: If a flex container's size on the main axis is
|
||||
:c:macro:`LV_SIZE_CONTENT` and it contains items with non-zero grow, the grown items
|
||||
initially use their own minimum size when determining the container's content size.
|
||||
If the container has min/max constraints that force a concrete size, the remaining
|
||||
space is then distributed among grow items (respecting each item's min/max).
|
||||
|
||||
- Wrapping with grow: For :cpp:enumerator:`LV_FLEX_FLOW_ROW_WRAP` and
|
||||
:cpp:enumerator:`LV_FLEX_FLOW_COLUMN_WRAP`, wrapping is used as expected even when the
|
||||
object is grown in the same direction and its size in that direction is
|
||||
:c:macro:`LV_SIZE_CONTENT`. In this case the :c:macro:`LV_SIZE_CONTENT` constraint is
|
||||
ignored to be consistent with how the object size is calculated, and the grown size is used.
|
||||
|
||||
- Min/max as content or percent: Item min/max width/height can be set to
|
||||
:c:macro:`LV_SIZE_CONTENT` or :cpp:expr:`LV_PCT(x)`. These constraints are respected
|
||||
during grow and wrapping and can clamp size of grown items.
|
||||
|
||||
- Gaps with zero-size grow: Padding/gap is still applied even if a grown item ends up
|
||||
with zero size on the main axis; this matches CSS flex behavior.
|
||||
|
||||
|
||||
.. _flex_examples:
|
||||
|
||||
|
||||
@@ -199,6 +199,15 @@ The columns will be placed from right to left.
|
||||
|
||||
|
||||
|
||||
Edge cases and notes
|
||||
--------------------
|
||||
|
||||
- Min/max as content or percent: Child Widgets can set min/max width/height to
|
||||
:c:macro:`LV_SIZE_CONTENT` or :cpp:expr:`LV_PCT(x)`. These constraints are respected
|
||||
when computing :c:macro:`LV_GRID_CONTENT` tracks (tracks sized to their largest
|
||||
child) and when distributing space to FR-unit tracks.
|
||||
|
||||
|
||||
.. admonition:: Further Reading
|
||||
|
||||
- Learn more about `CSS Grid`_ layout.
|
||||
|
||||
@@ -64,6 +64,7 @@ LVGL can be freely extended by a custom layout like this:
|
||||
...
|
||||
|
||||
MY_LAYOUT = lv_layout_register(my_layout_update, &user_data);
|
||||
lv_layout_set_min_size_cb(MY_LAYOUT, my_layout_get_min_size); /* Optional */
|
||||
|
||||
...
|
||||
|
||||
@@ -72,6 +73,10 @@ LVGL can be freely extended by a custom layout like this:
|
||||
/* Will be called automatically if it's required to reposition/resize the children of "widget" */
|
||||
}
|
||||
|
||||
The min size callback is optional and can be used to precompute the minimum size of all the children in
|
||||
the layout before sizing and positioning them. This is useful for layouts like flex that need to know
|
||||
the minimum size of children to properly calculate the grow size of the children.
|
||||
|
||||
Custom style properties can be added which can be retrieved and used in the update
|
||||
callback. For example:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user