Skip to content

Updated label.py to correct position of initial blank text #81

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

Merged
merged 4 commits into from
Aug 11, 2020

Conversation

kmatch98
Copy link
Contributor

@kmatch98 kmatch98 commented Aug 8, 2020

This is to resolve issue #80

Some background on label positioning:
There are two ways to specify a label's position, either by x,y or by anchor_point and anchored_position.
These two methods could be inconsistent, so I coded this so that setting anchored_position actually updates just the x,y locations. That way we don't have inconsistencies betwee the two. And the anchored_position getter just calculates the value based on the stored x,y value.
However, that means that the positioning of the label will depend upon the order of setting the position. For example, if you set x,y directly, then it will go to that position until you set anchored_position to another value.

In order to keep the anchored_position consistent, the text setter first gets the current anchored_position, then updates the text (in case the size changes) and then resets the anchored_position (which sets the appropriate x,y values).

To solve this issue #80, I updated anchor_point to allow a value of None. That way, if the anchor_point is None, then the anchored_position is also invalid. That will ensure that the x,y values are not changed when the anchor_point is not set and then the text is changed. I hope this is solution is generic enough to resolve most issues like this.

Copy link
Contributor Author

@kmatch98 kmatch98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it took me a couple of tries for your comment to sink in so I could fix this.
Deleted else, updated tabbing and recommited.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tannewt tannewt merged commit dc3dcd2 into adafruit:master Aug 11, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 19, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_EPD to 2.7.0 from 2.6.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_EPD#41 from makermelissa/master
  > Merge pull request adafruit/Adafruit_CircuitPython_EPD#40 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.8.1 from 2.8.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#83 from FoamyGuy/fix_anchored_position_rounding
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#85 from kmatch98/glyph_speedup
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#79 from kmatch98/bitmap_label
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#81 from kmatch98/anchor_fix
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

Successfully merging this pull request may close these issues.

2 participants