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 minimum_character_count to SpinBox #64538

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Aug 17, 2022

Closes godotengine/godot-proposals#4138

Defaults to auto-adjust, but it doesn't seem to work well. I'm using the minimum_character_width theme property of LineEdit and it tends to make the SpinBox wider than necessary. Also determining the longest possible string is a bit tricky. But other than that, the feature is functional.

@akien-mga
Copy link
Member

It seems a bit weird to me to add a property that is used to set theme overrides on an internal node. Can't we have theme items in SpinBox that could do that in a cleaner way? CC @YuriSizov

@YuriSizov
Copy link
Contributor

My first question is, why wouldn't it be a feature of LineEdit, to automatically adjust the width? Why would we only put it in the higher-order control?

If it's a feature of LineEdit, then SpinBox can have a proxy property to enable it without touching the theme, and SpinBox can have its own theme property exposed that would directly override the LineEdit's property.


In more general terms, I think we need utilize type variations for every customizable control which is an inner child of another built-in control. So themes can be created globally and granularly.

@KoBeWi
Copy link
Member Author

KoBeWi commented Aug 26, 2022

My first question is, why wouldn't it be a feature of LineEdit, to automatically adjust the width? Why would we only put it in the higher-order control?

The auto-adjustment I added adjusts the LineEdit to the maximum possible width achievable with the specified value range (.e.g for -100, 100 with step 1, the max width is 4). This can't be done in LineEdit.

@YuriSizov
Copy link
Contributor

YuriSizov commented Aug 26, 2022

The auto-adjustment I added adjusts the LineEdit to the maximum possible width achievable with the specified value range (.e.g for -100, 100 with step 1, the max width is 4). This can't be done in LineEdit.

Hmm, I see. This is a weird case for theme properties, to have minimum_character_width as one to begin with. But since we don't have a good way to set per-project default values for nodes, I guess we have to live with this.

I think it's worth adding a theme property to SpinBox as well, though, and then using the biggest minimum we have out of two to override the LineEdit's theme property. That way we preserve direct control for styling, if it is needed in a project. And then I guess this doesn't need to be an integer field minimum_character_count, it can be a boolean toggle fit_to_range_limits, or something.

@KoBeWi
Copy link
Member Author

KoBeWi commented Sep 26, 2022

Rebased.

I think it's worth adding a theme property to SpinBox as well, though, and then using the biggest minimum we have out of two to override the LineEdit's theme property. That way we preserve direct control for styling, if it is needed in a project. And then I guess this doesn't need to be an integer field minimum_character_count, it can be a boolean toggle fit_to_range_limits, or something.

I don't think this can be implemented without modifying LineEdit. Affecting the LineEdit's character count in any way requires adding override for the property, but then it's impossible to use "biggest minimum we have out of two", because adding override will shift the value in LineEdit.
(btw I thought you wanted max of 2 values, but now after reading it properly I'm confused what is a biggest minimum here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it easier to change minimum size of SpinBox
3 participants