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

Add option to expand/set icon size in PopupMenu #6139

Closed
rsubtil opened this issue Jan 21, 2023 · 3 comments
Closed

Add option to expand/set icon size in PopupMenu #6139

rsubtil opened this issue Jan 21, 2023 · 3 comments
Milestone

Comments

@rsubtil
Copy link

rsubtil commented Jan 21, 2023

Describe the project you are working on

Game launcher frontend, which constantly loads and uses user supplied assets in it's UI nodes

Describe the problem or limitation you are having in your project

OptionMenu has an option to expand icon size. Together with a custom minimum size, developers can tweak the final icon size to their needs. However PopupMenu doesn't offer such option, so icons display at their original resolution, which looks bad:
image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Major improvements have been made (godotengine/godot#41640) to PopupMenu's usability, and I believe this issue is one of the last long standing nuisances of it. In a similar vein to the implemented max_size property, there should be a way to define a given menu item's maximum size. It's not enough to just add an "Expand Icon" option to it, as the icon can become too small due to the text size. Like with OptionButton, there should be a way to specify some minimum size:
image

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

For PopupMenu:

  • Add a max_item_size Vector2 property that controls the maximum size for a menu item.
    • It should still respect minimum size requirements (e.g. for text), in which case the final size would be bigger than requested

For OptionButton:

  • Add an expand_item_to_size bool setting, that will set the maximum size of menu item's to the control's minimum size. This makes all menu items have the same size as the button itself, which looks better.
    • If another size is desired, it would still be possible to set it in code:
$OptionButton.get_popup().max_item_size = new Vector2(...)

If this enhancement will not be used often, can it be worked around with a few lines of script?

AFAIK there's no way to change icon sizes of PopupMenus from scripts.

Is there a reason why this should be core and not an add-on in the asset library?

Modifies core behavior

@KoBeWi
Copy link
Member

KoBeWi commented Jan 21, 2023

I think OptionButton should automatically adjust the menu to it's expand option. I reported it as a bug: godotengine/godot#58283

@rsubtil
Copy link
Author

rsubtil commented Jan 21, 2023

I think OptionButton should automatically adjust the menu to it's expand option

I can implement that behavior as default then 👍.

@rsubtil
Copy link
Author

rsubtil commented May 6, 2023

Implemented with godotengine/godot#75472

@rsubtil rsubtil closed this as completed May 6, 2023
@Calinou Calinou added this to the 4.1 milestone May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Implemented
Development

No branches or pull requests

3 participants