lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
250 stars 161 forks source link

align, set_align, and set_style_align: only 2 work #183

Closed jdtsmith closed 3 years ago

jdtsmith commented 3 years ago

The micropython bindings for object alignment include the three methods align, set_align, and set_style_align. align and set_style_align work (the former with x,y offsets), but set_align does not function in a recent build, silently ignoring its inputs.

amirgon commented 3 years ago

@jdtsmith - I cannot reproduce the problem you are seeing.

See this example that works as expected:

scr = lv.obj()
btn = lv.btn(scr)
btn.set_align(lv.ALIGN.CENTER)

Could you send an example that shows the problem?

jdtsmith commented 3 years ago

Hmm, I see that it does indeed work for some elements. Here's a reproduction using a textarea, which is where I have noticed the issue:

ta = lv.textarea(lv.scr_act())
ta.set_style_bg_color(lv.color_black(),0)
ta.set_height(lv.scr_act().get_height()//2)
ta.set_align(lv.ALIGN.BOTTOM_MID) # Doesn't work
ta.set_style_align(lv.ALIGN.BOTTOM_MID,0) # Works
ta.set_align(lv.ALIGN.TOP_MID) # Doesn't work
ta.align(lv.ALIGN.TOP_MID, 0, 0) # Works
amirgon commented 3 years ago

That's because lv_textarea_set_align has a different meaning than lv_obj_set_align.

See https://forum.lvgl.io/t/spinbox-text-centering-not-working-as-intended-expected/6762?u=amirgon

jdtsmith commented 3 years ago

Aha, thanks. So it's an inconsistency in the LVGL API, which it looks like they have now deprecated (_"Deprecated: use the normal textalign style property instead").

I'll patch around it.