Skip to content

y position of text can be wrong if constructor does not specify text #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kevinjwalters opened this issue Aug 7, 2020 · 5 comments
Closed

Comments

@kevinjwalters
Copy link

kevinjwalters commented Aug 7, 2020

I updated my libraries last night to ones from adafruit-circuitpython-bundle-5.x-mpy-20200806.zip. I noticed the performance improvement with moving around text but I also spotted one solitary piece of text that was misplaced slightly off screen.

I've just made a simple recreation of this, I think it's when text is not specified or it is empty string, y is set, and then text is set. I am using scaled text here.

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit CLUE nRF52840 Express with nRF52840
>>>
>>> import displayio, terminalio, board
>>> from adafruit_display_text.label import Label
>>> fdim = terminalio.FONT.get_bounding_box()
>>> l1 = Label(terminalio.FONT, max_glyphs=9, scale=3, color=0xff0000)
>>> l2 = Label(terminalio.FONT, text="", max_glyphs=9, scale=3, color=0x00ff00)
>>> l3 = Label(terminalio.FONT, text="Chad", max_glyphs=9, scale=3, color=0x0000ff)
>>> l1.y = l2.y = l3.y = round(240 - (3 * fdim[1] / 2))
>>> (l1.y, l2.y, l3.y)
(219, 219, 219)
>>> l2.x = 80
>>> l3.x = 160
>>> tg = displayio.Group(max_size=3)
>>> tg.append(l1)
>>> tg.append(l2)
>>> tg.append(l3)
>>> board.DISPLAY.show(tg)
>>> l1.text="Wot"
>>> l2.text="No"
>>> (l1.y, l2.y, l3.y)
(240, 240, 219)

Only l3 is correctly position, l1 and l2 are half off screen.

I see #78 which sounds like it could be in the same area?

Setting to whitespace seems to be a workaround for me, e.g. text=" ", and might be able to re-order my code to set text once in constructor.

@kmatch98
Copy link
Contributor

kmatch98 commented Aug 7, 2020

Put this in my queue. I think it’s probably different than the case you mention. My first thought is that the bounding_box has something wrong with it but I’ll have to dig in. Glad you found a workaround in the meantime.

@kmatch98
Copy link
Contributor

kmatch98 commented Aug 8, 2020

@kevinjwalters thanks for the heads-up on this issue with the text setter.

I uncovered that the anchor_point is being set to (0,0) as a default value. So, when you update the text, it checks the anchor_point and anchored_position as if they are valid data.

The code should be updated such that anchor_point = None when the anchor_point isn't defined.

There will need to be associated changes with the anything that uses the anchor_point or get/sets the anchored_position to respond properly when anchor_point = None. It'll take me a day or two to sort through this and test it out a bit.

@kevinjwalters
Copy link
Author

kevinjwalters commented Aug 10, 2020

I re-ordered my code as I can easily set the text to its (final) value when the Label is constructed.

@kmatch98
Copy link
Contributor

This was resolved by the merge PR #81

@FoamyGuy
Copy link
Contributor

Closed by #81 thanks @kmatch98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants