Menu: Add icon property
This adds an icon that is displayed to the left of the title, and is also shown for Menus are inside of a parent menu.
Closes #7791
Thanks for this much appreciated patch. Looks good to me, but I'm not the right person to judge the aesthetics, but I think it is ok for now. Could you make sure that the gallery has at least one menu entry with one icon? (Also a disabled entry would be nice)
Looks like the CI is failing in the C++ tests.
Error: /Users/runner/work/slint/cppbuild/api/cpp/generated_include/slint_builtin_structs_internal.h:139:5: error: unknown type name 'Image'
Image icon;
^
This is because the builtin struct now contain an image. This header is generated in https://github.com/slint-ui/slint/blob/ec1e125e8007e0c3fa086bf354e3e39b1d7a3c1b/api/cpp/cbindgen.rs#L119 , and it should be sufficient to add an #include <slint_image.h> there.
Also the muda implementation in muda.rs is missing.
Looking at the PR again, it looks like there are still some issue in the generated headers. Is that something you need help with?
Looking at the PR again, it looks like there are still some issue in the generated headers. Is that something you need help with?
Absolutely! I have no idea what I'm doing in the C++ part of Slint, so I'm just putting in stuff blind
I've fixed the include issue, but there is still an error in C++ 32bit (esp-idf):
/__w/slint/slint/api/cpp/include/slint_sharedvector.h: In instantiation of 'struct slint::SharedVector<slint::cbindgen_private::MenuEntry>':
/__w/slint/slint/api/cpp/include/slint_window.h:106:31: required from here
/__w/slint/slint/api/cpp/include/slint_sharedvector.h:227:30: error: static assertion failed: Not yet supported because we would need to add padding
227 | static_assert(alignof(T) <= alignof(SharedVectorHeader),
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/__w/slint/slint/api/cpp/include/slint_sharedvector.h:227:30: note: the comparison reduces to '(8 <= 4)'
The problem is because Image constains a CacheKey which contains a u64, and so can't be put in a SharedVector because struct for which alignment is bigger than the alignment of the helper data.
https://github.com/slint-ui/slint/blob/a176a553522adb052aa7c50b7e23ef2f9f3ce604/internal/core/graphics/image.rs#L293
Option include:
- Fix SharedVector to support higher alignment of its data
- Use a usize instead of a u64 for this field
- Something else.
Option 2. is the easier, @tronical: do you think it is safe? Otherwise I think Option 1. (fixing SharedVector) should actually be the most correct.
The usize holds a pointer, so u64 is ok for now.
(Rebased to fix conflicts)