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

[bgw-gui] Broken CardStack alignment #411

Open
taubenangriff opened this issue Jul 30, 2024 · 0 comments
Open

[bgw-gui] Broken CardStack alignment #411

taubenangriff opened this issue Jul 30, 2024 · 0 comments

Comments

@taubenangriff
Copy link

Describe the bug

Setting Height/Width on a CardView as well as on a CardStack results in the positioning being off. This is due to card and StackWidth being added.

To Reproduce
Steps to reproduce the behavior:

Set up two card stacks:

val stackLeft = CardStack<CardView>(
        height = 180,
        width = 130,
        posX = width/2 + 100,
        posY = height/2)

val stackRight = CardStack<CardView>(
        height = 0,
        width = 0,
        posX = width/2 + 100,
        posY = height/2)

each with CardViews initialized to height=180, width=130.

Expected behavior

The CardStack should be aligned by using just the individual cards dimension for positioning.

Screenshots / Stack trace
If applicable, add screenshots and/or stack trace to help explain your problem.

grafik

As we can see, stackLeft is moved out of position, while stackRight is perfectly centered.

Please complete the following information:

  • OS: Any
  • Java version: Any

Additional context

private fun T.layoutX() {
posXProperty.setSilent(
when (alignment.horizontalAlignment) {
HorizontalAlignment.LEFT -> 0.0
HorizontalAlignment.CENTER -> (this@CardStack.width - this.width) / 2
HorizontalAlignment.RIGHT -> this@CardStack.width - this.width
})
}
private fun T.layoutY() {
posYProperty.setSilent(
when (alignment.verticalAlignment) {
VerticalAlignment.TOP -> 0.0
VerticalAlignment.CENTER -> (this@CardStack.height - this.height) / 2
VerticalAlignment.BOTTOM -> this@CardStack.height - this.height
})
}
}

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

1 participant