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

Scaled Controls don't align properly #19068

Open
Essojadojef opened this issue May 20, 2018 · 9 comments
Open

Scaled Controls don't align properly #19068

Essojadojef opened this issue May 20, 2018 · 9 comments

Comments

@Essojadojef
Copy link
Contributor

Godot version: 3.0

OS/device including version:

Issue description:
Margins ignore the scale of the control.
The top-left corner is set as if the node was not scaled.

Scale: 1x1, Anchor: center right
selezione_025

Scale: 2x2, Anchor: center right (the transparent panel is also scaled 2x2, but the textureRect didn't align to it's center right)
selezione_026

What was expected: (with Anchor: center left)
selezione_028

Steps to reproduce:
Add a Control to a parent Control.
Change the child's scale.
Change the child's anchor from the Layout menu (to a layout different from top left).

Minimal reproduction project:
align-scaled-issue.zip

@evelant
Copy link

evelant commented Jun 30, 2020

Is there a workaround for this? From what I can tell this issue makes some (responsive) UIs impossible to create.

@KoBeWi
Copy link
Member

KoBeWi commented Jun 30, 2020

Well, the workaround is to avoid using rect_scale. I did numerous GUIs in Godot and never needed it.

From what I can tell this issue makes some (responsive) UIs impossible to create.

Any examples?

@Calinou
Copy link
Member

Calinou commented Jun 30, 2020

From what I can tell this issue makes some (responsive) UIs impossible to create.

See Multiple resolutions in the documentation.

@ghost
Copy link

ghost commented Jun 2, 2021

@ghost
Copy link

ghost commented Jun 2, 2021

This is not a workaround for the issue though.

@Calinou
Copy link
Member

Calinou commented Jun 2, 2021

@Callinou This documentation link is broken. Archive: http://web.archive.org/web/20181105034839/https://docs.godotengine.org/en/latest/tutorials/viewports/multiple_resolutions.html

Documentation pages were moved around in master, but redirects haven't been set up yet due to a Read the Docs limitation. Here's the new link: https://docs.godotengine.org/en/latest/tutorials/rendering/multiple_resolutions.html

This is not a workaround for the issue though.

Can you describe your use case for Control scaling?

@ghost
Copy link

ghost commented Jun 3, 2021

@Callinou For now it'd be just to reduce the size of a large-resolution logo.

@Calinou
Copy link
Member

Calinou commented Jun 3, 2021

For now it'd be just to reduce the size of a large-resolution logo.

If you use a TextureRect node and check Expand, you'll be allowed to resize it to a size smaller than the original size. Remember to enable Mipmaps on the original texture to avoid noisy artifacts.

@Hanprogramer
Copy link

Hanprogramer commented May 2, 2024

Tested on: Godot v4.3.dev5.mono - Windows 10.0.22000

Adding this video to better explain the issue
https://github.com/godotengine/godot/assets/30620423/ade433ce-f87f-435a-8b85-abcc4d61aefd
Or in GIF:
ezgif-6-db5e727565

Found a workaround for this temporarily:
Scale the children of the control according to parent control's scale. (Haven't tested in nested scaling though.)

Re-Edit:
Found out the actual problem is that get_rect() does not return rectangle with the transform scale. If you take this into account for your animations it should remain centered and my workaround is not needed.

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

7 participants