Avoid marking settings as dirty when window is marked unsaved + minor FocusWindow() optimisation

This commit is contained in:
ocornut 2015-01-04 18:23:30 +00:00
parent 4bccc06933
commit 2268b098e0

View File

@ -202,6 +202,7 @@
- widgets: checkbox/radio active on press, is that standard/correct ?
- widgets: widget-label types of function calls don't play nicely with SameLine (github issue #100) because of how they intentionally not declare the label extent. separate extent for auto-size vs extent for cursor.
- widgets: IsItemHovered() returns true even if mouse is active on another widget (e.g. dragging outside of sliders). Maybe not a sensible default? Add parameter or alternate function?
- widgets: activating widget doesn't move parent to front
- main: make IsHovered() more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
- main: make IsHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
- scrollbar: use relative mouse movement when first-clicking inside of scroll grab box.
@ -2361,7 +2362,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
window->IDStack.resize(0);
ImGui::PushID(window);
// Move window (at the beginning of the frame to avoid lag)
// Move window (at the beginning of the frame to avoid input lag or sheering)
const ImGuiID move_id = window->GetID("#MOVE");
RegisterAliveId(move_id);
if (g.ActiveId == move_id)
@ -2371,6 +2372,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
if (!(window->Flags & ImGuiWindowFlags_NoMove))
{
window->PosFloat += g.IO.MouseDelta;
if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
MarkSettingsDirty();
}
FocusWindow(window);
@ -2434,6 +2436,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
if (g.HoveredWindow == window && IsMouseHoveringBox(title_bar_aabb) && g.IO.MouseDoubleClicked[0])
{
window->Collapsed = !window->Collapsed;
if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
MarkSettingsDirty();
FocusWindow(window);
}
@ -2482,6 +2485,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
window->SizeFull = ImMax(window->SizeFull, size_auto_fit);
else
window->SizeFull = size_auto_fit;
if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
MarkSettingsDirty();
}
else if (!(window->Flags & ImGuiWindowFlags_NoResize))
@ -2498,6 +2502,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
// Manual auto-fit
window->SizeFull = size_auto_fit;
window->Size = window->SizeFull;
if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
MarkSettingsDirty();
}
else if (held)
@ -2505,6 +2510,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
// Resize
window->SizeFull = ImMax(window->SizeFull + g.IO.MouseDelta, style.WindowMinSize);
window->Size = window->SizeFull;
if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
MarkSettingsDirty();
}
}
@ -2709,12 +2715,15 @@ void ImGui::End()
g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
}
// Moving window to front
// Moving window to front of display (which happens to be back of our sorted list)
static void FocusWindow(ImGuiWindow* window)
{
ImGuiState& g = GImGui;
g.FocusedWindow = window;
if (g.Windows.back() == window)
return;
for (size_t i = 0; i < g.Windows.size(); i++)
if (g.Windows[i] == window)
{