Merge branch 'master' into navigation

# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_draw.cpp
This commit is contained in:
omar
2017-11-06 23:58:28 +01:00
4 changed files with 34 additions and 41 deletions

View File

@ -250,6 +250,7 @@
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
- 2017/11/02 (1.53) - marked IsRootWindowOrAnyChildHovered() as obsolete is favor of using IsWindowHovered(ImGuiHoveredFlags_FlattenChilds);
- 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency.
- 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it.
- 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details.
@ -2312,6 +2313,8 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
if (!window->DC.LastItemRectHoveredRect)
return false;
IM_ASSERT((flags & ImGuiHoveredFlags_FlattenChilds) == 0); // Flags not supported by this function
// [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself.
// Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while.
//if (g.HoveredWindow != window)
@ -3917,6 +3920,7 @@ void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale)
case ImGuiDir_Left:
r = -r; // ...fall through, no break!
case ImGuiDir_Right:
center.x -= r * 0.25f;
a = ImVec2(1,0) * r;
b = ImVec2(-0.500f,+0.866f) * r;
c = ImVec2(-0.500f,-0.866f) * r;
@ -5090,24 +5094,17 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
g.SetNextWindowFocus = false;
}
// Update known root window (if we are a child window, otherwise window == window->RootWindow)
int root_idx, root_non_popup_idx;
for (root_idx = g.CurrentWindowStack.Size - 1; root_idx > 0; root_idx--)
if (!(g.CurrentWindowStack[root_idx]->Flags & ImGuiWindowFlags_ChildWindow))
break;
for (root_non_popup_idx = root_idx; root_non_popup_idx > 0; root_non_popup_idx--)
if (!(g.CurrentWindowStack[root_non_popup_idx]->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) || (g.CurrentWindowStack[root_non_popup_idx]->Flags & ImGuiWindowFlags_Modal))
break;
window->ParentWindow = parent_window;
window->RootWindow = g.CurrentWindowStack[root_idx];
window->RootNonPopupWindow = g.CurrentWindowStack[root_non_popup_idx]; // Used to display TitleBgActive color and for selecting which window to use for NavWindowing
window->RootNavWindow = window;
//while (window->RootNavWindow->Flags & ImGuiWindowFlags_NavFlattened)
// window->RootNavWindow = window->RootNavWindow->ParentWindow;
// When reusing window again multiple times a frame, just append content (don't need to setup again)
if (first_begin_of_the_frame)
{
// Initialize
window->ParentWindow = parent_window;
window->RootWindow = !(flags & ImGuiWindowFlags_ChildWindow) ? window : parent_window->RootWindow;
window->RootNonPopupWindow = !(flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) || (flags & ImGuiWindowFlags_Modal) ? window : parent_window->RootNonPopupWindow; // Used to display TitleBgActive color and for selecting which window to use for NavWindowing
window->RootNavWindow = window;
//while (window->RootNavWindow->Flags & ImGuiWindowFlags_NavFlattened)
// window->RootNavWindow = window->RootNavWindow->ParentWindow;
window->Active = true;
window->OrderWithinParent = 0;
window->BeginCount = 0;
@ -6089,12 +6086,20 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
{
IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
ImGuiContext& g = *GImGui;
if (g.HoveredWindow != g.CurrentWindow)
return false;
if (flags & ImGuiHoveredFlags_FlattenChilds)
{
if (g.HoveredRootWindow != g.CurrentWindow->RootWindow)
return false;
}
else
{
if (g.HoveredWindow != g.CurrentWindow)
return false;
}
if (!IsWindowContentHoverable(g.HoveredRootWindow, flags))
return false;
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
if (g.ActiveId != 0 && g.ActiveIdWindow != g.CurrentWindow)
if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId)
return false;
return true;
}
@ -6120,21 +6125,6 @@ bool ImGui::IsRootWindowOrAnyChildFocused()
return g.NavWindow && g.NavWindow->RootWindow == g.CurrentWindow->RootWindow;
}
bool ImGui::IsRootWindowOrAnyChildHovered(ImGuiHoveredFlags flags)
{
ImGuiContext& g = *GImGui;
IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
if (!g.HoveredRootWindow || (g.HoveredRootWindow != g.CurrentWindow->RootWindow))
return false;
if (!IsWindowContentHoverable(g.HoveredRootWindow, flags))
return false;
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
if (g.ActiveId != 0 && g.ActiveIdWindow != g.CurrentWindow)
return false;
return true;
}
float ImGui::GetWindowWidth()
{
ImGuiWindow* window = GImGui->CurrentWindow;
@ -10234,7 +10224,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
PopStyleColor();
}
if (selected)
RenderCheckMark(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * (0.20f+0.200f), g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f);
RenderCheckMark(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f);
}
return pressed;
}
@ -10384,7 +10374,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w);
pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
if (!enabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
RenderTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.20f, 0.0f), ImGuiDir_Right);
RenderTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), ImGuiDir_Right);
if (!enabled) PopStyleColor();
}