-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Splitter #319
Comments
EDITED 2018: If you are stumbling on this thread, read the post at the end of the thread, tl;dr; you can use SplitterBehavior in imgui_internal.h as a helper There's a Columns() API that does some of that, depending exactly what is your use case and what you are trying to do. Splitter is a rather vague term. For high-level layout you can possibly get away by implementing cheap splitters yourself: |
But yes I agree we need better moveable separator in general. |
thanks |
Where are you clicking for it to not work? You can replace InvisibleButton() by Button() to see them. |
Oops , seems i was trying with an old version of imgui , now i am switching to 1.45 and it works fine now ;) |
Reused this idiom in an app. The code is app specific here, we'd want to formalize into an official API call once we can figure out an api to handle n-part splitting.
Usage
|
nice. move tutorial will be great! |
Hi, I have try to change the mouse cursor once we are over the split bar, but nothing is changing : if (GImGui->HoveredIdAllowHoveringOthers && horizontal_splitter)
|
@ghost Sorry I missed this question. Is your binding applying the hardware mouse cursor as requested by ImGui? (by reading GetMouseCursor). ImGui can display a software cursor for you but hardware are much much more pleasant so it is better to avoid them if you can. FYI Today I have added a It previously worked because I was using an alpha of 0.0 for the splitter hovered color, so when hovering a button you wouldn't see that the splitter was actually seeing itself as hovered as well. With that new flag we can now implement a splitter that has a hovered color and still allow for overlapping widgets. |
I just modified two lines for correct visual effect:
and
|
I'm currently working on splitter toward formalizing Docking #351 features. If you are using the old splitter patterns, here's a little update for the code to handle mouse going out of limits more gracefully. Replace:
With:
I will create a helper for it as it is a common pattern for dragging operations. |
FYI the pattern above has been reworked and included in imgui.cpp for internal use (via
You can now reproduce the behavior of the function listed above with a smaller function:
However I don't think that old signature is good, and not including this facade in the public API. I'm working on a better higher-level system. Mostly posting this here for the records. Test code:
|
@ocornut here, |
@nikki93 Correct, I edited my post above. Thanks! (It doesn't affect anything on the git repository as that Splitter() function was just part of my message.) |
…which is helpful to reduce visual noise. (#319)
If you are using SplitterBehavior() from imgui_internal.h, note that I have inverted the 2 first parameters From Which is more consistent with other internal functions of the same type. |
We had a question re the best way to handle nested child Windows using the splitter with regards to Horizontal layout ? Say we are looking at 1 vertical splitter and each vertical half has multiple horiz splitters. We are trying to create the ability to do the layout from config file and have each container area (Child windows that is not visible) have the ability to add multiple panels (Child windows) with possible splitters in them. If we do them one container at time then the draw cursor is not at the appropriate place so the SameLine() call cannot be used. Should we be using SetCursorPos() to position before drawing every container ? Or is there a better way ? Something like a Horizontal layout stack for all subsequent calls that can be popped to bring us back to line we started ie the original child container window pos ?? |
Hello @turmansky, |
Thx. We will take a look at that branch. |
Yes will eventually. |
Hey, i am using a Binding for ImGui (ImGui.NET), which is the reason why i can't use private void DrawSplitter(bool split_vertically, float thickness, ref float size0, ref float size1,
float min_size0, float min_size1, float size = -1.0f)
{
var backup_pos = ImGui.GetCursorPos();
if (split_vertically)
ImGui.SetCursorPosY(backup_pos.Y + size0);
else
ImGui.SetCursorPosX(backup_pos.X + size0);
ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero);
ImGui.PushStyleColor(ImGuiCol.ButtonActive, Vector4.Zero);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.6f,0.6f,0.6f,0.1f));
ImGui.Button("##Splitter", new Vector2(split_vertically ? thickness : size, !split_vertically ? thickness : size));
ImGui.PopStyleColor(3);
ImGui.SetItemAllowOverlap(); // This is to allow having other buttons OVER our splitter.
if (ImGui.IsItemActive())
{
float mouse_delta = split_vertically ? ImGui.GetMouseDragDelta().Y : ImGui.GetMouseDragDelta().X;
// Minimum pane size
if (mouse_delta < min_size0 - size0)
mouse_delta = min_size0 - size0;
if (mouse_delta > size1 - min_size1)
mouse_delta = size1 - min_size1;
// Apply resize
size0 += mouse_delta;
size1 -= mouse_delta;
}
ImGui.SetCursorPos(backup_pos);
} The issue is that the original snippet isn't working at all. |
It’s already in ImGui as you pointed out :)
Maybe see how your binding could optionally expose/export the internal function(s) you want, otherwise it is probably a small patch to add it yourself?
No ETA for making it in public api yet.
|
By the way, even though the current function differs from the original snippets, looking at your code it seems like it should work. So that’s also worth investigating!
|
…mit of the function, not sure why). (#319)
Please note that #1710 just added support for resizable child windows. e.g. "Demo->Examples->Simple Layout" now does: ImGui::BeginChild("left pane", ImVec2(150, 0), ImGuiChildFlags_Border | ImGuiChildFlags_ResizeX);
for (int i = 0; i < 100; i++)
{
char label[128];
sprintf(label, "MyObject %d", i);
if (ImGui::Selectable(label, selected == i))
selected = i;
}
ImGui::EndChild();
ImGui::SameLine();
....
ImGui::BeginChild("item view", ....); Double-clicking fits to required size. |
Hi
is it possible to add splitter between 2 widgets ? . if no then i hope you consider it as a todo :) , because changing layout space in realtime is really good thing .
The text was updated successfully, but these errors were encountered: