lvgl / lv_binding_cpp

[WIP] C++ binding for LVGL
MIT License
44 stars 20 forks source link

Detail ways to create a C++ binding #13

Open boulabiar opened 5 months ago

boulabiar commented 5 months ago

I opened this issue to discuss ways to create C++ bindings for lvgl.

I don't think the bounty will do it, especially with the conditions that it should be perfect and with examples.. So let's discuss how to do the binding and start with simple examples so it can be done one step each time.

Can we generate code from the rust bindings ? so we have similar APIs ?

kisvegabor commented 4 months ago

I think we should use the JSON generated from LVGL's API and generate the C++ binding based on that.

kdschlosser commented 4 months ago

If the JSON generation code gets added to LVGL the workload of putting together a C++ binding just got reduced by a HUGE amount. Couple that with the documentation for LVGL being available in that JSON output and now you can add that documentation to the binding code and make changes to the documentation programmatically so it would suit the C++ binding.

Examples and unit tests would probably need to be written by hand. unit tests are pretty easy to do actually. Instead of writing the data to a display in the flush callback you dump it into a buffer and you compare the data in that buffer to the data of what the expected output is supposed to be. You basically add a bunch of widgets you want to test and size them how you want and then call lv_refr_now and that will force the rendering to take place and the flush callback to get called. The only thing that you need to do special is setting the render mode to direct and making the frame buffer the same size as the "fake" displays resolution using 3 bytes per pixel.