Imgui: Add more small widgets using "click-and-drag" interfaces

Created on 23 Feb 2015  路  8Comments  路  Source: ocornut/imgui

Nothings preventing them from being build with current ImGui setup, but we need some small widget using this sort of interface.

e.g.

  • Dials for values (bounded and infinite), click and drag horizontally to adjust value
  • Dials for angles, click and drag over a circle to adjust value
  • Sliders than takes no space until clicked on
  • 3D sphere for rotation
  • etc.
    That type of stuff.
enhancement

Most helpful comment

image
Nice, the internal API made it easy to fix the colors; just needs the culling sorted and mouse interaction. The code supports a direction widget as well, shown here.
Oh, and here's the original, for reference:
image

All 8 comments

3d rotation would be real cool

The 3D rotation widgets in AntTweakBar are perfect.... Be great to have them in ImGui too.

image
I had a quick play with dropping the AntTweakBar code into ImGui for a quat rotator.
It looks promising, but needs a couple of features from ImGui. The code works by projecting the 3D geometry to 2D so it can easily integrate with the 2D engine in ImGui.

  • There is no way to pass vertex colors to the path render/fill code (hence the flat shaded appearance). I don't know how easy this is to fix.
  • There is no way to pass cull direction for a given set of triangles. The backend device API usually has culling turned off from what I can see. But because the sphere is projected it needs culling. I guess this is trivial enough to do in software....

Nice!
For vertex colors you can pass individual vertices to the lowest-level ImDrawList API.

draw_list->PrimReserves(3, 3); // 3 indices, 3 vertices
draw_list->PrimWriteIdx(draw_list->_VtxCurrentIdx+0);
draw_list->PrimWriteIdx(draw_list->_VtxCurrentIdx+1);
draw_list->PrimWriteIdx(draw_list->_VtxCurrentIdx+2);
draw_list->PrimWriteVtx(pos, uv, col);
draw_list->PrimWriteVtx(pos, uv, col);
draw_list->PrimWriteVtx(pos, uv, col);

I realize it is a little awkward to draw a single triangle, but we don't have the common helper for a single triangle with 3 different uv and 3 different colors.
You can (and its better) call PrimReserve() a single time.

I could possibly add helpers for that.

No culling in typical backends sorry, as you said it is trivial to do in trivial - we do potentially add helpers to figure out clockwiseness from a triangle.

image
Nice, the internal API made it easy to fix the colors; just needs the culling sorted and mouse interaction. The code supports a direction widget as well, shown here.
Oh, and here's the original, for reference:
image

Nice!
Would you like to post the code for it?

Sure, of course. The code is a bit untidy currently - due to the different nature of TweakBar (and I haven't finished with the mouse interaction). I should get some time before the weekend to finish it up, then I'll send it along.

I posted it to the screenshots (3) thread. The code is here: https://github.com/cmaughan/imgui.

Was this page helpful?
0 / 5 - 0 ratings