-
-
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
SetScrollHere and one-frame delays #1526
Comments
I'm really interested in making this delay disappear, even if it's a lot of work. I don't have a clue of where to start, I've been looking at the rendering code but I'm quite lost... any guidance would be much appreciated :) |
This is the first commit with the scrolling demo in it. Hopefully it will be easier to experiment in a simpler version of imgui :) For visualization puposes, this reproduces the one-frame delay (replace the for (int line = 0; line < 100; line++)
{
if (track && line == track_line) {
ImGui::Text("Line %d ====", line);
ImGui::SetScrollPosHere(i * 0.50f); // 0.0f,0.5f,1.0f
} else {
ImGui::Text("Line %d", line);
}
} I tried changing where the Cursor variables are updated (i.e. tried to do it soon as SetScrollPosHere is called) but had no success. |
v1.11 repros this if you backport the scrolling demo :) paste this around line 6033 if (ImGui::CollapsingHeader("Scrolling"))
{
static bool track = true;
static int track_line = 50;
ImGui::Checkbox("Track", &track);
ImGui::SameLine(); ImGui::SliderInt("##line", &track_line, 0, 99, "Line %.0f");
ImGui::BeginChild("asd", ImVec2(ImGui::GetWindowWidth() * 0.25f, 200.0f), true);
for (int line = 0; line < 100; line++)
{
if (track && line == track_line) {
ImGui::Text("Line %d ====", line);
ImGui::SetScrollPosHere();
} else {
ImGui::Text("Line %d", line);
}
}
ImGui::EndChild();
} |
@franciscod What are you trying to solve exactly? Which problem do you have with that? It's more likely that the more natural solution would be to adjust the user code. What the demo code does (altering the look of the output based on expected scroll value) is actually quite unusual, in a way the demo is faulty here. Another possible solution is to have (I'd like to rework the SetNextWindow/SetWindow entry points to be more flexible. Right now we have too many of them including some using |
Oh, that makes a lot of sense: at the time of I want to have a way to animate a smooth scroll (set the scroll y of THIS frame) a child on a window. I've learned that the only way is setting the scroll before the child's |
Scrollbars seem to have this 'one-frame scroll' ability, though... |
You may also be able to reframe the problem or solve it another way but without more information we can't imagine it. Just create yourself a function for that:
Because they are processed in Begin() before the scrolling is locked. |
Variant, this will also work:
The problem from my point of the view (or, the API point of view) is that there are several issues with scrolling and SetXXXWindow functions and I probably need to tackle them together, so I can't just add this entry point in the API. But this function (using |
Awesome! I'll try that as soon as I can and comment on how it worked on my usecase. Thank you Omar, for the in-depth explanations and suggestions :) |
That Not sure if you want to leave this issue open. Maybe open another one for improving the scrolling API? I'm happy to help with that. |
FindWindowByName gets tricky on child windows... see #1698 |
@franciscod I have added a |
Interesting! I'll check that out. We're already importing imgui_internal.h and using a fair deal of non-exported stuff :) Thanks! |
I can confirm |
With commit 7380b98 I have moved |
When using SetScrollHere (example: Demo Window -> Layout -> Scrolling -> drag the "Line = 50") the scrolled content has a ~1frame delay compared with the color highlight. Is there any way to remove this delay?
The text was updated successfully, but these errors were encountered: