Allowing the user to call NewFrame() multiple times without calling Render()

Note that this is never a good idea. But, allowing it reduce confusion
in the initial stage of setup.
This commit is contained in:
ocornut 2014-08-16 18:47:59 +01:00
parent 969b1e0563
commit ddf8b280e9

View File

@ -109,7 +109,6 @@
ISSUES AND TODO-LIST ISSUES AND TODO-LIST
- misc: allow user to call NewFrame() multiple times without a render.
- misc: merge ImVec4 / ImGuiAabb, they are essentially duplicate containers - misc: merge ImVec4 / ImGuiAabb, they are essentially duplicate containers
- window: autofit is losing its purpose when user relies on any dynamic layout (window width multiplier, column). maybe just discard autofit? - window: autofit is losing its purpose when user relies on any dynamic layout (window width multiplier, column). maybe just discard autofit?
- window: support horizontal scroll - window: support horizontal scroll
@ -148,6 +147,7 @@
- input: keyboard: full keyboard navigation and focus. - input: keyboard: full keyboard navigation and focus.
- input: support trackpad style scrolling & slider edit. - input: support trackpad style scrolling & slider edit.
- misc: not thread-safe - misc: not thread-safe
- misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
- optimisation/render: use indexed rendering - optimisation/render: use indexed rendering
- optimisation/render: move clip-rect to vertex data? would allow merging all commands - optimisation/render: move clip-rect to vertex data? would allow merging all commands
- optimisation/render: merge command-list of all windows into one command-list? - optimisation/render: merge command-list of all windows into one command-list?
@ -1247,7 +1247,7 @@ void NewFrame()
float scale = new_font_scale / window->FontScale; float scale = new_font_scale / window->FontScale;
window->FontScale = new_font_scale; window->FontScale = new_font_scale;
ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size; const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
window->Pos += offset; window->Pos += offset;
window->PosFloat += offset; window->PosFloat += offset;
window->Size *= scale; window->Size *= scale;
@ -1271,11 +1271,17 @@ void NewFrame()
// Mark all windows as not visible // Mark all windows as not visible
for (size_t i = 0; i != g.Windows.size(); i++) for (size_t i = 0; i != g.Windows.size(); i++)
g.Windows[i]->Visible = false; {
ImGuiWindow* window = g.Windows[i];
window->Visible = false;
window->Accessed = false;
}
// Create implicit window // No window should be open at the beginning of the frame.
// We will only render it if the user has added something to it. // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
IM_ASSERT(g.CurrentWindowStack.empty()); // No window should be open at the beginning of the frame! g.CurrentWindowStack.clear();
// Create implicit window - we will only render it if the user has added something to it.
ImGui::Begin("Debug", NULL, ImVec2(400,400)); ImGui::Begin("Debug", NULL, ImVec2(400,400));
} }