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

fix: listen for changes in layout bounds in FXGLDefaultMenu.kt #1365

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Bart-del
Copy link

Hi!
Issue link: #1020

This PR contains fix for title width calculation. Now it will listen for changes in layoutBounds and should update title width when font size will change. I've also changed the variable names to be more descriptive.

@Bart-del Bart-del force-pushed the dev branch 2 times, most recently from 6dd326a to 8d5c543 Compare March 26, 2024 20:51
@AlmasB AlmasB added this to the 21.2 milestone Mar 31, 2024
Copy link
Owner

@AlmasB AlmasB left a comment

Choose a reason for hiding this comment

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

Thanks for this. It looks good, just need to address the last few bits. Let me know if the attached comments make sense


val titleWidth = firstLetterWidth + restOfTheTitleWidth

val border = Rectangle(titleWidth + 30, 65.0, null)
Copy link
Owner

Choose a reason for hiding this comment

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

The width of this rectangle is still fixed, it should be updated based on changes to layout bounds of the text objects. Something like:

firstLetter.layoutBoundsProperty().addListener { _, _, newBounds -> update border width }

box.alignment = Pos.CENTER

val titleRoot = StackPane(border, box)
titleRoot.translateX = appWidth / 2.0 - (textWidth + 30) / 2
titleRoot.translateX = appWidth / 2.0 - (titleWidth + 30) / 2
Copy link
Owner

Choose a reason for hiding this comment

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

The translateX property should also be bound to the new value of restOfTheTitle layout bounds. Something like:

firstLetter.layoutBoundsProperty().addListener { _, _, newBounds -> update titleRoot translateX }

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