-
Notifications
You must be signed in to change notification settings - Fork 379
Add input_scalar
and allow setting float input precision
#544
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
Conversation
* allow setting display format for input_float
Should we add |
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.
Looks great! I think if you rebase and then run cargo fmt --all
we should be basically good to go!
@@ -530,19 +533,36 @@ impl<'ui, 'p, L: AsRef<str>> InputFloat<'ui, 'p, L> { | |||
value, | |||
step: 0.0, | |||
step_fast: 0.0, | |||
display_format: None, |
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.
we should default this display format to "%.3f"
, as it originally was. That also means that display_format can actually become F
instead of Option<F>
, and start life with the type &'static str
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.
Just for the float case I presume? For InputScalar
I'd definitely stick with letting imgui pick the format.
pub fn build(self) -> bool { | ||
let value: $MINT_TARGET = (*self.value).into(); | ||
let mut value: [f32; $N] = value.into(); | ||
|
||
let (one, two) = self |
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.
same thing with the display format as above
@@ -551,6 +551,30 @@ impl<'ui> Ui { | |||
{ | |||
InputInt4::new(self, label, value) | |||
} | |||
#[doc(alias = "InputScalar")] |
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.
Can we add some doc comments here explaining what InputScalar
is, and maybe in particular how it differs from the other Input
types (something about basically "let's you do this with u64s and other data types than float or int").
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.
Added a comment in 41c93de.
Personally, as long as Dear ImGui has both, confusingly, I'm fine with us having both too. It's a bit odd, but since we can do this all with generics, our |
Are you sure about that? Maybe it still shows up when
|
Ahhh this is a cargo problem that we run into! Try running cargo clean and then going again. That's really not great and I'm sorry about that. We have too many gliums |
No problem! I also just pushed simplifying our support of I didn't realize the step issue! Glad to know about that. That lead to me to check through the implementation, and.... So I agree, but I'd like to accept this PR now and then run What do you think about that plan? |
Sounds good to me. Thanks again! |
ach, forgot to name ya in the changelog. will push that and the input float deprecation stuff now. thanks! |
Continuation of #490, closes #489
I haven't been able to test it yet since the examples fail to build on the main branch.