mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-11 19:39:29 +08:00
Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui.h # imgui_internal.h
This commit is contained in:
commit
0110f4c8cc
@ -106,9 +106,20 @@ Breaking changes:
|
||||
- IO: Obsoleted io.ClearInputCharacters() (added in 1.47) as it now ambiguous
|
||||
and often incorrect/misleading considering the existence of a higher-level
|
||||
input queue. (#4921)
|
||||
- ImDrawData: CmdLists[] arra is now owned, changed from 'ImDrawList**' to
|
||||
'ImVector<ImDrawList*>'. Majority of users shouldn't be affected, but you
|
||||
cannot compare to NULL nor reassign manually anymore.
|
||||
Instead use AddDrawList(). (#6406, #4879, #1878)
|
||||
|
||||
Other changes:
|
||||
|
||||
- ImDrawData: CmdLists[] array is now an ImVector<> owned by ImDrawData rather
|
||||
than a pointer to internal state.
|
||||
- This makes it easier for user to create their own or append to an existing draw data.
|
||||
Added a ImDrawData::AddDrawList() helper function to do that. (#6406, #4879, #1878)
|
||||
- This makes it easier to perform a deep-swap instead of a deep-copy, as array
|
||||
ownership is now clear. (#6597, #6475, #6167, #5776, #5109, #4763, #3515, #1860)
|
||||
- Syntax and allocation count are otherwise identical.
|
||||
- Fixed CTRL+Tab dimming background assert when target window has a callback
|
||||
in the last ImDrawCmd. (#4857, #5937)
|
||||
- InputText: Fixed a case where deactivation frame would write to underlying
|
||||
|
153
imgui.cpp
153
imgui.cpp
@ -407,6 +407,7 @@ CODE
|
||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
|
||||
- 2023/07/12 (1.89.8) - ImDrawData: CmdLists now owned, changed from ImDrawList** to ImVector<ImDrawList*>. Majority of users shouldn't be affected, but you cannot compare to NULL nor reassign manually anymore. Instead use AddDrawList(). (#6406, #4879, #1878)
|
||||
- 2023/06/28 (1.89.7) - overlapping items: obsoleted 'SetItemAllowOverlap()' (called after item) in favor of calling 'SetNextItemAllowOverlap()' (called before item). 'SetItemAllowOverlap()' didn't and couldn't work reliably since 1.89 (2022-11-15).
|
||||
- 2023/06/28 (1.89.7) - overlapping items: renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete).
|
||||
- 2023/06/28 (1.89.7) - overlapping items: IsItemHovered() now by default return false when querying an item using AllowOverlap mode which is being overlapped. Use ImGuiHoveredFlags_AllowWhenOverlappedByItem to revert to old behavior.
|
||||
@ -1022,7 +1023,6 @@ static void FindHoveredWindow();
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags);
|
||||
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window);
|
||||
|
||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
|
||||
|
||||
// Settings
|
||||
@ -2977,7 +2977,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
||||
const bool is_nav_request = (g.NavMoveScoringItems && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
|
||||
if (is_nav_request)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(g.NavScoringNoClipRect.Min.y, g.NavScoringNoClipRect.Max.y, 0, 0));
|
||||
if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && g.NavTabbingDir == -1)
|
||||
if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && g.NavTabbingDir == -1)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(clipper->ItemsCount - 1, clipper->ItemsCount));
|
||||
|
||||
// Add focused/active item
|
||||
@ -4978,41 +4978,6 @@ static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, Im
|
||||
}
|
||||
}
|
||||
|
||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
||||
{
|
||||
if (draw_list->CmdBuffer.Size == 0)
|
||||
return;
|
||||
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
|
||||
return;
|
||||
|
||||
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||
// May trigger for you if you are using PrimXXX functions incorrectly.
|
||||
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
||||
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
||||
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
|
||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
||||
|
||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
|
||||
// If this assert triggers because you are drawing lots of stuff manually:
|
||||
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
|
||||
// Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents.
|
||||
// - If you want large meshes with more than 64K vertices, you can either:
|
||||
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
|
||||
// Most example backends already support this from 1.71. Pre-1.71 backends won't.
|
||||
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
|
||||
// (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
|
||||
// Most example backends already support this. For example, the OpenGL example code detect index size at compile-time:
|
||||
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
|
||||
// Your own engine or render API may use different parameters or function calls to specify index sizes.
|
||||
// 2 and 4 bytes indices are generally supported by most graphics API.
|
||||
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
|
||||
// the 64K limit to split your draw commands in multiple draw lists.
|
||||
if (sizeof(ImDrawIdx) == 2)
|
||||
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
|
||||
|
||||
out_list->push_back(draw_list);
|
||||
}
|
||||
|
||||
static void AddWindowToDrawData(ImGuiWindow* window, int layer)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -5021,7 +4986,7 @@ static void AddWindowToDrawData(ImGuiWindow* window, int layer)
|
||||
g.IO.MetricsRenderWindows++;
|
||||
if (window->Flags & ImGuiWindowFlags_DockNodeHost)
|
||||
window->DrawList->ChannelsMerge();
|
||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
||||
ImGui::AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
||||
for (int i = 0; i < window->DC.ChildWindows.Size; i++)
|
||||
{
|
||||
ImGuiWindow* child = window->DC.ChildWindows[i];
|
||||
@ -5041,26 +5006,35 @@ static inline void AddRootWindowToDrawData(ImGuiWindow* window)
|
||||
AddWindowToDrawData(window, GetWindowDisplayLayer(window));
|
||||
}
|
||||
|
||||
void ImDrawDataBuilder::FlattenIntoSingleLayer()
|
||||
static void FlattenDrawDataIntoSingleLayer(ImDrawDataBuilder* builder)
|
||||
{
|
||||
int n = Layers[0].Size;
|
||||
int size = n;
|
||||
for (int i = 1; i < IM_ARRAYSIZE(Layers); i++)
|
||||
size += Layers[i].Size;
|
||||
Layers[0].resize(size);
|
||||
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++)
|
||||
int n = builder->Layers[0]->Size;
|
||||
int full_size = n;
|
||||
for (int i = 1; i < IM_ARRAYSIZE(builder->Layers); i++)
|
||||
full_size += builder->Layers[i]->Size;
|
||||
builder->Layers[0]->resize(full_size);
|
||||
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(builder->Layers); layer_n++)
|
||||
{
|
||||
ImVector<ImDrawList*>& layer = Layers[layer_n];
|
||||
if (layer.empty())
|
||||
ImVector<ImDrawList*>* layer = builder->Layers[layer_n];
|
||||
if (layer->empty())
|
||||
continue;
|
||||
memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*));
|
||||
n += layer.Size;
|
||||
layer.resize(0);
|
||||
memcpy(builder->Layers[0]->Data + n, layer->Data, layer->Size * sizeof(ImDrawList*));
|
||||
n += layer->Size;
|
||||
layer->resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*>* draw_lists)
|
||||
static void InitViewportDrawData(ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||
|
||||
viewport->DrawData = draw_data; // Make publicly accessible
|
||||
viewport->DrawDataBuilder.Layers[0] = &draw_data->CmdLists;
|
||||
viewport->DrawDataBuilder.Layers[1] = &viewport->DrawDataBuilder.LayerData1;
|
||||
viewport->DrawDataBuilder.Layers[0]->resize(0);
|
||||
viewport->DrawDataBuilder.Layers[1]->resize(0);
|
||||
|
||||
// When minimized, we report draw_data->DisplaySize as zero to be consistent with non-viewport mode,
|
||||
// and to allow applications/backends to easily skip rendering.
|
||||
// FIXME: Note that we however do NOT attempt to report "zero drawlist / vertices" into the ImDrawData structure.
|
||||
@ -5068,24 +5042,13 @@ static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*
|
||||
// it earlier in the pipeline, rather than pretend to hide the data at the end of the pipeline.
|
||||
const bool is_minimized = (viewport->Flags & ImGuiViewportFlags_IsMinimized) != 0;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||
viewport->DrawData = draw_data; // Make publicly accessible
|
||||
draw_data->Valid = true;
|
||||
draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL;
|
||||
draw_data->CmdListsCount = draw_lists->Size;
|
||||
draw_data->CmdListsCount = 0;
|
||||
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
|
||||
draw_data->DisplayPos = viewport->Pos;
|
||||
draw_data->DisplaySize = is_minimized ? ImVec2(0.0f, 0.0f) : viewport->Size;
|
||||
draw_data->FramebufferScale = io.DisplayFramebufferScale; // FIXME-VIEWPORT: This may vary on a per-monitor/viewport basis?
|
||||
draw_data->OwnerViewport = viewport;
|
||||
for (int n = 0; n < draw_lists->Size; n++)
|
||||
{
|
||||
ImDrawList* draw_list = draw_lists->Data[n];
|
||||
draw_list->_PopUnusedDrawCmd();
|
||||
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
|
||||
}
|
||||
}
|
||||
|
||||
// Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering.
|
||||
@ -5354,9 +5317,9 @@ void ImGui::Render()
|
||||
for (int n = 0; n != g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
viewport->DrawDataBuilder.Clear();
|
||||
InitViewportDrawData(viewport);
|
||||
if (viewport->DrawLists[0] != NULL)
|
||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
||||
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
||||
}
|
||||
|
||||
// Add ImDrawList to render
|
||||
@ -5387,14 +5350,14 @@ void ImGui::Render()
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
viewport->DrawDataBuilder.FlattenIntoSingleLayer();
|
||||
FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
|
||||
|
||||
// Add foreground ImDrawList (for each active viewport)
|
||||
if (viewport->DrawLists[1] != NULL)
|
||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
||||
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
||||
|
||||
SetupViewportDrawData(viewport, &viewport->DrawDataBuilder.Layers[0]);
|
||||
ImDrawData* draw_data = viewport->DrawData;
|
||||
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||
IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
|
||||
g.IO.MetricsRenderVertices += draw_data->TotalVtxCount;
|
||||
g.IO.MetricsRenderIndices += draw_data->TotalIdxCount;
|
||||
}
|
||||
@ -8268,7 +8231,7 @@ void ImGui::FocusItem()
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSelect;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSelect;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
SetNavWindow(window);
|
||||
NavMoveRequestSubmit(ImGuiDir_None, ImGuiDir_Up, move_flags, scroll_flags);
|
||||
@ -8303,7 +8266,7 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
||||
|
||||
SetNavWindow(window);
|
||||
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
NavMoveRequestSubmit(ImGuiDir_None, offset < 0 ? ImGuiDir_Up : ImGuiDir_Down, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
||||
if (offset == -1)
|
||||
@ -11734,7 +11697,7 @@ static void ImGui::NavProcessItem()
|
||||
// FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy)
|
||||
if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
||||
{
|
||||
const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) != 0;
|
||||
const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) != 0;
|
||||
if (is_tabbing)
|
||||
{
|
||||
NavProcessItemForTabbingRequest(id, item_flags, g.NavMoveFlags);
|
||||
@ -11840,7 +11803,7 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.NavWindow != NULL);
|
||||
|
||||
if (move_flags & ImGuiNavMoveFlags_Tabbing)
|
||||
if (move_flags & ImGuiNavMoveFlags_IsTabbing)
|
||||
move_flags |= ImGuiNavMoveFlags_AllowCurrentNavId;
|
||||
|
||||
g.NavMoveSubmitted = g.NavMoveScoringItems = true;
|
||||
@ -12392,7 +12355,7 @@ void ImGui::NavUpdateCreateTabbingRequest()
|
||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.NavDisableHighlight == true && g.ActiveId == 0) ? 0 : +1;
|
||||
else
|
||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 : +1;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
ImGuiDir clip_dir = (g.NavTabbingDir < 0) ? ImGuiDir_Up : ImGuiDir_Down;
|
||||
NavMoveRequestSubmit(ImGuiDir_None, clip_dir, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
||||
@ -12412,7 +12375,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL;
|
||||
|
||||
// Tabbing forward wrap
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && result == NULL)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && result == NULL)
|
||||
if ((g.NavTabbingCounter == 1 || g.NavTabbingDir == 0) && g.NavTabbingResultFirst.ID)
|
||||
result = &g.NavTabbingResultFirst;
|
||||
|
||||
@ -12420,7 +12383,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
if (result == NULL)
|
||||
{
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
||||
NavRestoreHighlightAfterMove();
|
||||
@ -12461,9 +12424,11 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
}
|
||||
if (g.ActiveId != result->ID)
|
||||
ClearActiveID();
|
||||
if (g.NavId != result->ID && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
||||
|
||||
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
||||
// PageUp/PageDown however sets always set NavJustMovedTo (vs Home/End which doesn't) mimicking Windows behavior.
|
||||
if ((g.NavId != result->ID || (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)) && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
||||
{
|
||||
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
||||
g.NavJustMovedToId = result->ID;
|
||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||
@ -12476,14 +12441,14 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
|
||||
// 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)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) == 0)
|
||||
{
|
||||
preferred_scoring_pos_rel[axis] = result->RectRel.GetCenter()[axis];
|
||||
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
|
||||
}
|
||||
|
||||
// Tabbing: Activates Inputable, otherwise only Focus
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
||||
g.NavMoveFlags &= ~ImGuiNavMoveFlags_Activate;
|
||||
|
||||
// Activate
|
||||
@ -12492,7 +12457,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
g.NavNextActivateId = result->ID;
|
||||
g.NavNextActivateFlags = ImGuiActivateFlags_None;
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
|
||||
g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState;
|
||||
}
|
||||
|
||||
@ -12592,14 +12557,14 @@ static float ImGui::NavUpdatePageUpPageDown()
|
||||
nav_scoring_rect_offset_y = -page_offset_y;
|
||||
g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
|
||||
g.NavMoveClipDir = ImGuiDir_Up;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||
}
|
||||
else if (IsKeyPressed(ImGuiKey_PageDown, true))
|
||||
{
|
||||
nav_scoring_rect_offset_y = +page_offset_y;
|
||||
g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
|
||||
g.NavMoveClipDir = ImGuiDir_Down;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||
}
|
||||
else if (home_pressed)
|
||||
{
|
||||
@ -19441,7 +19406,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// DrawLists
|
||||
int drawlist_count = 0;
|
||||
for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++)
|
||||
drawlist_count += g.Viewports[viewport_i]->DrawDataBuilder.GetDrawListCount();
|
||||
drawlist_count += g.Viewports[viewport_i]->DrawDataP.CmdLists.Size;
|
||||
if (TreeNode("DrawLists", "DrawLists (%d)", drawlist_count))
|
||||
{
|
||||
Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh);
|
||||
@ -19450,14 +19415,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[viewport_i];
|
||||
bool viewport_has_drawlist = false;
|
||||
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
|
||||
{
|
||||
if (!viewport_has_drawlist)
|
||||
Text("Active DrawLists in Viewport #%d, ID: 0x%08X", viewport->Idx, viewport->ID);
|
||||
viewport_has_drawlist = true;
|
||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
|
||||
}
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
||||
{
|
||||
if (!viewport_has_drawlist)
|
||||
Text("Active DrawLists in Viewport #%d, ID: 0x%08X", viewport->Idx, viewport->ID);
|
||||
viewport_has_drawlist = true;
|
||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
||||
}
|
||||
}
|
||||
TreePop();
|
||||
}
|
||||
@ -20261,9 +20225,8 @@ void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
|
||||
(flags & ImGuiViewportFlags_NoAutoMerge) ? " NoAutoMerge" : "",
|
||||
(flags & ImGuiViewportFlags_TopMost) ? " TopMost" : "",
|
||||
(flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "");
|
||||
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
|
||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
|
||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
||||
TreePop();
|
||||
}
|
||||
}
|
||||
|
23
imgui.h
23
imgui.h
@ -25,7 +25,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.8 WIP"
|
||||
#define IMGUI_VERSION_NUM 18972
|
||||
#define IMGUI_VERSION_NUM 18973
|
||||
#define IMGUI_HAS_TABLE
|
||||
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||
#define IMGUI_HAS_DOCK // Docking WIP branch
|
||||
@ -2856,19 +2856,20 @@ struct ImDrawList
|
||||
// as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList)
|
||||
struct ImDrawData
|
||||
{
|
||||
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
||||
int CmdListsCount; // Number of ImDrawList* to render
|
||||
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||
ImDrawList** CmdLists; // Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here.
|
||||
ImVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
|
||||
ImVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
|
||||
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
|
||||
ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
|
||||
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
||||
int CmdListsCount; // Number of ImDrawList* to render
|
||||
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||
ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here.
|
||||
ImVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
|
||||
ImVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
|
||||
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
|
||||
ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
|
||||
|
||||
// Functions
|
||||
ImDrawData() { Clear(); }
|
||||
void Clear() { memset(this, 0, sizeof(*this)); } // The ImDrawList are owned by ImGuiContext!
|
||||
IMGUI_API void Clear();
|
||||
IMGUI_API void AddDrawList(ImDrawList* draw_list); // Helper to add an external draw list into an existing ImDrawData.
|
||||
IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||
IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||
};
|
||||
|
@ -1814,6 +1814,63 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
||||
// [SECTION] ImDrawData
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImDrawData::Clear()
|
||||
{
|
||||
Valid = false;
|
||||
CmdListsCount = TotalIdxCount = TotalVtxCount = 0;
|
||||
CmdLists.resize(0); // The ImDrawList are NOT owned by ImDrawData but e.g. by ImGuiContext, so we don't clear them.
|
||||
DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.0f, 0.0f);
|
||||
OwnerViewport = NULL;
|
||||
}
|
||||
|
||||
// Important: 'out_list' is generally going to be draw_data->CmdLists, but may be another temporary list
|
||||
// as long at it is expected that the result will be later merged into draw_data->CmdLists[].
|
||||
void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
||||
{
|
||||
if (draw_list->CmdBuffer.Size == 0)
|
||||
return;
|
||||
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
|
||||
return;
|
||||
|
||||
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||
// May trigger for you if you are using PrimXXX functions incorrectly.
|
||||
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
||||
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
||||
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
|
||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
||||
|
||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
|
||||
// If this assert triggers because you are drawing lots of stuff manually:
|
||||
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
|
||||
// Be mindful that the lower-level ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents.
|
||||
// - If you want large meshes with more than 64K vertices, you can either:
|
||||
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
|
||||
// Most example backends already support this from 1.71. Pre-1.71 backends won't.
|
||||
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
|
||||
// (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
|
||||
// Most example backends already support this. For example, the OpenGL example code detect index size at compile-time:
|
||||
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
|
||||
// Your own engine or render API may use different parameters or function calls to specify index sizes.
|
||||
// 2 and 4 bytes indices are generally supported by most graphics API.
|
||||
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
|
||||
// the 64K limit to split your draw commands in multiple draw lists.
|
||||
if (sizeof(ImDrawIdx) == 2)
|
||||
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
|
||||
|
||||
// Add to output list + records state in ImDrawData
|
||||
out_list->push_back(draw_list);
|
||||
draw_list->_PopUnusedDrawCmd();
|
||||
draw_data->CmdListsCount++;
|
||||
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
|
||||
}
|
||||
|
||||
void ImDrawData::AddDrawList(ImDrawList* draw_list)
|
||||
{
|
||||
IM_ASSERT(CmdLists.Size == CmdListsCount);
|
||||
ImGui::AddDrawListToDrawDataEx(this, &CmdLists, draw_list);
|
||||
}
|
||||
|
||||
// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||
void ImDrawData::DeIndexAllBuffers()
|
||||
{
|
||||
|
@ -782,12 +782,10 @@ struct IMGUI_API ImDrawListSharedData
|
||||
|
||||
struct ImDrawDataBuilder
|
||||
{
|
||||
ImVector<ImDrawList*> Layers[2]; // Global layers for: regular, tooltip
|
||||
ImVector<ImDrawList*>* Layers[2]; // Pointers to global layers for: regular, tooltip. LayersP[0] is owned by DrawData.
|
||||
ImVector<ImDrawList*> LayerData1;
|
||||
|
||||
void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
|
||||
void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
|
||||
int GetDrawListCount() const { int count = 0; for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) count += Layers[n].Size; return count; }
|
||||
IMGUI_API void FlattenIntoSingleLayer();
|
||||
ImDrawDataBuilder() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1514,10 +1512,11 @@ enum ImGuiNavMoveFlags_
|
||||
ImGuiNavMoveFlags_Forwarded = 1 << 7,
|
||||
ImGuiNavMoveFlags_DebugNoResult = 1 << 8, // Dummy scoring for debug purpose, don't apply result
|
||||
ImGuiNavMoveFlags_FocusApi = 1 << 9, // Requests from focus API can land/focus/activate items even if they are marked with _NoTabStop (see NavProcessItemForTabbingRequest() for details)
|
||||
ImGuiNavMoveFlags_Tabbing = 1 << 10, // == Focus + Activate if item is Inputable + DontChangeNavHighlight
|
||||
ImGuiNavMoveFlags_Activate = 1 << 11, // Activate/select target item.
|
||||
ImGuiNavMoveFlags_NoSelect = 1 << 12, // Don't trigger selection by not setting g.NavJustMovedTo
|
||||
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 13, // Do not alter the visible state of keyboard vs mouse nav highlight
|
||||
ImGuiNavMoveFlags_IsTabbing = 1 << 10, // == Focus + Activate if item is Inputable + DontChangeNavHighlight
|
||||
ImGuiNavMoveFlags_IsPageMove = 1 << 11, // Identify a PageDown/PageUp request.
|
||||
ImGuiNavMoveFlags_Activate = 1 << 12, // Activate/select target item.
|
||||
ImGuiNavMoveFlags_NoSelect = 1 << 13, // Don't trigger selection by not setting g.NavJustMovedTo
|
||||
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 14, // Do not alter the visible state of keyboard vs mouse nav highlight
|
||||
};
|
||||
|
||||
enum ImGuiNavLayer
|
||||
@ -1772,7 +1771,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
||||
ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
||||
ImDrawData DrawDataP;
|
||||
ImDrawDataBuilder DrawDataBuilder;
|
||||
ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
|
||||
ImVec2 LastPlatformPos;
|
||||
ImVec2 LastPlatformSize;
|
||||
ImVec2 LastRendererSize;
|
||||
@ -3038,6 +3037,7 @@ namespace ImGui
|
||||
IMGUI_API void SetCurrentFont(ImFont* font);
|
||||
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
||||
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { return GetForegroundDrawList(window->Viewport); }
|
||||
IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||
|
||||
// Init
|
||||
IMGUI_API void Initialize();
|
||||
|
Loading…
Reference in New Issue
Block a user