-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Fix Spinbox display does not round properly when using decimal custom arrow steps #97573
Conversation
a1f2449
to
371ef98
Compare
791cf21
to
bf36c46
Compare
This comment was marked as outdated.
This comment was marked as outdated.
bf36c46
to
1319a73
Compare
a24b775
to
9a73644
Compare
I think it's fixed now? |
scene/gui/spin_box.cpp
Outdated
bool original_do_round = is_using_rounded_values(); | ||
double step = get_step(); | ||
double temp_step = get_custom_arrow_step() != 0.0 ? get_custom_arrow_step() : get_step(); | ||
_rounded_values = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this? rounded
should always make the value rounded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, now that you mention it, I think it should be removed too. It's been awhile but I think the reasoning was the value was not updating if the arrow_step was too low. But I guess that logic is flawed. I'll remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, so if i set the step to 0.8 the value cannot get beyond 2.
Maybe the rounding logic is flawed somehow? Or is that not how I'm supposed to use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pre-existing bug, so it can be fixed later.
Not sure what's the expected behavior here, maybe rounded
could force the arrow step to be at least 1.
Then again, when both steps are 0, the arrows don't work either.
9a73644
to
011c87b
Compare
Maybe we could give set value () an optional custom_step parameter or maybe that's a bad idea |
What about the |
|
Is it possible to hide it from the inspector somehow? |
Yes, by using |
Okay maybe for another pr if I can figure out how to use it 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine now.
You could maybe add some comments for the new code, on why is it like that.
011c87b
to
f820558
Compare
f820558
to
ab0a102
Compare
ab0a102
to
afeecad
Compare
@KoBeWi void SpinBox::_update_text(bool p_keep_line_edit) {
String value = String::num(get_value(), Math::range_step_decimals(get_step()));
double value_for_calculating_precision = get_value();
int decimal = 0;
while((int)value_for_calculating_precision != value_for_calculating_precision) {
value_for_calculating_precision *= 10;
++decimal;
if(decimal >= 10) {
break;
}
}
String value = String::num(get_value(), decimal); |
I think that's a separate issue. |
Thanks! |
Fixes #97561