Repository navigation
Conversation
|
Looks good. Will not be implemented? |
imgui development is on hold for a few months and this is not a priority but it should eventually be merged in some way or another. |
|
There is a bom in imgui.cpp and imgui_internal.h (and maybe others) that shouldn't be there. |
|
Im just going to raise this question then searched for this issue. |
|
@b1tc0der I'm thinking about that. I need to find some time to update and wrap up code. |
|
@thedmd I think you've done an awesome job on this :-) If you need any help with wrapping up this code I am happy to help. |
|
@thedmd I just found out the awesome job you made with the node editor. I am really interested in it because I was tasked with creating a small tool to help teaching design students the ropes of mathematics used in CG. I would love to have a blueprint-like interface for the software, but building something on top of the Unreal Engine would be complete overkill. |
|
@francesco-cattoglio I just published all code related to Node Editor. You can find it here. |
|
@thedmd ty so much! I'll keep you posted about any good or bad news that will show up in 2018! |
|
It would be awesome if this could get merged into mainline. I'm trying to use @thedmd's awesome node editor, but its current code is built against v1.50 and my code base is all v1.60. I'm hoping to clean up the node editor's code, have it compile against 1.60 (once this is merged), and submit a pull request to the node editor's repository. Having these layout options wouldn't hurt either. @ocornut, any chance you might be able to look at this soon? |
|
@sherief Unfortunately I don't think this would realistically get merged soon, I have too much open topics on my plate and need to close the Nav then Viewport/Docking features before I embark into layout stuff. I am however going to try replacing the 3 IndentX, GroupOffsetX, ColumnsOffsetX with ImVec2 (without using the .y coordinates at all) so ease with merging this code (those are the main reasons for conflicts afaik). I consider those 3 variables a mess at the moment, I don't mind adding 3 unused float per-window to facilitate this work. EDIT I tried that and it didn't look like it made much of a difference in term of the patch. |
|
Here's a quick attempt at merging this with current master It looks like there are some spacing bugs, I don't know what caused them. Maybe thedmd may want to look at it. |
|
Totally understandable. Nav, viewports, and docking are also incredibly useful for everyone. Thanks a ton! |
|
Bounds measurement code relied heavily on internal positioning code and cursor placement, if I recall correctly there were changes and unfortunately errors in spacing are expected. I will look into that, since this is one of the features used in node editor. |
|
Rebased to resolve conflict with master branch. |
2ad726b to
437adbe
Compare
Thank you! It works well with setting cursor pos, although it's somewhat cumbersome, so I'm curious what you mean by implementing a custom widget using Behaviour API? |
since im using it for my custom widget this is how i do it |
I think there is no other that this function appeared around 3 years after this PR was open 😅 |
|
Measuring springs I'm toying with an idea of an API that does return size of a spring. What is holding me up is breaking that perfect frame behavior. Notice that whatever you throw in stack layout it is in correct place in very same frame. There will be no flickering. The problem is spring size information is available after top most stack layout ends. This mean returned size will be lagging one frame, because you do need it while doing layouts. This in turn can influence layout measurements and start feedback look of updates that will launch layout size to infinity if not played correctly. I will give such API a try with next update/rebase. We will see how practical it will be. I think I will make it internal first because of that one frame lag. |
|
Yeah that makes sense. I implemented versions of @wyxather idea, calling them It generally works well, but I ran into both the issues you mention. The layout is off by a frame, which is mostly fine for static layouts, but once you start resizing a window it obviously looks a little strange. I also had the infinite size problem, eg using a standard |
|
@ocornut Omar plz merge this! Signed an ImGui fan |
|
Hi, I'm very curious about the current status and whether there are plans to merge these features into the main branch, it's not clear to me as I've read different things. Thanks for your time! |
|
I plan to allow for this or an equivalent feature by revamping the layout system so this can be distributed as an extension rather an a patch. I unfortunately can't provide any solid timeline. Note the variation here: I believe this PR should ideally use the -external approach and the non-external versions could/should be removed, imho. As ultimately this is the direction we are aiming at. |
|
cant wait for this PR to land !! ;-) |
|
Rebased on 19267. Changes:
|
Stack layout expected user to interleave horizontal/vertical layouts. Mixing same type layout in a row isn't supported. Sorry, this will make layout math more complicated. Stack layout work hard to produce correct result within same frame. I'm not sure if case provided by your example can be resolved in single pass. Your example would probably benefit from tables:
{
static float x, y, z;
ImGui::BeginTable("##properties", 2);
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::Text("Scale");
ImGui::TableNextColumn();
auto cellWidth = ImGui::GetContentRegionAvail().x;
ImGui::BeginHorizontal("##showDemoh1", ImVec2(cellWidth, 0.0f));
ImGui::Button("ICO");
ImGui::Spring(0.0f);
auto totalButtonsWidth = ImGui::CalcTextSize("ICO").x + ImGui::CalcTextSize("RESET").x + style.FramePadding.x * 4.0f; // 'ICO' + 'RESET' + spacing between them
auto totalLabelTextWidth = ImGui::CalcTextSize("X").x + ImGui::CalcTextSize("Y").x + ImGui::CalcTextSize("Y").x;
auto totalSpacingWidth = style.ItemSpacing.x * 7.0f; // spacing between after 'ICO', 'X', 'Y', 'Z', 'RESET', and two springs
auto inputContentWidth = cellWidth - totalButtonsWidth - totalLabelTextWidth - totalSpacingWidth;
auto inputWidth = inputContentWidth / 3.0f;
ImGui::Text("X");
ImGui::SetNextItemWidth(inputWidth);
ImGui::InputFloat("##X", &x);
ImGui::Text("Y");
ImGui::SetNextItemWidth(inputWidth);
ImGui::InputFloat("##Y", &y);
ImGui::Text("Z");
ImGui::SetNextItemWidth(inputWidth);
ImGui::InputFloat("##Z", &z);
ImGui::Spring();
ImGui::Button("RESET");
ImGui::EndHorizontal();
ImGui::EndTable();
} |
|
Hi, Some info for the users of @thedmd's Stack Layout branches (March 2026 rebase): three PRs that correct issues are available. I thought I ought to mention them here, after posting them on thedmd repo. 1. Content submitted after a nested layout is not displayed.This is the cause of @wkster's report above (the 2. Small fixesThree smaller fixes are proposed in this other PR: compilation warnings, a 3.
|
Stack Layout updateAll four Stack Layout branches are rebased on Dear ImGui 1.93.0 WIP (
Breaking change
Fixes
|
|
Thanks for rebasing and updating! |
|
I agree with Omar. The external version is much easier to maintain and this is the one I use (and would advise to use). |
|
Sure. I will drop non-external version in next update. |
…le is submitted in a horizontal layout (e.g. a menu bar). Items in cells used the layout type of the host window, so each ItemSize() in a cell ended with SameLine(). BeginTable() now sets a vertical layout until EndTable(). Tables with their own child window were not affected.
…en a hook callback adds a hook. A callback calling AddContextHook(), e.g. an extension registering its hooks on first use from inside another hook, could reallocate g.Hooks while CallContextHooks() iterated it with a range-based for loop. Later hooks were then skipped or read from freed memory.
Stack Layout v2.2With this update, branches PR does grow to three commits, because CI needs updating. Stack Layouts remain a single commit.
I did run PR through review and I did put some work to Stack Layouts, resulting in v2.2 version. v2.2 highlightsThe full list is in the changelog at the top of Breaking:
Changes:
Known limitations
|
|
@thedmd, thank you for this update! Dear ImGui Bundle now uses it as is, and it replaces all five of my StackLayout patches. All my C++ and Python demos + the node editor tests inside the bundle run without a single regression (DragFloat3() and friends also now work in horizontal layouts), so that is great! |
|
That's great news |
|
Very cool work :) Out of curiosity, what would it take to make stack layouts completely external to imgui such that users wouldn't need to use your custom branch? (sorry if I missed some discussion about this earlier in the thread) |
|
The signature and feature set of ItemSize/ItemAdd needs to be redesigned and it is planned in order to support many other features. |


PR was recreated due to lost references after changing fork origin. That was not my intention, sorry.
For comments please look at previous PR.
After searching for some layout related solution I decided to pull my own after everything I found was only issues listed on this repository (#97).
I think BeginHorizontal/EndHorizontal API was promissing, so I gave it a shot. There is how code look like and what results it produce.
I tried to bend ImGui to help me layout widgets easly. This is what API I came up with:
This code works by caching sizes of widgets in first frame and positioning them in next. Layout is evaluated only if something related to size changes.
Code was crafted in a few hours so it may be cruel in some places. I tried to be as consistent with ImGui code style. Please grab this code and try to use it. Let me know what you think about this solution. : )
Example code show one use case. There are however many more. Widgets can be interleaved by Springs which may have zero (sticking widgets together) weight or greater than zero. Free space will be divide according to them. There is an option to provide spacing which acts like in SameLine() function but works for both horizontal and vertical layouts. Layouts can be mixed together, you may put one in another as you can see on example gif.