-
Notifications
You must be signed in to change notification settings - Fork 564
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
ed::EditorContext::LoadSettings() - inverted "m_VisibleRect" test #159
Comments
outputs to second file automatically on startup/shutdown, both of which are bad caveats that we have to fix. but it works, assuming this is fixed: thedmd/imgui-node-editor#159
Idea behind this change is to save visible area and restore view using this rectangle. This way when you open editor in window with different size, you will see same content as when closing. Does it work differently for you? |
It is broken. When settings are saved, the view rectangle is such that This is serialized correctly on close, and parsed (in ed::EditorContext::LoadSettings() ) correctly on open. All valid deseralized settings will fail the I found that if I inverted the test, this causes the original rectangle AND zoom to be used, and then the closed and re-opened views are the same. Is the problem that the zoom is set to zero in Is the else clause the one that is triggered when:
Because, the else clause is always called for me, which makes the view different every time between close and open with the same window size. |
@crolando I'm trying to tackle this problem. Let's investigate in more details.
New code save When Last passed argument '0.0f' is not zoom, but animation duration - telling action to navigate instantly. I argue that the code is correct. Am I missing something? if (ImRect_IsEmpty(m_Settings.m_VisibleRect))
{
m_NavigateAction.m_Scroll = m_Settings.m_ViewScroll;
m_NavigateAction.m_Zoom = m_Settings.m_ViewZoom;
}
else
{
m_NavigateAction.NavigateTo(m_Settings.m_VisibleRect, NavigateAction::ZoomMode::Exact, 0.0f);
} |
Thanks for the write-up - I need see time before I can get back to it. |
After what I said, I found other unrelated issue that made |
@crolando I pushed fix that may help. Can you confirm it on your side? |
Hey, first time trying to use the library and I am experiencing this very same issue with the code from the simple_example.cpp. Great work btw! |
Hey, Do you by any change have a repro of this issue? Thanks! |
I'm back! Thank you for taking the time to debug and fix this. Everything is working on my end now on both master and develop branch. I believe you fixed it with the "first frame" bug fix to @thedmd I am willing to close this. Should we wait for @mtrebi 's repro? |
I'm fine with closing this. Thank you for confirming issue is solved. |
im on the develop branch.
in imgui_node_editor.cpp..
in ed::EditorContext::LoadSettings() ...
line 2045 there is this if statement, that guards assigning the deserialized m_Settings to the m_NavigateAction, specifically the scroll and zoom:
I think this test is inverted. That is, that it should read:
if (!ImRect_IsEmpty(m_Settings.m_VisibleRect))
I found that when I invert this test, then my scroll and zoom deserialization works correctly.
The json that is saved out during normal serialization has a valid rectangle like this:
"visible_rect":{"max":{"x":1623.708251953125,"y":-1014.2291259765625},"min":{"x":718.125244140625,"y":-1469.4290771484375}}
So the current code looks at that valid rectangle, and ImRect_IsEmpty correctly returns "false" (because it's not empty), and this skips the scroll and zoom assignment. What happens next is the "else" clause is used, which recomputes and uses new zoom and scroll values. So this "throws out" the deseralized zoom and scroll from the json file, and gives you a default-ish zoom and scroll.
The text was updated successfully, but these errors were encountered: