godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.59k stars 20.74k forks source link

Button size being inherited from the theme unexpectedly 4.3 beta #93437

Closed brane-games closed 2 months ago

brane-games commented 3 months ago

Tested versions

Reproducible in: Godot_v4.3-beta2_mono_win64, Godot_v4.3-beta2_mono_win64 Not reproducible in: Godot_v4.3-dev5_mono_win64

System information

Windows 10 / Vulkan API 1.3.242 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 1660

Issue description

In dev5 image

In betas: image

As you can see, the Slider component is quite stretched. It's a custom component that looks completely fine when being run on its own. Only when used inside other scenes does it gets distorted. The slider grabber in my custom Slider node is a Button node.

Steps to reproduce

It's hard to provide reproducable steps. This is simply a regression between dev5 and betas.

Minimal reproduction project (MRP)

N/A

Calinou commented 3 months ago

Please upload a minimal reproduction project[^1] to make this easier to troubleshoot.

[^1]: A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the .godot folder in the archive (but keep project.godot).

Drag and drop a ZIP archive to upload it. Do not select another field until the project is done uploading.

Note for C# users: If your issue is not Mono-specific, please upload a minimal reproduction project written in GDScript or VisualScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a Mono setup available.

brane-games commented 3 months ago

I was unable to create a minimal reproduction project. It all just works in a completely new project.

brane-games commented 3 months ago

Okay I've managed to track it down and fix it in a way.

The problem was that the button of the custom slider component (a Button node) for some reason inherited the size of the button component which is in the theme of the game. The minimum x size of this button is 58 pixels.

For some reason this value would be inherited inside this node with completely custom Normal/Hover/Pressed textures and the button wouldn't resize to the desired value of 31 pixels. After setting up a completely new theme on the level of my CustomSlider component that has overriden button component styles it is fixed.

brane-games commented 3 months ago

I still maintain there's some kind of regression and a bug here but it has a decent enough hack fix.

brane-games commented 3 months ago

bug-report.zip

Reproduced!

The problem is that the button in my custom slider node doesn't override the Disabled styles (which makes sense, it's never disabled). Because the Disabled style of the Button in the theme I'm using is overridden, the whole node uses the size of the disabled style of the theme button instead of completely ignoring it.

matheusmdx commented 3 months ago

Bisecting points to #92009 as the culprit:

image

KoBeWi commented 3 months ago

There is a new theme constant align_to_largest_stylebox. You have to set it to 0.

akien-mga commented 3 months ago

There is a new theme constant align_to_largest_stylebox. You have to set it to 0.

Should we default it to 0? I'm afraid we introduced a breaking behavior change here that's unexpected in the default theme.

KoBeWi commented 3 months ago

I checked the MRP and the new constant has no effect for some reason. It's already 0 by default.

bruvzg commented 3 months ago

It is set to 0 by default and works as expected when applied directly, but seems like something is wrong with theme inheritance (for both disabled style and new constant). It might be interpreting 0 as unset at some point and somehow pulling value from the editor theme, not sure what's exactly wrong.