-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add expand_mode (see TextureRect) to TextureButton #11624
Comments
I don't understand what you are asking for. Godot's UI system allows creating any UI. maybe if you showed some picture of what you want to achieve we could help you more. That said,
all controls have |
Describe the project you are working on
A cRPG with heavy quantities of UI.
Describe the problem or limitation you are having in your project
I want to place Buttons or TextureButtons (featuring an icon) that resize themselves to fit a parent container while keeping a 1:1 ratio. This is currently not possible without using
minimum_size
(which must be updated manually and is bothersome) or setting the texture file to a very specific size so that it doesn't need resizing at all and is used as is (bothersome too if the UI every changes sizes).Describe the feature / enhancement and how it helps to overcome the problem or limitation
"expand_mode" is a feature in
TextureRect
that makes it easy to automatically adjust a Texture's size to a parent container, particularly with thefit_width
andfit_height
options, therefore making it unnecessary to rely on theControl
'sminimum_size
to achieve desired layouts or having to prepare the image file at the exact desired size to avoid resizing altogether.Currently the
TextureButton
(textures
) does not feature this, yet it could be a useful and intuitive addition to make buttons that resize their textures according to their width or height. This is particularly useful when you need Buttons to resize their attached texture/icon to the container holding them.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Exact same behavior from
TextureRect
'sexpand_mode
would be expected, just applied toTextureButton
instead.If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes. You can set the texture size to the very specific size you need and avoid resizing the image altogether, i.e. set
ignore_texture_size
toFALSE
or set the Button'sminimum_size
to whichever size is needed.However, this eliminates automatic-resizing, meaning I have to tweak either the texture or the Buttons min_size every time the UI changes size, which could be somewhat often when making test layouts or iterating on the UI.
Is there a reason why this should be core and not an add-on in the asset library?
Because it would be a somewhat simple added property to a core Node of Godot UI system (
TextureButton
).The text was updated successfully, but these errors were encountered: