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

InputScalar: Inconsistent output behavior between smaller and bigger data types #8235

Open
Riztazz opened this issue Dec 17, 2024 · 0 comments

Comments

@Riztazz
Copy link

Riztazz commented Dec 17, 2024

Version/Branch of Dear ImGui:

1.91 Docking

Back-ends:

imgui_impl_sdl2

Compiler, OS:

Windows 10, MSVC 2022

Full config/build information:

Dear ImGui 1.91.0 (19100)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1929
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_sdl2
io.BackendRendererName: NULL
io.ConfigFlags: 0x00000480
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C06
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasViewports
--------------------------------
io.Fonts: 9 fonts, Flags: 0x00000000, TexSize: 4096,8192
io.DisplaySize: 3852.00,2087.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,4.00
style.WindowBorderSize: 2.00
style.FramePadding: 8.38,8.38
style.FrameRounding: 4.00
style.FrameBorderSize: 1.00
style.ItemSpacing: 11.00,5.00
style.ItemInnerSpacing: 5.00,5.00

Details:

My Issue/Question:

InputScalar for data types smaller than 4 bytes is clamped to min/max values and it is not for bigger types.
https://github.com/ocornut/imgui/blob/master/imgui_widgets.cpp#L2285
Would be a nice feature if it behaved for all types the same it does for smaller types

Screenshots/Video:

inputScalar.mp4

I've stumbled upon it while building node widgets for a graph
The code for the widget can be viewed here, Result of the node is a sum of two values controlled by InputScalar
https://gist.github.com/Riztazz/c90d71bb35950186e00762ab320dbd73

Minimal, Complete and Verifiable Example code:

ImGui::Begin("Example Bug");
        static uint8_t valueA = 0;
        static uint32_t valueB = 0;
        // Input -1 into the field and observe the result
        int step = 1;
        int fstep = 10;
        SetNextItemWidth( 200.f );
        InputScalar( "Test A", ImGuiDataType_U8, &valueA, &step, &fstep );
        SetNextItemWidth( 200.f );
        // Do the same, it will underflow
        InputScalar( "Test B", ImGuiDataType_U32, &valueB, &step, &fstep );
        Text( "A: %u", valueA );
        Text( "B: %u", valueB );
ImGui::End();
@ocornut ocornut changed the title Widgets(InputScalar): Inconsistent output behavior between smaller and bigger data types InputScalar: Inconsistent output behavior between smaller and bigger data types Dec 17, 2024
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