mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 20:48:46 +02:00
Merge branch 'master' into viewport
# Conflicts: # imgui.cpp
This commit is contained in:
48
imgui.cpp
48
imgui.cpp
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.66 WIP
|
||||
// dear imgui, v1.66
|
||||
// (main code and documentation)
|
||||
|
||||
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
||||
@ -2314,7 +2314,7 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl
|
||||
return;
|
||||
if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw))
|
||||
return;
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (window->DC.NavHideHighlightOneFrame)
|
||||
return;
|
||||
|
||||
@ -3823,7 +3823,7 @@ void ImGui::Render()
|
||||
IM_ASSERT(g.Initialized);
|
||||
|
||||
if (g.FrameCountEnded != g.FrameCount)
|
||||
ImGui::EndFrame();
|
||||
EndFrame();
|
||||
g.FrameCountRendered = g.FrameCount;
|
||||
|
||||
// Gather ImDrawList to render (for each active window)
|
||||
@ -4423,13 +4423,18 @@ static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, b
|
||||
window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags);
|
||||
}
|
||||
|
||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiID id = ImHash(name, 0);
|
||||
return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id);
|
||||
}
|
||||
|
||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
{
|
||||
ImGuiID id = ImHash(name, 0);
|
||||
return FindWindowByID(id);
|
||||
}
|
||||
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -4690,7 +4695,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
||||
if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y);
|
||||
bool hovered, held;
|
||||
ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
|
||||
//GetOverlayDrawList()->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
//GetOverlayDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
if (hovered || held)
|
||||
g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE;
|
||||
|
||||
@ -4715,7 +4720,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
||||
bool hovered, held;
|
||||
ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS);
|
||||
ButtonBehavior(border_rect, window->GetID((void*)(intptr_t)(border_n + 4)), &hovered, &held, ImGuiButtonFlags_FlattenChildren);
|
||||
//GetOverlayDrawList()->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
//GetOverlayDrawList(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
if ((hovered && g.HoveredIdTimer > RESIZE_WINDOWS_FROM_EDGES_FEEDBACK_TIMER) || held)
|
||||
{
|
||||
g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS;
|
||||
@ -5424,7 +5429,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
/*
|
||||
if (g.ActiveId == move_id)
|
||||
if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C))
|
||||
ImGui::LogToClipboard();
|
||||
LogToClipboard();
|
||||
*/
|
||||
|
||||
// Inner rectangle
|
||||
@ -5499,13 +5504,13 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use,
|
||||
{
|
||||
// Old API feature: we could pass the initial window size as a parameter. This was misleading because it only had an effect if the window didn't have data in the .ini file.
|
||||
if (size_first_use.x != 0.0f || size_first_use.y != 0.0f)
|
||||
ImGui::SetNextWindowSize(size_first_use, ImGuiCond_FirstUseEver);
|
||||
SetNextWindowSize(size_first_use, ImGuiCond_FirstUseEver);
|
||||
|
||||
// Old API feature: override the window background alpha with a parameter.
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
ImGui::SetNextWindowBgAlpha(bg_alpha_override);
|
||||
SetNextWindowBgAlpha(bg_alpha_override);
|
||||
|
||||
return ImGui::Begin(name, p_open, flags);
|
||||
return Begin(name, p_open, flags);
|
||||
}
|
||||
#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
@ -7860,7 +7865,7 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
||||
}
|
||||
else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate.
|
||||
{
|
||||
if (IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; }
|
||||
if (ImGui::IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; }
|
||||
if (quadrant == g.NavMoveDir)
|
||||
{
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
|
||||
@ -8247,7 +8252,7 @@ static void ImGui::NavUpdate()
|
||||
g.NavJustMovedToId = 0;
|
||||
|
||||
// Process navigation move request
|
||||
if (g.NavMoveRequest && (g.NavMoveResultLocal.ID != 0 || g.NavMoveResultOther.ID != 0))
|
||||
if (g.NavMoveRequest)
|
||||
NavUpdateMoveResult();
|
||||
|
||||
// When a forwarded move request failed, we restore the highlight that we disabled during the forward frame
|
||||
@ -8458,14 +8463,26 @@ static void ImGui::NavUpdate()
|
||||
g.NavScoringCount = 0;
|
||||
#if IMGUI_DEBUG_NAV_RECTS
|
||||
if (g.NavWindow) { for (int layer = 0; layer < 2; layer++) GetOverlayDrawList(g.NavWindow)->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
|
||||
if (g.NavWindow) { ImU32 col = (g.NavWindow->HiddenFrames == 0) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(NULL); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); GetOverlayDrawList(g.NavWindow)->AddCircleFilled(p, 3.0f, col); GetOverlayDrawList(g.NavWindow)->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
if (g.NavWindow) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); GetOverlayDrawList(g.NavWindow)->AddCircleFilled(p, 3.0f, col); GetOverlayDrawList(g.NavWindow)->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
#endif
|
||||
}
|
||||
|
||||
// Apply result from previous frame navigation directional move request
|
||||
static void ImGui::NavUpdateMoveResult()
|
||||
{
|
||||
// Select which result to use
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
|
||||
{
|
||||
// In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
|
||||
if (g.NavId != 0)
|
||||
{
|
||||
g.NavDisableHighlight = false;
|
||||
g.NavDisableMouseHover = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Select which result to use
|
||||
ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
|
||||
|
||||
// PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
|
||||
@ -8495,7 +8512,6 @@ static void ImGui::NavUpdateMoveResult()
|
||||
NavScrollToBringItemIntoView(result->Window->ParentWindow, ImRect(rect_abs.Min + delta_scroll, rect_abs.Max + delta_scroll));
|
||||
}
|
||||
|
||||
// Apply result from previous frame navigation directional move request
|
||||
ClearActiveID();
|
||||
g.NavWindow = result->Window;
|
||||
SetNavIDWithRectRel(result->ID, g.NavLayer, result->RectRel);
|
||||
|
Reference in New Issue
Block a user