deps: update imgui to version v1.89.6
This commit is contained in:
parent
bb92e9f7a4
commit
bd946bfbea
|
@ -592,6 +592,7 @@ void ImGui_ImplDX11_Shutdown()
|
|||
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
|
||||
io.BackendRendererName = nullptr;
|
||||
io.BackendRendererUserData = nullptr;
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
IM_DELETE(bd);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,6 +287,7 @@ void ImGui_ImplDX9_Shutdown()
|
|||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||
io.BackendRendererName = nullptr;
|
||||
io.BackendRendererUserData = nullptr;
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
IM_DELETE(bd);
|
||||
}
|
||||
|
||||
|
|
|
@ -1005,6 +1005,7 @@ void ImGui_ImplVulkan_Shutdown()
|
|||
ImGui_ImplVulkan_DestroyDeviceObjects();
|
||||
io.BackendRendererName = nullptr;
|
||||
io.BackendRendererUserData = nullptr;
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
IM_DELETE(bd);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.89.5
|
||||
// dear imgui, v1.89.6
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
|
@ -11,7 +11,7 @@
|
|||
// - FAQ http://dearimgui.com/faq
|
||||
// - Homepage & latest https://github.com/ocornut/imgui
|
||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/5886 (please post your screenshots/video there!)
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/6478 (please post your screenshots/video there!)
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
|
@ -397,7 +397,13 @@ CODE
|
|||
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2023/03/14 (1.89.4) - commented out redirecting enums/functions names that were marked obsolete two years ago:
|
||||
- 2023/05/30 (1.89.6) - backends: renamed "imgui_impl_sdlrenderer.cpp" to "imgui_impl_sdlrenderer2.cpp" and "imgui_impl_sdlrenderer.h" to "imgui_impl_sdlrenderer2.h". This is in prevision for the future release of SDL3.
|
||||
- 2023/05/22 (1.89.6) - listbox: commented out obsolete/redirecting functions that were marked obsolete more than two years ago:
|
||||
- ListBoxHeader() -> use BeginListBox() (note how two variants of ListBoxHeader() existed. Check commented versions in imgui.h for reference)
|
||||
- ListBoxFooter() -> use EndListBox()
|
||||
- 2023/05/15 (1.89.6) - clipper: commented out obsolete redirection constructor 'ImGuiListClipper(int items_count, float items_height = -1.0f)' that was marked obsolete in 1.79. Use default constructor + clipper.Begin().
|
||||
- 2023/05/15 (1.89.6) - clipper: renamed ImGuiListClipper::ForceDisplayRangeByIndices() to ImGuiListClipper::IncludeRangeByIndices().
|
||||
- 2023/03/14 (1.89.4) - commented out redirecting enums/functions names that were marked obsolete two years ago:
|
||||
- ImGuiSliderFlags_ClampOnInput -> use ImGuiSliderFlags_AlwaysClamp
|
||||
- ImGuiInputTextFlags_AlwaysInsertMode -> use ImGuiInputTextFlags_AlwaysOverwrite
|
||||
- ImDrawList::AddBezierCurve() -> use ImDrawList::AddBezierCubic()
|
||||
|
@ -1056,7 +1062,6 @@ static void RenderWindowDecorations(ImGuiWindow* window, const ImRec
|
|||
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
||||
static void RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32 col);
|
||||
static void RenderDimmedBackgrounds();
|
||||
static ImGuiWindow* FindBlockingModal(ImGuiWindow* window);
|
||||
|
||||
// Viewports
|
||||
static void UpdateViewportsNewFrame();
|
||||
|
@ -1541,7 +1546,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
|||
// Filter duplicate
|
||||
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
|
||||
const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
|
||||
if (latest_focused == focused)
|
||||
if (latest_focused == focused || (ConfigDebugIgnoreFocusLoss && !focused))
|
||||
return;
|
||||
|
||||
ImGuiInputEvent e;
|
||||
|
@ -2804,13 +2809,13 @@ void ImGuiListClipper::End()
|
|||
ItemsCount = -1;
|
||||
}
|
||||
|
||||
void ImGuiListClipper::ForceDisplayRangeByIndices(int item_min, int item_max)
|
||||
void ImGuiListClipper::IncludeRangeByIndices(int item_begin, int item_end)
|
||||
{
|
||||
ImGuiListClipperData* data = (ImGuiListClipperData*)TempData;
|
||||
IM_ASSERT(DisplayStart < 0); // Only allowed after Begin() and if there has not been a specified range yet.
|
||||
IM_ASSERT(item_min <= item_max);
|
||||
if (item_min < item_max)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(item_min, item_max));
|
||||
IM_ASSERT(item_begin <= item_end);
|
||||
if (item_begin < item_end)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(item_begin, item_end));
|
||||
}
|
||||
|
||||
static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
||||
|
@ -3689,6 +3694,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* ctx, const char* name) : DrawListInst(NUL
|
|||
DrawList = &DrawListInst;
|
||||
DrawList->_Data = &Ctx->DrawListSharedData;
|
||||
DrawList->_OwnerName = Name;
|
||||
NavPreferredScoringPosRel[0] = NavPreferredScoringPosRel[1] = ImVec2(FLT_MAX, FLT_MAX);
|
||||
DragScrolling = false;
|
||||
}
|
||||
|
||||
|
@ -3744,7 +3750,10 @@ static void SetCurrentWindow(ImGuiWindow* window)
|
|||
g.CurrentWindow = window;
|
||||
g.CurrentTable = window && window->DC.CurrentTableIdx != -1 ? g.Tables.GetByIndex(window->DC.CurrentTableIdx) : NULL;
|
||||
if (window)
|
||||
{
|
||||
g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
|
||||
ImGui::NavUpdateCurrentWindowIsScrollPushableX();
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::GcCompactTransientMiscBuffers()
|
||||
|
@ -3909,7 +3918,7 @@ bool ImGui::IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flag
|
|||
|
||||
// Inhibit hover unless the window is within the stack of our modal/popup
|
||||
if (want_inhibit)
|
||||
if (!ImGui::IsWindowWithinBeginStackOf(window->RootWindow, focused_root_window))
|
||||
if (!IsWindowWithinBeginStackOf(window->RootWindow, focused_root_window))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -4294,10 +4303,10 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
|||
if (g.HoveredIdDisabled)
|
||||
g.MovingWindow = NULL;
|
||||
}
|
||||
else if (root_window == NULL && g.NavWindow != NULL && GetTopMostPopupModal() == NULL)
|
||||
else if (root_window == NULL && g.NavWindow != NULL)
|
||||
{
|
||||
// Clicking on void disable focus
|
||||
FocusWindow(NULL);
|
||||
FocusWindow(NULL, ImGuiFocusRequestFlags_UnlessBelowModal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4622,7 +4631,7 @@ void ImGui::NewFrame()
|
|||
|
||||
// Closing the focused window restore focus to the first active root window in descending z-order
|
||||
if (g.NavWindow && !g.NavWindow->WasActive)
|
||||
FocusTopMostWindowUnderOne(NULL, NULL);
|
||||
FocusTopMostWindowUnderOne(NULL, NULL, NULL, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
||||
|
||||
// No window should be open at the beginning of the frame.
|
||||
// But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
|
||||
|
@ -4908,7 +4917,7 @@ void ImGui::EndFrame()
|
|||
ImGuiPlatformImeData* ime_data = &g.PlatformImeData;
|
||||
if (g.IO.SetPlatformImeDataFn && memcmp(ime_data, &g.PlatformImeDataPrev, sizeof(ImGuiPlatformImeData)) != 0)
|
||||
{
|
||||
IMGUI_DEBUG_LOG_IO("Calling io.SetPlatformImeDataFn(): WantVisible: %d, InputPos (%.2f,%.2f)\n", ime_data->WantVisible, ime_data->InputPos.x, ime_data->InputPos.y);
|
||||
IMGUI_DEBUG_LOG_IO("[io] Calling io.SetPlatformImeDataFn(): WantVisible: %d, InputPos (%.2f,%.2f)\n", ime_data->WantVisible, ime_data->InputPos.x, ime_data->InputPos.y);
|
||||
ImGuiViewport* viewport = GetMainViewport();
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
if (viewport->PlatformHandleRaw == NULL && g.IO.ImeWindowHandle != NULL)
|
||||
|
@ -5313,11 +5322,15 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
|
|||
parent_window->DC.CursorPos = child_window->Pos;
|
||||
|
||||
// Process navigation-in immediately so NavInit can run on first frame
|
||||
if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavHasScroll))
|
||||
// Can enter a child if (A) it has navigatable items or (B) it can be scrolled.
|
||||
const ImGuiID temp_id_for_activation = (id + 1);
|
||||
if (g.ActiveId == temp_id_for_activation)
|
||||
ClearActiveID();
|
||||
if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavWindowHasScrollY))
|
||||
{
|
||||
FocusWindow(child_window);
|
||||
NavInitWindow(child_window, false);
|
||||
SetActiveID(id + 1, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item
|
||||
SetActiveID(temp_id_for_activation, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item
|
||||
g.ActiveIdSource = g.NavInputSource;
|
||||
}
|
||||
return ret;
|
||||
|
@ -5360,7 +5373,7 @@ void ImGui::EndChild()
|
|||
ImGuiWindow* parent_window = g.CurrentWindow;
|
||||
ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz);
|
||||
ItemSize(sz);
|
||||
if ((window->DC.NavLayersActiveMask != 0 || window->DC.NavHasScroll) && !(window->Flags & ImGuiWindowFlags_NavFlattened))
|
||||
if ((window->DC.NavLayersActiveMask != 0 || window->DC.NavWindowHasScrollY) && !(window->Flags & ImGuiWindowFlags_NavFlattened))
|
||||
{
|
||||
ItemAdd(bb, window->ChildId);
|
||||
RenderNavHighlight(bb, window->ChildId);
|
||||
|
@ -5373,6 +5386,10 @@ void ImGui::EndChild()
|
|||
{
|
||||
// Not navigable into
|
||||
ItemAdd(bb, 0);
|
||||
|
||||
// But when flattened we directly reach items, adjust active layer mask accordingly
|
||||
if (window->Flags & ImGuiWindowFlags_NavFlattened)
|
||||
parent_window->DC.NavLayersActiveMaskNext |= window->DC.NavLayersActiveMaskNext;
|
||||
}
|
||||
if (g.HoveredWindow == window)
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow;
|
||||
|
@ -5713,6 +5730,11 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||
const float grip_hover_inner_size = IM_FLOOR(grip_draw_size * 0.75f);
|
||||
const float grip_hover_outer_size = g.IO.ConfigWindowsResizeFromEdges ? WINDOWS_HOVER_PADDING : 0.0f;
|
||||
|
||||
ImRect clamp_rect = visibility_rect;
|
||||
const bool window_move_from_title_bar = g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar);
|
||||
if (window_move_from_title_bar)
|
||||
clamp_rect.Min.y -= window->TitleBarHeight();
|
||||
|
||||
ImVec2 pos_target(FLT_MAX, FLT_MAX);
|
||||
ImVec2 size_target(FLT_MAX, FLT_MAX);
|
||||
|
||||
|
@ -5749,8 +5771,8 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||
{
|
||||
// Resize from any of the four corners
|
||||
// We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
|
||||
ImVec2 clamp_min = ImVec2(def.CornerPosN.x == 1.0f ? visibility_rect.Min.x : -FLT_MAX, def.CornerPosN.y == 1.0f ? visibility_rect.Min.y : -FLT_MAX);
|
||||
ImVec2 clamp_max = ImVec2(def.CornerPosN.x == 0.0f ? visibility_rect.Max.x : +FLT_MAX, def.CornerPosN.y == 0.0f ? visibility_rect.Max.y : +FLT_MAX);
|
||||
ImVec2 clamp_min = ImVec2(def.CornerPosN.x == 1.0f ? clamp_rect.Min.x : -FLT_MAX, (def.CornerPosN.y == 1.0f || (def.CornerPosN.y == 0.0f && window_move_from_title_bar)) ? clamp_rect.Min.y : -FLT_MAX);
|
||||
ImVec2 clamp_max = ImVec2(def.CornerPosN.x == 0.0f ? clamp_rect.Max.x : +FLT_MAX, def.CornerPosN.y == 0.0f ? clamp_rect.Max.y : +FLT_MAX);
|
||||
ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(def.InnerDir * grip_hover_outer_size, def.InnerDir * -grip_hover_inner_size, def.CornerPosN); // Corner of the window corresponding to our corner grip
|
||||
corner_target = ImClamp(corner_target, clamp_min, clamp_max);
|
||||
CalcResizePosSizeFromAnyCorner(window, corner_target, def.CornerPosN, &pos_target, &size_target);
|
||||
|
@ -5779,8 +5801,8 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||
}
|
||||
if (held)
|
||||
{
|
||||
ImVec2 clamp_min(border_n == ImGuiDir_Right ? visibility_rect.Min.x : -FLT_MAX, border_n == ImGuiDir_Down ? visibility_rect.Min.y : -FLT_MAX);
|
||||
ImVec2 clamp_max(border_n == ImGuiDir_Left ? visibility_rect.Max.x : +FLT_MAX, border_n == ImGuiDir_Up ? visibility_rect.Max.y : +FLT_MAX);
|
||||
ImVec2 clamp_min(border_n == ImGuiDir_Right ? clamp_rect.Min.x : -FLT_MAX, border_n == ImGuiDir_Down || (border_n == ImGuiDir_Up && window_move_from_title_bar) ? clamp_rect.Min.y : -FLT_MAX);
|
||||
ImVec2 clamp_max(border_n == ImGuiDir_Left ? clamp_rect.Max.x : +FLT_MAX, border_n == ImGuiDir_Up ? clamp_rect.Max.y : +FLT_MAX);
|
||||
ImVec2 border_target = window->Pos;
|
||||
border_target[axis] = g.IO.MousePos[axis] - g.ActiveIdClickOffset[axis] + WINDOWS_HOVER_PADDING;
|
||||
border_target = ImClamp(border_target, clamp_min, clamp_max);
|
||||
|
@ -5807,7 +5829,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
|
|||
const float NAV_RESIZE_SPEED = 600.0f;
|
||||
const float resize_step = NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y);
|
||||
g.NavWindowingAccumDeltaSize += nav_resize_dir * resize_step;
|
||||
g.NavWindowingAccumDeltaSize = ImMax(g.NavWindowingAccumDeltaSize, visibility_rect.Min - window->Pos - window->Size); // We need Pos+Size >= visibility_rect.Min, so Size >= visibility_rect.Min - Pos, so size_delta >= visibility_rect.Min - window->Pos - window->Size
|
||||
g.NavWindowingAccumDeltaSize = ImMax(g.NavWindowingAccumDeltaSize, clamp_rect.Min - window->Pos - window->Size); // We need Pos+Size >= clmap_rect.Min, so Size >= clmap_rect.Min - Pos, so size_delta >= clmap_rect.Min - window->Pos - window->Size
|
||||
g.NavWindowingToggleLayer = false;
|
||||
g.NavDisableMouseHover = true;
|
||||
resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive);
|
||||
|
@ -6074,7 +6096,10 @@ void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags
|
|||
// - Window // .. returns Modal2
|
||||
// - Window // .. returns Modal2
|
||||
// - Modal2 // .. returns Modal2
|
||||
static ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window)
|
||||
// Notes:
|
||||
// - FindBlockingModal(NULL) == NULL is generally equivalent to GetTopMostPopupModal() == NULL.
|
||||
// Only difference is here we check for ->Active/WasActive but it may be unecessary.
|
||||
ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.OpenPopupStack.Size <= 0)
|
||||
|
@ -6088,6 +6113,8 @@ static ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window)
|
|||
continue;
|
||||
if (!popup_window->Active && !popup_window->WasActive) // Check WasActive, because this code may run before popup renders on current frame, also check Active to handle newly created windows.
|
||||
continue;
|
||||
if (window == NULL) // FindBlockingModal(NULL) test for if FocusWindow(NULL) is naturally possible via a mouse click.
|
||||
return popup_window;
|
||||
if (IsWindowWithinBeginStackOf(window, popup_window)) // Window is rendered over last modal, no render order change needed.
|
||||
break;
|
||||
for (ImGuiWindow* parent = popup_window->ParentWindowInBeginStack->RootWindow; parent != NULL; parent = parent->ParentWindowInBeginStack->RootWindow)
|
||||
|
@ -6462,22 +6489,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
want_focus = true;
|
||||
else if ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) == 0)
|
||||
want_focus = true;
|
||||
|
||||
ImGuiWindow* modal = GetTopMostPopupModal();
|
||||
if (modal != NULL && !IsWindowWithinBeginStackOf(window, modal))
|
||||
{
|
||||
// Avoid focusing a window that is created outside of active modal. This will prevent active modal from being closed.
|
||||
// Since window is not focused it would reappear at the same display position like the last time it was visible.
|
||||
// In case of completely new windows it would go to the top (over current modal), but input to such window would still be blocked by modal.
|
||||
// Position window behind a modal that is not a begin-parent of this window.
|
||||
want_focus = false;
|
||||
if (window == window->RootWindow)
|
||||
{
|
||||
ImGuiWindow* blocking_modal = FindBlockingModal(window);
|
||||
IM_ASSERT(blocking_modal != NULL);
|
||||
BringWindowToDisplayBehind(window, blocking_modal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [Test Engine] Register whole window in the item system (before submitting further decorations)
|
||||
|
@ -6604,8 +6615,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
// - We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping childs
|
||||
ImGuiWindow* previous_child = parent_window->DC.ChildWindows.Size >= 2 ? parent_window->DC.ChildWindows[parent_window->DC.ChildWindows.Size - 2] : NULL;
|
||||
bool previous_child_overlapping = previous_child ? previous_child->Rect().Overlaps(window->Rect()) : false;
|
||||
bool parent_is_empty = parent_window->DrawList->VtxBuffer.Size > 0;
|
||||
if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_is_empty && !previous_child_overlapping)
|
||||
bool parent_is_empty = (parent_window->DrawList->VtxBuffer.Size == 0);
|
||||
if (window->DrawList->CmdBuffer.back().ElemCount == 0 && !parent_is_empty && !previous_child_overlapping)
|
||||
render_decorations_in_parent = true;
|
||||
}
|
||||
if (render_decorations_in_parent)
|
||||
|
@ -6670,8 +6681,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
||||
window->DC.NavLayersActiveMask = window->DC.NavLayersActiveMaskNext;
|
||||
window->DC.NavLayersActiveMaskNext = 0x00;
|
||||
window->DC.NavIsScrollPushableX = true;
|
||||
window->DC.NavHideHighlightOneFrame = false;
|
||||
window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f);
|
||||
window->DC.NavWindowHasScrollY = (window->ScrollMax.y > 0.0f);
|
||||
|
||||
window->DC.MenuBarAppending = false;
|
||||
window->DC.MenuColumns.Update(style.ItemSpacing.x, window_just_activated_by_user);
|
||||
|
@ -6694,11 +6706,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
window->AutoFitFramesY--;
|
||||
|
||||
// Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there)
|
||||
// We ImGuiFocusRequestFlags_UnlessBelowModal to:
|
||||
// - Avoid focusing a window that is created outside of a modal. This will prevent active modal from being closed.
|
||||
// - Position window behind the modal that is not a begin-parent of this window.
|
||||
if (want_focus)
|
||||
{
|
||||
FocusWindow(window);
|
||||
FocusWindow(window, ImGuiFocusRequestFlags_UnlessBelowModal);
|
||||
if (want_focus && window == g.NavWindow)
|
||||
NavInitWindow(window, false); // <-- this is in the way for us to be able to defer and sort reappearing FocusWindow() calls
|
||||
}
|
||||
|
||||
// Title bar
|
||||
if (!(flags & ImGuiWindowFlags_NoTitleBar))
|
||||
|
@ -6924,10 +6938,25 @@ int ImGui::FindWindowDisplayIndex(ImGuiWindow* window)
|
|||
}
|
||||
|
||||
// Moving window to front of display and set focus (which happens to be back of our sorted list)
|
||||
void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
void ImGui::FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
// Modal check?
|
||||
if ((flags & ImGuiFocusRequestFlags_UnlessBelowModal) && (g.NavWindow != window)) // Early out in common case.
|
||||
if (ImGuiWindow* blocking_modal = FindBlockingModal(window))
|
||||
{
|
||||
IMGUI_DEBUG_LOG_FOCUS("[focus] FocusWindow(\"%s\", UnlessBelowModal): prevented by \"%s\".\n", window ? window->Name : "<NULL>", blocking_modal->Name);
|
||||
if (window && window == window->RootWindow && (window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0)
|
||||
BringWindowToDisplayBehind(window, blocking_modal); // Still bring to right below modal.
|
||||
return;
|
||||
}
|
||||
|
||||
// Find last focused child (if any) and focus it instead.
|
||||
if ((flags & ImGuiFocusRequestFlags_RestoreFocusedChild) && window != NULL)
|
||||
window = NavRestoreLastChildNavWindow(window);
|
||||
|
||||
// Apply focus
|
||||
if (g.NavWindow != window)
|
||||
{
|
||||
SetNavWindow(window);
|
||||
|
@ -6964,9 +6993,10 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|||
BringWindowToDisplayFront(display_front_window);
|
||||
}
|
||||
|
||||
void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window)
|
||||
void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window, ImGuiViewport* filter_viewport, ImGuiFocusRequestFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_UNUSED(filter_viewport); // Unused in master branch.
|
||||
int start_idx = g.WindowsFocusOrder.Size - 1;
|
||||
if (under_this_window != NULL)
|
||||
{
|
||||
|
@ -6984,15 +7014,15 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind
|
|||
// We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user.
|
||||
ImGuiWindow* window = g.WindowsFocusOrder[i];
|
||||
IM_ASSERT(window == window->RootWindow);
|
||||
if (window != ignore_window && window->WasActive)
|
||||
if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs))
|
||||
{
|
||||
ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window);
|
||||
FocusWindow(focus_window);
|
||||
return;
|
||||
}
|
||||
if (window == ignore_window || !window->WasActive)
|
||||
continue;
|
||||
if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs))
|
||||
{
|
||||
FocusWindow(window, flags);
|
||||
return;
|
||||
}
|
||||
}
|
||||
FocusWindow(NULL);
|
||||
FocusWindow(NULL, flags);
|
||||
}
|
||||
|
||||
// Important: this alone doesn't alter current ImDrawList state. This is called by PushFont/PopFont only.
|
||||
|
@ -7562,12 +7592,11 @@ void ImGui::SetItemDefaultFocus()
|
|||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (!window->Appearing)
|
||||
return;
|
||||
if (g.NavWindow != window->RootWindowForNav || (!g.NavInitRequest && g.NavInitResultId == 0) || g.NavLayer != window->DC.NavLayerCurrent)
|
||||
if (g.NavWindow != window->RootWindowForNav || (!g.NavInitRequest && g.NavInitResult.ID == 0) || g.NavLayer != window->DC.NavLayerCurrent)
|
||||
return;
|
||||
|
||||
g.NavInitRequest = false;
|
||||
g.NavInitResultId = g.LastItemData.ID;
|
||||
g.NavInitResultRectRel = WindowRectAbsToRel(window, g.LastItemData.Rect);
|
||||
NavApplyItemToResult(&g.NavInitResult);
|
||||
NavUpdateAnyRequestFlag();
|
||||
|
||||
// Scroll could be done in NavInitRequestApplyResult() via an opt-in flag (we however don't want regular init requests to scroll)
|
||||
|
@ -8531,7 +8560,7 @@ static void LockWheelingWindow(ImGuiWindow* window, float wheel_amount)
|
|||
g.WheelingWindowReleaseTimer = 0.0f;
|
||||
if (g.WheelingWindow == window)
|
||||
return;
|
||||
IMGUI_DEBUG_LOG_IO("LockWheelingWindow() \"%s\"\n", window ? window->Name : "NULL");
|
||||
IMGUI_DEBUG_LOG_IO("[io] LockWheelingWindow() \"%s\"\n", window ? window->Name : "NULL");
|
||||
g.WheelingWindow = window;
|
||||
g.WheelingWindowRefMousePos = g.IO.MousePos;
|
||||
if (window == NULL)
|
||||
|
@ -8695,12 +8724,12 @@ static const char* GetMouseSourceName(ImGuiMouseSource source)
|
|||
static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (e->Type == ImGuiInputEventType_MousePos) { if (e->MousePos.PosX == -FLT_MAX && e->MousePos.PosY == -FLT_MAX) IMGUI_DEBUG_LOG_IO("%s: MousePos (-FLT_MAX, -FLT_MAX)\n", prefix); else IMGUI_DEBUG_LOG_IO("%s: MousePos (%.1f, %.1f) (%s)\n", prefix, e->MousePos.PosX, e->MousePos.PosY, GetMouseSourceName(e->MouseWheel.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_MouseButton) { IMGUI_DEBUG_LOG_IO("%s: MouseButton %d %s (%s)\n", prefix, e->MouseButton.Button, e->MouseButton.Down ? "Down" : "Up", GetMouseSourceName(e->MouseWheel.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_MouseWheel) { IMGUI_DEBUG_LOG_IO("%s: MouseWheel (%.3f, %.3f) (%s)\n", prefix, e->MouseWheel.WheelX, e->MouseWheel.WheelY, GetMouseSourceName(e->MouseWheel.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_Key) { IMGUI_DEBUG_LOG_IO("%s: Key \"%s\" %s\n", prefix, ImGui::GetKeyName(e->Key.Key), e->Key.Down ? "Down" : "Up"); return; }
|
||||
if (e->Type == ImGuiInputEventType_Text) { IMGUI_DEBUG_LOG_IO("%s: Text: %c (U+%08X)\n", prefix, e->Text.Char, e->Text.Char); return; }
|
||||
if (e->Type == ImGuiInputEventType_Focus) { IMGUI_DEBUG_LOG_IO("%s: AppFocused %d\n", prefix, e->AppFocused.Focused); return; }
|
||||
if (e->Type == ImGuiInputEventType_MousePos) { if (e->MousePos.PosX == -FLT_MAX && e->MousePos.PosY == -FLT_MAX) IMGUI_DEBUG_LOG_IO("[io] %s: MousePos (-FLT_MAX, -FLT_MAX)\n", prefix); else IMGUI_DEBUG_LOG_IO("[io] %s: MousePos (%.1f, %.1f) (%s)\n", prefix, e->MousePos.PosX, e->MousePos.PosY, GetMouseSourceName(e->MouseWheel.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_MouseButton) { IMGUI_DEBUG_LOG_IO("[io] %s: MouseButton %d %s (%s)\n", prefix, e->MouseButton.Button, e->MouseButton.Down ? "Down" : "Up", GetMouseSourceName(e->MouseWheel.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_MouseWheel) { IMGUI_DEBUG_LOG_IO("[io] %s: MouseWheel (%.3f, %.3f) (%s)\n", prefix, e->MouseWheel.WheelX, e->MouseWheel.WheelY, GetMouseSourceName(e->MouseWheel.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_Key) { IMGUI_DEBUG_LOG_IO("[io] %s: Key \"%s\" %s\n", prefix, ImGui::GetKeyName(e->Key.Key), e->Key.Down ? "Down" : "Up"); return; }
|
||||
if (e->Type == ImGuiInputEventType_Text) { IMGUI_DEBUG_LOG_IO("[io] %s: Text: %c (U+%08X)\n", prefix, e->Text.Char, e->Text.Char); return; }
|
||||
if (e->Type == ImGuiInputEventType_Focus) { IMGUI_DEBUG_LOG_IO("[io] %s: AppFocused %d\n", prefix, e->AppFocused.Focused); return; }
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -9183,6 +9212,11 @@ void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, vo
|
|||
if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name);
|
||||
PopStyleVar();
|
||||
}
|
||||
while (g.FontStack.Size > stack_sizes->SizeOfFontStack) //-V1044
|
||||
{
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing PopFont() in '%s'", window->Name);
|
||||
PopFont();
|
||||
}
|
||||
while (g.FocusScopeStack.Size > stack_sizes->SizeOfFocusScopeStack + 1) //-V1044
|
||||
{
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name);
|
||||
|
@ -9369,6 +9403,8 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|||
DebugLocateItemResolveWithLastItem();
|
||||
#endif
|
||||
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
|
||||
//if ((g.LastItemData.InFlags & ImGuiItemFlags_NoNav) == 0)
|
||||
// window->DrawList->AddRect(g.LastItemData.NavRect.Min, g.LastItemData.NavRect.Max, IM_COL32(255,255,0,255)); // [DEBUG]
|
||||
|
||||
// We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
|
||||
if (is_rect_visible)
|
||||
|
@ -10093,6 +10129,7 @@ bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags)
|
|||
return IsPopupOpen(id, popup_flags);
|
||||
}
|
||||
|
||||
// Also see FindBlockingModal(NULL)
|
||||
ImGuiWindow* ImGui::GetTopMostPopupModal()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -10103,6 +10140,7 @@ ImGuiWindow* ImGui::GetTopMostPopupModal()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// See Demo->Stacked Modal to confirm what this is for.
|
||||
ImGuiWindow* ImGui::GetTopMostAndVisiblePopupModal()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -10231,7 +10269,7 @@ void ImGui::ClosePopupsExceptModals()
|
|||
for (popup_count_to_keep = g.OpenPopupStack.Size; popup_count_to_keep > 0; popup_count_to_keep--)
|
||||
{
|
||||
ImGuiWindow* window = g.OpenPopupStack[popup_count_to_keep - 1].Window;
|
||||
if (!window || window->Flags & ImGuiWindowFlags_Modal)
|
||||
if (!window || (window->Flags & ImGuiWindowFlags_Modal))
|
||||
break;
|
||||
}
|
||||
if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
|
||||
|
@ -10253,16 +10291,9 @@ void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_
|
|||
{
|
||||
ImGuiWindow* focus_window = (popup_window && popup_window->Flags & ImGuiWindowFlags_ChildMenu) ? popup_window->ParentWindow : popup_backup_nav_window;
|
||||
if (focus_window && !focus_window->WasActive && popup_window)
|
||||
{
|
||||
// Fallback
|
||||
FocusTopMostWindowUnderOne(popup_window, NULL);
|
||||
}
|
||||
FocusTopMostWindowUnderOne(popup_window, NULL, NULL, ImGuiFocusRequestFlags_RestoreFocusedChild); // Fallback
|
||||
else
|
||||
{
|
||||
if (g.NavLayer == ImGuiNavLayer_Main && focus_window)
|
||||
focus_window = NavRestoreLastChildNavWindow(focus_window);
|
||||
FocusWindow(focus_window);
|
||||
}
|
||||
FocusWindow(focus_window, (g.NavLayer == ImGuiNavLayer_Main) ? ImGuiFocusRequestFlags_RestoreFocusedChild : ImGuiFocusRequestFlags_None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10609,6 +10640,12 @@ void ImGui::SetNavWindow(ImGuiWindow* window)
|
|||
NavUpdateAnyRequestFlag();
|
||||
}
|
||||
|
||||
void ImGui::NavClearPreferredPosForAxis(ImGuiAxis axis)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer][axis] = FLT_MAX;
|
||||
}
|
||||
|
||||
void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -10619,6 +10656,10 @@ void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id
|
|||
g.NavFocusScopeId = focus_scope_id;
|
||||
g.NavWindow->NavLastIds[nav_layer] = id;
|
||||
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
||||
|
||||
// Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it)
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_Y);
|
||||
}
|
||||
|
||||
void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
||||
|
@ -10643,38 +10684,28 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|||
g.NavDisableMouseHover = true;
|
||||
else
|
||||
g.NavDisableHighlight = true;
|
||||
|
||||
// Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it)
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_Y);
|
||||
}
|
||||
|
||||
ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
|
||||
static ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
|
||||
{
|
||||
if (ImFabs(dx) > ImFabs(dy))
|
||||
return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
|
||||
return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up;
|
||||
}
|
||||
|
||||
static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
|
||||
static float inline NavScoreItemDistInterval(float cand_min, float cand_max, float curr_min, float curr_max)
|
||||
{
|
||||
if (a1 < b0)
|
||||
return a1 - b0;
|
||||
if (b1 < a0)
|
||||
return a0 - b1;
|
||||
if (cand_max < curr_min)
|
||||
return cand_max - curr_min;
|
||||
if (curr_max < cand_min)
|
||||
return cand_min - curr_max;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect)
|
||||
{
|
||||
if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right)
|
||||
{
|
||||
r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y);
|
||||
r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y);
|
||||
}
|
||||
else // FIXME: PageUp/PageDown are leaving move_dir == None
|
||||
{
|
||||
r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x);
|
||||
r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x);
|
||||
}
|
||||
}
|
||||
|
||||
// Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057
|
||||
static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
||||
{
|
||||
|
@ -10697,10 +10728,6 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
|||
cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window
|
||||
}
|
||||
|
||||
// We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items)
|
||||
// For example, this ensures that items in one column are not reached when moving vertically from items in another column.
|
||||
NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect);
|
||||
|
||||
// Compute distance between boxes
|
||||
// FIXME-NAV: Introducing biases for vertical navigation, needs to be removed.
|
||||
float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x);
|
||||
|
@ -10739,32 +10766,41 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
|||
quadrant = (g.LastItemData.ID < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right;
|
||||
}
|
||||
|
||||
const ImGuiDir move_dir = g.NavMoveDir;
|
||||
#if IMGUI_DEBUG_NAV_SCORING
|
||||
char buf[128];
|
||||
if (IsMouseHoveringRect(cand.Min, cand.Max))
|
||||
char buf[200];
|
||||
if (g.IO.KeyCtrl) // Hold CTRL to preview score in matching quadrant. CTRL+Arrow to rotate.
|
||||
{
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
|
||||
ImDrawList* draw_list = GetForegroundDrawList(window);
|
||||
draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
|
||||
draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
|
||||
draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40,0,0,150));
|
||||
draw_list->AddText(cand.Max, ~0U, buf);
|
||||
}
|
||||
else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate.
|
||||
{
|
||||
if (quadrant == g.NavMoveDir)
|
||||
if (quadrant == move_dir)
|
||||
{
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
|
||||
ImDrawList* draw_list = GetForegroundDrawList(window);
|
||||
draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
|
||||
draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 80));
|
||||
draw_list->AddRectFilled(cand.Min, cand.Min + CalcTextSize(buf), IM_COL32(255, 0, 0, 200));
|
||||
draw_list->AddText(cand.Min, IM_COL32(255, 255, 255, 255), buf);
|
||||
}
|
||||
}
|
||||
const bool debug_hovering = IsMouseHoveringRect(cand.Min, cand.Max);
|
||||
const bool debug_tty = (g.IO.KeyCtrl && IsKeyPressed(ImGuiKey_Space));
|
||||
if (debug_hovering || debug_tty)
|
||||
{
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf),
|
||||
"d-box (%7.3f,%7.3f) -> %7.3f\nd-center (%7.3f,%7.3f) -> %7.3f\nd-axial (%7.3f,%7.3f) -> %7.3f\nnav %c, quadrant %c",
|
||||
dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "-WENS"[move_dir+1], "-WENS"[quadrant+1]);
|
||||
if (debug_hovering)
|
||||
{
|
||||
ImDrawList* draw_list = GetForegroundDrawList(window);
|
||||
draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255, 200, 0, 100));
|
||||
draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255, 255, 0, 200));
|
||||
draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40, 0, 0, 200));
|
||||
draw_list->AddText(cand.Max, ~0U, buf);
|
||||
}
|
||||
if (debug_tty) { IMGUI_DEBUG_LOG_NAV("id 0x%08X\n%s\n", g.LastItemData.ID, buf); }
|
||||
}
|
||||
#endif
|
||||
|
||||
// Is it in the quadrant we're interested in moving to?
|
||||
bool new_best = false;
|
||||
const ImGuiDir move_dir = g.NavMoveDir;
|
||||
if (quadrant == move_dir)
|
||||
{
|
||||
// Does it beat the current best candidate?
|
||||
|
@ -10820,6 +10856,15 @@ static void ImGui::NavApplyItemToResult(ImGuiNavItemData* result)
|
|||
result->RectRel = WindowRectAbsToRel(window, g.LastItemData.NavRect);
|
||||
}
|
||||
|
||||
// True when current work location may be scrolled horizontally when moving left / right.
|
||||
// This is generally always true UNLESS within a column. We don't have a vertical equivalent.
|
||||
void ImGui::NavUpdateCurrentWindowIsScrollPushableX()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
window->DC.NavIsScrollPushableX = (g.CurrentTable == NULL && window->DC.CurrentColumns == NULL);
|
||||
}
|
||||
|
||||
// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
|
||||
// This is called after LastItemData is set.
|
||||
static void ImGui::NavProcessItem()
|
||||
|
@ -10827,18 +10872,24 @@ static void ImGui::NavProcessItem()
|
|||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
const ImGuiID id = g.LastItemData.ID;
|
||||
const ImRect nav_bb = g.LastItemData.NavRect;
|
||||
const ImGuiItemFlags item_flags = g.LastItemData.InFlags;
|
||||
|
||||
// When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221)
|
||||
if (window->DC.NavIsScrollPushableX == false)
|
||||
{
|
||||
g.LastItemData.NavRect.Min.x = ImClamp(g.LastItemData.NavRect.Min.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
||||
g.LastItemData.NavRect.Max.x = ImClamp(g.LastItemData.NavRect.Max.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
||||
}
|
||||
const ImRect nav_bb = g.LastItemData.NavRect;
|
||||
|
||||
// Process Init Request
|
||||
if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
||||
{
|
||||
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
|
||||
const bool candidate_for_nav_default_focus = (item_flags & ImGuiItemFlags_NoNavDefaultFocus) == 0;
|
||||
if (candidate_for_nav_default_focus || g.NavInitResultId == 0)
|
||||
if (candidate_for_nav_default_focus || g.NavInitResult.ID == 0)
|
||||
{
|
||||
g.NavInitResultId = id;
|
||||
g.NavInitResultRectRel = WindowRectAbsToRel(window, nav_bb);
|
||||
NavApplyItemToResult(&g.NavInitResult);
|
||||
}
|
||||
if (candidate_for_nav_default_focus)
|
||||
{
|
||||
|
@ -10871,7 +10922,7 @@ static void ImGui::NavProcessItem()
|
|||
}
|
||||
}
|
||||
|
||||
// Update window-relative bounding box of navigated item
|
||||
// Update information for currently focused/navigated item
|
||||
if (g.NavId == id)
|
||||
{
|
||||
if (g.NavWindow != window)
|
||||
|
@ -10879,7 +10930,7 @@ static void ImGui::NavProcessItem()
|
|||
g.NavLayer = window->DC.NavLayerCurrent;
|
||||
g.NavFocusScopeId = g.CurrentFocusScopeId;
|
||||
g.NavIdIsAlive = true;
|
||||
window->NavRectRel[window->DC.NavLayerCurrent] = WindowRectAbsToRel(window, nav_bb); // Store item bounding box (relative to window position)
|
||||
window->NavRectRel[window->DC.NavLayerCurrent] = WindowRectAbsToRel(window, nav_bb); // Store item bounding box (relative to window position)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11009,10 +11060,12 @@ void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNav
|
|||
void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags wrap_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(wrap_flags != 0); // Call with _WrapX, _WrapY, _LoopX, _LoopY
|
||||
// In theory we should test for NavMoveRequestButNoResultYet() but there's no point doing it, NavEndFrame() will do the same test
|
||||
IM_ASSERT((wrap_flags & ImGuiNavMoveFlags_WrapMask_ ) != 0 && (wrap_flags & ~ImGuiNavMoveFlags_WrapMask_) == 0); // Call with _WrapX, _WrapY, _LoopX, _LoopY
|
||||
|
||||
// In theory we should test for NavMoveRequestButNoResultYet() but there's no point doing it:
|
||||
// as NavEndFrame() will do the same test. It will end up calling NavUpdateCreateWrappingRequest().
|
||||
if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == ImGuiNavLayer_Main)
|
||||
g.NavMoveFlags |= wrap_flags;
|
||||
g.NavMoveFlags = (g.NavMoveFlags & ~ImGuiNavMoveFlags_WrapMask_) | wrap_flags;
|
||||
}
|
||||
|
||||
// FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0).
|
||||
|
@ -11094,8 +11147,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|||
SetNavID(0, g.NavLayer, window->NavRootFocusScopeId, ImRect());
|
||||
g.NavInitRequest = true;
|
||||
g.NavInitRequestFromMove = false;
|
||||
g.NavInitResultId = 0;
|
||||
g.NavInitResultRectRel = ImRect();
|
||||
g.NavInitResult.ID = 0;
|
||||
NavUpdateAnyRequestFlag();
|
||||
}
|
||||
else
|
||||
|
@ -11180,12 +11232,12 @@ static void ImGui::NavUpdate()
|
|||
g.NavInputSource = ImGuiInputSource_Keyboard;
|
||||
|
||||
// Process navigation init request (select first/default focus)
|
||||
if (g.NavInitResultId != 0)
|
||||
g.NavJustMovedToId = 0;
|
||||
if (g.NavInitResult.ID != 0)
|
||||
NavInitRequestApplyResult();
|
||||
g.NavInitRequest = false;
|
||||
g.NavInitRequestFromMove = false;
|
||||
g.NavInitResultId = 0;
|
||||
g.NavJustMovedToId = 0;
|
||||
g.NavInitResult.ID = 0;
|
||||
|
||||
// Process navigation move request
|
||||
if (g.NavMoveSubmitted)
|
||||
|
@ -11269,7 +11321,7 @@ static void ImGui::NavUpdate()
|
|||
ImGuiWindow* window = g.NavWindow;
|
||||
const float scroll_speed = IM_ROUND(window->CalcFontSize() * 100 * io.DeltaTime); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
|
||||
const ImGuiDir move_dir = g.NavMoveDir;
|
||||
if (window->DC.NavLayersActiveMask == 0x00 && window->DC.NavHasScroll && move_dir != ImGuiDir_None)
|
||||
if (window->DC.NavLayersActiveMask == 0x00 && window->DC.NavWindowHasScrollY && move_dir != ImGuiDir_None)
|
||||
{
|
||||
if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right)
|
||||
SetScrollX(window, ImFloor(window->Scroll.x + ((move_dir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed));
|
||||
|
@ -11309,11 +11361,11 @@ static void ImGui::NavUpdate()
|
|||
// [DEBUG]
|
||||
g.NavScoringDebugCount = 0;
|
||||
#if IMGUI_DEBUG_NAV_RECTS
|
||||
if (g.NavWindow)
|
||||
if (ImGuiWindow* debug_window = g.NavWindow)
|
||||
{
|
||||
ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow);
|
||||
if (1) { for (int layer = 0; layer < 2; layer++) { ImRect r = WindowRectRelToAbs(g.NavWindow, g.NavWindow->NavRectRel[layer]); draw_list->AddRect(r.Min, r.Max, IM_COL32(255,200,0,255)); } } // [DEBUG]
|
||||
if (1) { 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); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
ImDrawList* draw_list = GetForegroundDrawList(debug_window);
|
||||
int layer = g.NavLayer; /* for (int layer = 0; layer < 2; layer++)*/ { ImRect r = WindowRectRelToAbs(debug_window, debug_window->NavRectRel[layer]); draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 200, 0, 255)); }
|
||||
//if (1) { ImU32 col = (!debug_window->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); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -11325,15 +11377,48 @@ void ImGui::NavInitRequestApplyResult()
|
|||
if (!g.NavWindow)
|
||||
return;
|
||||
|
||||
ImGuiNavItemData* result = &g.NavInitResult;
|
||||
if (g.NavId != result->ID)
|
||||
{
|
||||
g.NavJustMovedToId = result->ID;
|
||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||
g.NavJustMovedToKeyMods = 0;
|
||||
}
|
||||
|
||||
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
|
||||
// FIXME-NAV: On _NavFlattened windows, g.NavWindow will only be updated during subsequent frame. Not a problem currently.
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: ApplyResult: NavID 0x%08X in Layer %d Window \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
|
||||
SetNavID(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel);
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: ApplyResult: NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name);
|
||||
SetNavID(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
|
||||
g.NavIdIsAlive = true; // Mark as alive from previous frame as we got a result
|
||||
if (g.NavInitRequestFromMove)
|
||||
NavRestoreHighlightAfterMove();
|
||||
}
|
||||
|
||||
// Bias scoring rect ahead of scoring + update preferred pos (if missing) using source position
|
||||
static void NavBiasScoringRect(ImRect& r, ImVec2& preferred_pos_rel, ImGuiDir move_dir, ImGuiNavMoveFlags move_flags)
|
||||
{
|
||||
// Bias initial rect
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImVec2 rel_to_abs_offset = g.NavWindow->DC.CursorStartPos;
|
||||
|
||||
// Initialize bias on departure if we don't have any. So mouse-click + arrow will record bias.
|
||||
// - We default to L/U bias, so moving down from a large source item into several columns will land on left-most column.
|
||||
// - But each successful move sets new bias on one axis, only cleared when using mouse.
|
||||
if ((move_flags & ImGuiNavMoveFlags_Forwarded) == 0)
|
||||
{
|
||||
if (preferred_pos_rel.x == FLT_MAX)
|
||||
preferred_pos_rel.x = ImMin(r.Min.x + 1.0f, r.Max.x) - rel_to_abs_offset.x;
|
||||
if (preferred_pos_rel.y == FLT_MAX)
|
||||
preferred_pos_rel.y = r.GetCenter().y - rel_to_abs_offset.y;
|
||||
}
|
||||
|
||||
// Apply general bias on the other axis
|
||||
if ((move_dir == ImGuiDir_Up || move_dir == ImGuiDir_Down) && preferred_pos_rel.x != FLT_MAX)
|
||||
r.Min.x = r.Max.x = preferred_pos_rel.x + rel_to_abs_offset.x;
|
||||
else if ((move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) && preferred_pos_rel.y != FLT_MAX)
|
||||
r.Min.y = r.Max.y = preferred_pos_rel.y + rel_to_abs_offset.y;
|
||||
}
|
||||
|
||||
void ImGui::NavUpdateCreateMoveRequest()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -11379,13 +11464,15 @@ void ImGui::NavUpdateCreateMoveRequest()
|
|||
g.NavScoringNoClipRect.TranslateY(scoring_rect_offset_y);
|
||||
}
|
||||
|
||||
// [DEBUG] Always send a request
|
||||
// [DEBUG] Always send a request when holding CTRL. Hold CTRL + Arrow change the direction.
|
||||
#if IMGUI_DEBUG_NAV_SCORING
|
||||
if (io.KeyCtrl && IsKeyPressed(ImGuiKey_C))
|
||||
g.NavMoveDirForDebug = (ImGuiDir)((g.NavMoveDirForDebug + 1) & 3);
|
||||
if (io.KeyCtrl && g.NavMoveDir == ImGuiDir_None)
|
||||
//if (io.KeyCtrl && IsKeyPressed(ImGuiKey_C))
|
||||
// g.NavMoveDirForDebug = (ImGuiDir)((g.NavMoveDirForDebug + 1) & 3);
|
||||
if (io.KeyCtrl)
|
||||
{
|
||||
g.NavMoveDir = g.NavMoveDirForDebug;
|
||||
if (g.NavMoveDir == ImGuiDir_None)
|
||||
g.NavMoveDir = g.NavMoveDirForDebug;
|
||||
g.NavMoveClipDir = g.NavMoveDir;
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_DebugNoResult;
|
||||
}
|
||||
#endif
|
||||
|
@ -11400,7 +11487,7 @@ void ImGui::NavUpdateCreateMoveRequest()
|
|||
{
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: from move, window \"%s\", layer=%d\n", window ? window->Name : "<NULL>", g.NavLayer);
|
||||
g.NavInitRequest = g.NavInitRequestFromMove = true;
|
||||
g.NavInitResultId = 0;
|
||||
g.NavInitResult.ID = 0;
|
||||
g.NavDisableHighlight = false;
|
||||
}
|
||||
|
||||
|
@ -11438,8 +11525,8 @@ void ImGui::NavUpdateCreateMoveRequest()
|
|||
ImRect nav_rect_rel = !window->NavRectRel[g.NavLayer].IsInverted() ? window->NavRectRel[g.NavLayer] : ImRect(0, 0, 0, 0);
|
||||
scoring_rect = WindowRectRelToAbs(window, nav_rect_rel);
|
||||
scoring_rect.TranslateY(scoring_rect_offset_y);
|
||||
scoring_rect.Min.x = ImMin(scoring_rect.Min.x + 1.0f, scoring_rect.Max.x);
|
||||
scoring_rect.Max.x = scoring_rect.Min.x;
|
||||
if (g.NavMoveSubmitted)
|
||||
NavBiasScoringRect(scoring_rect, window->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer], g.NavMoveDir, g.NavMoveFlags);
|
||||
IM_ASSERT(!scoring_rect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allow us to remove extraneous ImFabs() calls in NavScoreItem().
|
||||
//GetForegroundDrawList()->AddRect(scoring_rect.Min, scoring_rect.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
||||
//if (!g.NavScoringNoClipRect.IsInverted()) { GetForegroundDrawList()->AddRect(g.NavScoringNoClipRect.Min, g.NavScoringNoClipRect.Max, IM_COL32(255, 200, 0, 255)); } // [DEBUG]
|
||||
|
@ -11493,12 +11580,15 @@ void ImGui::NavMoveRequestApplyResult()
|
|||
result = &g.NavTabbingResultFirst;
|
||||
|
||||
// In a situation when there are no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
|
||||
const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
if (result == NULL)
|
||||
{
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight;
|
||||
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_DontSetNavHighlight) == 0)
|
||||
NavRestoreHighlightAfterMove();
|
||||
NavClearPreferredPosForAxis(axis); // On a failed move, clear preferred pos for this axis.
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveSubmitted but not led to a result!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11542,10 +11632,19 @@ void ImGui::NavMoveRequestApplyResult()
|
|||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||
}
|
||||
|
||||
// Focus
|
||||
// Apply new NavID/Focus
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name);
|
||||
ImVec2 preferred_scoring_pos_rel = g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer];
|
||||
SetNavID(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
|
||||
|
||||
// Restore last preferred position for current axis
|
||||
// (storing in RootWindowForNav-> as the info is desirable at the beginning of a Move Request. In theory all storage should use RootWindowForNav..)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) == 0)
|
||||
{
|
||||
preferred_scoring_pos_rel[axis] = result->RectRel.GetCenter()[axis];
|
||||
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
|
||||
}
|
||||
|
||||
// Tabbing: Activates Inputable or Focus non-Inputable
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable))
|
||||
{
|
||||
|
@ -11635,7 +11734,7 @@ static float ImGui::NavUpdatePageUpPageDown()
|
|||
if (g.NavLayer != ImGuiNavLayer_Main)
|
||||
NavRestoreLayer(ImGuiNavLayer_Main);
|
||||
|
||||
if (window->DC.NavLayersActiveMask == 0x00 && window->DC.NavHasScroll)
|
||||
if (window->DC.NavLayersActiveMask == 0x00 && window->DC.NavWindowHasScrollY)
|
||||
{
|
||||
// Fallback manual-scroll when window has no navigable item
|
||||
if (IsKeyPressed(ImGuiKey_PageUp, ImGuiKeyOwner_None, ImGuiInputFlags_Repeat))
|
||||
|
@ -11703,8 +11802,7 @@ static void ImGui::NavEndFrame()
|
|||
// Perform wrap-around in menus
|
||||
// FIXME-NAV: Wrap may need to apply a weight bias on the other axis. e.g. 4x4 grid with 2 last items missing on last item won't handle LoopY/WrapY correctly.
|
||||
// FIXME-NAV: Wrap (not Loop) support could be handled by the scoring function and then WrapX would function without an extra frame.
|
||||
const ImGuiNavMoveFlags wanted_flags = ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX | ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY;
|
||||
if (g.NavWindow && NavMoveRequestButNoResultYet() && (g.NavMoveFlags & wanted_flags) && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded) == 0)
|
||||
if (g.NavWindow && NavMoveRequestButNoResultYet() && (g.NavMoveFlags & ImGuiNavMoveFlags_WrapMask_) && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded) == 0)
|
||||
NavUpdateCreateWrappingRequest();
|
||||
}
|
||||
|
||||
|
@ -11716,7 +11814,9 @@ static void ImGui::NavUpdateCreateWrappingRequest()
|
|||
bool do_forward = false;
|
||||
ImRect bb_rel = window->NavRectRel[g.NavLayer];
|
||||
ImGuiDir clip_dir = g.NavMoveDir;
|
||||
|
||||
const ImGuiNavMoveFlags move_flags = g.NavMoveFlags;
|
||||
//const ImGuiAxis move_axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
|
||||
{
|
||||
bb_rel.Min.x = bb_rel.Max.x = window->ContentSize.x + window->WindowPadding.x;
|
||||
|
@ -11760,6 +11860,8 @@ static void ImGui::NavUpdateCreateWrappingRequest()
|
|||
if (!do_forward)
|
||||
return;
|
||||
window->NavRectRel[g.NavLayer] = bb_rel;
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_Y);
|
||||
NavMoveRequestForward(g.NavMoveDir, clip_dir, move_flags, g.NavMoveScrollFlags);
|
||||
}
|
||||
|
||||
|
@ -11813,7 +11915,7 @@ static void ImGui::NavUpdateWindowing()
|
|||
bool apply_toggle_layer = false;
|
||||
|
||||
ImGuiWindow* modal_window = GetTopMostPopupModal();
|
||||
bool allow_windowing = (modal_window == NULL);
|
||||
bool allow_windowing = (modal_window == NULL); // FIXME: This prevent CTRL+TAB from being usable with windows that are inside the Begin-stack of that modal.
|
||||
if (!allow_windowing)
|
||||
g.NavWindowingTarget = NULL;
|
||||
|
||||
|
@ -11942,9 +12044,9 @@ static void ImGui::NavUpdateWindowing()
|
|||
{
|
||||
ClearActiveID();
|
||||
NavRestoreHighlightAfterMove();
|
||||
apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window);
|
||||
ClosePopupsOverWindow(apply_focus_window, false);
|
||||
FocusWindow(apply_focus_window);
|
||||
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
||||
apply_focus_window = g.NavWindow;
|
||||
if (apply_focus_window->NavLastIds[0] == 0)
|
||||
NavInitWindow(apply_focus_window, false);
|
||||
|
||||
|
@ -12717,6 +12819,7 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
|||
}
|
||||
|
||||
// Zero-tolerance, no error reporting, cheap .ini parsing
|
||||
// Set ini_size==0 to let us use strlen(ini_data). Do not call this function with a 0 if your buffer is actually empty!
|
||||
void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -13312,7 +13415,7 @@ void ImGui::DebugRenderKeyboardPreview(ImDrawList* draw_list)
|
|||
draw_list->AddRectFilled(face_min, face_max, IM_COL32(252, 252, 252, 255), key_face_rounding);
|
||||
ImVec2 label_min = ImVec2(key_min.x + key_label_pos.x, key_min.y + key_label_pos.y);
|
||||
draw_list->AddText(label_min, IM_COL32(64, 64, 64, 255), key_data->Label);
|
||||
if (ImGui::IsKeyDown(key_data->Key))
|
||||
if (IsKeyDown(key_data->Key))
|
||||
draw_list->AddRectFilled(key_min, key_max, IM_COL32(255, 0, 0, 128), key_rounding);
|
||||
}
|
||||
draw_list->PopClipRect();
|
||||
|
@ -13322,7 +13425,7 @@ void ImGui::DebugRenderKeyboardPreview(ImDrawList* draw_list)
|
|||
void ImGui::DebugTextEncoding(const char* str)
|
||||
{
|
||||
Text("Text: \"%s\"", str);
|
||||
if (!BeginTable("list", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit))
|
||||
if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable))
|
||||
return;
|
||||
TableSetupColumn("Offset");
|
||||
TableSetupColumn("UTF-8");
|
||||
|
@ -14173,13 +14276,11 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label)
|
|||
char* p = buf;
|
||||
const char* buf_end = buf + IM_ARRAYSIZE(buf);
|
||||
const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2);
|
||||
p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*");
|
||||
p += ImFormatString(p, buf_end - p, " { ");
|
||||
p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s {", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*");
|
||||
for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++)
|
||||
{
|
||||
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
|
||||
p += ImFormatString(p, buf_end - p, "%s'%s'",
|
||||
tab_n > 0 ? ", " : "", TabBarGetTabName(tab_bar, tab));
|
||||
p += ImFormatString(p, buf_end - p, "%s'%s'", tab_n > 0 ? ", " : "", TabBarGetTabName(tab_bar, tab));
|
||||
}
|
||||
p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } ");
|
||||
if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); }
|
||||
|
@ -14269,6 +14370,9 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
|
|||
BulletText("NavLastIds[%d]: 0x%08X at +(%.1f,%.1f)(%.1f,%.1f)", layer, window->NavLastIds[layer], r.Min.x, r.Min.y, r.Max.x, r.Max.y);
|
||||
DebugLocateItemOnHover(window->NavLastIds[layer]);
|
||||
}
|
||||
const ImVec2* pr = window->NavPreferredScoringPosRel;
|
||||
for (int layer = 0; layer < ImGuiNavLayer_COUNT; layer++)
|
||||
BulletText("NavPreferredScoringPosRel[%d] = {%.1f,%.1f)", layer, (pr[layer].x == FLT_MAX ? -99999.0f : pr[layer].x), (pr[layer].y == FLT_MAX ? -99999.0f : pr[layer].y)); // Display as 99999.0f so it looks neater.
|
||||
BulletText("NavLayersActiveMask: %X, NavLastChildNavWindow: %s", window->DC.NavLayersActiveMask, window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
|
||||
if (window->RootWindow != window) { DebugNodeWindow(window->RootWindow, "RootWindow"); }
|
||||
if (window->ParentWindow != NULL) { DebugNodeWindow(window->ParentWindow, "ParentWindow"); }
|
||||
|
@ -14387,7 +14491,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
|||
TextUnformatted(line_begin, line_end);
|
||||
ImRect text_rect = g.LastItemData.Rect;
|
||||
if (IsItemHovered())
|
||||
for (const char* p = line_begin; p < line_end - 10; p++)
|
||||
for (const char* p = line_begin; p <= line_end - 10; p++)
|
||||
{
|
||||
ImGuiID id = 0;
|
||||
if (p[0] != '0' || (p[1] != 'x' && p[1] != 'X') || sscanf(p + 2, "%X", &id) != 1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.89.5
|
||||
// dear imgui, v1.89.6
|
||||
// (headers)
|
||||
|
||||
// Help:
|
||||
|
@ -11,7 +11,7 @@
|
|||
// - FAQ http://dearimgui.com/faq
|
||||
// - Homepage & latest https://github.com/ocornut/imgui
|
||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/5886 (please post your screenshots/video there!)
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/6478 (please post your screenshots/video there!)
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
|
@ -21,9 +21,9 @@
|
|||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
||||
#define IMGUI_VERSION "1.89.5"
|
||||
#define IMGUI_VERSION_NUM 18950
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.89.6"
|
||||
#define IMGUI_VERSION_NUM 18960
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
|
@ -1953,11 +1953,15 @@ struct ImGuiIO
|
|||
|
||||
// Debug options
|
||||
// - tools to test correct Begin/End and BeginChild/EndChild behaviors.
|
||||
// - presently Begn()/End() and BeginChild()EndChild() needs to ALWAYS be called in tandem, regardless of return value of BeginXXX()
|
||||
// - presently Begin()/End() and BeginChild()/EndChild() needs to ALWAYS be called in tandem, regardless of return value of BeginXXX()
|
||||
// this is inconsistent with other BeginXXX functions and create confusion for many users.
|
||||
// - we expect to update the API eventually. In the meanwhile we provided tools to facilitate checking user-code behavior.
|
||||
bool ConfigDebugBeginReturnValueOnce; // = false // First-time calls to Begin()/BeginChild() will return false. NEEDS TO BE SET AT APPLICATION BOOT TIME if you don't want to miss windows.
|
||||
bool ConfigDebugBeginReturnValueLoop; // = false // Some calls to Begin()/BeginChild() will return false. Will cycle through window depths then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering while running.
|
||||
// - we expect to update the API eventually. In the meanwhile we provide tools to facilitate checking user-code behavior.
|
||||
bool ConfigDebugBeginReturnValueOnce;// = false // First-time calls to Begin()/BeginChild() will return false. NEEDS TO BE SET AT APPLICATION BOOT TIME if you don't want to miss windows.
|
||||
bool ConfigDebugBeginReturnValueLoop;// = false // Some calls to Begin()/BeginChild() will return false. Will cycle through window depths then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering while running.
|
||||
// - option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.
|
||||
// - backends may have other side-effects on focus loss, so this will reduce side-effects but not necessary remove all of them.
|
||||
// - consider using e.g. Win32's IsDebuggerPresent() as an additional filter (or see ImOsIsDebuggerPresent() in imgui_test_engine/imgui_te_utils.cpp for a Unix compatible version).
|
||||
bool ConfigDebugIgnoreFocusLoss; // = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys() in input processing.
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Platform Functions
|
||||
|
@ -2341,11 +2345,13 @@ struct ImGuiListClipper
|
|||
IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
|
||||
IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
|
||||
|
||||
// Call ForceDisplayRangeByIndices() before first call to Step() if you need a range of items to be displayed regardless of visibility.
|
||||
IMGUI_API void ForceDisplayRangeByIndices(int item_min, int item_max); // item_max is exclusive e.g. use (42, 42+1) to make item 42 always visible BUT due to alignment/padding of certain items it is likely that an extra item may be included on either end of the display range.
|
||||
// Call IncludeRangeByIndices() *BEFORE* first call to Step() if you need a range of items to not be clipped, regardless of their visibility.
|
||||
// (Due to alignment / padding of certain items it is possible that an extra item may be included on either end of the display range).
|
||||
IMGUI_API void IncludeRangeByIndices(int item_begin, int item_end); // item_end is exclusive e.g. use (42, 42+1) to make item 42 never clipped.
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79]
|
||||
inline void ForceDisplayRangeByIndices(int item_begin, int item_end) { IncludeRangeByIndices(item_begin, item_end); } // [renamed in 1.89.6]
|
||||
//inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79]
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -2353,7 +2359,6 @@ struct ImGuiListClipper
|
|||
// - It is important that we are keeping those disabled by default so they don't leak in user space.
|
||||
// - This is in order to allow user enabling implicit cast operators between ImVec2/ImVec4 and their own types (using IM_VEC2_CLASS_EXTRA in imconfig.h)
|
||||
// - You can use '#define IMGUI_DEFINE_MATH_OPERATORS' to import our operators, provided as a courtesy.
|
||||
// - We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
|
||||
#ifdef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS_IMPLEMENTED
|
||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
|
@ -2363,6 +2368,7 @@ static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return
|
|||
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); }
|
||||
static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||||
static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); }
|
||||
static inline ImVec2 operator-(const ImVec2& lhs) { return ImVec2(-lhs.x, -lhs.y); }
|
||||
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
||||
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
||||
static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
|
||||
|
@ -2829,7 +2835,8 @@ struct ImFontAtlas
|
|||
//-------------------------------------------
|
||||
|
||||
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
|
||||
// NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details.
|
||||
// NB: Make sure that your string are UTF-8 and NOT in your local code page.
|
||||
// Read https://github.com/ocornut/imgui/blob/master/docs/FONTS.md/#about-utf-8-encoding for details.
|
||||
// NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data.
|
||||
IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
|
||||
IMGUI_API const ImWchar* GetGlyphRangesGreek(); // Default + Greek and Coptic
|
||||
|
@ -3036,12 +3043,12 @@ namespace ImGui
|
|||
IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // Calculate coarse clipping for large list of evenly sized items. Prefer using ImGuiListClipper.
|
||||
// OBSOLETED in 1.85 (from August 2021)
|
||||
static inline float GetWindowContentRegionWidth() { return GetWindowContentRegionMax().x - GetWindowContentRegionMin().x; }
|
||||
// OBSOLETED in 1.81 (from February 2021)
|
||||
IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // Helper to calculate size from items_count and height_in_items
|
||||
static inline bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0, 0)) { return BeginListBox(label, size); }
|
||||
static inline void ListBoxFooter() { EndListBox(); }
|
||||
|
||||
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
|
||||
//-- OBSOLETED in 1.81 (from February 2021)
|
||||
//static inline bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0, 0)) { return BeginListBox(label, size); }
|
||||
//static inline bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1) { float height = GetTextLineHeightWithSpacing() * ((height_in_items < 0 ? ImMin(items_count, 7) : height_in_items) + 0.25f) + GetStyle().FramePadding.y * 2.0f; return BeginListBox(label, ImVec2(0.0f, height)); } // Helper to calculate size from items_count and height_in_items
|
||||
//static inline void ListBoxFooter() { EndListBox(); }
|
||||
//-- OBSOLETED in 1.79 (from August 2020)
|
||||
//static inline void OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mb = 1) { OpenPopupOnItemClick(str_id, mb); } // Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry!
|
||||
//-- OBSOLETED in 1.78 (from June 2020): Old drag/sliders functions that took a 'float power > 1.0f' argument instead of ImGuiSliderFlags_Logarithmic. See github.com/ocornut/imgui/issues/3361 for details.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.89.5
|
||||
// dear imgui, v1.89.6
|
||||
// (demo code)
|
||||
|
||||
// Help:
|
||||
|
@ -398,23 +398,21 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||
IMGUI_DEMO_MARKER("Help");
|
||||
if (ImGui::CollapsingHeader("Help"))
|
||||
{
|
||||
ImGui::Text("ABOUT THIS DEMO:");
|
||||
ImGui::SeparatorText("ABOUT THIS DEMO:");
|
||||
ImGui::BulletText("Sections below are demonstrating many aspects of the library.");
|
||||
ImGui::BulletText("The \"Examples\" menu above leads to more demo contents.");
|
||||
ImGui::BulletText("The \"Tools\" menu above gives access to: About Box, Style Editor,\n"
|
||||
"and Metrics/Debugger (general purpose Dear ImGui debugging tool).");
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("PROGRAMMER GUIDE:");
|
||||
ImGui::SeparatorText("PROGRAMMER GUIDE:");
|
||||
ImGui::BulletText("See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
|
||||
ImGui::BulletText("See comments in imgui.cpp.");
|
||||
ImGui::BulletText("See example applications in the examples/ folder.");
|
||||
ImGui::BulletText("Read the FAQ at http://www.dearimgui.com/faq/");
|
||||
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
|
||||
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("USER GUIDE:");
|
||||
ImGui::SeparatorText("USER GUIDE:");
|
||||
ImGui::ShowUserGuide();
|
||||
}
|
||||
|
||||
|
@ -471,6 +469,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||
ImGui::SameLine(); HelpMarker("First calls to Begin()/BeginChild() will return false.\n\nTHIS OPTION IS DISABLED because it needs to be set at application boot-time to make sense. Showing the disabled option is a way to make this feature easier to discover");
|
||||
ImGui::Checkbox("io.ConfigDebugBeginReturnValueLoop", &io.ConfigDebugBeginReturnValueLoop);
|
||||
ImGui::SameLine(); HelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.");
|
||||
ImGui::Checkbox("io.ConfigDebugIgnoreFocusLoss", &io.ConfigDebugIgnoreFocusLoss);
|
||||
ImGui::SameLine(); HelpMarker("Option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.");
|
||||
|
||||
ImGui::TreePop();
|
||||
ImGui::Spacing();
|
||||
|
@ -631,7 +631,7 @@ static void ShowDemoWindowWidgets()
|
|||
ImGui::Text("Tooltips:");
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SmallButton("Button");
|
||||
ImGui::SmallButton("Basic");
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("I am a tooltip");
|
||||
|
||||
|
@ -744,7 +744,7 @@ static void ShowDemoWindowWidgets()
|
|||
static int elem = Element_Fire;
|
||||
const char* elems_names[Element_COUNT] = { "Fire", "Earth", "Air", "Water" };
|
||||
const char* elem_name = (elem >= 0 && elem < Element_COUNT) ? elems_names[elem] : "Unknown";
|
||||
ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name);
|
||||
ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name); // Use ImGuiSliderFlags_NoInput flag to disable CTRL+Click here.
|
||||
ImGui::SameLine(); HelpMarker("Using the format string parameter to display a name instead of the underlying integer.");
|
||||
}
|
||||
|
||||
|
@ -1390,7 +1390,15 @@ static void ShowDemoWindowWidgets()
|
|||
{
|
||||
struct TextFilters
|
||||
{
|
||||
// Return 0 (pass) if the character is 'i' or 'm' or 'g' or 'u' or 'i'
|
||||
// Modify character input by altering 'data->Eventchar' (ImGuiInputTextFlags_CallbackCharFilter callback)
|
||||
static int FilterCasingSwap(ImGuiInputTextCallbackData* data)
|
||||
{
|
||||
if (data->EventChar >= 'a' && data->EventChar <= 'z') { data->EventChar = data->EventChar - 'A' - 'a'; } // Lowercase becomes uppercase
|
||||
else if (data->EventChar >= 'A' && data->EventChar <= 'Z') { data->EventChar = data->EventChar + 'a' - 'A'; } // Uppercase becomes lowercase
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return 0 (pass) if the character is 'i' or 'm' or 'g' or 'u' or 'i', otherwise return 1 (filter out)
|
||||
static int FilterImGuiLetters(ImGuiInputTextCallbackData* data)
|
||||
{
|
||||
if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar))
|
||||
|
@ -1399,12 +1407,13 @@ static void ShowDemoWindowWidgets()
|
|||
}
|
||||
};
|
||||
|
||||
static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
|
||||
static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
|
||||
static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
||||
static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
|
||||
static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
|
||||
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
||||
static char buf1[32] = ""; ImGui::InputText("default", buf1, 32);
|
||||
static char buf2[32] = ""; ImGui::InputText("decimal", buf2, 32, ImGuiInputTextFlags_CharsDecimal);
|
||||
static char buf3[32] = ""; ImGui::InputText("hexadecimal", buf3, 32, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
||||
static char buf4[32] = ""; ImGui::InputText("uppercase", buf4, 32, ImGuiInputTextFlags_CharsUppercase);
|
||||
static char buf5[32] = ""; ImGui::InputText("no blank", buf5, 32, ImGuiInputTextFlags_CharsNoBlank);
|
||||
static char buf6[32] = ""; ImGui::InputText("casing swap", buf6, 32, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterCasingSwap); // Use CharFilter callback to replace characters.
|
||||
static char buf7[32] = ""; ImGui::InputText("\"imgui\"", buf7, 32, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters); // Use CharFilter callback to disable some characters.
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.89.5
|
||||
// dear imgui, v1.89.6
|
||||
// (drawing and font code)
|
||||
|
||||
/*
|
||||
|
@ -2553,13 +2553,10 @@ static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||
// 9. Setup ImFont and glyphs for runtime
|
||||
for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
|
||||
{
|
||||
ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
|
||||
if (src_tmp.GlyphsCount == 0)
|
||||
continue;
|
||||
|
||||
// When merging fonts with MergeMode=true:
|
||||
// - We can have multiple input fonts writing into a same destination font.
|
||||
// - dst_font->ConfigData is != from cfg which is our source configuration.
|
||||
ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
|
||||
ImFontConfig& cfg = atlas->ConfigData[src_i];
|
||||
ImFont* dst_font = cfg.DstFont;
|
||||
|
||||
|
@ -2623,6 +2620,9 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opa
|
|||
|
||||
ImVector<ImFontAtlasCustomRect>& user_rects = atlas->CustomRects;
|
||||
IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
|
||||
#ifdef __GNUC__
|
||||
if (user_rects.Size < 1) { __builtin_unreachable(); } // Workaround for GCC bug if IM_ASSERT() is defined to conditionally throw (see #5343)
|
||||
#endif
|
||||
|
||||
ImVector<stbrp_rect> pack_rects;
|
||||
pack_rects.resize(user_rects.Size);
|
||||
|
@ -3200,7 +3200,25 @@ void ImFont::BuildLookupTable()
|
|||
SetGlyphVisible((ImWchar)' ', false);
|
||||
SetGlyphVisible((ImWchar)'\t', false);
|
||||
|
||||
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||
// Setup Fallback character
|
||||
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackGlyph = &Glyphs.back();
|
||||
FallbackChar = (ImWchar)FallbackGlyph->Codepoint;
|
||||
}
|
||||
}
|
||||
FallbackAdvanceX = FallbackGlyph->AdvanceX;
|
||||
for (int i = 0; i < max_codepoint + 1; i++)
|
||||
if (IndexAdvanceX[i] < 0.0f)
|
||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||
|
||||
// Setup Ellipsis character. It is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
||||
// FIXME: Note that 0x2026 is rarely included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||
const ImWchar ellipsis_chars[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
|
||||
|
@ -3221,25 +3239,6 @@ void ImFont::BuildLookupTable()
|
|||
EllipsisCharStep = (glyph->X1 - glyph->X0) + 1.0f;
|
||||
EllipsisWidth = EllipsisCharStep * 3.0f - 1.0f;
|
||||
}
|
||||
|
||||
// Setup fallback character
|
||||
const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars));
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
if (FallbackGlyph == NULL)
|
||||
{
|
||||
FallbackGlyph = &Glyphs.back();
|
||||
FallbackChar = (ImWchar)FallbackGlyph->Codepoint;
|
||||
}
|
||||
}
|
||||
|
||||
FallbackAdvanceX = FallbackGlyph->AdvanceX;
|
||||
for (int i = 0; i < max_codepoint + 1; i++)
|
||||
if (IndexAdvanceX[i] < 0.0f)
|
||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||
}
|
||||
|
||||
// API is designed this way to avoid exposing the 4K page size
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.89.5
|
||||
// dear imgui, v1.89.6
|
||||
// (internal structures/api)
|
||||
|
||||
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
||||
|
@ -164,6 +164,7 @@ typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // E
|
|||
// Flags
|
||||
typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later)
|
||||
typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
|
||||
typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow();
|
||||
typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: for IsKeyPressed(), IsMouseClicked(), SetKeyOwner(), SetItemKeyOwner() etc.
|
||||
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), g.LastItemData.InFlags
|
||||
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
|
||||
|
@ -478,7 +479,6 @@ IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, c
|
|||
IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||||
IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
|
||||
inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
|
||||
IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy);
|
||||
|
||||
// Helper: ImVec1 (1D vector)
|
||||
// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
|
||||
|
@ -903,7 +903,17 @@ enum ImGuiSeparatorFlags_
|
|||
ImGuiSeparatorFlags_None = 0,
|
||||
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
||||
ImGuiSeparatorFlags_Vertical = 1 << 1,
|
||||
ImGuiSeparatorFlags_SpanAllColumns = 1 << 2,
|
||||
ImGuiSeparatorFlags_SpanAllColumns = 1 << 2, // Make separator cover all columns of a legacy Columns() set.
|
||||
};
|
||||
|
||||
// Flags for FocusWindow(). This is not called ImGuiFocusFlags to avoid confusion with public-facing ImGuiFocusedFlags.
|
||||
// FIXME: Once we finishing replacing more uses of GetTopMostPopupModal()+IsWindowWithinBeginStackOf()
|
||||
// and FindBlockingModal() with this, we may want to change the flag to be opt-out instead of opt-in.
|
||||
enum ImGuiFocusRequestFlags_
|
||||
{
|
||||
ImGuiFocusRequestFlags_None = 0,
|
||||
ImGuiFocusRequestFlags_RestoreFocusedChild = 1 << 0, // Find last focused child (if any) and focus it instead.
|
||||
ImGuiFocusRequestFlags_UnlessBelowModal = 1 << 1, // Do not set focus if the window is below a modal.
|
||||
};
|
||||
|
||||
enum ImGuiTextFlags_
|
||||
|
@ -1394,6 +1404,7 @@ enum ImGuiInputFlags_
|
|||
// [SECTION] Clipper support
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Note that Max is exclusive, so perhaps should be using a Begin/End convention.
|
||||
struct ImGuiListClipperRange
|
||||
{
|
||||
int Min;
|
||||
|
@ -1462,6 +1473,7 @@ enum ImGuiNavMoveFlags_
|
|||
ImGuiNavMoveFlags_LoopY = 1 << 1,
|
||||
ImGuiNavMoveFlags_WrapX = 1 << 2, // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
|
||||
ImGuiNavMoveFlags_WrapY = 1 << 3, // This is not super useful but provided for completeness
|
||||
ImGuiNavMoveFlags_WrapMask_ = ImGuiNavMoveFlags_LoopX | ImGuiNavMoveFlags_LoopY | ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_WrapY,
|
||||
ImGuiNavMoveFlags_AllowCurrentNavId = 1 << 4, // Allow scoring and considering the current NavId as a move target candidate. This is used when the move source is offset (e.g. pressing PageDown actually needs to send a Up move request, if we are pressing PageDown from the bottom-most item we need to stay in place)
|
||||
ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5, // Store alternate result in NavMoveResultLocalVisible that only comprise elements that are already fully visible (used by PageUp/PageDown)
|
||||
ImGuiNavMoveFlags_ScrollToEdgeY = 1 << 6, // Force scrolling to min/max (used by Home/End) // FIXME-NAV: Aim to remove or reword, probably unnecessary
|
||||
|
@ -1869,8 +1881,7 @@ struct ImGuiContext
|
|||
bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest this is to perform early out in ItemAdd()
|
||||
bool NavInitRequest; // Init request for appearing window to select first item
|
||||
bool NavInitRequestFromMove;
|
||||
ImGuiID NavInitResultId; // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called)
|
||||
ImRect NavInitResultRectRel; // Init request result rectangle (relative to parent window)
|
||||
ImGuiNavItemData NavInitResult; // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called)
|
||||
bool NavMoveSubmitted; // Move request submitted, will process result on next NewFrame()
|
||||
bool NavMoveScoringItems; // Move request submitted, still scoring incoming items
|
||||
bool NavMoveForwardToNextFrame;
|
||||
|
@ -2109,7 +2120,6 @@ struct ImGuiContext
|
|||
NavAnyRequest = false;
|
||||
NavInitRequest = false;
|
||||
NavInitRequestFromMove = false;
|
||||
NavInitResultId = 0;
|
||||
NavMoveSubmitted = false;
|
||||
NavMoveScoringItems = false;
|
||||
NavMoveForwardToNextFrame = false;
|
||||
|
@ -2226,14 +2236,15 @@ struct IMGUI_API ImGuiWindowTempData
|
|||
ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
|
||||
ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
|
||||
ImVec1 GroupOffset;
|
||||
ImVec2 CursorStartPosLossyness;// Record the loss of precision of CursorStartPos due to really large scrolling amount. This is used by clipper to compensentate and fix the most common use case of large scroll area.
|
||||
ImVec2 CursorStartPosLossyness;// Record the loss of precision of CursorStartPos due to really large scrolling amount. This is used by clipper to compensate and fix the most common use case of large scroll area.
|
||||
|
||||
// Keyboard/Gamepad navigation
|
||||
ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
|
||||
short NavLayersActiveMask; // Which layers have been written to (result from previous frame)
|
||||
short NavLayersActiveMaskNext;// Which layers have been written to (accumulator for current frame)
|
||||
bool NavIsScrollPushableX; // Set when current work location may be scrolled horizontally when moving left / right. This is generally always true UNLESS within a column.
|
||||
bool NavHideHighlightOneFrame;
|
||||
bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
|
||||
bool NavWindowHasScrollY; // Set per window when scrolling can be used (== ScrollMax.y > 0.0f)
|
||||
|
||||
// Miscellaneous
|
||||
bool MenuBarAppending; // FIXME: Remove this
|
||||
|
@ -2355,6 +2366,7 @@ struct IMGUI_API ImGuiWindow
|
|||
ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
|
||||
ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1)
|
||||
ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space
|
||||
ImVec2 NavPreferredScoringPosRel[ImGuiNavLayer_COUNT]; // Preferred X/Y position updated when moving on a given axis, reset to FLT_MAX.
|
||||
ImGuiID NavRootFocusScopeId; // Focus Scope ID at the time of Begin()
|
||||
|
||||
int MemoryDrawListIdxCapacity; // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy
|
||||
|
@ -2467,7 +2479,7 @@ struct IMGUI_API ImGuiTabBar
|
|||
typedef ImS16 ImGuiTableColumnIdx;
|
||||
typedef ImU16 ImGuiTableDrawChannelIdx;
|
||||
|
||||
// [Internal] sizeof() ~ 104
|
||||
// [Internal] sizeof() ~ 112
|
||||
// We use the terminology "Enabled" to refer to a column that is not Hidden by user/api.
|
||||
// We use the terminology "Clipped" to refer to a column that is out of sight because of scrolling/clipping.
|
||||
// This is in contrast with some user-facing api such as IsItemVisible() / IsRectVisible() which use "Visible" to mean "not clipped".
|
||||
|
@ -2513,7 +2525,7 @@ struct ImGuiTableColumn
|
|||
ImU8 SortDirection : 2; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending
|
||||
ImU8 SortDirectionsAvailCount : 2; // Number of available sort directions (0 to 3)
|
||||
ImU8 SortDirectionsAvailMask : 4; // Mask of available sort directions (1-bit each)
|
||||
ImU8 SortDirectionsAvailList; // Ordered of available sort directions (2-bits each)
|
||||
ImU8 SortDirectionsAvailList; // Ordered list of available sort directions (2-bits each, total 8-bits)
|
||||
|
||||
ImGuiTableColumn()
|
||||
{
|
||||
|
@ -2548,6 +2560,7 @@ struct ImGuiTableInstanceData
|
|||
};
|
||||
|
||||
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs, incoming RowData
|
||||
// sizeof() ~ 580 bytes + heap allocs described in TableBeginInitMemory()
|
||||
struct IMGUI_API ImGuiTable
|
||||
{
|
||||
ImGuiID ID;
|
||||
|
@ -2663,6 +2676,7 @@ struct IMGUI_API ImGuiTable
|
|||
// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
|
||||
// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
|
||||
// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
|
||||
// sizeof() ~ 112 bytes.
|
||||
struct IMGUI_API ImGuiTableTempData
|
||||
{
|
||||
int TableIndex; // Index in g.Tables.Buf[] pool
|
||||
|
@ -2750,10 +2764,11 @@ namespace ImGui
|
|||
IMGUI_API void SetWindowHiddendAndSkipItemsForCurrentFrame(ImGuiWindow* window);
|
||||
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
|
||||
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
|
||||
inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
|
||||
|
||||
// Windows: Display Order and Focus Order
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags = 0);
|
||||
IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window, ImGuiViewport* filter_viewport, ImGuiFocusRequestFlags flags);
|
||||
IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window);
|
||||
IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window);
|
||||
IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window);
|
||||
|
@ -2873,6 +2888,7 @@ namespace ImGui
|
|||
IMGUI_API ImRect GetPopupAllowedExtentRect(ImGuiWindow* window);
|
||||
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
||||
IMGUI_API ImGuiWindow* GetTopMostAndVisiblePopupModal();
|
||||
IMGUI_API ImGuiWindow* FindBlockingModal(ImGuiWindow* window);
|
||||
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
||||
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
||||
|
||||
|
@ -2896,6 +2912,8 @@ namespace ImGui
|
|||
IMGUI_API void NavMoveRequestCancel();
|
||||
IMGUI_API void NavMoveRequestApplyResult();
|
||||
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
||||
IMGUI_API void NavClearPreferredPosForAxis(ImGuiAxis axis);
|
||||
IMGUI_API void NavUpdateCurrentWindowIsScrollPushableX();
|
||||
IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
|
||||
IMGUI_API void SetNavWindow(ImGuiWindow* window);
|
||||
IMGUI_API void SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel);
|
||||
|
@ -3112,7 +3130,7 @@ namespace ImGui
|
|||
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags);
|
||||
IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags, float thickness = 1.0f);
|
||||
IMGUI_API void SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_width);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, ImS64* flags, ImS64 flags_value);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.89.5
|
||||
// dear imgui, v1.89.6
|
||||
// (tables and columns code)
|
||||
|
||||
/*
|
||||
|
@ -80,20 +80,20 @@ Index of this file:
|
|||
// - outer_size.x <= 0.0f -> Right-align from window/work-rect right-most edge. With -FLT_MIN or 0.0f will align exactly on right-most edge.
|
||||
// - outer_size.x > 0.0f -> Set Fixed width.
|
||||
// Y with ScrollX/ScrollY disabled: we output table directly in current window
|
||||
// - outer_size.y < 0.0f -> Bottom-align (but will auto extend, unless _NoHostExtendY is set). Not meaningful is parent window can vertically scroll.
|
||||
// - outer_size.y < 0.0f -> Bottom-align (but will auto extend, unless _NoHostExtendY is set). Not meaningful if parent window can vertically scroll.
|
||||
// - outer_size.y = 0.0f -> No minimum height (but will auto extend, unless _NoHostExtendY is set)
|
||||
// - outer_size.y > 0.0f -> Set Minimum height (but will auto extend, unless _NoHostExtenY is set)
|
||||
// Y with ScrollX/ScrollY enabled: using a child window for scrolling
|
||||
// - outer_size.y < 0.0f -> Bottom-align. Not meaningful is parent window can vertically scroll.
|
||||
// - outer_size.y < 0.0f -> Bottom-align. Not meaningful if parent window can vertically scroll.
|
||||
// - outer_size.y = 0.0f -> Bottom-align, consistent with BeginChild(). Not recommended unless table is last item in parent window.
|
||||
// - outer_size.y > 0.0f -> Set Exact height. Recommended when using Scrolling on any axis.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Outer size is also affected by the NoHostExtendX/NoHostExtendY flags.
|
||||
// Important to that note how the two flags have slightly different behaviors!
|
||||
// Important to note how the two flags have slightly different behaviors!
|
||||
// - ImGuiTableFlags_NoHostExtendX -> Make outer width auto-fit to columns (overriding outer_size.x value). Only available when ScrollX/ScrollY are disabled and Stretch columns are not used.
|
||||
// - ImGuiTableFlags_NoHostExtendY -> Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY is disabled. Data below the limit will be clipped and not visible.
|
||||
// In theory ImGuiTableFlags_NoHostExtendY could be the default and any non-scrolling tables with outer_size.y != 0.0f would use exact height.
|
||||
// This would be consistent but perhaps less useful and more confusing (as vertically clipped items are not easily noticeable)
|
||||
// This would be consistent but perhaps less useful and more confusing (as vertically clipped items are not useful and not easily noticeable).
|
||||
//-----------------------------------------------------------------------------
|
||||
// About 'inner_width':
|
||||
// With ScrollX disabled:
|
||||
|
@ -112,15 +112,16 @@ Index of this file:
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
// COLUMNS SIZING POLICIES
|
||||
// (Reference: ImGuiTableFlags_SizingXXX flags and ImGuiTableColumnFlags_WidthXXX flags)
|
||||
//-----------------------------------------------------------------------------
|
||||
// About overriding column sizing policy and width/weight with TableSetupColumn():
|
||||
// We use a default parameter of 'init_width_or_weight == -1'.
|
||||
// We use a default parameter of -1 for 'init_width'/'init_weight'.
|
||||
// - with ImGuiTableColumnFlags_WidthFixed, init_width <= 0 (default) --> width is automatic
|
||||
// - with ImGuiTableColumnFlags_WidthFixed, init_width > 0 (explicit) --> width is custom
|
||||
// - with ImGuiTableColumnFlags_WidthStretch, init_weight <= 0 (default) --> weight is 1.0f
|
||||
// - with ImGuiTableColumnFlags_WidthStretch, init_weight > 0 (explicit) --> weight is custom
|
||||
// Widths are specified _without_ CellPadding. If you specify a width of 100.0f, the column will be cover (100.0f + Padding * 2.0f)
|
||||
// and you can fit a 100.0f wide item in it without clipping and with full padding.
|
||||
// and you can fit a 100.0f wide item in it without clipping and with padding honored.
|
||||
//-----------------------------------------------------------------------------
|
||||
// About default sizing policy (if you don't specify a ImGuiTableColumnFlags_WidthXXXX flag)
|
||||
// - with Table policy ImGuiTableFlags_SizingFixedFit --> default Column policy is ImGuiTableColumnFlags_WidthFixed, default Width is equal to contents width
|
||||
|
@ -134,10 +135,10 @@ Index of this file:
|
|||
// - using mixed policies with ScrollX does not make much sense, as using Stretch columns with ScrollX does not make much sense in the first place!
|
||||
// that is, unless 'inner_width' is passed to BeginTable() to explicitly provide a total width to layout columns in.
|
||||
// - when using ImGuiTableFlags_SizingFixedSame with mixed columns, only the Fixed/Auto columns will match their widths to the width of the maximum contents.
|
||||
// - when using ImGuiTableFlags_SizingStretchSame with mixed columns, only the Stretch columns will match their weight/widths.
|
||||
// - when using ImGuiTableFlags_SizingStretchSame with mixed columns, only the Stretch columns will match their weights/widths.
|
||||
//-----------------------------------------------------------------------------
|
||||
// About using column width:
|
||||
// If a column is manual resizable or has a width specified with TableSetupColumn():
|
||||
// If a column is manually resizable or has a width specified with TableSetupColumn():
|
||||
// - you may use GetContentRegionAvail().x to query the width available in a given column.
|
||||
// - right-side alignment features such as SetNextItemWidth(-x) or PushItemWidth(-x) will rely on this width.
|
||||
// If the column is not resizable and has no width specified with TableSetupColumn():
|
||||
|
@ -151,7 +152,7 @@ Index of this file:
|
|||
// TABLES CLIPPING/CULLING
|
||||
//-----------------------------------------------------------------------------
|
||||
// About clipping/culling of Rows in Tables:
|
||||
// - For large numbers of rows, it is recommended you use ImGuiListClipper to only submit visible rows.
|
||||
// - For large numbers of rows, it is recommended you use ImGuiListClipper to submit only visible rows.
|
||||
// ImGuiListClipper is reliant on the fact that rows are of equal height.
|
||||
// See 'Demo->Tables->Vertical Scrolling' or 'Demo->Tables->Advanced' for a demo of using the clipper.
|
||||
// - Note that auto-resizing columns don't play well with using the clipper.
|
||||
|
@ -168,7 +169,7 @@ Index of this file:
|
|||
// - Case C: column is hidden explicitly by the user (e.g. via the context menu, or _DefaultHide column flag, etc.).
|
||||
//
|
||||
// [A] [B] [C]
|
||||
// TableNextColumn(): true false false -> [userland] when TableNextColumn() / TableSetColumnIndex() return false, user can skip submitting items but only if the column doesn't contribute to row height.
|
||||
// TableNextColumn(): true false false -> [userland] when TableNextColumn() / TableSetColumnIndex() returns false, user can skip submitting items but only if the column doesn't contribute to row height.
|
||||
// SkipItems: false false true -> [internal] when SkipItems is true, most widgets will early out if submitted, resulting is no layout output.
|
||||
// ClipRect: normal zero-width zero-width -> [internal] when ClipRect is zero, ItemAdd() will return false and most widgets will early out mid-way.
|
||||
// ImDrawList output: normal dummy dummy -> [internal] when using the dummy channel, ImDrawList submissions (if any) will be wasted (because cliprect is zero-width anyway).
|
||||
|
@ -319,7 +320,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||
if (flags & ImGuiTableFlags_ScrollX)
|
||||
IM_ASSERT(inner_width >= 0.0f);
|
||||
|
||||
// If an outer size is specified ahead we will be able to early out when not visible. Exact clipping rules may evolve.
|
||||
// If an outer size is specified ahead we will be able to early out when not visible. Exact clipping criteria may evolve.
|
||||
const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0;
|
||||
const ImVec2 avail_size = GetContentRegionAvail();
|
||||
ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f);
|
||||
|
@ -366,7 +367,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||
IM_ASSERT(table->ColumnsCount == columns_count && "BeginTable(): Cannot change columns count mid-frame while preserving same ID");
|
||||
if (table->InstanceDataExtra.Size < instance_no)
|
||||
table->InstanceDataExtra.push_back(ImGuiTableInstanceData());
|
||||
instance_id = GetIDWithSeed(instance_no, GetIDWithSeed("##Instances", NULL, id)); // Push "##Instance" followed by (int)instance_no in ID stack.
|
||||
instance_id = GetIDWithSeed(instance_no, GetIDWithSeed("##Instances", NULL, id)); // Push "##Instances" followed by (int)instance_no in ID stack.
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -477,12 +478,13 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||
table->IsUnfrozenRows = true;
|
||||
table->DeclColumnsCount = 0;
|
||||
|
||||
// Using opaque colors facilitate overlapping elements of the grid
|
||||
// Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders()
|
||||
table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong);
|
||||
table->BorderColorLight = GetColorU32(ImGuiCol_TableBorderLight);
|
||||
|
||||
// Make table current
|
||||
g.CurrentTable = table;
|
||||
outer_window->DC.NavIsScrollPushableX = false; // Shortcut for NavUpdateCurrentWindowIsScrollPushableX();
|
||||
outer_window->DC.CurrentTableIdx = table_idx;
|
||||
if (inner_window != outer_window) // So EndChild() within the inner window can restore the table properly.
|
||||
inner_window->DC.CurrentTableIdx = table_idx;
|
||||
|
@ -490,7 +492,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||
if ((table_last_flags & ImGuiTableFlags_Reorderable) && (flags & ImGuiTableFlags_Reorderable) == 0)
|
||||
table->IsResetDisplayOrderRequest = true;
|
||||
|
||||
// Mark as used
|
||||
// Mark as used to avoid GC
|
||||
if (table_idx >= g.TablesLastTimeActive.Size)
|
||||
g.TablesLastTimeActive.resize(table_idx + 1, -1.0f);
|
||||
g.TablesLastTimeActive[table_idx] = (float)g.Time;
|
||||
|
@ -583,13 +585,13 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||
}
|
||||
|
||||
// For reference, the average total _allocation count_ for a table is:
|
||||
// + 0 (for ImGuiTable instance, we are pooling allocations in g.Tables)
|
||||
// + 0 (for ImGuiTable instance, we are pooling allocations in g.Tables[])
|
||||
// + 1 (for table->RawData allocated below)
|
||||
// + 1 (for table->ColumnsNames, if names are used)
|
||||
// Shared allocations per number of nested tables
|
||||
// Shared allocations for the maximum number of simultaneously nested tables (generally a very small number)
|
||||
// + 1 (for table->Splitter._Channels)
|
||||
// + 2 * active_channels_count (for ImDrawCmd and ImDrawIdx buffers inside channels)
|
||||
// Where active_channels_count is variable but often == columns_count or columns_count + 1, see TableSetupDrawChannels() for details.
|
||||
// Where active_channels_count is variable but often == columns_count or == columns_count + 1, see TableSetupDrawChannels() for details.
|
||||
// Unused channels don't perform their +2 allocations.
|
||||
void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count)
|
||||
{
|
||||
|
@ -616,7 +618,7 @@ void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count)
|
|||
void ImGui::TableBeginApplyRequests(ImGuiTable* table)
|
||||
{
|
||||
// Handle resizing request
|
||||
// (We process this at the first TableBegin of the frame)
|
||||
// (We process this in the TableBegin() of the first instance of each table)
|
||||
// FIXME-TABLE: Contains columns if our work area doesn't allow for scrolling?
|
||||
if (table->InstanceCurrent == 0)
|
||||
{
|
||||
|
@ -661,8 +663,7 @@ void ImGui::TableBeginApplyRequests(ImGuiTable* table)
|
|||
table->Columns[table->DisplayOrderToIndex[order_n]].DisplayOrder -= (ImGuiTableColumnIdx)reorder_dir;
|
||||
IM_ASSERT(dst_column->DisplayOrder == dst_order - reorder_dir);
|
||||
|
||||
// Display order is stored in both columns->IndexDisplayOrder and table->DisplayOrder[],
|
||||
// rebuild the later from the former.
|
||||
// Display order is stored in both columns->IndexDisplayOrder and table->DisplayOrder[]. Rebuild later from the former.
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
table->DisplayOrderToIndex[table->Columns[column_n].DisplayOrder] = (ImGuiTableColumnIdx)column_n;
|
||||
table->ReorderColumnDir = 0;
|
||||
|
@ -736,8 +737,8 @@ static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, I
|
|||
}
|
||||
}
|
||||
|
||||
// Layout columns for the frame. This is in essence the followup to BeginTable().
|
||||
// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first.
|
||||
// Layout columns for the frame. This is in essence the followup to BeginTable() and this is our largest function.
|
||||
// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() and other TableSetupXXXXX() functions to be called first.
|
||||
// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for _WidthAuto columns.
|
||||
// Increase feedback side-effect with widgets relying on WorkRect.Max.x... Maybe provide a default distribution for _WidthAuto columns?
|
||||
void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
|
@ -858,8 +859,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||
table->IsSettingsDirty = true;
|
||||
|
||||
// [Part 3] Fix column flags and record a few extra information.
|
||||
float sum_width_requests = 0.0f; // Sum of all width for fixed and auto-resize columns, excluding width contributed by Stretch columns but including spacing/padding.
|
||||
float stretch_sum_weights = 0.0f; // Sum of all weights for stretch columns.
|
||||
float sum_width_requests = 0.0f; // Sum of all width for fixed and auto-resize columns, excluding width contributed by Stretch columns but including spacing/padding.
|
||||
float stretch_sum_weights = 0.0f; // Sum of all weights for stretch columns.
|
||||
table->LeftMostStretchedColumn = table->RightMostStretchedColumn = -1;
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
{
|
||||
|
@ -1144,7 +1145,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||
EndPopup();
|
||||
}
|
||||
|
||||
// [Part 12] Sanitize and build sort specs before we have a change to use them for display.
|
||||
// [Part 12] Sanitize and build sort specs before we have a chance to use them for display.
|
||||
// This path will only be exercised when sort specs are modified before header rows (e.g. init or visibility change)
|
||||
if (table->IsSortSpecsDirty && (table->Flags & ImGuiTableFlags_Sortable))
|
||||
TableSortSpecsBuild(table);
|
||||
|
@ -1165,9 +1166,9 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||
}
|
||||
|
||||
// Process hit-testing on resizing borders. Actual size change will be applied in EndTable()
|
||||
// - Set table->HoveredColumnBorder with a short delay/timer to reduce feedback noise
|
||||
// - Submit ahead of table contents and header, use ImGuiButtonFlags_AllowItemOverlap to prioritize widgets
|
||||
// overlapping the same area.
|
||||
// - Set table->HoveredColumnBorder with a short delay/timer to reduce visual feedback noise.
|
||||
// - Submit ahead of table contents and header, use ImGuiButtonFlags_AllowItemOverlap to prioritize
|
||||
// widgets overlapping the same area.
|
||||
void ImGui::TableUpdateBorders(ImGuiTable* table)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -1436,6 +1437,7 @@ void ImGui::EndTable()
|
|||
g.CurrentTable->DrawSplitter = &temp_data->DrawSplitter;
|
||||
}
|
||||
outer_window->DC.CurrentTableIdx = g.CurrentTable ? g.Tables.GetIndex(g.CurrentTable) : -1;
|
||||
NavUpdateCurrentWindowIsScrollPushableX();
|
||||
}
|
||||
|
||||
// See "COLUMN SIZING POLICIES" comments at the top of this file
|
||||
|
@ -1641,7 +1643,7 @@ ImGuiID ImGui::TableGetColumnResizeID(ImGuiTable* table, int column_n, int insta
|
|||
return instance_id + 1 + column_n; // FIXME: #6140: still not ideal
|
||||
}
|
||||
|
||||
// Return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
||||
// Return -1 when table is not hovered. return columns_count if hovering the unused space at the right of the right-most visible column.
|
||||
int ImGui::TableGetHoveredColumn()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -1978,6 +1980,7 @@ bool ImGui::TableNextColumn()
|
|||
// FIXME-TABLE FIXME-OPT: Could probably shortcut some things for non-active or clipped columns.
|
||||
void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||
ImGuiWindow* window = table->InnerWindow;
|
||||
table->CurrentColumn = column_n;
|
||||
|
@ -2002,7 +2005,6 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
|||
window->SkipItems = column->IsSkipItems;
|
||||
if (column->IsSkipItems)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.LastItemData.ID = 0;
|
||||
g.LastItemData.StatusFlags = 0;
|
||||
}
|
||||
|
@ -2021,7 +2023,6 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
|||
}
|
||||
|
||||
// Logging
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.LogEnabled && !column->IsSkipItems)
|
||||
{
|
||||
LogRenderedText(&window->DC.CursorPos, "|");
|
||||
|
@ -2141,7 +2142,7 @@ void ImGui::TableSetColumnWidth(int column_n, float width)
|
|||
// - All stretch: easy.
|
||||
// - One or more fixed + one stretch: easy.
|
||||
// - One or more fixed + more than one stretch: tricky.
|
||||
// Qt when manual resize is enabled only support a single _trailing_ stretch column.
|
||||
// Qt when manual resize is enabled only supports a single _trailing_ stretch column, we support more cases here.
|
||||
|
||||
// When forwarding resize from Wn| to Fn+1| we need to be considerate of the _NoResize flag on Fn+1.
|
||||
// FIXME-TABLE: Find a way to rewrite all of this so interactions feel more consistent for the user.
|
||||
|
@ -2224,7 +2225,7 @@ void ImGui::TableUpdateColumnsWeightFromWidth(ImGuiTable* table)
|
|||
{
|
||||
IM_ASSERT(table->LeftMostStretchedColumn != -1 && table->RightMostStretchedColumn != -1);
|
||||
|
||||
// Measure existing quantity
|
||||
// Measure existing quantities
|
||||
float visible_weight = 0.0f;
|
||||
float visible_width = 0.0f;
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
|
@ -2381,11 +2382,11 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
|
|||
struct MergeGroup
|
||||
{
|
||||
ImRect ClipRect;
|
||||
int ChannelsCount;
|
||||
ImBitArrayPtr ChannelsMask;
|
||||
int ChannelsCount = 0;
|
||||
ImBitArrayPtr ChannelsMask = NULL;
|
||||
};
|
||||
int merge_group_mask = 0x00;
|
||||
MergeGroup merge_groups[4] = {};
|
||||
MergeGroup merge_groups[4];
|
||||
|
||||
// Use a reusable temp buffer for the merge masks as they are dynamically sized.
|
||||
const int max_draw_channels = (4 + table->ColumnsCount * 2);
|
||||
|
@ -2499,11 +2500,9 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
|
|||
merge_clip_rect.Max.x = ImMax(merge_clip_rect.Max.x, host_rect.Max.x);
|
||||
if ((merge_group_n & 2) != 0 && (table->Flags & ImGuiTableFlags_NoHostExtendY) == 0)
|
||||
merge_clip_rect.Max.y = ImMax(merge_clip_rect.Max.y, host_rect.Max.y);
|
||||
#if 0
|
||||
GetOverlayDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 0, 0, 200), 0.0f, 0, 1.0f);
|
||||
GetOverlayDrawList()->AddLine(merge_group->ClipRect.Min, merge_clip_rect.Min, IM_COL32(255, 100, 0, 200));
|
||||
GetOverlayDrawList()->AddLine(merge_group->ClipRect.Max, merge_clip_rect.Max, IM_COL32(255, 100, 0, 200));
|
||||
#endif
|
||||
//GetForegroundDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 0, 0, 200), 0.0f, 0, 1.0f); // [DEBUG]
|
||||
//GetForegroundDrawList()->AddLine(merge_group->ClipRect.Min, merge_clip_rect.Min, IM_COL32(255, 100, 0, 200));
|
||||
//GetForegroundDrawList()->AddLine(merge_group->ClipRect.Max, merge_clip_rect.Max, IM_COL32(255, 100, 0, 200));
|
||||
remaining_count -= merge_group->ChannelsCount;
|
||||
for (int n = 0; n < (size_for_masks_bitarrays_one >> 2); n++)
|
||||
remaining_mask[n] &= ~merge_group->ChannelsMask[n];
|
||||
|
@ -2667,7 +2666,6 @@ ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
|
|||
TableUpdateLayout(table);
|
||||
|
||||
TableSortSpecsBuild(table);
|
||||
|
||||
return &table->SortSpecs;
|
||||
}
|
||||
|
||||
|
@ -2786,7 +2784,7 @@ void ImGui::TableSortSpecsSanitize(ImGuiTable* table)
|
|||
}
|
||||
}
|
||||
|
||||
// Fallback default sort order (if no column had the ImGuiTableColumnFlags_DefaultSort flag)
|
||||
// Fallback default sort order (if no column with the ImGuiTableColumnFlags_DefaultSort flag)
|
||||
if (sort_order_count == 0 && !(table->Flags & ImGuiTableFlags_SortTristate))
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
{
|
||||
|
@ -3007,7 +3005,7 @@ void ImGui::TableHeader(const char* label)
|
|||
}
|
||||
|
||||
// Sort order arrow
|
||||
const float ellipsis_max = cell_r.Max.x - w_arrow - w_sort_text;
|
||||
const float ellipsis_max = ImMax(cell_r.Max.x - w_arrow - w_sort_text, label_pos.x);
|
||||
if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort))
|
||||
{
|
||||
if (column->SortOrder != -1)
|
||||
|
@ -3477,12 +3475,12 @@ static void TableSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandle
|
|||
if (!save_column)
|
||||
continue;
|
||||
buf->appendf("Column %-2d", column_n);
|
||||
if (column->UserID != 0) buf->appendf(" UserID=%08X", column->UserID);
|
||||
if (save_size && column->IsStretch) buf->appendf(" Weight=%.4f", column->WidthOrWeight);
|
||||
if (save_size && !column->IsStretch) buf->appendf(" Width=%d", (int)column->WidthOrWeight);
|
||||
if (save_visible) buf->appendf(" Visible=%d", column->IsEnabled);
|
||||
if (save_order) buf->appendf(" Order=%d", column->DisplayOrder);
|
||||
if (save_sort && column->SortOrder != -1) buf->appendf(" Sort=%d%c", column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? 'v' : '^');
|
||||
if (column->UserID != 0) { buf->appendf(" UserID=%08X", column->UserID); }
|
||||
if (save_size && column->IsStretch) { buf->appendf(" Weight=%.4f", column->WidthOrWeight); }
|
||||
if (save_size && !column->IsStretch) { buf->appendf(" Width=%d", (int)column->WidthOrWeight); }
|
||||
if (save_visible) { buf->appendf(" Visible=%d", column->IsEnabled); }
|
||||
if (save_order) { buf->appendf(" Order=%d", column->DisplayOrder); }
|
||||
if (save_sort && column->SortOrder != -1) { buf->appendf(" Sort=%d%c", column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? 'v' : '^'); }
|
||||
buf->append("\n");
|
||||
}
|
||||
buf->append("\n");
|
||||
|
@ -3530,7 +3528,7 @@ void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table)
|
|||
IM_ASSERT(table->MemoryCompacted == false);
|
||||
table->SortSpecs.Specs = NULL;
|
||||
table->SortSpecsMulti.clear();
|
||||
table->IsSortSpecsDirty = true; // FIXME: shouldn't have to leak into user performing a sort
|
||||
table->IsSortSpecsDirty = true; // FIXME: In theory shouldn't have to leak into user performing a sort on resume.
|
||||
table->ColumnsNames.clear();
|
||||
table->MemoryCompacted = true;
|
||||
for (int n = 0; n < table->ColumnsCount; n++)
|
||||
|
@ -3583,13 +3581,9 @@ static const char* DebugNodeTableGetSizingPolicyDesc(ImGuiTableFlags sizing_poli
|
|||
|
||||
void ImGui::DebugNodeTable(ImGuiTable* table)
|
||||
{
|
||||
char buf[512];
|
||||
char* p = buf;
|
||||
const char* buf_end = buf + IM_ARRAYSIZE(buf);
|
||||
const bool is_active = (table->LastFrameActive >= ImGui::GetFrameCount() - 2); // Note that fully clipped early out scrolling tables will appear as inactive here.
|
||||
ImFormatString(p, buf_end - p, "Table 0x%08X (%d columns, in '%s')%s", table->ID, table->ColumnsCount, table->OuterWindow->Name, is_active ? "" : " *Inactive*");
|
||||
const bool is_active = (table->LastFrameActive >= GetFrameCount() - 2); // Note that fully clipped early out scrolling tables will appear as inactive here.
|
||||
if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); }
|
||||
bool open = TreeNode(table, "%s", buf);
|
||||
bool open = TreeNode(table, "Table 0x%08X (%d columns, in '%s')%s", table->ID, table->ColumnsCount, table->OuterWindow->Name, is_active ? "" : " *Inactive*");
|
||||
if (!is_active) { PopStyleColor(); }
|
||||
if (IsItemHovered())
|
||||
GetForegroundDrawList()->AddRect(table->OuterRect.Min, table->OuterRect.Max, IM_COL32(255, 255, 0, 255));
|
||||
|
@ -3598,7 +3592,7 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
|
|||
if (!open)
|
||||
return;
|
||||
if (table->InstanceCurrent > 0)
|
||||
ImGui::Text("** %d instances of same table! Some data below will refer to last instance.", table->InstanceCurrent + 1);
|
||||
Text("** %d instances of same table! Some data below will refer to last instance.", table->InstanceCurrent + 1);
|
||||
bool clear_settings = SmallButton("Clear settings");
|
||||
BulletText("OuterRect: Pos: (%.1f,%.1f) Size: (%.1f,%.1f) Sizing: '%s'", table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.GetWidth(), table->OuterRect.GetHeight(), DebugNodeTableGetSizingPolicyDesc(table->Flags));
|
||||
BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", table->ColumnsGivenWidth, table->ColumnsAutoFitWidth, table->InnerWidth, table->InnerWidth == 0.0f ? " (auto)" : "");
|
||||
|
@ -3614,6 +3608,7 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
|
|||
{
|
||||
ImGuiTableColumn* column = &table->Columns[n];
|
||||
const char* name = TableGetColumnName(table, n);
|
||||
char buf[512];
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf),
|
||||
"Column %d order %d '%s': offset %+.2f to %+.2f%s\n"
|
||||
"Enabled: %d, VisibleX/Y: %d/%d, RequestOutput: %d, SkipItems: %d, DrawChannels: %d,%d\n"
|
||||
|
@ -3902,6 +3897,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFl
|
|||
columns->Count = columns_count;
|
||||
columns->Flags = flags;
|
||||
window->DC.CurrentColumns = columns;
|
||||
window->DC.NavIsScrollPushableX = false; // Shortcut for NavUpdateCurrentWindowIsScrollPushableX();
|
||||
|
||||
columns->HostCursorPosY = window->DC.CursorPos.y;
|
||||
columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x;
|
||||
|
@ -4092,6 +4088,7 @@ void ImGui::EndColumns()
|
|||
window->DC.CurrentColumns = NULL;
|
||||
window->DC.ColumnsOffset.x = 0.0f;
|
||||
window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||
NavUpdateCurrentWindowIsScrollPushableX();
|
||||
}
|
||||
|
||||
void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.89.5
|
||||
// dear imgui, v1.89.6
|
||||
// (widgets code)
|
||||
|
||||
/*
|
||||
|
@ -1416,8 +1416,9 @@ void ImGui::AlignTextToFramePadding()
|
|||
}
|
||||
|
||||
// Horizontal/vertical separating line
|
||||
// FIXME: Surprisingly, this seemingly simple widget is adjacent to MANY different legacy/tricky layout issues.
|
||||
void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
||||
// FIXME: Surprisingly, this seemingly trivial widget is a victim of many different legacy/tricky layout issues.
|
||||
// Note how thickness == 1.0f is handled specifically as not moving CursorPos by 'thickness', but other values are.
|
||||
void ImGui::SeparatorEx(ImGuiSeparatorFlags flags, float thickness)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
|
@ -1425,8 +1426,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
|||
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected
|
||||
IM_ASSERT(thickness > 0.0f);
|
||||
|
||||
const float thickness = 1.0f; // Cannot use g.Style.SeparatorTextSize yet for various reasons.
|
||||
if (flags & ImGuiSeparatorFlags_Vertical)
|
||||
{
|
||||
// Vertical separator, for menu bars (use current line height).
|
||||
|
@ -1460,6 +1461,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
|||
x2 = table->Columns[table->CurrentColumn].MaxX;
|
||||
}
|
||||
|
||||
// Before Tables API happened, we relied on Separator() to span all columns of a Columns() set.
|
||||
// We currently don't need to provide the same feature for tables because tables naturally have border features.
|
||||
ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
|
||||
if (columns)
|
||||
PushColumnsBackground();
|
||||
|
@ -1469,8 +1472,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
|||
const float thickness_for_layout = (thickness == 1.0f) ? 0.0f : thickness; // FIXME: See 1.70/1.71 Separator() change: makes legacy 1-px separator not affect layout yet. Should change.
|
||||
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness));
|
||||
ItemSize(ImVec2(0.0f, thickness_for_layout));
|
||||
const bool item_visible = ItemAdd(bb, 0);
|
||||
if (item_visible)
|
||||
|
||||
if (ItemAdd(bb, 0))
|
||||
{
|
||||
// Draw
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator));
|
||||
|
@ -1493,10 +1496,11 @@ void ImGui::Separator()
|
|||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
// Those flags should eventually be overridable by the user
|
||||
// Those flags should eventually be configurable by the user
|
||||
// FIXME: We cannot g.Style.SeparatorTextBorderSize for thickness as it relates to SeparatorText() which is a decorated separator, not defaulting to 1.0f.
|
||||
ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal;
|
||||
flags |= ImGuiSeparatorFlags_SpanAllColumns; // NB: this only applies to legacy Columns() api as they relied on Separator() a lot.
|
||||
SeparatorEx(flags);
|
||||
SeparatorEx(flags, 1.0f);
|
||||
}
|
||||
|
||||
void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w)
|
||||
|
@ -1556,8 +1560,8 @@ void ImGui::SeparatorText(const char* label)
|
|||
return;
|
||||
|
||||
// The SeparatorText() vs SeparatorTextEx() distinction is designed to be considerate that we may want:
|
||||
// - allow headers to be draggable items (would require a stable ID + a noticeable highlight)
|
||||
// - this high-level entry point to allow formatting? (may require ID separate from formatted string)
|
||||
// - allow separator-text to be draggable items (would require a stable ID + a noticeable highlight)
|
||||
// - this high-level entry point to allow formatting? (which in turns may require ID separate from formatted string)
|
||||
// - because of this we probably can't turn 'const char* label' into 'const char* fmt, ...'
|
||||
// Otherwise, we can decide that users wanting to drag this would layout a dedicated drag-item,
|
||||
// and then we can turn this into a format function.
|
||||
|
@ -2114,7 +2118,8 @@ bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void
|
|||
memcpy(&data_backup, p_data, type_info->Size);
|
||||
|
||||
// Sanitize format
|
||||
// For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
|
||||
// - For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
|
||||
// - In theory could treat empty format as using default, but this would only cover rare/bizarre case of using InputScalar() + integer + format string without %.
|
||||
char format_sanitized[32];
|
||||
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
||||
format = type_info->ScanFmt;
|
||||
|
@ -3297,7 +3302,7 @@ const char* ImParseFormatFindEnd(const char* fmt)
|
|||
}
|
||||
|
||||
// Extract the format out of a format string with leading or trailing decorations
|
||||
// fmt = "blah blah" -> return fmt
|
||||
// fmt = "blah blah" -> return ""
|
||||
// fmt = "%.3f" -> return fmt
|
||||
// fmt = "hello %.3f" -> return fmt + 6
|
||||
// fmt = "%.3f hello" -> return buf written with "%.3f"
|
||||
|
@ -3305,7 +3310,7 @@ const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_
|
|||
{
|
||||
const char* fmt_start = ImParseFormatFindStart(fmt);
|
||||
if (fmt_start[0] != '%')
|
||||
return fmt;
|
||||
return "";
|
||||
const char* fmt_end = ImParseFormatFindEnd(fmt_start);
|
||||
if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data.
|
||||
return fmt_start;
|
||||
|
@ -3423,9 +3428,14 @@ static inline ImGuiInputTextFlags InputScalar_DefaultCharsFilter(ImGuiDataType d
|
|||
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
||||
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max)
|
||||
{
|
||||
// FIXME: May need to clarify display behavior if format doesn't contain %.
|
||||
// "%d" -> "%d" / "There are %d items" -> "%d" / "items" -> "%d" (fallback). Also see #6405
|
||||
const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
|
||||
char fmt_buf[32];
|
||||
char data_buf[32];
|
||||
format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf));
|
||||
if (format[0] == 0)
|
||||
format = type_info->PrintFmt;
|
||||
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format);
|
||||
ImStrTrimBlanks(data_buf);
|
||||
|
||||
|
@ -3436,7 +3446,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
|||
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
||||
{
|
||||
// Backup old value
|
||||
size_t data_type_size = DataTypeGetInfo(data_type)->Size;
|
||||
size_t data_type_size = type_info->Size;
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
memcpy(&data_backup, p_data, data_type_size);
|
||||
|
||||
|
@ -4320,7 +4330,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||
// Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget.
|
||||
// Down the line we should have a cleaner library-wide concept of Selected vs Active.
|
||||
g.ActiveIdAllowOverlap = !io.MouseDown[0];
|
||||
g.WantTextInputNextFrame = 1;
|
||||
|
||||
// Edit in progress
|
||||
const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + state->ScrollX;
|
||||
|
@ -4759,8 +4768,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||
}
|
||||
|
||||
// Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value)
|
||||
if (clear_active_id && g.ActiveId == id)
|
||||
// Otherwise request text input ahead for next frame.
|
||||
if (g.ActiveId == id && clear_active_id)
|
||||
ClearActiveID();
|
||||
else if (g.ActiveId == id)
|
||||
g.WantTextInputNextFrame = 1;
|
||||
|
||||
// Render frame
|
||||
if (!is_multiline)
|
||||
|
@ -6235,11 +6247,13 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|||
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open)
|
||||
{
|
||||
toggled = true;
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavMoveRequestCancel();
|
||||
}
|
||||
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the priority?
|
||||
{
|
||||
toggled = true;
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavMoveRequestCancel();
|
||||
}
|
||||
|
||||
|
@ -6635,20 +6649,6 @@ bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
// OBSOLETED in 1.81 (from February 2021)
|
||||
bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items)
|
||||
{
|
||||
// If height_in_items == -1, default height is maximum 7.
|
||||
ImGuiContext& g = *GImGui;
|
||||
float height_in_items_f = (height_in_items < 0 ? ImMin(items_count, 7) : height_in_items) + 0.25f;
|
||||
ImVec2 size;
|
||||
size.x = 0.0f;
|
||||
size.y = GetTextLineHeightWithSpacing() * height_in_items_f + g.Style.FramePadding.y * 2.0f;
|
||||
return BeginListBox(label, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ImGui::EndListBox()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -7112,7 +7112,7 @@ void ImGui::EndMainMenuBar()
|
|||
// FIXME: With this strategy we won't be able to restore a NULL focus.
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest)
|
||||
FocusTopMostWindowUnderOne(g.NavWindow, NULL);
|
||||
FocusTopMostWindowUnderOne(g.NavWindow, NULL, NULL, ImGuiFocusRequestFlags_UnlessBelowModal | ImGuiFocusRequestFlags_RestoreFocusedChild);
|
||||
|
||||
End();
|
||||
}
|
||||
|
@ -7126,9 +7126,9 @@ static bool IsRootOfOpenMenuSet()
|
|||
|
||||
// Initially we used 'upper_popup->OpenParentId == window->IDStack.back()' to differentiate multiple menu sets from each others
|
||||
// (e.g. inside menu bar vs loose menu items) based on parent ID.
|
||||
// This would however prevent the use of e.g. PuhsID() user code submitting menus.
|
||||
// This would however prevent the use of e.g. PushID() user code submitting menus.
|
||||
// Previously this worked between popup and a first child menu because the first child menu always had the _ChildWindow flag,
|
||||
// making hovering on parent popup possible while first child menu was focused - but this was generally a bug with other side effects.
|
||||
// making hovering on parent popup possible while first child menu was focused - but this was generally a bug with other side effects.
|
||||
// Instead we don't treat Popup specifically (in order to consistently support menu features in them), maybe the first child menu of a Popup
|
||||
// doesn't have the _ChildWindow flag, and we rely on this IsRootOfOpenMenuSet() check to allow hovering between root window/popup and first child menu.
|
||||
// In the end, lack of ID check made it so we could no longer differentiate between separate menu sets. To compensate for that, we at least check parent window nav layer.
|
||||
|
@ -7136,7 +7136,9 @@ static bool IsRootOfOpenMenuSet()
|
|||
// open on hover, but that should be a lesser problem, because if such menus are close in proximity in window content then it won't feel weird and if they are far apart
|
||||
// it likely won't be a problem anyone runs into.
|
||||
const ImGuiPopupData* upper_popup = &g.OpenPopupStack[g.BeginPopupStack.Size];
|
||||
return (window->DC.NavLayerCurrent == upper_popup->ParentNavLayer && upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu));
|
||||
if (window->DC.NavLayerCurrent != upper_popup->ParentNavLayer)
|
||||
return false;
|
||||
return upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu) && ImGui::IsWindowChildOf(upper_popup->Window, window, true);
|
||||
}
|
||||
|
||||
bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
||||
|
|
Loading…
Reference in New Issue