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

doubles and various (un)signed integer lengths #708

Closed
cgloeckner opened this issue Jun 20, 2016 · 13 comments
Closed

doubles and various (un)signed integer lengths #708

cgloeckner opened this issue Jun 20, 2016 · 13 comments

Comments

@cgloeckner
Copy link

Hi, is there any support planned for doubles or various (un)signed integer lengths?

@ocornut
Copy link
Owner

ocornut commented Jun 20, 2016

Hello,
Which widgets were you thinking? Probably not soon for all widgets, but if you want to input them with keyboard like InputInt you can create a function that does sprintf + InputText + scanf to work with any type you want.

@cgloeckner
Copy link
Author

I was thinking about InputInt as guessed. Have you got an example for that sprintf + InputText + scanf? I cannot imagine how oO

@ocornut
Copy link
Owner

ocornut commented Jun 20, 2016

Print your number into a string, call InputText, when it return true scanf back from string to number. Literally 4 lines of code. Look up how those functions work.

@cgloeckner
Copy link
Author

cgloeckner commented Jun 20, 2016

My problem is to avoid the additional string handling, because (1st) an extra variable is necessary to keep the string state and (2nd) the imgui API doesn't support std::string for writing purposes. Or did I get something wrong?

@ocornut
Copy link
Owner

ocornut commented Jun 20, 2016

bool InputDouble(const char* label, double* mydouble)
char buf[64];
sprintf(buf, "%g", *mydouble);
if (ImGui::InputText("....."))
    sscanf(buf, "%s", mydouble);

@cgloeckner
Copy link
Author

I'm a bit confused: Text (like in the example) or InputText like above?

@ocornut
Copy link
Owner

ocornut commented Jun 20, 2016

Sorry I meant InputText, was a typo..

@cgloeckner
Copy link
Author

Ok. Once I need more then plain keyboard input (like +/- buttons), I'd need to workaround-build this, too.. right?

@ocornut
Copy link
Owner

ocornut commented Jun 20, 2016

Yes. But for integer than that are smaller than int you can also just copy your value into an int and call any Int function.

@cgloeckner
Copy link
Author

cgloeckner commented Jun 20, 2016

True, but the overflow/underflow won't be handled correctly. I'd prefer an imgui-internal solution ;-)
Have you done any research on pitfalls for changing the current implementation towards that feature?

@ocornut
Copy link
Owner

ocornut commented Jun 20, 2016

I'd prefer an imgui-internal solution ;-)

Well I'd prefer a full-time job working on ImGui!

What overflow?
You can set limits to InputMin, SliderMin, etc.
It's really low priority, I've got millions of things to do on ImGui and already overwhelmed with tasks that are arguably more important. This is sort-of rare use case and there are perfectly usable workaround so it is unlikely I would want to work on a better solution anytime soon.

@cgloeckner
Copy link
Author

Ok thx :)

@ocornut ocornut closed this as completed Jun 20, 2016
ocornut added a commit that referenced this issue May 3, 2018
…putScalar(). Removed internal.h InputScalarEx() to InputScalar(). Removed cheap-relative-operators support in recently added U32 data path, since this is heading toward being legacy code. + Fixed InputDouble parsing code. (#1011, #320, #708)
ocornut added a commit that referenced this issue May 3, 2018
…tor and no absolute values so we will be able to manipulate double as well as 64-bit integers. (#1011, #708, #320)
ocornut added a commit that referenced this issue May 3, 2018
ocornut added a commit that referenced this issue May 3, 2018
…ScalarN(), removed InputFloatN(), InputInt(). Note that DragInt2/3/4 will %f format strings will currently be broken. (#320, #643, #708, #1011)
ocornut added a commit that referenced this issue May 3, 2018
ocornut added a commit that referenced this issue May 4, 2018
…h various ranges/limits. Note that Drag/Slider/Input currently fail if the format string doesn't preview the actual value. Will fix next. (#320, #643, #708, #1011)
@ocornut
Copy link
Owner

ocornut commented May 4, 2018

FYI, I have added functions in a branch to work with float, double, 32/64 bits, signed and unsigned (and in a proper lossless manner, as previously some functions didn't work great with big integers).
See #643 for details.

ocornut added a commit that referenced this issue Sep 11, 2018
…ed or with a power curve erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075).
ocornut added a commit that referenced this issue Feb 27, 2019
…6 data types. We are reusing function instances for larger types to reduce code size. (#643, #320, #708, #1011)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants