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

Textbutton over-offset #7316

Open
harofax opened this issue Jan 10, 2024 · 1 comment
Open

Textbutton over-offset #7316

harofax opened this issue Jan 10, 2024 · 1 comment

Comments

@harofax
Copy link

harofax commented Jan 10, 2024

Sorry if this is the wrong place, but couldn't find anywhere else. Saw that there was a label for feature requests so here I go;

It would be nice (and probably not too big a hurdle maybe?) to have an offset for when a TextButton is hovered, similar to how there's one for pressed, checked, unpressed.

Looking through the source, checks using the isPressed() methods, then sets offset according to the button style. There is a isOver() method as well, so I was surprised when I didn't find a over-offset.

It was easy enough to work around but I feel like it would fit in with the other offset options.

Again if this is the wrong place, feel free to delete this, and I apologize in advance.

@NathanSweet
Copy link
Member

I think this is reasonable. It would go in Button.ButtonStyle (not TextButtonStyle). The logic in Button#draw becomes:

float offsetX = style.unpressedOffsetX, offsetY = style.unpressedOffsetY;
if (!isDisabled()) {
	if (isPressed()) {
		offsetX = style.pressedOffsetX;
		offsetY = style.pressedOffsetY;
	} else if (isChecked()) {
		offsetX = style.checkedOffsetX;
		offsetY = style.checkedOffsetY;
	} else if (isOver()) {
		offsetX = style.overOffsetX;
		offsetY = style.overOffsetY;
	}
}

This has a subtle difference: if not pressed and not checked, you get the over offset rather than the unpressed offset. That makes this a breaking change for apps that don't use 0 for unpressed offset. 0 for that is common, but the potential is there.

If everybody else is OK with that, I think it's OK.

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

No branches or pull requests

3 participants