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

The length of ImGui::Separator() not correct #25

Closed
ketoo opened this issue Mar 5, 2020 · 4 comments
Closed

The length of ImGui::Separator() not correct #25

ketoo opened this issue Mar 5, 2020 · 4 comments

Comments

@ketoo
Copy link
Contributor

ketoo commented Mar 5, 2020

The issue showed as below:

image

The length of the line should the same length as the window.

@Nelarius
Copy link
Owner

Nelarius commented Mar 6, 2020

Oh shoot, I'm not sure I have a good solution for this right now 😰

When ImGui::Separator is called, we don't yet know the size of the node because imnodes::EndNode hasn't been called yet. So the ImGui::Separator call uses the size of the current window, which is the canvas, I guess? 😬

I will have to create a list of known issues or something, and add this there until I can figure out what to do about this.

EDIT: in general, this is related to the problem of layout using imnodes: you also have to manually "align" your UI elements on the right side of the node for the same reason. I will have to investigate better ways of handling window size.

EDIT2: it also looks like ImGui::PushItemWidth has no effect on ImGui::Separator 😞

@Nelarius
Copy link
Owner

Nelarius commented Mar 7, 2020

Added a mention of this in the README for now, thanks for reporting this!

@Nelarius Nelarius closed this as completed Mar 7, 2020
@ketoo
Copy link
Contributor Author

ketoo commented Mar 8, 2020

Thanks, I use a small button to meet the same goal.

@hiroMTB
Copy link

hiroMTB commented Oct 1, 2023

This can be solved by similar approach like #167 (comment)

But for Separator() we overwrite window->Size.x

ImGuiWindow* window = ImGui::GetCurrentWindow();
  
int xbackup = window->Size.x;
window->Size.x = window->DC.CursorPos.x + width;

ImGui::Separator();

// don't forget to tidy up
window->Size.x = xbackup;

I tested and can confirm it works but somehow Separator's line became slightly longer than node width like 10%.
It might be good to do this overwrite window variable inside BeginNode() so that all imgui widgets work fine until imgui officially supports this kind of feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants