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

ImageButton doesn't show an image at center when background props: up, down are set. #7298

Open
4 tasks
supermaximus80 opened this issue Dec 12, 2023 · 6 comments

Comments

@supermaximus80
Copy link
Contributor

Issue details

ImageButton doesn't show an image when background props: up, down are set. The only possible way to show an image at center of an ImageButton is do not set background properties.

Reproduction steps/code

Create the style in uiskin.json

com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: {
	default: { down: button3Up, up: button3Up, checked: button3Up, imageUp: beigeRefresh, imageDown: beigeRefresh, imageChecked: beigeRefresh, imageOver: beigeRefresh },
	button1: { up: button3Up, imageUp: beigeRefresh }
}

Then create a button:

ImageButton btnRefresh = new ImageButton(skin, "default");
stage.addActor(btnRefresh);

In the end you'll see a button without an image at center, which specified in the default style.

Version of libGDX and/or relevant dependencies

1.12.1

Stacktrace

//Please provide the stacktrace if applicable 

Please select the affected platforms

  • [*] Android
  • iOS
  • HTML/GWT
  • [*] Windows
  • Linux
  • macOS
@raeleus
Copy link
Contributor

raeleus commented Dec 12, 2023

I use ImageButton all the time in the way you describe. Can you provide a skin and simple project that demonstrates the issue?

@supermaximus80
Copy link
Contributor Author

@raeleus I can't because it's a commerсial project. But this issue is easy to recreate in empty libgdx project. If you want, I will recreate it.

@raeleus
Copy link
Contributor

raeleus commented Dec 12, 2023

Yes, please do.

@supermaximus80
Copy link
Contributor Author

@raeleus
test3.zip
I found the problem. This issue happens when the size of an ImageButton is too small. See attached example.

@HydrolienF
Copy link
Contributor

It is caused by hight differencies in button background (down) and button foreground (imageDown) size.

@HydrolienF
Copy link
Contributor

I can't find where it is, but it is probably in Group#draw(...) or Table#draw(...). Margin is the same for a big and for a small button, for the small one center image is <0

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

3 participants