Skip to content
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

Horizontal text alignment for TextBoxLayout objects #617

Closed
conradmagnes opened this issue Jul 7, 2024 · 0 comments · Fixed by #653
Closed

Horizontal text alignment for TextBoxLayout objects #617

conradmagnes opened this issue Jul 7, 2024 · 0 comments · Fixed by #653
Labels
bug Something isn't working

Comments

@conradmagnes
Copy link

Describe the bug
Right horizontal text alignment does not properly account for padding. Specifically, the "align_all_rows_right()" function of TextBoxLayout objects chooses as a starting point the width of its layout_rect. With nonzero padding, this effectively doubles the padding when aligning to the right. I think a more appropriate starting point would be layout_rect.right.

To Reproduce
Steps to reproduce the behaviour:

  1. Create a UILabel element of fixed width and nonzero horizontal padding.
  2. Compare the padding when the text of the element is aligned to the left vs the right. The padding is not equal.
  3. Check label.drawable_shape.text_box_layout for underlying alignment behaviour.

Expected behaviour
Equal size padding with right and left alignment.

Screenshots

def align_right_all_rows(self, x_padding):
        """
        Align all rows to the right hand side of the layout.

        :param x_padding: the amount of padding to insert to on the right
                          before the text starts.
        """
        start_right = self.layout_rect.width - x_padding  # should change to self.layout_rect.right
        for row in self.layout_rows:
            row.align_right_row(start_right, self.floating_rects)

Platform and software (please complete the following information):

  • OS: Mac
  • Pygame GUI version: 6.9
@conradmagnes conradmagnes added the bug Something isn't working label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant