-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Modal window flickers when shown? #690
Comments
Hi, The problem is that TextWrapped() relies on the window width (content width) which is undefined when you first open a window with The easy solution is to set an explicit width via e.g. To draw the icon you could just use SetCursorPos(), Text(), SetCursorPos(), TextWrapped(). You can also lock the X position with BeginGroup()/EndGroup() but it isn't needed here as you have a single TextWrapped() element. |
I was under the impression that it would freeze the window width and resize vertically as items are added but that's not the case (and if it was it would probably have the same problem as the auto resize option). I'd have to specify a height big enough for everyone which isn't really possible nor desirable. Maybe I'll play with the clipping rectangle to avoid the window being shown for the first frame and let it have a chance to decide on its size. Or maybe not, since imgui is a programmer's UI, It's not likely that people will demand fixes for something like that :) Thanks! |
Woot, I decided to draw the icon using your technique and the flicker is gone! if ( m_Icon != NULL )
{
ImVec2 size = ImGui::CalcTextSize( m_Icon );
ImVec2 pos = ImGui::GetCursorPos();
float save_y = pos.y;
pos.y += size.y * 2;
ImGui::SetCursorPos( pos );
ImGui::Text( "%s", m_Icon );
pos.x += size.x;
pos.y = save_y;
ImGui::SetCursorPos( pos );
ImGui::TextWrapped( "%s", m_Text );
}
else
{
ImGui::TextWrapped( "%s", m_Text );
} So I guess all is good now :D Thanks again! |
It's a totally legit question and i'd like to solve it. If width is known then the vertical extent of TextWrapped() will be known on the first pass so there shouldn't be a problem. It's just that auto-width + textwrapped can't work together. Maybe (400,-1) as size, I don't have the code in front of me but there should be a way to keep auto resize on the vertical axis but not the horizontal one. Or you can also set explicit text wrapping x position instead of using TextWrapping() that would also work. |
Re- on the discussion above
Without That also works:
I have fixed a minor bug now where TextWrapped() would override the wrap position is one was already set. So:
Would have lost the explicit 400 before that fix. |
I've implemented a message box dialog on top of imgui, but it seems to flicker a little when the dialog is shown as if it is deciding how to layout the controls in it.
This screenshot was taken just before the window accommodates its contents:
After maybe just one frame, the final window is shown until its closed:
It could be something wrong with my code, but I decided to open an issue just to make sure it's not a known problem.
The text was updated successfully, but these errors were encountered: