Hi guys,
Description
I do draw a custom model railway layout using lots of lv_lines. On the turnouts (consisting of two lines, one for straight one for the turn), I want to add text giving the turnout number.
What MCU/Processor/Board and compiler are you using?
Windows for testing and ESP32 for actual usage.
What LVGL version are you using?
9
What do you want to achieve?
I do calculate the bounding box of the lines and want to place a lv_label in the middle of it, but it is always a bit off.
I do all my calculations in screen space (so the full resolution, no other parent involved).
What have you tried so far?
auto lbl = lv_label_create(lvglScreenRailway);
lv_obj_set_pos(lbl, bounds.min.x + (bounds.max.x - bounds.min.x)/2 - 16, bounds.min.y + (bounds.max.y - bounds.min.y) / 2 - 16);
lv_obj_set_size(lbl, 32, 32);
of course I can try and play around with some offsets.
I am also open to do this in a different way… maybe a base object, adding the lines there and then centering the text inside? What are your recommendations?
Screenshot and/or video
Here is a small portion of what I mean: Orange are the lines (only the active one is visible). I want to have the label centered on the two lines.
Thanks
Daniel