mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
Nav: Fixed navigation within tables/columns where item boundaries goes beyond columns limits. (#2221)
This commit is contained in:
parent
8d9e50c807
commit
00d3f9295e
@ -46,6 +46,8 @@ Other changes:
|
||||
showing when a sorting column has no visible name. (#6342) [@lukaasm]
|
||||
- InputText: Avoid setting io.WantTextInputNextFrame during the deactivation frame.
|
||||
(#6341) [@lukaasm]
|
||||
- Nav: Fixed navigation within tables/columns where item boundaries goes beyond columns limits,
|
||||
unclipped bounding boxes would interfere with other columns. (#2221) [@zzzyap, @ocornut]
|
||||
- Debug Tools: Debug Log: Fixed not parsing 0xXXXXXXXX values for geo-locating on mouse
|
||||
hover hover when the identifier is at the end of the line. (#5855)
|
||||
- Backends: Clear bits sets io.BackendFlags on backend Shutdown(). (#6334, #6335] [@GereonV]
|
||||
|
26
imgui.cpp
26
imgui.cpp
@ -3743,7 +3743,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()
|
||||
@ -6670,6 +6673,7 @@ 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.NavWindowHasScrollY = (window->ScrollMax.y > 0.0f);
|
||||
|
||||
@ -10825,6 +10829,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()
|
||||
@ -10832,9 +10845,16 @@ 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)
|
||||
{
|
||||
@ -10876,7 +10896,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)
|
||||
@ -10884,7 +10904,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)
|
||||
}
|
||||
}
|
||||
|
||||
|
2
imgui.h
2
imgui.h
@ -23,7 +23,7 @@
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
||||
#define IMGUI_VERSION "1.89.6 WIP"
|
||||
#define IMGUI_VERSION_NUM 18951
|
||||
#define IMGUI_VERSION_NUM 18952
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
|
@ -2232,6 +2232,7 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
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 NavWindowHasScrollY; // Set per window when scrolling can be used (== ScrollMax.y > 0.0f)
|
||||
|
||||
@ -2894,6 +2895,7 @@ namespace ImGui
|
||||
IMGUI_API void NavMoveRequestCancel();
|
||||
IMGUI_API void NavMoveRequestApplyResult();
|
||||
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
||||
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);
|
||||
|
@ -483,6 +483,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
|
||||
// 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;
|
||||
@ -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
|
||||
@ -3902,6 +3904,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 +4095,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)
|
||||
|
Loading…
Reference in New Issue
Block a user