From a2eff6eadc0cd605a4d116d5bd24b625580361fb Mon Sep 17 00:00:00 2001 From: 4DBug <115124145+4DBug@users.noreply.github.com> Date: Wed, 21 Oct 2026 01:29:48 -0500 Subject: [PATCH] build: rebuild Roblox bundle + worker (round 2: bundle-time ImGui.* localization, patches.lua, library allocations, backend raster/bookkeeping) --- build/ImGui.linemap.json | 2 +- build/ImGui.luau | 13650 +++++++++++++++++--------------- build/ImGuiWorker.client.luau | 31 +- 3 files changed, 7204 insertions(+), 6479 deletions(-) diff --git a/build/ImGui.linemap.json b/build/ImGui.linemap.json index 2e07f7f..c8b8ea6 100644 --- a/build/ImGui.linemap.json +++ b/build/ImGui.linemap.json @@ -1 +1 @@ -[[46, "imgui.lua"], [22716, "imgui_demo.lua"], [34573, "imgui_draw.lua"], [42966, "imgui_h.lua"], [45969, "roblox/raster.lua"], [46902, "roblox/textures.lua"], [47140, "roblox/layers.lua"], [47524, "roblox/overlays.lua"], [47605, "roblox/render.lua"], [48499, "roblox/parallel.lua"], [49028, "imgui_impl_roblox.lua"], [49529, "imgui_impl_roblox_fonts.lua"], [55932, "imgui_internal.lua"], [59903, "imgui_tables.lua"], [65016, "imgui_widgets.lua"], [77307, "imstb_rectpack.lua"], [77984, "imstb_textedit.lua"], [79526, "imstb_truetype.lua"], [82487, "imstd_minstdio.lua"]] \ No newline at end of file +[[49, "imgui.lua"], [22772, "imgui_demo.lua"], [34632, "imgui_draw.lua"], [43051, "imgui_h.lua"], [46054, "roblox/raster.lua"], [47012, "roblox/textures.lua"], [47263, "roblox/layers.lua"], [47675, "roblox/overlays.lua"], [47756, "roblox/render.lua"], [48818, "roblox/parallel.lua"], [49348, "roblox/patches.lua"], [49633, "imgui_impl_roblox.lua"], [50137, "imgui_impl_roblox_fonts.lua"], [56542, "imgui_internal.lua"], [60516, "imgui_tables.lua"], [65640, "imgui_widgets.lua"], [78007, "imstb_rectpack.lua"], [78684, "imstb_textedit.lua"], [80226, "imstb_truetype.lua"], [83187, "imstd_minstdio.lua"]] \ No newline at end of file diff --git a/build/ImGui.luau b/build/ImGui.luau index e40eae2..47a9694 100644 --- a/build/ImGui.luau +++ b/build/ImGui.luau @@ -1,7 +1,7 @@ --!optimize 2 -- GENERATED by tools/bundle.py from *.lua, backends/, fonts/ - do not edit -local ImGui, ImVec2, ImVec4, ImRect, ImVec2_Copy, HelpMarker, IMGUI_DEMO_MARKER, ImGuiTableFlags, ImStd, ImVector, ImDrawFlags, ImGuiInputFlags, ImRect_Copy, ImStb, ImGuiDataType, IM_TRUNC, ImGuiKey, ImGuiStyleVarInfo, ImVec2_CopyV, IM_ASSERT_USER_ERROR, ImGuiHoveredFlags, ImHashStr, IM_ASSERT_USER_ERROR_RET, ImIsPowerOfTwo, ImS32, ImGuiColorEditFlags, ImVec4_Copy, ImAbs, ExampleAppConsoleMT, ImFormatString, IM_ROUND, ImGuiTableColumnFlags, ImGuiTreeNodeFlags, PopStyleCompact, PushStyleCompact, IM_ASSERT_PARANOID, ImU16, ExampleNames, ImGuiWindowFlags, ImGuiItemFlags, stbte, ImColor, ImCos, ImGuiButtonFlags, ImGuiDebugLogFlags, ImGuiListClipper, ImGuiLocKey, ImU32, ExampleTreeFuncs, ImS16, _PathArcToFastExXY, ImGuiMultiSelectFlags, ImSin, ImGuiTabBarFlags, ImLengthSqr, ImUpperPowerOfTwo, IM_F32_TO_INT8_SAT, ImFontAtlasPackGetRect, ImS64, DockSettingsRenameNodeReferences, ExampleDualListBoxMT, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImCeil, ImFabs, ImGuiCol, ImGuiSelectionBasicStorage, ImS8, ImU8, ExampleAppPropertyEditorMT, ImGuiChildFlags, ImGuiDockNodeFlags, ImGuiLastItemData_Copy, IMGUI_DEBUG_LOG_IO, ImAddClampOverflow, ImGuiScrollFlags, ImLog, ImMemchr, ImStrByte, ImSubClampOverflow, ExampleSelectionWithDeletionMT, IMGUI_DEBUG_LOG_VIEWPORT, ImFontCalcWordWrapPositionEx, ImGuiInputEvent, ImGuiPackedDate, ImGuiTextBuffer, ImHashData, ImPow, ImTrunc64, ImU64, CustomConstraints, ExampleAppLogMT, IMGUI_DEBUG_LOG_FONT, IMGUI_DEBUG_LOG_SELECTION, IMGUI_DISABLE_DEBUG_TOOLS, ImFontAtlasBuildInit, ImFontAtlasFontDestroyOutput, ImGuiComboFlags, ImGuiLastItemData, ImGuiPayload_IsDataType, ImGuiPopupFlags, ImGuiSliderFlags, ImGuiTextFilter, ImRotate, ImSqrt, ImTextClassifierSetCharClass, ImTextureRef, MyDocument, ShowExampleMenuFile, CalcCornerArcStepAndCount, CalcNextScrollFromScrollTargetAndClamp, DataTypeFormatStringCached, IMGUI_PAYLOAD_TYPE_WINDOW, IMGUI_VERSION, ImCharIsBlankW, ImCharIsSeparatorW, ImFmod, ImFontAtlasBakedAddFontGlyph, ImFontAtlasPackAddRect, ImFontBaked_BuildLoadGlyph, ImFontConfig, ImGuiInputTextFlags, ImGuiLogFlags, ImGuiNavMoveFlags, ImGuiStyle_Copy, ImVec1_Copy, ExampleAsset_s_current_sort_specs, ExampleMemberInfo, ExampleTree_CreateNode, IMGUI_PAYLOAD_TYPE_COLOR_4F, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC, IM_F32_TO_INT8_UNBOUND, IM_PI, ImCharIsBlankA, ImFontAtlasBuildNotifySetFont, ImFontAtlasBuildRenderBitmapFromString, ImFontAtlasFontDestroySourceData, ImFontAtlasFontDiscardBakes, ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit, ImFontAtlasRectId_GetIndex, ImFontAtlasTextureAdd, ImFontAtlasTextureBlockQueueUpload, ImFontAtlasTextureGrow, ImFontBaked_BuildGrowIndex, ImFontGlyph, ImGuiTableColumn, ImGuiWindowClass, ImParseFormatFindStart, ImRect_CopyFromV4, ImTextureRect, MyItem_s_current_sort_specs, stb_textedit_key, stbtt_GetGlyphBitmapBoxSubpixel, DockSettingsHandler_ClearAll, EditTableSizingFlags, ExampleSelectionWithDeletion, FormatCached, IMGUI_DEBUG_LOG_TABLE, IMGUI_PAYLOAD_TYPE_COLOR_3F, IM_FREE +local ImGui, ImVec2, ImVec4, ImRect, HelpMarker, ImVec2_Copy, IMGUI_DEMO_MARKER, ImGuiTableFlags, ImStd, ImVector, ImDrawFlags, ImRect_Copy, ImGuiInputFlags, ImStb, ImGuiDataType, IM_TRUNC, ImGuiKey, ImVec2_CopyV, ImGuiStyleVarInfo, IM_ASSERT_USER_ERROR, ImGuiHoveredFlags, ImHashStr, IM_ASSERT_USER_ERROR_RET, ImIsPowerOfTwo, ImS32, ImGuiColorEditFlags, ImVec4_Copy, ImAbs, ExampleAppConsoleMT, ImFormatString, IM_ROUND, ImGuiTableColumnFlags, ImGuiTreeNodeFlags, PopStyleCompact, PushStyleCompact, IM_ASSERT_PARANOID, ImU16, ExampleNames, ImGuiWindowFlags, ImGuiItemFlags, stbte, ImColor, ImCos, ImGuiButtonFlags, ImGuiDebugLogFlags, ImGuiListClipper, ImGuiLocKey, ImU32, ExampleTreeFuncs, ImS16, _PathArcToFastExXY, ImGuiMultiSelectFlags, ImSin, ImGuiTabBarFlags, ImLengthSqr, ImUpperPowerOfTwo, IM_F32_TO_INT8_SAT, ImFontAtlasPackGetRect, ImS64, DockSettingsRenameNodeReferences, ExampleDualListBoxMT, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImCeil, ImFabs, ImGuiCol, ImGuiSelectionBasicStorage, ImS8, ImU8, ExampleAppPropertyEditorMT, ImFontCalcWordWrapPositionEx, ImGuiChildFlags, ImGuiDockNodeFlags, ImGuiLastItemData_Copy, ImMemchr, IMGUI_DEBUG_LOG_IO, ImAddClampOverflow, ImGuiScrollFlags, ImLog, ImStrByte, ImSubClampOverflow, ExampleSelectionWithDeletionMT, IMGUI_DEBUG_LOG_VIEWPORT, ImGuiInputEvent, ImGuiPackedDate, ImGuiTextBuffer, ImHashData, ImPow, ImTrunc64, ImU64, CustomConstraints, ExampleAppLogMT, IMGUI_DEBUG_LOG_FONT, IMGUI_DEBUG_LOG_SELECTION, IMGUI_DISABLE_DEBUG_TOOLS, ImFontAtlasBuildInit, ImFontAtlasFontDestroyOutput, ImGuiComboFlags, ImGuiLastItemData, ImGuiPayload_IsDataType, ImGuiPopupFlags, ImGuiSliderFlags, ImGuiTextFilter, ImRotate, ImSqrt, ImTextClassifierSetCharClass, ImTextureRef, MyDocument, ShowExampleMenuFile, CalcCornerArcStepAndCount, CalcNextScrollFromScrollTargetAndClamp, DataTypeFormatStringCached, IMGUI_PAYLOAD_TYPE_WINDOW, IMGUI_VERSION, ImCharIsBlankW, ImCharIsSeparatorW, ImFmod, ImFontAtlasBakedAddFontGlyph, ImFontAtlasPackAddRect, ImFontBaked_BuildLoadGlyph, ImFontCalcTextSizeXY, ImFontConfig, ImGuiInputTextFlags, ImGuiLogFlags, ImGuiNavMoveFlags, ImGuiStyle_Copy, ImVec1_Copy, ExampleAsset_s_current_sort_specs, ExampleMemberInfo, ExampleTree_CreateNode, IMGUI_PAYLOAD_TYPE_COLOR_4F, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC, IM_F32_TO_INT8_UNBOUND, IM_PI, ImCharIsBlankA, ImFontAtlasBuildNotifySetFont, ImFontAtlasBuildRenderBitmapFromString, ImFontAtlasFontDestroySourceData, ImFontAtlasFontDiscardBakes, ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit, ImFontAtlasRectId_GetIndex, ImFontAtlasTextureAdd, ImFontAtlasTextureBlockQueueUpload, ImFontAtlasTextureGrow, ImFontBaked_BuildGrowIndex, ImFontGlyph, ImGuiTableColumn, ImGuiWindowClass, ImParseFormatFindStart, ImRect_CopyFromV4, ImTextureRect, MyItem_s_current_sort_specs, stb_textedit_key, stbtt_GetGlyphBitmapBoxSubpixel, DockSettingsHandler_ClearAll, EditTableSizingFlags, ExampleSelectionWithDeletion, FormatCached, IMGUI_DEBUG_LOG_TABLE, IMGUI_PAYLOAD_TYPE_COLOR_3F local type, mathMin, mathMax, mathFloor, mathCeil, bitOr, bitLShift = type, math.min, math.max, math.floor, math.ceil, bit32.bor, bit32.lshift local function IM_COL32(R, G, B, A) return (bitOr(bitLShift(A, 24 --[[IM_COL32_A_SHIFT]]), bitLShift(B, 16 --[[IM_COL32_B_SHIFT]]), bitLShift(G, 8 --[[IM_COL32_G_SHIFT]]), bitLShift(R, 0 --[[IM_COL32_R_SHIFT]]))) end @native @@ -35,14 +35,17 @@ local function ImTrunc(v) end local function ImFloor(f) return math.floor(f) end local function ImSaturate(f) return ((f < 0.0 and 0.0) or (f > 1.0 and 1.0) or f) end -local __FILES, __LOADED = {}, {} +local __FILES, __LOADED, __BIND = {}, {}, {} function IM_INCLUDE(name) local r = __LOADED[name] - if r == nil then r = __FILES[name](); if r == nil then r = true end; __LOADED[name] = r end + if r == nil then r = __FILES[name](); if r == nil then r = true end; __LOADED[name] = r; for i = 1, #__BIND do __BIND[i]() end end return r end -__FILES['imgui.lua'] = function() +__FILES['imgui.lua'] = (function() +local ImGui_AddUpdateViewport, ImGui_BeginDisabled, ImGui_BeginPopupEx, ImGui_BeginTable, ImGui_BringWindowToDisplayFront, ImGui_BulletText, ImGui_Button, ImGui_ButtonBehavior, ImGui_CalcRoundingFlagsForRectInRect, ImGui_CalcTextSize, ImGui_CalcTextSizeXY, ImGui_CallContextHooks, ImGui_Checkbox, ImGui_CheckboxFlags, ImGui_ClearActiveID, ImGui_ClearDragDrop, ImGui_ClosePopupToLevel, ImGui_ClosePopupsOverWindow, ImGui_ColorConvertU32ToFloat4, ImGui_ConvertSingleModFlagToKey, ImGui_CreateNewWindowSettings, ImGui_DebugLocateItemOnHover, ImGui_DebugNodeDockNode, ImGui_DebugNodeWindow, ImGui_DebugNodeWindowsList, ImGui_DockContextAddNode, ImGui_DockContextClearNodes, ImGui_DockContextDeleteNode, ImGui_DockContextFindNodeByID, ImGui_DockContextProcessUndockWindow, ImGui_DockContextRemoveNode, ImGui_DockNodeAddWindow, ImGui_DockNodeGetRootNode, ImGui_DockNodeMoveWindows, ImGui_DockNodeRemoveTabBar, ImGui_DockNodeRemoveWindow, ImGui_DockNodeTreeFindVisibleNodeByPos, ImGui_DockNodeTreeUpdatePosSize, ImGui_DockNodeUpdate, ImGui_DockNodeUpdateHasCentralNodeChild, ImGui_EndDisabled, ImGui_EndPopup, ImGui_EndTable, ImGui_EndTooltip, ImGui_FindRenderedTextEnd, ImGui_FindViewportByID, ImGui_FindWindowByID, ImGui_FindWindowByName, ImGui_FindWindowSettingsByID, ImGui_FocusWindow, ImGui_GetColorU32, ImGui_GetCurrentContext, ImGui_GetCurrentWindow, ImGui_GetCurrentWindowRead, ImGui_GetFontSize, ImGui_GetForegroundDrawList, ImGui_GetFrameHeight, ImGui_GetKeyData, ImGui_GetKeyName, ImGui_GetMainViewport, ImGui_GetTopMostPopupModal, ImGui_GetWindowDrawList, ImGui_Indent, ImGui_IsItemHovered, ImGui_IsKeyDown, ImGui_IsKeyPressedEx, ImGui_IsMouseClicked, ImGui_IsMouseHoveringRect, ImGui_IsMousePosValid, ImGui_IsNamedKeyOrMod, ImGui_IsPopupOpen, ImGui_IsWindowActiveAndVisible, ImGui_IsWindowChildOf, ImGui_IsWindowWithinBeginStackOf, ImGui_KeepAliveID, ImGui_LogRenderedText, ImGui_LogText, ImGui_MarkIniSettingsDirty, ImGui_MouseButtonToKey, ImGui_NavApplyItemToResult, ImGui_NavClearPreferredPosForAxis, ImGui_NavInitWindow, ImGui_NavUpdateAnyRequestFlag, ImGui_OpenPopupEx, ImGui_PopID, ImGui_PopStyleColor, ImGui_PopStyleVar, ImGui_PushID, ImGui_PushStyleColor, ImGui_PushStyleVar, ImGui_SameLine, ImGui_ScrollToRectEx, ImGui_Selectable, ImGui_Separator, ImGui_SeparatorText, ImGui_SetActiveID, ImGui_SetCurrentViewport, ImGui_SetKeyOwner, ImGui_SetNavCursorVisibleAfterMove, ImGui_SetNavFocusScope, ImGui_SetNavID, ImGui_SetNavWindow, ImGui_SetNextItemWidth, ImGui_SetNextWindowPos, ImGui_SetNextWindowSize, ImGui_SetScrollFromPosX, ImGui_SetScrollFromPosY, ImGui_SetScrollY, ImGui_SetWindowPos, ImGui_Shortcut, ImGui_SmallButton, ImGui_TabBarFindTabByID, ImGui_TabBarGetTabName, ImGui_TableNextColumn, ImGui_TableSetupColumn, ImGui_TestKeyOwner, ImGui_Text, ImGui_TextUnformatted, ImGui_TreePop, ImGui_Unindent, ImGui_WindowRectAbsToRel +__BIND[#__BIND + 1] = function() if ImGui then ImGui_AddUpdateViewport = ImGui.AddUpdateViewport ImGui_BeginDisabled = ImGui.BeginDisabled ImGui_BeginPopupEx = ImGui.BeginPopupEx ImGui_BeginTable = ImGui.BeginTable ImGui_BringWindowToDisplayFront = ImGui.BringWindowToDisplayFront ImGui_BulletText = ImGui.BulletText ImGui_Button = ImGui.Button ImGui_ButtonBehavior = ImGui.ButtonBehavior ImGui_CalcRoundingFlagsForRectInRect = ImGui.CalcRoundingFlagsForRectInRect ImGui_CalcTextSize = ImGui.CalcTextSize ImGui_CalcTextSizeXY = ImGui.CalcTextSizeXY ImGui_CallContextHooks = ImGui.CallContextHooks ImGui_Checkbox = ImGui.Checkbox ImGui_CheckboxFlags = ImGui.CheckboxFlags ImGui_ClearActiveID = ImGui.ClearActiveID ImGui_ClearDragDrop = ImGui.ClearDragDrop ImGui_ClosePopupToLevel = ImGui.ClosePopupToLevel ImGui_ClosePopupsOverWindow = ImGui.ClosePopupsOverWindow ImGui_ColorConvertU32ToFloat4 = ImGui.ColorConvertU32ToFloat4 ImGui_ConvertSingleModFlagToKey = ImGui.ConvertSingleModFlagToKey ImGui_CreateNewWindowSettings = ImGui.CreateNewWindowSettings ImGui_DebugLocateItemOnHover = ImGui.DebugLocateItemOnHover ImGui_DebugNodeDockNode = ImGui.DebugNodeDockNode ImGui_DebugNodeWindow = ImGui.DebugNodeWindow ImGui_DebugNodeWindowsList = ImGui.DebugNodeWindowsList ImGui_DockContextAddNode = ImGui.DockContextAddNode ImGui_DockContextClearNodes = ImGui.DockContextClearNodes ImGui_DockContextDeleteNode = ImGui.DockContextDeleteNode ImGui_DockContextFindNodeByID = ImGui.DockContextFindNodeByID ImGui_DockContextProcessUndockWindow = ImGui.DockContextProcessUndockWindow ImGui_DockContextRemoveNode = ImGui.DockContextRemoveNode ImGui_DockNodeAddWindow = ImGui.DockNodeAddWindow ImGui_DockNodeGetRootNode = ImGui.DockNodeGetRootNode ImGui_DockNodeMoveWindows = ImGui.DockNodeMoveWindows ImGui_DockNodeRemoveTabBar = ImGui.DockNodeRemoveTabBar ImGui_DockNodeRemoveWindow = ImGui.DockNodeRemoveWindow ImGui_DockNodeTreeFindVisibleNodeByPos = ImGui.DockNodeTreeFindVisibleNodeByPos ImGui_DockNodeTreeUpdatePosSize = ImGui.DockNodeTreeUpdatePosSize ImGui_DockNodeUpdate = ImGui.DockNodeUpdate ImGui_DockNodeUpdateHasCentralNodeChild = ImGui.DockNodeUpdateHasCentralNodeChild ImGui_EndDisabled = ImGui.EndDisabled ImGui_EndPopup = ImGui.EndPopup ImGui_EndTable = ImGui.EndTable ImGui_EndTooltip = ImGui.EndTooltip ImGui_FindRenderedTextEnd = ImGui.FindRenderedTextEnd ImGui_FindViewportByID = ImGui.FindViewportByID ImGui_FindWindowByID = ImGui.FindWindowByID ImGui_FindWindowByName = ImGui.FindWindowByName ImGui_FindWindowSettingsByID = ImGui.FindWindowSettingsByID ImGui_FocusWindow = ImGui.FocusWindow ImGui_GetColorU32 = ImGui.GetColorU32 ImGui_GetCurrentContext = ImGui.GetCurrentContext ImGui_GetCurrentWindow = ImGui.GetCurrentWindow ImGui_GetCurrentWindowRead = ImGui.GetCurrentWindowRead ImGui_GetFontSize = ImGui.GetFontSize ImGui_GetForegroundDrawList = ImGui.GetForegroundDrawList ImGui_GetFrameHeight = ImGui.GetFrameHeight ImGui_GetKeyData = ImGui.GetKeyData ImGui_GetKeyName = ImGui.GetKeyName ImGui_GetMainViewport = ImGui.GetMainViewport ImGui_GetTopMostPopupModal = ImGui.GetTopMostPopupModal ImGui_GetWindowDrawList = ImGui.GetWindowDrawList ImGui_Indent = ImGui.Indent ImGui_IsItemHovered = ImGui.IsItemHovered ImGui_IsKeyDown = ImGui.IsKeyDown ImGui_IsKeyPressedEx = ImGui.IsKeyPressedEx ImGui_IsMouseClicked = ImGui.IsMouseClicked ImGui_IsMouseHoveringRect = ImGui.IsMouseHoveringRect ImGui_IsMousePosValid = ImGui.IsMousePosValid ImGui_IsNamedKeyOrMod = ImGui.IsNamedKeyOrMod ImGui_IsPopupOpen = ImGui.IsPopupOpen ImGui_IsWindowActiveAndVisible = ImGui.IsWindowActiveAndVisible ImGui_IsWindowChildOf = ImGui.IsWindowChildOf ImGui_IsWindowWithinBeginStackOf = ImGui.IsWindowWithinBeginStackOf ImGui_KeepAliveID = ImGui.KeepAliveID ImGui_LogRenderedText = ImGui.LogRenderedText ImGui_LogText = ImGui.LogText ImGui_MarkIniSettingsDirty = ImGui.MarkIniSettingsDirty ImGui_MouseButtonToKey = ImGui.MouseButtonToKey ImGui_NavApplyItemToResult = ImGui.NavApplyItemToResult ImGui_NavClearPreferredPosForAxis = ImGui.NavClearPreferredPosForAxis ImGui_NavInitWindow = ImGui.NavInitWindow ImGui_NavUpdateAnyRequestFlag = ImGui.NavUpdateAnyRequestFlag ImGui_OpenPopupEx = ImGui.OpenPopupEx ImGui_PopID = ImGui.PopID ImGui_PopStyleColor = ImGui.PopStyleColor ImGui_PopStyleVar = ImGui.PopStyleVar ImGui_PushID = ImGui.PushID ImGui_PushStyleColor = ImGui.PushStyleColor ImGui_PushStyleVar = ImGui.PushStyleVar ImGui_SameLine = ImGui.SameLine ImGui_ScrollToRectEx = ImGui.ScrollToRectEx ImGui_Selectable = ImGui.Selectable ImGui_Separator = ImGui.Separator ImGui_SeparatorText = ImGui.SeparatorText ImGui_SetActiveID = ImGui.SetActiveID ImGui_SetCurrentViewport = ImGui.SetCurrentViewport ImGui_SetKeyOwner = ImGui.SetKeyOwner ImGui_SetNavCursorVisibleAfterMove = ImGui.SetNavCursorVisibleAfterMove ImGui_SetNavFocusScope = ImGui.SetNavFocusScope ImGui_SetNavID = ImGui.SetNavID ImGui_SetNavWindow = ImGui.SetNavWindow ImGui_SetNextItemWidth = ImGui.SetNextItemWidth ImGui_SetNextWindowPos = ImGui.SetNextWindowPos ImGui_SetNextWindowSize = ImGui.SetNextWindowSize ImGui_SetScrollFromPosX = ImGui.SetScrollFromPosX ImGui_SetScrollFromPosY = ImGui.SetScrollFromPosY ImGui_SetScrollY = ImGui.SetScrollY ImGui_SetWindowPos = ImGui.SetWindowPos ImGui_Shortcut = ImGui.Shortcut ImGui_SmallButton = ImGui.SmallButton ImGui_TabBarFindTabByID = ImGui.TabBarFindTabByID ImGui_TabBarGetTabName = ImGui.TabBarGetTabName ImGui_TableNextColumn = ImGui.TableNextColumn ImGui_TableSetupColumn = ImGui.TableSetupColumn ImGui_TestKeyOwner = ImGui.TestKeyOwner ImGui_Text = ImGui.Text ImGui_TextUnformatted = ImGui.TextUnformatted ImGui_TreePop = ImGui.TreePop ImGui_Unindent = ImGui.Unindent ImGui_WindowRectAbsToRel = ImGui.WindowRectAbsToRel end end; __BIND[#__BIND]() +return function() -- dear imgui, v1.93 WIP (Luau port) -- (main code and documentation) @@ -588,11 +591,11 @@ do --[[ [SECTION] imgui_dragdrop (was imgui_dragdrop.lua) ]] ------------------------------------------------------------------------------- function ImGui.IsDragDropActive() - return ImGui.GetCurrentContext().DragDropActive + return ImGui_GetCurrentContext().DragDropActive end function ImGui.ClearDragDrop() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() g.DragDropActive = false ImGuiPayload_Clear(g.DragDropPayload) g.DragDropAcceptFlagsCurr = 0 --[[ImGuiDragDropFlags.None]] @@ -611,7 +614,7 @@ end -- - Currently always assume left mouse button. function ImGui.BeginDragDropSource(flags) if flags == nil then flags = 0 end - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow -- FIXME-DRAGDROP: While in the common-most "drag from non-zero active id" case we can tell the mouse button, @@ -650,11 +653,11 @@ function ImGui.BeginDragDropSource(flags) -- Rely on keeping other window.LastItemXXX fields intact. source_id = window:GetIDFromRectangle(g.LastItemData.Rect) g.LastItemData.ID = source_id - ImGui.KeepAliveID(source_id) + ImGui_KeepAliveID(source_id) local is_hovered = ImGui.ItemHoverable(g.LastItemData.Rect, source_id, g.LastItemData.ItemFlags) if is_hovered and g.IO.MouseClicked[mouse_button] then - ImGui.SetActiveID(source_id, window) - ImGui.FocusWindow(window) + ImGui_SetActiveID(source_id, window) + ImGui_FocusWindow(window) end if g.ActiveId == source_id then g.ActiveIdAllowOverlap = is_hovered end -- Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker. end @@ -670,8 +673,8 @@ function ImGui.BeginDragDropSource(flags) source_id = ImHashStr("#SourceExtern") source_drag_active = true mouse_button = g.IO.MouseDown[0] and 0 or -1 - ImGui.KeepAliveID(source_id) - ImGui.SetActiveID(source_id, nil) + ImGui_KeepAliveID(source_id) + ImGui_SetActiveID(source_id, nil) end assert(g.DragDropWithinTarget == false) -- Can't nest BeginDragDropSource() and BeginDragDropTarget() @@ -680,7 +683,7 @@ function ImGui.BeginDragDropSource(flags) -- Activate drag and drop if not g.DragDropActive then assert(source_id ~= 0) - ImGui.ClearDragDrop() + ImGui_ClearDragDrop() local payload = g.DragDropPayload payload.SourceId = source_id payload.SourceParentId = source_parent_id @@ -711,16 +714,16 @@ function ImGui.BeginDragDropSource(flags) end function ImGui.EndDragDropSource() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(g.DragDropActive) assert(g.DragDropWithinSource, "Not after a BeginDragDropSource()?") if bit32.band(g.DragDropSourceFlags, 1 --[[ImGuiDragDropFlags.SourceNoPreviewTooltip]]) == 0 then - ImGui.EndTooltip() + ImGui_EndTooltip() end -- Discard the drag if have not called SetDragDropPayload() - if g.DragDropPayload.DataFrameCount == -1 then ImGui.ClearDragDrop() end + if g.DragDropPayload.DataFrameCount == -1 then ImGui_ClearDragDrop() end g.DragDropWithinSource = false end @@ -728,7 +731,7 @@ end --- @param data any # any Lua value --- @return bool accepted function ImGui.SetDragDropPayload(type, data, data_size, cond) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local payload = g.DragDropPayload if cond == nil or cond == 0 then cond = 1 --[[ImGuiCond.Always]] end @@ -750,14 +753,14 @@ function ImGui.SetDragDropPayload(type, data, data_size, cond) end function ImGui.BeginDragDropTargetCustom(bb, id) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if not g.DragDropActive then return false end local window = g.CurrentWindow local hovered_window = g.HoveredWindowUnderMovingWindow if hovered_window == nil or window.RootWindowDockTree ~= hovered_window.RootWindowDockTree then return false end assert(id ~= 0) - if not ImGui.IsMouseHoveringRect(bb.Min, bb.Max) or (id == g.DragDropPayload.SourceId) then return false end + if not ImGui_IsMouseHoveringRect(bb.Min, bb.Max) or (id == g.DragDropPayload.SourceId) then return false end if window.SkipItems then return false end assert(g.DragDropWithinTarget == false and g.DragDropWithinSource == false) -- Can't nest BeginDragDropSource() and BeginDragDropTarget() @@ -774,12 +777,12 @@ end -- if ImGui.BeginDragDropTargetViewport(ImGui.GetMainViewport(), nil) then -- But we are leaving the hover test to the caller for maximum flexibility. function ImGui.BeginDragDropTargetViewport(viewport, p_bb) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if not g.DragDropActive then return false end local bb = p_bb or viewport:GetWorkRect() local id = viewport.ID - if g.MouseViewport ~= viewport or not ImGui.IsMouseHoveringRect(bb.Min, bb.Max, false) or (id == g.DragDropPayload.SourceId) then + if g.MouseViewport ~= viewport or not ImGui_IsMouseHoveringRect(bb.Min, bb.Max, false) or (id == g.DragDropPayload.SourceId) then return false end @@ -797,7 +800,7 @@ end -- 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can. -- Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case) function ImGui.BeginDragDropTarget() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if not g.DragDropActive then return false end local window = g.CurrentWindow @@ -809,7 +812,7 @@ function ImGui.BeginDragDropTarget() local id = g.LastItemData.ID if id == 0 then id = window:GetIDFromRectangle(display_rect) - ImGui.KeepAliveID(id) + ImGui_KeepAliveID(id) end if g.DragDropPayload.SourceId == id then return false end @@ -823,14 +826,14 @@ function ImGui.BeginDragDropTarget() end function ImGui.IsDragDropPayloadBeingAccepted() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() return g.DragDropActive and g.DragDropAcceptIdPrev ~= 0 end --- @return ImGuiPayload? function ImGui.AcceptDragDropPayload(type, flags) if flags == nil then flags = 0 end - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local payload = g.DragDropPayload assert(g.DragDropActive) -- Not called between BeginDragDropTarget() and EndDragDropTarget() ? assert(payload.DataFrameCount ~= -1) -- Forgot to call EndDragDropTarget() ? @@ -870,7 +873,7 @@ end -- FIXME-STYLE FIXME-DRAGDROP: Settle on a proper default visuals for drop target. function ImGui.RenderDragDropTargetRectForItem(bb) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow local bb_display = ImRect(bb.Min, bb.Max) bb_display:ClipWith(g.DragDropTargetClipRect) -- Clip THEN expand so we have a way to visualize that target is not entirely visible. @@ -882,34 +885,34 @@ function ImGui.RenderDragDropTargetRectForItem(bb) end function ImGui.RenderDragDropTargetRectForViewport(viewport_id, bb) - local g = ImGui.GetCurrentContext() - local viewport = ImGui.FindViewportByID(viewport_id) + local g = ImGui_GetCurrentContext() + local viewport = ImGui_FindViewportByID(viewport_id) assert(viewport ~= nil) local bb_padded = ImRect(bb.Min, bb.Max) bb_padded:Expand(-g.Style.DragDropTargetPadding) - ImGui.RenderDragDropTargetRectEx(ImGui.GetForegroundDrawList(viewport), bb_padded, g.Style.DragDropTargetRounding) + ImGui.RenderDragDropTargetRectEx(ImGui_GetForegroundDrawList(viewport), bb_padded, g.Style.DragDropTargetRounding) end function ImGui.RenderDragDropTargetRectEx(draw_list, bb, rounding) - local g = ImGui.GetCurrentContext() - draw_list:AddRectFilled(bb.Min, bb.Max, ImGui.GetColorU32(57 --[[ImGuiCol.DragDropTargetBg]]), rounding, 0) - draw_list:AddRect(bb.Min, bb.Max, ImGui.GetColorU32(56 --[[ImGuiCol.DragDropTarget]]), rounding, g.Style.DragDropTargetBorderSize) + local g = ImGui_GetCurrentContext() + draw_list:AddRectFilled(bb.Min, bb.Max, ImGui_GetColorU32(57 --[[ImGuiCol.DragDropTargetBg]]), rounding, 0) + draw_list:AddRect(bb.Min, bb.Max, ImGui_GetColorU32(56 --[[ImGuiCol.DragDropTarget]]), rounding, g.Style.DragDropTargetBorderSize) end --- @return ImGuiPayload? function ImGui.GetDragDropPayload() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() return (g.DragDropActive and g.DragDropPayload.DataFrameCount ~= -1) and g.DragDropPayload or nil end function ImGui.EndDragDropTarget() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(g.DragDropActive) assert(g.DragDropWithinTarget) g.DragDropWithinTarget = false -- Clear drag and drop state payload right after delivery - if g.DragDropPayload.Delivery then ImGui.ClearDragDrop() end + if g.DragDropPayload.Delivery then ImGui_ClearDragDrop() end end -- [Port] Payload methods (C++ ImGuiPayload members): payload:IsDataType(t) etc. also work through these globals @@ -1255,7 +1258,7 @@ end function ImGui.DockContextShutdown(ctx) for _, id in ipairs(DockContextNodesSorted(ctx)) do local node = ctx.DockContext.Nodes[id] - if node then ImGui.DockContextDeleteNode(ctx, node) end + if node then ImGui_DockContextDeleteNode(ctx, node) end end end @@ -1270,7 +1273,7 @@ function ImGui.DockContextRebuildNodes(ctx) local dc = ctx.DockContext ImGui.SaveIniSettingsToMemory() local root_id = 0 -- Rebuild all - ImGui.DockContextClearNodes(ctx, root_id, false) + ImGui_DockContextClearNodes(ctx, root_id, false) ImGui.DockContextBuildNodesFromSettings(ctx, dc.NodesSettings.Data, dc.NodesSettings.Size) ImGui.DockContextBuildAddWindowsToNodes(ctx, root_id) end @@ -1281,7 +1284,7 @@ function ImGui.DockContextNewFrameUpdateUndocking(ctx) local dc = ctx.DockContext if bit32.band(g.IO.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) == 0 then if next(dc.Nodes) ~= nil or dc.Requests.Size > 0 then - ImGui.DockContextClearNodes(ctx, 0, true) + ImGui_DockContextClearNodes(ctx, 0, true) end return end @@ -1306,7 +1309,7 @@ function ImGui.DockContextNewFrameUpdateUndocking(ctx) -- Process Undocking requests (we need to process them _before_ the UpdateMouseMovingWindowNewFrame call in NewFrame) for _, req in dc.Requests:iter() do if req.Type == ImGuiDockRequestType.Undock and req.UndockTargetWindow then - ImGui.DockContextProcessUndockWindow(ctx, req.UndockTargetWindow) + ImGui_DockContextProcessUndockWindow(ctx, req.UndockTargetWindow) elseif req.Type == ImGuiDockRequestType.Undock and req.UndockTargetNode then ImGui.DockContextProcessUndockNode(ctx, req.UndockTargetNode) end @@ -1326,7 +1329,7 @@ function ImGui.DockContextNewFrameUpdateDocking(ctx) local hovered_window = g.HoveredWindowUnderMovingWindow if hovered_window then if hovered_window.DockNodeAsHost then - g.DebugHoveredDockNode = ImGui.DockNodeTreeFindVisibleNodeByPos(hovered_window.DockNodeAsHost, g.IO.MousePos) + g.DebugHoveredDockNode = ImGui_DockNodeTreeFindVisibleNodeByPos(hovered_window.DockNodeAsHost, g.IO.MousePos) elseif hovered_window.RootWindow.DockNode then g.DebugHoveredDockNode = hovered_window.RootWindow.DockNode end @@ -1344,7 +1347,7 @@ function ImGui.DockContextNewFrameUpdateDocking(ctx) for _, id in ipairs(DockContextNodesSorted(ctx)) do local node = dc.Nodes[id] if node and node:IsFloatingNode() then - ImGui.DockNodeUpdate(node) + ImGui_DockNodeUpdate(node) end end end @@ -1356,8 +1359,8 @@ function ImGui.DockContextEndFrame(ctx) for _, id in ipairs(DockContextNodesSorted(ctx)) do local node = dc.Nodes[id] if node and node.LastFrameActive == g.FrameCount and node.IsVisible and node.HostWindow and node:IsLeafNode() and not node.IsBgDrawnThisFrame then - local bg_rect = ImRect(node.Pos + ImVec2(0.0, ImGui.GetFrameHeight()), node.Pos + node.Size) - local bg_rounding_flags = ImGui.CalcRoundingFlagsForRectInRect(bg_rect, node.HostWindow:Rect(), g.Style.DockingSeparatorSize) + local bg_rect = ImRect(node.Pos + ImVec2(0.0, ImGui_GetFrameHeight()), node.Pos + node.Size) + local bg_rounding_flags = ImGui_CalcRoundingFlagsForRectInRect(bg_rect, node.HostWindow:Rect(), g.Style.DockingSeparatorSize) node.HostWindow.DrawList:ChannelsSetCurrent(DOCKING_HOST_DRAW_CHANNEL_BG) node.HostWindow.DrawList:AddRectFilled(bg_rect.Min, bg_rect.Max, node.LastBgColor, node.HostWindow.WindowRounding, bg_rounding_flags) end @@ -1373,7 +1376,7 @@ function ImGui.DockContextGenNodeID(ctx) -- FIXME-OPT FIXME-DOCK: This is suboptimal, even if the node count is small enough not to be a worry.0 -- We should poke in ctx.Nodes to find a suitable ID faster. Even more so trivial that ctx.Nodes lookup is already sorted. local id = 0x0001 - while ImGui.DockContextFindNodeByID(ctx, id) ~= nil do id = id + 1 end + while ImGui_DockContextFindNodeByID(ctx, id) ~= nil do id = id + 1 end return id end @@ -1382,7 +1385,7 @@ function ImGui.DockContextAddNode(ctx, id) if id == 0 then id = ImGui.DockContextGenNodeID(ctx) else - assert(ImGui.DockContextFindNodeByID(ctx, id) == nil) + assert(ImGui_DockContextFindNodeByID(ctx, id) == nil) end -- We don't set node.LastFrameAlive on construction. Nodes are always created at all time to reflect .ini settings! @@ -1392,7 +1395,7 @@ function ImGui.DockContextAddNode(ctx, id) end function ImGui.DockContextRemoveNode(ctx, node, merge_sibling_into_parent_node) - assert(ImGui.DockContextFindNodeByID(ctx, node.ID) == node) + assert(ImGui_DockContextFindNodeByID(ctx, node.ID) == node) assert(node.ChildNodes[0] == nil and node.ChildNodes[1] == nil) assert(node.Windows.Size == 0) @@ -1410,7 +1413,7 @@ function ImGui.DockContextRemoveNode(ctx, node, merge_sibling_into_parent_node) if parent_node.ChildNodes[n] == node then node.ParentNode.ChildNodes[n] = nil end end end - ImGui.DockContextDeleteNode(ctx, node) + ImGui_DockContextDeleteNode(ctx, node) end end @@ -1457,7 +1460,7 @@ function ImGui.DockContextPruneUnusedSettingsNodes(ctx) -- We track the 'auto-DockNode <- manual-Window <- manual-DockSpace' in order to avoid 'auto-DockNode' being ditched by DockContextPruneUnusedSettingsNodes() for _, settings in dc.NodesSettings:iter() do if settings.ParentWindowId ~= 0 then - local window_settings = ImGui.FindWindowSettingsByID(settings.ParentWindowId) + local window_settings = ImGui_FindWindowSettingsByID(settings.ParentWindowId) if window_settings and window_settings.DockId ~= 0 then local data = pool[window_settings.DockId] if data then data.CountChildNodes = data.CountChildNodes + 1 end @@ -1506,9 +1509,9 @@ function ImGui.DockContextBuildNodesFromSettings(ctx, node_settings_array, node_ -- Build nodes for node_n = 1, node_settings_count do local settings = node_settings_array[node_n] - if settings.ID ~= 0 and ImGui.DockContextFindNodeByID(ctx, settings.ID) == nil then - local node = ImGui.DockContextAddNode(ctx, settings.ID) - node.ParentNode = (settings.ParentNodeId ~= 0) and ImGui.DockContextFindNodeByID(ctx, settings.ParentNodeId) or nil + if settings.ID ~= 0 and ImGui_DockContextFindNodeByID(ctx, settings.ID) == nil then + local node = ImGui_DockContextAddNode(ctx, settings.ID) + node.ParentNode = (settings.ParentNodeId ~= 0) and ImGui_DockContextFindNodeByID(ctx, settings.ParentNodeId) or nil node.Pos = ImVec2(settings.Pos.x, settings.Pos.y) node.Size = ImVec2(settings.Size.x, settings.Size.y) node.SizeRef = ImVec2(settings.SizeRef.x, settings.SizeRef.y) @@ -1526,8 +1529,8 @@ function ImGui.DockContextBuildNodesFromSettings(ctx, node_settings_array, node_ -- Bind host window immediately if it already exist (in case of a rebuild) -- This is useful as the RootWindowForTitleBarHighlight links necessary to highlight the currently focused node requires node.HostWindow to be set. - local root_node = ImGui.DockNodeGetRootNode(node) - node.HostWindow = ImGui.FindWindowByName(DockNodeGetHostWindowTitle(root_node)) + local root_node = ImGui_DockNodeGetRootNode(node) + node.HostWindow = ImGui_FindWindowByName(DockNodeGetHostWindowTitle(root_node)) end end end @@ -1537,10 +1540,10 @@ function ImGui.DockContextBuildAddWindowsToNodes(ctx, root_id) local g = ctx for _, window in g.Windows:iter() do if window.DockId ~= 0 and window.LastFrameActive >= g.FrameCount - 1 and window.DockNode == nil then - local node = ImGui.DockContextFindNodeByID(ctx, window.DockId) + local node = ImGui_DockContextFindNodeByID(ctx, window.DockId) assert(node ~= nil) -- This should have been called after DockContextBuildNodesFromSettings() - if root_id == 0 or ImGui.DockNodeGetRootNode(node).ID == root_id then - ImGui.DockNodeAddWindow(node, window, true) + if root_id == 0 or ImGui_DockNodeGetRootNode(node).ID == root_id then + ImGui_DockNodeAddWindow(node, window, true) end end end @@ -1622,11 +1625,11 @@ function ImGui.DockContextProcessDock(ctx, req) -- Create new node and add existing window to it if node == nil then - node = ImGui.DockContextAddNode(ctx, 0) + node = ImGui_DockContextAddNode(ctx, 0) node.Pos = ImVec2(target_window.Pos.x, target_window.Pos.y) node.Size = ImVec2(target_window.Size.x, target_window.Size.y) if target_window.DockNodeAsHost == nil then - ImGui.DockNodeAddWindow(node, target_window, true) + ImGui_DockNodeAddWindow(node, target_window, true) local t0 = node.TabBar.Tabs.Data[1] t0.Flags = bit32.band(t0.Flags, bit32.bnot(8388608 --[[ImGuiTabItemFlags.Unsorted]])) target_window.DockIsActive = true @@ -1665,17 +1668,17 @@ function ImGui.DockContextProcessDock(ctx, req) assert(payload_node.OnlyNodeWithWindows ~= nil) -- The docking should have been blocked by DockNodePreviewDockSetup() early on and never submitted. local visible_node = payload_node.OnlyNodeWithWindows if visible_node.TabBar then assert(visible_node.TabBar.Tabs.Size > 0) end - ImGui.DockNodeMoveWindows(node, visible_node) - ImGui.DockNodeMoveWindows(visible_node, node) + ImGui_DockNodeMoveWindows(node, visible_node) + ImGui_DockNodeMoveWindows(visible_node, node) DockSettingsRenameNodeReferences(node.ID, visible_node.ID) end if node:IsCentralNode() then -- Central node property needs to be moved to a leaf node, pick the last focused one. -- FIXME-DOCK: If we had to transfer other flags here, what would the policy be? - local last_focused_node = ImGui.DockContextFindNodeByID(ctx, payload_node.LastFocusedNodeId) + local last_focused_node = ImGui_DockContextFindNodeByID(ctx, payload_node.LastFocusedNodeId) assert(last_focused_node ~= nil) - local last_focused_root_node = ImGui.DockNodeGetRootNode(last_focused_node) - assert(last_focused_root_node == ImGui.DockNodeGetRootNode(payload_node)) + local last_focused_root_node = ImGui_DockNodeGetRootNode(last_focused_node) + assert(last_focused_root_node == ImGui_DockNodeGetRootNode(payload_node)) last_focused_node:SetLocalFlags(bit32.bor(last_focused_node.LocalFlags, 2048 --[[ImGuiDockNodeFlags.CentralNode]])) node:SetLocalFlags(bit32.band(node.LocalFlags, bit32.bnot(2048 --[[ImGuiDockNodeFlags.CentralNode]]))) last_focused_root_node.CentralNode = last_focused_node @@ -1685,15 +1688,15 @@ function ImGui.DockContextProcessDock(ctx, req) ImGui.DockNodeMoveChildNodes(node, payload_node) else local payload_dock_id = payload_node.ID - ImGui.DockNodeMoveWindows(node, payload_node) + ImGui_DockNodeMoveWindows(node, payload_node) DockSettingsRenameNodeReferences(payload_dock_id, node.ID) end - ImGui.DockContextRemoveNode(ctx, payload_node, true) + ImGui_DockContextRemoveNode(ctx, payload_node, true) elseif payload_window then -- Transfer single window local payload_dock_id = payload_window.DockId node.VisibleWindow = payload_window - ImGui.DockNodeAddWindow(node, payload_window, true) + ImGui_DockNodeAddWindow(node, payload_window, true) if payload_dock_id ~= 0 then DockSettingsRenameNodeReferences(payload_dock_id, node.ID) end @@ -1706,7 +1709,7 @@ function ImGui.DockContextProcessDock(ctx, req) -- Update selection immediately local tab_bar = node.TabBar if tab_bar then tab_bar.NextSelectedTabId = next_selected_id end - ImGui.MarkIniSettingsDirty() + ImGui_MarkIniSettingsDirty() end -- Problem: @@ -1726,7 +1729,7 @@ end function ImGui.DockContextProcessUndockWindow(ctx, window, clear_persistent_docking_ref) if clear_persistent_docking_ref == nil then clear_persistent_docking_ref = true end -- [Port] C++ default argument if window.DockNode then - ImGui.DockNodeRemoveWindow(window.DockNode, window, clear_persistent_docking_ref and 0 or window.DockId) + ImGui_DockNodeRemoveWindow(window.DockNode, window, clear_persistent_docking_ref and 0 or window.DockId) else window.DockId = 0 end @@ -1737,7 +1740,7 @@ function ImGui.DockContextProcessUndockWindow(ctx, window, clear_persistent_dock local sz = FixLargeWindowsWhenUndocking(window.SizeFull, window.Viewport) ImVec2_Copy(window.Size, sz) ImVec2_Copy(window.SizeFull, sz) - ImGui.MarkIniSettingsDirty() + ImGui_MarkIniSettingsDirty() end function ImGui.DockContextProcessUndockNode(ctx, node) @@ -1746,11 +1749,11 @@ function ImGui.DockContextProcessUndockNode(ctx, node) if node:IsRootNode() or node:IsCentralNode() then -- In the case of a root node or central node, the node will have to stay in place. Create a new node to receive the payload. - local new_node = ImGui.DockContextAddNode(ctx, 0) + local new_node = ImGui_DockContextAddNode(ctx, 0) new_node.Pos = ImVec2(node.Pos.x, node.Pos.y) new_node.Size = ImVec2(node.Size.x, node.Size.y) new_node.SizeRef = ImVec2(node.SizeRef.x, node.SizeRef.y) - ImGui.DockNodeMoveWindows(new_node, node) + ImGui_DockNodeMoveWindows(new_node, node) DockSettingsRenameNodeReferences(node.ID, new_node.ID) node = new_node else @@ -1771,7 +1774,7 @@ function ImGui.DockContextProcessUndockNode(ctx, node) node.AuthorityForSize = 1 --[[ImGuiDataAuthority.DockNode]] node.Size = FixLargeWindowsWhenUndocking(node.Size, node.Windows.Data[1].Viewport) node.WantMouseMove = true - ImGui.MarkIniSettingsDirty() + ImGui_MarkIniSettingsDirty() end -- This is mostly used for automation. @@ -1827,7 +1830,7 @@ end function ImGui.DockNodeGetTabOrder(window) local tab_bar = window.DockNode.TabBar if tab_bar == nil then return -1 end - local tab = ImGui.TabBarFindTabByID(tab_bar, window.TabId) + local tab = ImGui_TabBarFindTabByID(tab_bar, window.TabId) return tab and ImGui.TabBarGetTabOrder(tab_bar, tab) or -1 end @@ -1840,7 +1843,7 @@ function ImGui.DockNodeAddWindow(node, window, add_to_tab_bar) if window.DockNode then -- Can overwrite an existing window.DockNode (e.g. pointing to a disabled DockSpace node) assert(window.DockNode.ID ~= node.ID) - ImGui.DockNodeRemoveWindow(window.DockNode, window, 0) + ImGui_DockNodeRemoveWindow(window.DockNode, window, 0) end assert(window.DockNode == nil or window.DockNodeAsHost == nil) @@ -1924,13 +1927,13 @@ function ImGui.DockNodeRemoveWindow(node, window, save_dock_id) ImGui.TabBarRemoveTab(node.TabBar, window.TabId) local tab_count_threshold_for_tab_bar = node:IsCentralNode() and 1 or 2 if node.Windows.Size < tab_count_threshold_for_tab_bar then - ImGui.DockNodeRemoveTabBar(node) + ImGui_DockNodeRemoveTabBar(node) end end if node.Windows.Size == 0 and not node:IsCentralNode() and not node:IsDockSpace() and window.DockId ~= node.ID then -- Automatic dock node delete themselves if they are not holding at least one tab - ImGui.DockContextRemoveNode(ImGui.GetCurrentContext(), node, true) + ImGui_DockContextRemoveNode(ImGui_GetCurrentContext(), node, true) return end @@ -1976,19 +1979,19 @@ function ImGui.DockNodeMoveWindows(dst_node, src_node) for _, window in ipairs(windows) do window.DockNode = nil window.DockIsActive = false - ImGui.DockNodeAddWindow(dst_node, window, not move_tab_bar) + ImGui_DockNodeAddWindow(dst_node, window, not move_tab_bar) end src_node.Windows:clear() if not move_tab_bar and src_node.TabBar then if dst_node.TabBar then dst_node.TabBar.SelectedTabId = src_node.TabBar.SelectedTabId end - ImGui.DockNodeRemoveTabBar(src_node) + ImGui_DockNodeRemoveTabBar(src_node) end end function ImGui.DockNodeApplyPosSizeToWindows(node) for _, window in node.Windows:iter() do - ImGui.SetWindowPos(window, node.Pos, 1 --[[ImGuiCond.Always]]) -- We don't assign directly to Pos because it can break the calculation of SizeContents on next frame + ImGui_SetWindowPos(window, node.Pos, 1 --[[ImGuiCond.Always]]) -- We don't assign directly to Pos because it can break the calculation of SizeContents on next frame ImGui.SetWindowSize(window, node.Size, 1 --[[ImGuiCond.Always]]) end end @@ -2002,7 +2005,7 @@ function ImGui.DockNodeHideHostWindow(node) node.VisibleWindow = node.Windows.Data[1] node.Windows.Data[1].DockIsActive = false end - if node.TabBar then ImGui.DockNodeRemoveTabBar(node) end + if node.TabBar then ImGui_DockNodeRemoveTabBar(node) end end local function ImGuiDockNodeTreeInfo() @@ -2036,7 +2039,7 @@ end -- - Remove inactive windows/nodes. -- - Update visibility flag. function ImGui.DockNodeUpdateFlagsAndCollapse(node) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(node.ParentNode == nil or node.ParentNode.ChildNodes[0] == node or node.ParentNode.ChildNodes[1] == node) -- Inherit most flags @@ -2070,10 +2073,10 @@ function ImGui.DockNodeUpdateFlagsAndCollapse(node) if node.Windows.Size == 1 and not node:IsCentralNode() then ImGui.DockNodeHideHostWindow(node) node.State = 1 --[[ImGuiDockNodeState.HostWindowHiddenBecauseSingleWindow]] - ImGui.DockNodeRemoveWindow(node, window, node.ID) -- Will delete the node so it'll be invalid on return + ImGui_DockNodeRemoveWindow(node, window, node.ID) -- Will delete the node so it'll be invalid on return return end - ImGui.DockNodeRemoveWindow(node, window, node.ID) + ImGui_DockNodeRemoveWindow(node, window, node.ID) else -- FIXME-DOCKING: Missing policies for conflict resolution, hence the "Experimental" tag on this. -- node.LocalFlagsInWindow = bit32.band(node.LocalFlagsInWindow, bit32.bnot(window.WindowClass.DockNodeFlagsOverrideClear)) @@ -2103,7 +2106,7 @@ function ImGui.DockNodeUpdateFlagsAndCollapse(node) node:SetLocalFlags(bit32.bxor(node.LocalFlags, 8192 --[[ImGuiDockNodeFlags.HiddenTabBar]])) end if bit32.band(bit32.bxor(node.LocalFlags, prev_local_flags), 261152 --[[ImGuiDockNodeFlags.SavedFlagsMask_]]) ~= 0 then - ImGui.MarkIniSettingsDirty() -- Bit flaky to only do this here. Perhaps compare node flags every frame? #9380 + ImGui_MarkIniSettingsDirty() -- Bit flaky to only do this here. Perhaps compare node flags every frame? #9380 end node.WantHiddenTabBarToggle = false @@ -2113,8 +2116,8 @@ end -- This is rarely called as DockNodeUpdateForRootNode() generally does it most frames. function ImGui.DockNodeUpdateHasCentralNodeChild(node) node.HasCentralNodeChild = false - if node.ChildNodes[0] then ImGui.DockNodeUpdateHasCentralNodeChild(node.ChildNodes[0]) end - if node.ChildNodes[1] then ImGui.DockNodeUpdateHasCentralNodeChild(node.ChildNodes[1]) end + if node.ChildNodes[0] then ImGui_DockNodeUpdateHasCentralNodeChild(node.ChildNodes[0]) end + if node.ChildNodes[1] then ImGui_DockNodeUpdateHasCentralNodeChild(node.ChildNodes[1]) end if node:IsRootNode() then local mark_node = node.CentralNode while mark_node do @@ -2134,7 +2137,7 @@ function ImGui.DockNodeUpdateVisibleFlag(node) end function ImGui.DockNodeStartMouseMovingWindow(node, window) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(node.WantMouseMove == true) ImGui.StartMouseMovingWindow(window) ImVec2_Copy(g.ActiveIdClickOffset, g.IO.MouseClickedPos[0] - node.Pos) @@ -2193,7 +2196,7 @@ local function DockNodeSetupHostWindow(node, host_window) end function ImGui.DockNodeUpdate(node) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(node.LastFrameActive ~= g.FrameCount) node.LastFrameAlive = g.FrameCount node.IsBgDrawnThisFrame = false @@ -2203,7 +2206,7 @@ function ImGui.DockNodeUpdate(node) if node:IsRootNode() then ImGui.DockNodeUpdateForRootNode(node) end -- Remove tab bar if not needed - if node.TabBar and node:IsNoTabBar() then ImGui.DockNodeRemoveTabBar(node) end + if node.TabBar and node:IsNoTabBar() then ImGui_DockNodeRemoveTabBar(node) end -- Early out for hidden root dock nodes (when all DockId references are in inactive windows, or there is only 1 floating window holding on the DockId) local want_to_hide_host_window = false @@ -2227,7 +2230,7 @@ function ImGui.DockNodeUpdate(node) -- Transfer focus immediately so when we revert to a regular window it is immediately selected if node.HostWindow and g.NavWindow == node.HostWindow then - ImGui.FocusWindow(single_window) + ImGui_FocusWindow(single_window) end if node.HostWindow then single_window.Viewport = node.HostWindow.Viewport @@ -2300,16 +2303,16 @@ function ImGui.DockNodeUpdate(node) -- Sync Pos if node.AuthorityForPos == 2 --[[ImGuiDataAuthority.Window]] and ref_window then - ImGui.SetNextWindowPos(ref_window.Pos) + ImGui_SetNextWindowPos(ref_window.Pos) elseif node.AuthorityForPos == 1 --[[ImGuiDataAuthority.DockNode]] then - ImGui.SetNextWindowPos(node.Pos) + ImGui_SetNextWindowPos(node.Pos) end -- Sync Size if node.AuthorityForSize == 2 --[[ImGuiDataAuthority.Window]] and ref_window then - ImGui.SetNextWindowSize(ref_window.SizeFull) + ImGui_SetNextWindowSize(ref_window.SizeFull) elseif node.AuthorityForSize == 1 --[[ImGuiDataAuthority.DockNode]] then - ImGui.SetNextWindowSize(node.Size) + ImGui_SetNextWindowSize(node.Size) end -- Sync Collapsed @@ -2327,9 +2330,9 @@ function ImGui.DockNodeUpdate(node) window_flags = bit32.bor(window_flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) ImGui.SetNextWindowBgAlpha(0.0) -- Don't set ImGuiWindowFlags.NoBackground because it disables borders - ImGui.PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0, 0)) + ImGui_PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0, 0)) ImGui.Begin(window_label, nil, window_flags) - ImGui.PopStyleVar() + ImGui_PopStyleVar() beginned_into_host_window = true host_window = g.CurrentWindow @@ -2344,7 +2347,7 @@ function ImGui.DockNodeUpdate(node) -- When reappearing B/C/D will request focus and be moved to the top of the display pile, but they are not linked to the dock host window -- during the frame they appear. The dock host window would keep its old display order, and the sorting in EndFrame would move B/C/D back -- after the dock host window, losing their top-most status. - if node.HostWindow.Appearing then ImGui.BringWindowToDisplayFront(node.HostWindow) end + if node.HostWindow.Appearing then ImGui_BringWindowToDisplayFront(node.HostWindow) end node.AuthorityForPos = 0 --[[ImGuiDataAuthority.Auto]] node.AuthorityForSize = 0 --[[ImGuiDataAuthority.Auto]] @@ -2367,7 +2370,7 @@ function ImGui.DockNodeUpdate(node) if node:IsRootNode() then local p_window = g.NavWindow and g.NavWindow.RootWindow or nil while p_window ~= nil and p_window.DockNode ~= nil do - local p_node = ImGui.DockNodeGetRootNode(p_window.DockNode) + local p_node = ImGui_DockNodeGetRootNode(p_window.DockNode) if p_node == node then node.LastFocusedNodeId = p_window.DockNode.ID -- Note: not using root node ID! break @@ -2391,7 +2394,7 @@ function ImGui.DockNodeUpdate(node) -- (But we only add it if there's something else on the other side of the hole, otherwise for e.g. fullscreen -- covering passthru node we'd have a gap on the edge not covered by the hole) assert(node:IsDockSpace()) -- We cannot pass this flag without the DockSpace() api. Testing this because we also setup the hole in host_window.ParentNode - local root_node = ImGui.DockNodeGetRootNode(central_node) + local root_node = ImGui_DockNodeGetRootNode(central_node) local root_rect = ImRect(root_node.Pos, root_node.Pos + root_node.Size) local hole_rect = ImRect(central_node.Pos, central_node.Pos + central_node.Size) if hole_rect.Min.x > root_rect.Min.x then hole_rect.Min.x = hole_rect.Min.x + g.WindowsBorderHoverPadding end @@ -2409,18 +2412,18 @@ function ImGui.DockNodeUpdate(node) -- Update position/size, process and draw resizing splitters if node:IsRootNode() and host_window then - ImGui.DockNodeTreeUpdatePosSize(node, host_window.Pos, host_window.Size) - ImGui.PushStyleColor(28 --[[ImGuiCol.Separator]], g.Style.Colors[5 --[[ImGuiCol.Border]]]) - ImGui.PushStyleColor(30 --[[ImGuiCol.SeparatorActive]], g.Style.Colors[33 --[[ImGuiCol.ResizeGripActive]]]) - ImGui.PushStyleColor(29 --[[ImGuiCol.SeparatorHovered]], g.Style.Colors[32 --[[ImGuiCol.ResizeGripHovered]]]) + ImGui_DockNodeTreeUpdatePosSize(node, host_window.Pos, host_window.Size) + ImGui_PushStyleColor(28 --[[ImGuiCol.Separator]], g.Style.Colors[5 --[[ImGuiCol.Border]]]) + ImGui_PushStyleColor(30 --[[ImGuiCol.SeparatorActive]], g.Style.Colors[33 --[[ImGuiCol.ResizeGripActive]]]) + ImGui_PushStyleColor(29 --[[ImGuiCol.SeparatorHovered]], g.Style.Colors[32 --[[ImGuiCol.ResizeGripHovered]]]) ImGui.DockNodeTreeUpdateSplitter(node) - ImGui.PopStyleColor(3) + ImGui_PopStyleColor(3) end -- Draw empty node background (currently can only be the Central Node) if host_window and node:IsEmpty() and node.IsVisible then host_window.DrawList:ChannelsSetCurrent(DOCKING_HOST_DRAW_CHANNEL_BG) - node.LastBgColor = (bit32.band(node_flags, 8 --[[ImGuiDockNodeFlags.PassthruCentralNode]]) ~= 0) and 0 or ImGui.GetColorU32(43 --[[ImGuiCol.DockingEmptyBg]]) + node.LastBgColor = (bit32.band(node_flags, 8 --[[ImGuiDockNodeFlags.PassthruCentralNode]]) ~= 0) and 0 or ImGui_GetColorU32(43 --[[ImGuiCol.DockingEmptyBg]]) if node.LastBgColor ~= 0 then host_window.DrawList:AddRectFilled(node.Pos, node.Pos + node.Size, node.LastBgColor) end @@ -2434,9 +2437,9 @@ function ImGui.DockNodeUpdate(node) if render_dockspace_bg and node.IsVisible then host_window.DrawList:ChannelsSetCurrent(DOCKING_HOST_DRAW_CHANNEL_BG) if central_node_hole then - ImGui.RenderRectFilledWithHole(host_window.DrawList, node:Rect(), central_node:Rect(), ImGui.GetColorU32(2 --[[ImGuiCol.WindowBg]]), 0.0) + ImGui.RenderRectFilledWithHole(host_window.DrawList, node:Rect(), central_node:Rect(), ImGui_GetColorU32(2 --[[ImGuiCol.WindowBg]]), 0.0) else - host_window.DrawList:AddRectFilled(node.Pos, node.Pos + node.Size, ImGui.GetColorU32(2 --[[ImGuiCol.WindowBg]]), 0.0) + host_window.DrawList:AddRectFilled(node.Pos, node.Pos + node.Size, ImGui_GetColorU32(2 --[[ImGuiCol.WindowBg]]), 0.0) end end @@ -2468,8 +2471,8 @@ function ImGui.DockNodeUpdate(node) -- Recurse into children -- FIXME-DOCK FIXME-OPT: Should not need to recurse into children if host_window then - if node.ChildNodes[0] then ImGui.DockNodeUpdate(node.ChildNodes[0]) end - if node.ChildNodes[1] then ImGui.DockNodeUpdate(node.ChildNodes[1]) end + if node.ChildNodes[0] then ImGui_DockNodeUpdate(node.ChildNodes[0]) end + if node.ChildNodes[1] then ImGui_DockNodeUpdate(node.ChildNodes[1]) end -- Render outer borders last (after the tab bar) if node:IsRootNode() then ImGui.RenderWindowOuterBorders(host_window) end @@ -2510,11 +2513,11 @@ function ImGui.DockNodeWindowMenuHandler_Default(ctx, node, tab_bar) for tab_n = 1, tab_bar.Tabs.Size do local tab = tab_bar.Tabs.Data[tab_n] if bit32.band(tab.Flags, 2097152 --[[ImGuiTabItemFlags.Button]]) == 0 then - if ImGui.Selectable(ImGui.TabBarGetTabName(tab_bar, tab), tab.ID == tab_bar.SelectedTabId) then + if ImGui_Selectable(ImGui_TabBarGetTabName(tab_bar, tab), tab.ID == tab_bar.SelectedTabId) then ImGui.TabBarQueueFocus(tab_bar, tab) end - ImGui.SameLine() - ImGui.Text(" ") + ImGui_SameLine() + ImGui_Text(" ") end end end @@ -2522,16 +2525,16 @@ end function ImGui.DockNodeWindowMenuUpdate(node, tab_bar) -- Try to position the menu so it is more likely to stays within the same viewport - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if g.Style.WindowMenuButtonPosition == 0 --[[ImGuiDir.Left]] then - ImGui.SetNextWindowPos(ImVec2(node.Pos.x, node.Pos.y + ImGui.GetFrameHeight()), 1 --[[ImGuiCond.Always]], ImVec2(0.0, 0.0)) + ImGui_SetNextWindowPos(ImVec2(node.Pos.x, node.Pos.y + ImGui_GetFrameHeight()), 1 --[[ImGuiCond.Always]], ImVec2(0.0, 0.0)) else - ImGui.SetNextWindowPos(ImVec2(node.Pos.x + node.Size.x, node.Pos.y + ImGui.GetFrameHeight()), 1 --[[ImGuiCond.Always]], ImVec2(1.0, 0.0)) + ImGui_SetNextWindowPos(ImVec2(node.Pos.x + node.Size.x, node.Pos.y + ImGui_GetFrameHeight()), 1 --[[ImGuiCond.Always]], ImVec2(1.0, 0.0)) end if ImGui.BeginPopup("#WindowMenu") then node.IsFocused = true g.DockNodeWindowMenuHandler(g, node, tab_bar) - ImGui.EndPopup() + ImGui_EndPopup() end end @@ -2549,13 +2552,13 @@ end function ImGui.DockNodeEndAmendTabBar() ImGui.EndTabBar() - ImGui.PopID() + ImGui_PopID() ImGui.End() end local function IsDockNodeTitleBarHighlighted(node, root_node) -- CTRL+Tab highlight (only highlighting leaf node, not whole hierarchy) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if g.NavWindowingTarget then return g.NavWindowingTarget.DockNode == node end @@ -2569,7 +2572,7 @@ local function IsDockNodeTitleBarHighlighted(node, root_node) end local parent_node = parent_window.DockNodeAsHost or parent_window.DockNode while parent_node ~= nil do - parent_node = ImGui.DockNodeGetRootNode(parent_node) + parent_node = ImGui_DockNodeGetRootNode(parent_node) if parent_node == root_node then return true end parent_node = parent_node.HostWindow and parent_node.HostWindow.RootWindow.DockNode or nil end @@ -2579,7 +2582,7 @@ end -- Submit the tab bar corresponding to a dock node and various housekeeping details. function ImGui.DockNodeUpdateTabBar(node, host_window) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local style = g.Style local node_was_active = (node.LastFrameActive + 1 == g.FrameCount) @@ -2588,7 +2591,7 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) -- Decide if we should use a focused title bar color local is_focused = false - local root_node = ImGui.DockNodeGetRootNode(node) + local root_node = ImGui_DockNodeGetRootNode(node) if IsDockNodeTitleBarHighlighted(node, root_node) then is_focused = true end -- Hidden tab bar will show a triangle on the upper-left (in Begin) @@ -2630,7 +2633,7 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) -- In a dock node, the Collapse Button turns into the Window Menu button. -- FIXME-DOCK FIXME-OPT: Could we recycle popups id across multiple dock nodes? - if has_window_menu_button and ImGui.IsPopupOpen("#WindowMenu") then + if has_window_menu_button and ImGui_IsPopupOpen("#WindowMenu") then local next_selected_tab_id = tab_bar.NextSelectedTabId ImGui.DockNodeWindowMenuUpdate(node, tab_bar) if tab_bar.NextSelectedTabId ~= 0 and tab_bar.NextSelectedTabId ~= next_selected_tab_id then @@ -2646,15 +2649,15 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) local tabs_count_old = tab_bar.Tabs.Size for window_n = 1, node.Windows.Size do local window = node.Windows.Data[window_n] - if ImGui.TabBarFindTabByID(tab_bar, window.TabId) == nil then + if ImGui_TabBarFindTabByID(tab_bar, window.TabId) == nil then ImGui.TabBarAddTab(tab_bar, 8388608 --[[ImGuiTabItemFlags.Unsorted]], window) end end -- Title bar if is_focused then node.LastFrameFocused = g.FrameCount end - local title_bar_col = ImGui.GetColorU32(host_window.Collapsed and 12 --[[ImGuiCol.TitleBgCollapsed]] or (is_focused and 11 --[[ImGuiCol.TitleBgActive]] or 10 --[[ImGuiCol.TitleBg]])) - local rounding_flags = ImGui.CalcRoundingFlagsForRectInRect(title_bar_rect, host_window:Rect(), g.Style.DockingSeparatorSize) + local title_bar_col = ImGui_GetColorU32(host_window.Collapsed and 12 --[[ImGuiCol.TitleBgCollapsed]] or (is_focused and 11 --[[ImGuiCol.TitleBgActive]] or 10 --[[ImGuiCol.TitleBg]])) + local rounding_flags = ImGui_CalcRoundingFlagsForRectInRect(title_bar_rect, host_window:Rect(), g.Style.DockingSeparatorSize) host_window.DrawList:AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window.WindowRounding, rounding_flags) -- Docking/Collapse button @@ -2663,7 +2666,7 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) ImGui.OpenPopup("#WindowMenu") end if ImGui.IsItemActive() then focus_tab_id = tab_bar.SelectedTabId end - if ImGui.IsItemHovered(bit32.bor(4096 --[[ImGuiHoveredFlags.ForTooltip]], 65536 --[[ImGuiHoveredFlags.DelayNormal]])) and g.HoveredIdTimer > 0.5 then + if ImGui_IsItemHovered(bit32.bor(4096 --[[ImGuiHoveredFlags.ForTooltip]], 65536 --[[ImGuiHoveredFlags.DelayNormal]])) and g.HoveredIdTimer > 0.5 then ImGui.SetTooltip("%s", ImGui.LocalizeGetMsg(15 --[[ImGuiLocKey.DockingDragToUndockOrMoveNode]])) end end @@ -2691,7 +2694,7 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) end -- Selected newly added tabs, or persistent tab ID if the tab bar was just recreated - if tab_bar_is_recreated and ImGui.TabBarFindTabByID(tab_bar, node.SelectedTabId) ~= nil then + if tab_bar_is_recreated and ImGui_TabBarFindTabByID(tab_bar, node.SelectedTabId) ~= nil then tab_bar.SelectedTabId = node.SelectedTabId tab_bar.NextSelectedTabId = node.SelectedTabId elseif tab_bar.Tabs.Size > tabs_count_old then @@ -2737,7 +2740,7 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) -- Apply stored style overrides for the window for color_n = 0, 9 --[[ImGuiWindowDockStyleCol.COUNT]] - 1 do - ImVec4_Copy(g.Style.Colors[GWindowDockStyleColors[color_n]], ImGui.ColorConvertU32ToFloat4(window.DockStyle.Colors[color_n])) + ImVec4_Copy(g.Style.Colors[GWindowDockStyleColors[color_n]], ImGui_ColorConvertU32ToFloat4(window.DockStyle.Colors[color_n])) end -- Note that TabItemEx() calls TabBarCalcTabID() so our tab item ID will ignore the current ID stack (rightly so) @@ -2775,7 +2778,7 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) if not close_button_is_enabled then ImGui.PushItemFlag(64 --[[ImGuiItemFlags.Disabled]], true) local tc = style.Colors[0 --[[ImGuiCol.Text]]] - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImVec4(tc.x, tc.y, tc.z, tc.w * 0.4)) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImVec4(tc.x, tc.y, tc.z, tc.w * 0.4)) end if ImGui.CloseButton(host_window:GetID("#CLOSE"), close_button_pos) then node.WantCloseAll = true @@ -2784,7 +2787,7 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) -- if IsItemActive() then -- focus_tab_id = tab_bar.SelectedTabId if not close_button_is_enabled then - ImGui.PopStyleColor() + ImGui_PopStyleColor() ImGui.PopItemFlag() end end @@ -2795,14 +2798,14 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) if g.HoveredId == 0 or g.HoveredId == title_bar_id or g.ActiveId == title_bar_id then -- AllowOverlap mode required for appending into dock node tab bar, -- otherwise dragging window will steal HoveredId and amended tabs cannot get them. - ImGui.KeepAliveID(title_bar_id) - local _, _, held = ImGui.ButtonBehavior(title_bar_rect, title_bar_id, 4096 --[[ImGuiButtonFlags.AllowOverlap]]) + ImGui_KeepAliveID(title_bar_id) + local _, _, held = ImGui_ButtonBehavior(title_bar_rect, title_bar_id, 4096 --[[ImGuiButtonFlags.AllowOverlap]]) if g.HoveredId == title_bar_id then g.LastItemData.ID = title_bar_id end if held then - if ImGui.IsMouseClicked(0) then focus_tab_id = tab_bar.SelectedTabId end + if ImGui_IsMouseClicked(0) then focus_tab_id = tab_bar.SelectedTabId end -- Forward moving request to selected window - local tab = ImGui.TabBarFindTabByID(tab_bar, tab_bar.SelectedTabId) + local tab = ImGui_TabBarFindTabByID(tab_bar, tab_bar.SelectedTabId) if tab then ImGui.StartMouseMovingWindowOrNode(tab.Window or node.HostWindow, node, false) -- Undock from tab bar empty space end @@ -2819,15 +2822,15 @@ function ImGui.DockNodeUpdateTabBar(node, host_window) -- Apply navigation focus if focus_tab_id ~= 0 then - local tab = ImGui.TabBarFindTabByID(tab_bar, focus_tab_id) + local tab = ImGui_TabBarFindTabByID(tab_bar, focus_tab_id) if tab and tab.Window then - ImGui.FocusWindow(tab.Window) - if g.NavId == 0 then ImGui.NavInitWindow(tab.Window, false) end -- only init if FocusWindow() didn't restore anything. + ImGui_FocusWindow(tab.Window) + if g.NavId == 0 then ImGui_NavInitWindow(tab.Window, false) end -- only init if FocusWindow() didn't restore anything. end end ImGui.EndTabBar() - ImGui.PopID() + ImGui_PopID() -- Restore SkipItems flag if not node:IsDockSpace() then @@ -2865,10 +2868,10 @@ local function DockNodeIsDropAllowedOne(payload, host_window) -- by e.g. adding a 'if not ImGui.IsWindowWithinBeginStackOf(host_window, popup_window)' test. -- But it would requires more work on our end because the dock host windows is technically created in NewFrame() -- and our .ParentXXX and .RootXXX pointers inside windows are currently mislading or lacking. - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() for i = g.OpenPopupStack.Size, 1, -1 do local popup_window = g.OpenPopupStack.Data[i].Window - if popup_window and ImGui.IsWindowWithinBeginStackOf(payload, popup_window) then -- Payload is created from within a popup begin stack. + if popup_window and ImGui_IsWindowWithinBeginStackOf(payload, popup_window) then -- Payload is created from within a popup begin stack. return false end end @@ -2889,7 +2892,7 @@ end -- FIXME: This is similar to RenderWindowTitleBarContents(), may want to share code. --- @return ImRect title_rect, ImRect tab_bar_rect, ImVec2 window_menu_button_pos, ImVec2? close_button_pos function ImGui.DockNodeCalcTabBarLayout(node) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local style = g.Style local r = ImRect(node.Pos.x, node.Pos.y, node.Pos.x + node.Size.x, node.Pos.y + g.FontSize + g.Style.FramePadding.y * 2.0) @@ -2918,7 +2921,7 @@ end --- [Port] Modifies pos_old/size_old/pos_new/size_new in place (ImVec2 tables) function ImGui.DockNodeCalcSplitRects(pos_old, size_old, pos_new, size_new, dir, size_new_desired) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local dock_spacing = g.Style.ItemInnerSpacing.x local axis = (dir == 0 --[[ImGuiDir.Left]] or dir == 1 --[[ImGuiDir.Right]]) and 1 --[[ImGuiAxis.X]] or 2 --[[ImGuiAxis.Y]] local a, o = axis, 3 - axis -- [Port] the port's ImGuiAxis is 1-based (X=1,Y=2): it is directly the ImVec2 index @@ -2954,7 +2957,7 @@ end -- Retrieve the drop rectangles for a given direction or for the center + perform hit testing. --- @return bool hit, ImRect out_r function ImGui.DockNodeCalcDropRectsAndTestMousePos(parent, dir, outer_docking, test_mouse_pos) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local parent_smaller_axis = ImMin(parent:GetWidth(), parent:GetHeight()) local hs_for_central_nodes = ImMin(g.FontSize * 1.5, ImMax(g.FontSize * 0.5, parent_smaller_axis / 8.0)) @@ -3004,13 +3007,13 @@ end -- host_node may be nil if the window doesn't have a DockNode already. -- FIXME-DOCK: This is misnamed since it's also doing the filtering. function ImGui.DockNodePreviewDockSetup(host_window, host_node, payload_window, payload_node, data, is_explicit_target, is_outer_docking) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() -- There is an edge case when docking into a dockspace which only has inactive nodes. -- In this case DockNodeTreeFindNodeByPos() will have selected a leaf node which is inactive. -- Because the inactive leaf node doesn't have proper pos/size yet, we'll use the root node as reference. if payload_node == nil then payload_node = payload_window.DockNodeAsHost end - local ref_node_for_rect = (host_node and not host_node.IsVisible) and ImGui.DockNodeGetRootNode(host_node) or host_node + local ref_node_for_rect = (host_node and not host_node.IsVisible) and ImGui_DockNodeGetRootNode(host_node) or host_node if ref_node_for_rect then assert(ref_node_for_rect.IsVisible == true) end -- Filter, figure out where we are allowed to dock @@ -3091,31 +3094,31 @@ function ImGui.DockNodePreviewDockSetup(host_window, host_node, payload_window, end function ImGui.DockNodePreviewDockRender(host_window, host_node, root_payload, data) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(g.CurrentWindow == host_window) -- Because we rely on font size to calculate tab sizes -- With this option, we only display the preview on the target viewport, and the payload viewport is made transparent. -- To compensate for the single layer obstructed by the payload, we'll increase the alpha of the preview nodes. local is_transparent_payload = g.IO.ConfigDockingTransparentPayload - local overlay_draw_lists = { ImGui.GetForegroundDrawList(host_window.Viewport) } + local overlay_draw_lists = { ImGui_GetForegroundDrawList(host_window.Viewport) } -- Draw main preview rectangle - local overlay_col_main = ImGui.GetColorU32(42 --[[ImGuiCol.DockingPreview]], is_transparent_payload and 0.60 or 0.40) - local overlay_col_drop = ImGui.GetColorU32(42 --[[ImGuiCol.DockingPreview]], is_transparent_payload and 0.90 or 0.70) - local overlay_col_drop_hovered = ImGui.GetColorU32(42 --[[ImGuiCol.DockingPreview]], is_transparent_payload and 1.20 or 1.00) - local overlay_col_lines = ImGui.GetColorU32(60 --[[ImGuiCol.NavWindowingHighlight]], is_transparent_payload and 0.80 or 0.60) + local overlay_col_main = ImGui_GetColorU32(42 --[[ImGuiCol.DockingPreview]], is_transparent_payload and 0.60 or 0.40) + local overlay_col_drop = ImGui_GetColorU32(42 --[[ImGuiCol.DockingPreview]], is_transparent_payload and 0.90 or 0.70) + local overlay_col_drop_hovered = ImGui_GetColorU32(42 --[[ImGuiCol.DockingPreview]], is_transparent_payload and 1.20 or 1.00) + local overlay_col_lines = ImGui_GetColorU32(60 --[[ImGuiCol.NavWindowingHighlight]], is_transparent_payload and 0.80 or 0.60) -- Display area preview local can_preview_tabs = (root_payload.DockNodeAsHost == nil or root_payload.DockNodeAsHost.Windows.Size > 0) if data.IsDropAllowed then local overlay_rect = data.FutureNode:Rect() if data.SplitDir == (-1) --[[ImGuiDir.None]] and can_preview_tabs then - overlay_rect.Min.y = overlay_rect.Min.y + ImGui.GetFrameHeight() + overlay_rect.Min.y = overlay_rect.Min.y + ImGui_GetFrameHeight() end if data.SplitDir ~= (-1) --[[ImGuiDir.None]] or data.IsCenterAvailable then for _, dl in ipairs(overlay_draw_lists) do - dl:AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window.WindowRounding, ImGui.CalcRoundingFlagsForRectInRect(overlay_rect, host_window:Rect(), g.Style.DockingSeparatorSize)) + dl:AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window.WindowRounding, ImGui_CalcRoundingFlagsForRectInRect(overlay_rect, host_window:Rect(), g.Style.DockingSeparatorSize)) end end end @@ -3149,11 +3152,11 @@ function ImGui.DockNodePreviewDockRender(host_window, host_node, root_payload, d local tab_size = ImGui.TabItemCalcSize(payload_window) local tab_bb = ImRect(tab_pos.x, tab_pos.y, tab_pos.x + tab_size.x, tab_pos.y + tab_size.y) tab_pos.x = tab_pos.x + tab_size.x + g.Style.ItemInnerSpacing.x - local overlay_col_text = ImGui.GetColorU32(payload_window.DockStyle.Colors[0 --[[ImGuiWindowDockStyleCol.Text]]], 1.0, true) - local overlay_col_tabs = ImGui.GetColorU32(payload_window.DockStyle.Colors[3 --[[ImGuiWindowDockStyleCol.TabSelected]]], 1.0, true) - local overlay_col_unsaved_marker = ImGui.GetColorU32(payload_window.DockStyle.Colors[8 --[[ImGuiWindowDockStyleCol.UnsavedMarker]]], 1.0, true) - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImGui.ColorConvertU32ToFloat4(overlay_col_text)) - ImGui.PushStyleColor(58 --[[ImGuiCol.UnsavedMarker]], ImGui.ColorConvertU32ToFloat4(overlay_col_unsaved_marker)) + local overlay_col_text = ImGui_GetColorU32(payload_window.DockStyle.Colors[0 --[[ImGuiWindowDockStyleCol.Text]]], 1.0, true) + local overlay_col_tabs = ImGui_GetColorU32(payload_window.DockStyle.Colors[3 --[[ImGuiWindowDockStyleCol.TabSelected]]], 1.0, true) + local overlay_col_unsaved_marker = ImGui_GetColorU32(payload_window.DockStyle.Colors[8 --[[ImGuiWindowDockStyleCol.UnsavedMarker]]], 1.0, true) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImGui_ColorConvertU32ToFloat4(overlay_col_text)) + ImGui_PushStyleColor(58 --[[ImGuiCol.UnsavedMarker]], ImGui_ColorConvertU32ToFloat4(overlay_col_unsaved_marker)) for _, dl in ipairs(overlay_draw_lists) do local tab_flags = bit32.band(payload_window.Flags, 262144 --[[ImGuiWindowFlags.UnsavedDocument]]) ~= 0 and 1 --[[ImGuiTabItemFlags.UnsavedDocument]] or 0 local contains = tab_bar_rect:Contains(tab_bb) @@ -3162,7 +3165,7 @@ function ImGui.DockNodePreviewDockRender(host_window, host_node, root_payload, d ImGui.TabItemLabelAndCloseButton(dl, tab_bb, tab_flags, g.Style.FramePadding, payload_window.Name, 0, 0, false) if not contains then dl:PopClipRect() end end - ImGui.PopStyleColor(2) + ImGui_PopStyleColor(2) end end end @@ -3211,13 +3214,13 @@ end ------------------------------------------------------------------------------- function ImGui.DockNodeTreeSplit(ctx, parent_node, split_axis, split_inheritor_child_idx, split_ratio, new_node) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(split_axis ~= 0 --[[ImGuiAxis.None]]) - local child_0 = (new_node and split_inheritor_child_idx ~= 0) and new_node or ImGui.DockContextAddNode(ctx, 0) + local child_0 = (new_node and split_inheritor_child_idx ~= 0) and new_node or ImGui_DockContextAddNode(ctx, 0) child_0.ParentNode = parent_node - local child_1 = (new_node and split_inheritor_child_idx ~= 1) and new_node or ImGui.DockContextAddNode(ctx, 0) + local child_1 = (new_node and split_inheritor_child_idx ~= 1) and new_node or ImGui_DockContextAddNode(ctx, 0) child_1.ParentNode = parent_node local child_inheritor = (split_inheritor_child_idx == 0) and child_0 or child_1 @@ -3239,10 +3242,10 @@ function ImGui.DockNodeTreeSplit(ctx, parent_node, split_axis, split_inheritor_c child_0.SizeRef[a] = ImTrunc(size_avail * split_ratio) child_1.SizeRef[a] = ImTrunc(size_avail - child_0.SizeRef[a]) - ImGui.DockNodeMoveWindows(parent_node.ChildNodes[split_inheritor_child_idx], parent_node) + ImGui_DockNodeMoveWindows(parent_node.ChildNodes[split_inheritor_child_idx], parent_node) DockSettingsRenameNodeReferences(parent_node.ID, parent_node.ChildNodes[split_inheritor_child_idx].ID) - ImGui.DockNodeUpdateHasCentralNodeChild(ImGui.DockNodeGetRootNode(parent_node)) - ImGui.DockNodeTreeUpdatePosSize(parent_node, parent_node.Pos, parent_node.Size) + ImGui_DockNodeUpdateHasCentralNodeChild(ImGui_DockNodeGetRootNode(parent_node)) + ImGui_DockNodeTreeUpdatePosSize(parent_node, parent_node.Pos, parent_node.Size) -- Flags transfer (e.g. this is where we transfer the ImGuiDockNodeFlags.CentralNode property) child_0.SharedFlags = bit32.band(parent_node.SharedFlags, 4294967295 --[[ImGuiDockNodeFlags.SharedFlagsInheritMask_]]) @@ -3253,7 +3256,7 @@ function ImGui.DockNodeTreeSplit(ctx, parent_node, split_axis, split_inheritor_c child_1:UpdateMergedFlags() parent_node:UpdateMergedFlags() if child_inheritor:IsCentralNode() then - ImGui.DockNodeGetRootNode(parent_node).CentralNode = child_inheritor + ImGui_DockNodeGetRootNode(parent_node).CentralNode = child_inheritor end end @@ -3271,11 +3274,11 @@ function ImGui.DockNodeTreeMerge(ctx, parent_node, merge_lead_child) local backup_last_explicit_size = ImVec2(parent_node.SizeRef.x, parent_node.SizeRef.y) ImGui.DockNodeMoveChildNodes(parent_node, merge_lead_child) if child_0 then - ImGui.DockNodeMoveWindows(parent_node, child_0) -- Generally only 1 of the 2 child node will have windows + ImGui_DockNodeMoveWindows(parent_node, child_0) -- Generally only 1 of the 2 child node will have windows DockSettingsRenameNodeReferences(child_0.ID, parent_node.ID) end if child_1 then - ImGui.DockNodeMoveWindows(parent_node, child_1) + ImGui_DockNodeMoveWindows(parent_node, child_1) DockSettingsRenameNodeReferences(child_1.ID, parent_node.ID) end ImGui.DockNodeApplyPosSizeToWindows(parent_node) @@ -3293,8 +3296,8 @@ function ImGui.DockNodeTreeMerge(ctx, parent_node, merge_lead_child) parent_node.LocalFlagsInWindows = bit32.bor(child_0 and child_0.LocalFlagsInWindows or 0, child_1 and child_1.LocalFlagsInWindows or 0) -- FIXME: Would be more consistent to update from actual windows parent_node:UpdateMergedFlags() - if child_0 then ImGui.DockContextDeleteNode(ctx, child_0) end - if child_1 then ImGui.DockContextDeleteNode(ctx, child_1) end + if child_0 then ImGui_DockContextDeleteNode(ctx, child_0) end + if child_1 then ImGui_DockContextDeleteNode(ctx, child_1) end end -- Update Pos/Size for a node hierarchy (don't affect child Windows yet) @@ -3302,7 +3305,7 @@ end function ImGui.DockNodeTreeUpdatePosSize(node, pos, size, only_write_to_single_node) -- During the regular dock node update we write to all nodes. -- 'only_write_to_single_node' is only set when turning a node visible mid-frame and we need its size right-away. - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local write_to_node = only_write_to_single_node == nil or only_write_to_single_node == node if write_to_node then node.Pos = ImVec2(pos.x, pos.y) @@ -3371,8 +3374,8 @@ function ImGui.DockNodeTreeUpdatePosSize(node, pos, size, only_write_to_single_n end local child_0_recurse = only_write_to_single_node and child_0_is_toward_single_node or (not only_write_to_single_node and child_0.IsVisible) local child_1_recurse = only_write_to_single_node and child_1_is_toward_single_node or (not only_write_to_single_node and child_1.IsVisible) - if child_0_recurse then ImGui.DockNodeTreeUpdatePosSize(child_0, child_0_pos, child_0_size) end - if child_1_recurse then ImGui.DockNodeTreeUpdatePosSize(child_1, child_1_pos, child_1_size) end + if child_0_recurse then ImGui_DockNodeTreeUpdatePosSize(child_0, child_0_pos, child_0_size) end + if child_1_recurse then ImGui_DockNodeTreeUpdatePosSize(child_1, child_1_pos, child_1_size) end end local function DockNodeTreeUpdateSplitterFindTouchingNode(node, axis, side, touching_nodes) @@ -3398,7 +3401,7 @@ local WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04 -- Reduce visual noise by function ImGui.DockNodeTreeUpdateSplitter(node) if node:IsLeafNode() then return end - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local child_0 = node.ChildNodes[0] local child_1 = node.ChildNodes[1] @@ -3416,11 +3419,11 @@ function ImGui.DockNodeTreeUpdateSplitter(node) local no_resize_axis_flag = (axis == 1 --[[ImGuiAxis.X]]) and 65536 --[[ImGuiDockNodeFlags.NoResizeX]] or 131072 --[[ImGuiDockNodeFlags.NoResizeY]] if bit32.band(merged_flags, 32 --[[ImGuiDockNodeFlags.NoResize]]) ~= 0 or bit32.band(merged_flags, no_resize_axis_flag) ~= 0 then local window = g.CurrentWindow - window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui.GetColorU32(28 --[[ImGuiCol.Separator]]), g.Style.FrameRounding) + window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui_GetColorU32(28 --[[ImGuiCol.Separator]]), g.Style.FrameRounding) else -- bb.Min[axis] = bb.Min[axis] + 1 -- Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node. -- bb.Max[axis] = bb.Max[axis] - 1 - ImGui.PushID(node.ID) + ImGui_PushID(node.ID) -- Find resizing limits by gathering list of nodes that are touching the splitter line. local touching_nodes = { [0] = {}, [1] = {} } @@ -3444,7 +3447,7 @@ function ImGui.DockNodeTreeUpdateSplitter(node) local cur_size_1 = child_1.Size[a] local min_size_0 = resize_limits[0] - child_0.Pos[a] local min_size_1 = child_1.Pos[a] + child_1.Size[a] - resize_limits[1] - local bg_col = ImGui.GetColorU32(2 --[[ImGuiCol.WindowBg]]) + local bg_col = ImGui_GetColorU32(2 --[[ImGuiCol.WindowBg]]) local changed changed, cur_size_0, cur_size_1 = ImGui.SplitterBehavior(bb, ImGui.GetID("##Splitter"), axis, cur_size_0, cur_size_1, min_size_0, min_size_1, g.WindowsBorderHoverPadding, WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER, bg_col) if changed then @@ -3468,12 +3471,12 @@ function ImGui.DockNodeTreeUpdateSplitter(node) end end - ImGui.DockNodeTreeUpdatePosSize(child_0, child_0.Pos, child_0.Size) - ImGui.DockNodeTreeUpdatePosSize(child_1, child_1.Pos, child_1.Size) - ImGui.MarkIniSettingsDirty() + ImGui_DockNodeTreeUpdatePosSize(child_0, child_0.Pos, child_0.Size) + ImGui_DockNodeTreeUpdatePosSize(child_1, child_1.Pos, child_1.Size) + ImGui_MarkIniSettingsDirty() end end - ImGui.PopID() + ImGui_PopID() end end @@ -3496,9 +3499,9 @@ function ImGui.DockNodeTreeFindVisibleNodeByPos(node, pos) local r = ImRect(node.Pos, node.Pos + node.Size) if not r:Contains(pos) then return nil end if node:IsLeafNode() then return node end - local hovered_node = ImGui.DockNodeTreeFindVisibleNodeByPos(node.ChildNodes[0], pos) + local hovered_node = ImGui_DockNodeTreeFindVisibleNodeByPos(node.ChildNodes[0], pos) if hovered_node then return hovered_node end - hovered_node = ImGui.DockNodeTreeFindVisibleNodeByPos(node.ChildNodes[1], pos) + hovered_node = ImGui_DockNodeTreeFindVisibleNodeByPos(node.ChildNodes[1], pos) if hovered_node then return hovered_node end -- This means we are hovering over the splitter/spacing of a parent node @@ -3522,11 +3525,11 @@ function ImGui.SetWindowDock(window, dock_id, cond) if window.DockId == dock_id then return end -- If the user attempt to set a dock id that is a split node, we'll dig within to find a suitable docking spot - local g = ImGui.GetCurrentContext() - local new_node = ImGui.DockContextFindNodeByID(g, dock_id) + local g = ImGui_GetCurrentContext() + local new_node = ImGui_DockContextFindNodeByID(g, dock_id) if new_node and new_node:IsSplitNode() then -- Policy: Find central node or latest focused node. We first move back to our root node. - new_node = ImGui.DockNodeGetRootNode(new_node) + new_node = ImGui_DockNodeGetRootNode(new_node) if new_node.CentralNode then assert(new_node.CentralNode:IsCentralNode()) dock_id = new_node.CentralNode.ID @@ -3537,7 +3540,7 @@ function ImGui.SetWindowDock(window, dock_id, cond) if window.DockId == dock_id then return end - if window.DockNode then ImGui.DockNodeRemoveWindow(window.DockNode, window, 0) end + if window.DockNode then ImGui_DockNodeRemoveWindow(window.DockNode, window, 0) end window.DockId = dock_id end @@ -3548,23 +3551,23 @@ end function ImGui.DockSpace(dockspace_id, size_arg, flags, window_class) if size_arg == nil then size_arg = ImVec2(0, 0) end if flags == nil then flags = 0 end - local g = ImGui.GetCurrentContext() - local window = ImGui.GetCurrentWindowRead() + local g = ImGui_GetCurrentContext() + local window = ImGui_GetCurrentWindowRead() if bit32.band(g.IO.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) == 0 then return 0 end -- Early out if parent window is hidden/collapsed -- This is faster but also DockNodeUpdateTabBar() relies on TabBarLayout() running (which won't if SkipItems=true) to set NextSelectedTabId = 0). See #2960. -- If for whichever reason this is causing problem we would need to ensure that DockNodeUpdateTabBar() ends up clearing NextSelectedTabId even if SkipItems=true. if window.SkipItems then flags = bit32.bor(flags, 1 --[[ImGuiDockNodeFlags.KeepAliveOnly]]) end - if bit32.band(flags, 1 --[[ImGuiDockNodeFlags.KeepAliveOnly]]) == 0 then window = ImGui.GetCurrentWindow() end -- call to set window.WriteAccessed = true; + if bit32.band(flags, 1 --[[ImGuiDockNodeFlags.KeepAliveOnly]]) == 0 then window = ImGui_GetCurrentWindow() end -- call to set window.WriteAccessed = true; assert(bit32.band(flags, 1024 --[[ImGuiDockNodeFlags.DockSpace]]) == 0) -- Flag is automatically set by DockSpace() as LocalFlags, not SharedFlags! assert(bit32.band(flags, 2048 --[[ImGuiDockNodeFlags.CentralNode]]) == 0) -- Flag is automatically set by DockSpace() as LocalFlags, not SharedFlags! (#8145) assert(dockspace_id ~= 0) - local node = ImGui.DockContextFindNodeByID(g, dockspace_id) + local node = ImGui_DockContextFindNodeByID(g, dockspace_id) if node == nil then - node = ImGui.DockContextAddNode(g, dockspace_id) + node = ImGui_DockContextAddNode(g, dockspace_id) node:SetLocalFlags(2048 --[[ImGuiDockNodeFlags.CentralNode]]) end node.SharedFlags = flags @@ -3594,8 +3597,8 @@ function ImGui.DockSpace(dockspace_id, size_arg, flags, window_class) node.Pos = ImVec2(window.DC.CursorPos.x, window.DC.CursorPos.y) node.Size = ImVec2(size.x, size.y) node.SizeRef = ImVec2(size.x, size.y) - ImGui.SetNextWindowPos(node.Pos) - ImGui.SetNextWindowSize(node.Size) + ImGui_SetNextWindowPos(node.Pos) + ImGui_SetNextWindowSize(node.Size) g.NextWindowData.PosUndock = false -- FIXME-DOCK: Why do we need a child window to host a dockspace, could we host it in the existing window? @@ -3607,9 +3610,9 @@ function ImGui.DockSpace(dockspace_id, size_arg, flags, window_class) local title = string.format("%s/DockSpace_%08X", window.Name, dockspace_id) - ImGui.PushStyleVar(8 --[[ImGuiStyleVar.ChildBorderSize]], 0.0) + ImGui_PushStyleVar(8 --[[ImGuiStyleVar.ChildBorderSize]], 0.0) ImGui.Begin(title, nil, window_flags) - ImGui.PopStyleVar() + ImGui_PopStyleVar() local host_window = g.CurrentWindow DockNodeSetupHostWindow(node, host_window) @@ -3629,14 +3632,14 @@ function ImGui.DockSpace(dockspace_id, size_arg, flags, window_class) end -- Update the node - ImGui.DockNodeUpdate(node) + ImGui_DockNodeUpdate(node) ImGui.End() local bb = ImRect(node.Pos, node.Pos + size) ImGui.ItemSize(size) ImGui.ItemAdd(bb, dockspace_id, nil, 2 --[[ImGuiItemFlags.NoNav]]) -- Not a nav point (could be, would need to draw the nav rect and replicate/refactor activation from BeginChild(), but seems like CTRL+Tab works better here?) - if bit32.band(g.LastItemData.StatusFlags, 1 --[[ImGuiItemStatusFlags.HoveredRect]]) ~= 0 and ImGui.IsWindowChildOf(g.HoveredWindow, host_window, false, true) then -- To fullfill IsItemHovered(), similar to EndChild() + if bit32.band(g.LastItemData.StatusFlags, 1 --[[ImGuiItemStatusFlags.HoveredRect]]) ~= 0 and ImGui_IsWindowChildOf(g.HoveredWindow, host_window, false, true) then -- To fullfill IsItemHovered(), similar to EndChild() g.LastItemData.StatusFlags = bit32.bor(g.LastItemData.StatusFlags, 128 --[[ImGuiItemStatusFlags.HoveredWindow]]) end @@ -3650,11 +3653,11 @@ end function ImGui.DockSpaceOverViewport(dockspace_id, viewport, dockspace_flags, window_class) if dockspace_id == nil then dockspace_id = 0 end if dockspace_flags == nil then dockspace_flags = 0 end - if viewport == nil then viewport = ImGui.GetMainViewport() end + if viewport == nil then viewport = ImGui_GetMainViewport() end -- Submit a window filling the entire viewport - ImGui.SetNextWindowPos(viewport.WorkPos) - ImGui.SetNextWindowSize(viewport.WorkSize) + ImGui_SetNextWindowPos(viewport.WorkPos) + ImGui_SetNextWindowSize(viewport.WorkSize) ImGui.SetNextWindowViewport(viewport.ID) local host_window_flags = 0 @@ -3672,11 +3675,11 @@ function ImGui.DockSpaceOverViewport(dockspace_id, viewport, dockspace_flags, wi local label = string.format("WindowOverViewport_%08X", viewport.ID) - ImGui.PushStyleVar(3 --[[ImGuiStyleVar.WindowRounding]], 0.0) - ImGui.PushStyleVar(4 --[[ImGuiStyleVar.WindowBorderSize]], 0.0) - ImGui.PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0.0, 0.0)) + ImGui_PushStyleVar(3 --[[ImGuiStyleVar.WindowRounding]], 0.0) + ImGui_PushStyleVar(4 --[[ImGuiStyleVar.WindowBorderSize]], 0.0) + ImGui_PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0.0, 0.0)) ImGui.Begin(label, nil, host_window_flags) - ImGui.PopStyleVar(3) + ImGui_PopStyleVar(3) -- Submit the dockspace if dockspace_id == 0 then dockspace_id = ImGui.GetID("DockSpace") end @@ -3713,7 +3716,7 @@ end function ImGui.DockBuilderDockWindow(window_name, node_id) -- We don't preserve relative order of multiple docked windows (by clearing DockOrder back to -1) local window_id = ImHashStr(window_name) - local window = ImGui.FindWindowByID(window_id) + local window = ImGui_FindWindowByID(window_id) if window then -- Apply to created window local prev_node_id = window.DockId @@ -3721,32 +3724,32 @@ function ImGui.DockBuilderDockWindow(window_name, node_id) if window.DockId ~= prev_node_id then window.DockOrder = -1 end else -- Apply to settings - local settings = ImGui.FindWindowSettingsByID(window_id) - if settings == nil then settings = ImGui.CreateNewWindowSettings(window_name) end + local settings = ImGui_FindWindowSettingsByID(window_id) + if settings == nil then settings = ImGui_CreateNewWindowSettings(window_name) end if settings.DockId ~= node_id then settings.DockOrder = -1 end settings.DockId = node_id end end function ImGui.DockBuilderGetNode(node_id) - return ImGui.DockContextFindNodeByID(ImGui.GetCurrentContext(), node_id) + return ImGui_DockContextFindNodeByID(ImGui_GetCurrentContext(), node_id) end function ImGui.DockBuilderGetCentralNode(node_id) local node = ImGui.DockBuilderGetNode(node_id) if not node then return nil end - return ImGui.DockNodeGetRootNode(node).CentralNode + return ImGui_DockNodeGetRootNode(node).CentralNode end function ImGui.DockBuilderSetNodePos(node_id, pos) - local node = ImGui.DockContextFindNodeByID(ImGui.GetCurrentContext(), node_id) + local node = ImGui_DockContextFindNodeByID(ImGui_GetCurrentContext(), node_id) if node == nil then return end node.Pos = ImVec2(pos.x, pos.y) node.AuthorityForPos = 1 --[[ImGuiDataAuthority.DockNode]] end function ImGui.DockBuilderSetNodeSize(node_id, size) - local node = ImGui.DockContextFindNodeByID(ImGui.GetCurrentContext(), node_id) + local node = ImGui_DockContextFindNodeByID(ImGui_GetCurrentContext(), node_id) if node == nil then return end assert(size.x > 0.0 and size.y > 0.0) node.Size = ImVec2(size.x, size.y) @@ -3764,15 +3767,15 @@ end function ImGui.DockBuilderAddNode(node_id, flags) if node_id == nil then node_id = 0 end if flags == nil then flags = 0 end - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if node_id ~= 0 then ImGui.DockBuilderRemoveNode(node_id) end local node if bit32.band(flags, 1024 --[[ImGuiDockNodeFlags.DockSpace]]) ~= 0 then ImGui.DockSpace(node_id, ImVec2(0, 0), bit32.bor(bit32.band(flags, bit32.bnot(1024 --[[ImGuiDockNodeFlags.DockSpace]])), 1 --[[ImGuiDockNodeFlags.KeepAliveOnly]])) - node = ImGui.DockContextFindNodeByID(g, node_id) + node = ImGui_DockContextFindNodeByID(g, node_id) else - node = ImGui.DockContextAddNode(g, node_id) + node = ImGui_DockContextAddNode(g, node_id) node:SetLocalFlags(flags) end node.LastFrameAlive = g.FrameCount -- Set this otherwise BeginDocked will undock during the same frame. @@ -3780,18 +3783,18 @@ function ImGui.DockBuilderAddNode(node_id, flags) end function ImGui.DockBuilderRemoveNode(node_id) - local g = ImGui.GetCurrentContext() - local node = ImGui.DockContextFindNodeByID(g, node_id) + local g = ImGui_GetCurrentContext() + local node = ImGui_DockContextFindNodeByID(g, node_id) if node == nil then return end ImGui.DockBuilderRemoveNodeDockedWindows(node_id, true) ImGui.DockBuilderRemoveNodeChildNodes(node_id) -- Node may have moved or deleted if e.g. any merge happened - node = ImGui.DockContextFindNodeByID(g, node_id) + node = ImGui_DockContextFindNodeByID(g, node_id) if node == nil then return end if node:IsCentralNode() and node.ParentNode then node.ParentNode:SetLocalFlags(bit32.bor(node.ParentNode.LocalFlags, 2048 --[[ImGuiDockNodeFlags.CentralNode]])) end - ImGui.DockContextRemoveNode(g, node, true) + ImGui_DockContextRemoveNode(g, node, true) end --- @param a ImGuiDockNode @@ -3802,10 +3805,10 @@ end -- root_id = 0 to remove all, root_id != 0 to remove child of given node. function ImGui.DockBuilderRemoveNodeChildNodes(root_id) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local dc = g.DockContext - local root_node = (root_id ~= 0) and ImGui.DockContextFindNodeByID(g, root_id) or nil + local root_node = (root_id ~= 0) and ImGui_DockContextFindNodeByID(g, root_id) or nil if root_id ~= 0 and root_node == nil then return end local has_central_node = false @@ -3817,12 +3820,12 @@ function ImGui.DockBuilderRemoveNodeChildNodes(root_id) for _, id in ipairs(DockContextNodesSorted(g)) do local node = dc.Nodes[id] if node then - local want_removal = (root_id == 0) or (node.ID ~= root_id and ImGui.DockNodeGetRootNode(node).ID == root_id) + local want_removal = (root_id == 0) or (node.ID ~= root_id and ImGui_DockNodeGetRootNode(node).ID == root_id) if want_removal then if node:IsCentralNode() then has_central_node = true end if root_id ~= 0 then ImGui.DockContextQueueNotifyRemovedNode(g, node) end if root_node then - ImGui.DockNodeMoveWindows(root_node, node) + ImGui_DockNodeMoveWindows(root_node, node) DockSettingsRenameNodeReferences(node.ID, root_node.ID) end table.insert(nodes_to_remove, node) @@ -3855,7 +3858,7 @@ function ImGui.DockBuilderRemoveNodeChildNodes(root_id) table.sort(nodes_to_remove, DockNodeComparerDepthMostFirst) end for _, n in ipairs(nodes_to_remove) do - ImGui.DockContextRemoveNode(g, n, false) + ImGui_DockContextRemoveNode(g, n, false) end if root_id == 0 then @@ -3870,13 +3873,13 @@ end function ImGui.DockBuilderRemoveNodeDockedWindows(root_id, clear_settings_refs) if clear_settings_refs == nil then clear_settings_refs = true end -- Clear references in settings - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if clear_settings_refs then for _, settings in g.SettingsWindows:iter() do local want_removal = (root_id == 0) or (settings.DockId == root_id) if not want_removal and settings.DockId ~= 0 then - local node = ImGui.DockContextFindNodeByID(g, settings.DockId) - if node and ImGui.DockNodeGetRootNode(node).ID == root_id then want_removal = true end + local node = ImGui_DockContextFindNodeByID(g, settings.DockId) + if node and ImGui_DockNodeGetRootNode(node).ID == root_id then want_removal = true end end if want_removal then settings.DockId = 0 end end @@ -3885,10 +3888,10 @@ function ImGui.DockBuilderRemoveNodeDockedWindows(root_id, clear_settings_refs) -- Clear references in windows for n = 1, g.Windows.Size do local window = g.Windows.Data[n] - local want_removal = (root_id == 0) or (window.DockNode and ImGui.DockNodeGetRootNode(window.DockNode).ID == root_id) or (window.DockNodeAsHost and window.DockNodeAsHost.ID == root_id) + local want_removal = (root_id == 0) or (window.DockNode and ImGui_DockNodeGetRootNode(window.DockNode).ID == root_id) or (window.DockNodeAsHost and window.DockNodeAsHost.ID == root_id) if want_removal then local backup_dock_id = window.DockId - ImGui.DockContextProcessUndockWindow(g, window, clear_settings_refs) + ImGui_DockContextProcessUndockWindow(g, window, clear_settings_refs) if not clear_settings_refs then assert(window.DockId == backup_dock_id) end end end @@ -3899,10 +3902,10 @@ end -- FIXME-DOCK: We are not exposing nor using split_outer. --- @return ImGuiID id_at_dir, ImGuiID id_at_opposite_dir function ImGui.DockBuilderSplitNode(id, split_dir, size_ratio_for_node_at_dir) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(split_dir ~= (-1) --[[ImGuiDir.None]]) - local node = ImGui.DockContextFindNodeByID(g, id) + local node = ImGui_DockContextFindNodeByID(g, id) if node == nil then assert(node ~= nil) return 0, 0 @@ -3925,8 +3928,8 @@ function ImGui.DockBuilderSplitNode(id, split_dir, size_ratio_for_node_at_dir) end local function DockBuilderCopyNodeRec(src_node, dst_node_id_if_known, out_node_remap_pairs) - local g = ImGui.GetCurrentContext() - local dst_node = ImGui.DockContextAddNode(g, dst_node_id_if_known) + local g = ImGui_GetCurrentContext() + local dst_node = ImGui_DockContextAddNode(g, dst_node_id_if_known) dst_node.SharedFlags = src_node.SharedFlags dst_node.LocalFlags = src_node.LocalFlags dst_node.LocalFlagsInWindows = 0 --[[ImGuiDockNodeFlags.None]] @@ -3950,14 +3953,14 @@ end --- @param out_node_remap_pairs table # 1-based array, cleared and filled with (src_id, dst_id) pairs function ImGui.DockBuilderCopyNode(src_node_id, dst_node_id, out_node_remap_pairs) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(src_node_id ~= 0) assert(dst_node_id ~= 0) assert(out_node_remap_pairs ~= nil) ImGui.DockBuilderRemoveNode(dst_node_id) - local src_node = ImGui.DockContextFindNodeByID(g, src_node_id) + local src_node = ImGui_DockContextFindNodeByID(g, src_node_id) assert(src_node ~= nil) for k in pairs(out_node_remap_pairs) do out_node_remap_pairs[k] = nil end @@ -3966,17 +3969,17 @@ function ImGui.DockBuilderCopyNode(src_node_id, dst_node_id, out_node_remap_pair end function ImGui.DockBuilderCopyWindowSettings(src_name, dst_name) - local src_window = ImGui.FindWindowByName(src_name) + local src_window = ImGui_FindWindowByName(src_name) if src_window == nil then return end - local dst_window = ImGui.FindWindowByName(dst_name) + local dst_window = ImGui_FindWindowByName(dst_name) if dst_window then ImVec2_Copy(dst_window.Pos, src_window.Pos) ImVec2_Copy(dst_window.Size, src_window.Size) ImVec2_Copy(dst_window.SizeFull, src_window.SizeFull) dst_window.Collapsed = src_window.Collapsed else - local dst_settings = ImGui.FindWindowSettingsByID(ImHashStr(dst_name)) - if not dst_settings then dst_settings = ImGui.CreateNewWindowSettings(dst_name) end + local dst_settings = ImGui_FindWindowSettingsByID(ImHashStr(dst_name)) + if not dst_settings then dst_settings = ImGui_CreateNewWindowSettings(dst_name) end local wx, wy = ImTrunc(src_window.Pos.x), ImTrunc(src_window.Pos.y) if src_window.ViewportId ~= 0 and src_window.ViewportId ~= 0x11111111 then ImVec2_CopyV(dst_settings.ViewportPos, wx, wy) @@ -4015,11 +4018,11 @@ function ImGui.DockBuilderCopyDockSpace(src_dockspace_id, dst_dockspace_id, in_w -- Search in the remapping tables local src_dock_id = 0 - local src_window = ImGui.FindWindowByID(src_window_id) + local src_window = ImGui_FindWindowByID(src_window_id) if src_window then src_dock_id = src_window.DockId else - local src_window_settings = ImGui.FindWindowSettingsByID(src_window_id) + local src_window_settings = ImGui_FindWindowSettingsByID(src_window_id) if src_window_settings then src_dock_id = src_window_settings.DockId end end local dst_dock_id = 0 @@ -4066,7 +4069,7 @@ end -- FIXME-DOCK: This is awkward because in series of split user is likely to loose access to its root node. function ImGui.DockBuilderFinish(root_id) --DockContextRebuild(g) - ImGui.DockContextBuildAddWindowsToNodes(ImGui.GetCurrentContext(), root_id) + ImGui.DockContextBuildAddWindowsToNodes(ImGui_GetCurrentContext(), root_id) end ------------------------------------------------------------------------------- @@ -4080,7 +4083,7 @@ end ------------------------------------------------------------------------------- function ImGui.GetWindowAlwaysWantOwnTabBar(window) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if g.IO.ConfigDockingAlwaysTabBar or window.WindowClass.DockingAlwaysTabBar then if bit32.band(window.Flags, bit32.bor(16777216 --[[ImGuiWindowFlags.ChildWindow]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 524288 --[[ImGuiWindowFlags.NoDocking]])) == 0 then if not window.IsFallbackWindow then return true end -- We don't support AlwaysTabBar on the fallback/implicit window to avoid unused dock-node overhead/noise @@ -4091,18 +4094,18 @@ end function ImGui.DockContextBindNodeToWindow(ctx, window) local g = ctx - local node = ImGui.DockContextFindNodeByID(ctx, window.DockId) + local node = ImGui_DockContextFindNodeByID(ctx, window.DockId) assert(window.DockNode == nil) -- We should not be docking into a split node (SetWindowDock should avoid this) if node and node:IsSplitNode() then - ImGui.DockContextProcessUndockWindow(ctx, window) + ImGui_DockContextProcessUndockWindow(ctx, window) return nil end -- Create node if node == nil then - node = ImGui.DockContextAddNode(ctx, window.DockId) + node = ImGui_DockContextAddNode(ctx, window.DockId) node.AuthorityForPos = 2 --[[ImGuiDataAuthority.Window]] node.AuthorityForSize = 2 --[[ImGuiDataAuthority.Window]] node.AuthorityForViewport = 2 --[[ImGuiDataAuthority.Window]] @@ -4119,20 +4122,20 @@ function ImGui.DockContextBindNodeToWindow(ctx, window) ancestor_node = ancestor_node.ParentNode end assert(ancestor_node.Size.x > 0.0 and ancestor_node.Size.y > 0.0) - ImGui.DockNodeUpdateHasCentralNodeChild(ImGui.DockNodeGetRootNode(ancestor_node)) - ImGui.DockNodeTreeUpdatePosSize(ancestor_node, ancestor_node.Pos, ancestor_node.Size, node) + ImGui_DockNodeUpdateHasCentralNodeChild(ImGui_DockNodeGetRootNode(ancestor_node)) + ImGui_DockNodeTreeUpdatePosSize(ancestor_node, ancestor_node.Pos, ancestor_node.Size, node) end -- Add window to node local node_was_visible = node.IsVisible - ImGui.DockNodeAddWindow(node, window, true) + ImGui_DockNodeAddWindow(node, window, true) node.IsVisible = node_was_visible -- Don't mark visible right away (so DockContextEndFrame() doesn't render it, maybe other side effects? will see) assert(node == window.DockNode) return node end local function StoreDockStyleForWindow(window) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() for color_n = 0, 9 --[[ImGuiWindowDockStyleCol.COUNT]] - 1 do window.DockStyle.Colors[color_n] = ImGui.ColorConvertFloat4ToU32(g.Style.Colors[GWindowDockStyleColors[color_n]]) end @@ -4141,7 +4144,7 @@ ImGui.StoreDockStyleForWindow = StoreDockStyleForWindow --- @return bool? p_open function ImGui.BeginDocked(window, p_open) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() -- Specific extra processing for fallback window (#9151), could be in Begin() as well. if window.IsFallbackWindow and not window.WasActive then @@ -4161,7 +4164,7 @@ function ImGui.BeginDocked(window, p_open) want_undock = want_undock or bit32.band(window.Flags, 524288 --[[ImGuiWindowFlags.NoDocking]]) ~= 0 want_undock = want_undock or (bit32.band(g.NextWindowData.HasFlags, 1 --[[ImGuiNextWindowDataFlags.HasPos]]) ~= 0 and bit32.band(window.SetWindowPosAllowFlags, g.NextWindowData.PosCond) ~= 0 and g.NextWindowData.PosUndock) if want_undock then - ImGui.DockContextProcessUndockWindow(g, window) + ImGui_DockContextProcessUndockWindow(g, window) return p_open end end @@ -4178,9 +4181,9 @@ function ImGui.BeginDocked(window, p_open) -- Note how we are testing for LastFrameAlive and NOT LastFrameActive. A DockSpace node can be maintained alive while being inactive with ImGuiDockNodeFlags.KeepAliveOnly. if node.LastFrameAlive < g.FrameCount then -- If the window has been orphaned, transition the docknode to an implicit node processed in DockContextNewFrameUpdateDocking() - local root_node = ImGui.DockNodeGetRootNode(node) + local root_node = ImGui_DockNodeGetRootNode(node) if root_node.LastFrameAlive < g.FrameCount then - ImGui.DockContextProcessUndockWindow(g, window) + ImGui_DockContextProcessUndockWindow(g, window) else window.DockIsActive = true end @@ -4211,13 +4214,13 @@ function ImGui.BeginDocked(window, p_open) -- Undock if we are submitted earlier than the host window if bit32.band(node.MergedFlags, 1 --[[ImGuiDockNodeFlags.KeepAliveOnly]]) == 0 and window.BeginOrderWithinContext < node.HostWindow.BeginOrderWithinContext then - ImGui.DockContextProcessUndockWindow(g, window) + ImGui_DockContextProcessUndockWindow(g, window) return p_open end -- Position/Size window - ImGui.SetNextWindowPos(node.Pos) - ImGui.SetNextWindowSize(node.Size) + ImGui_SetNextWindowPos(node.Pos) + ImGui_SetNextWindowSize(node.Size) g.NextWindowData.PosUndock = false -- Cancel implicit undocking of SetNextWindowPos() window.DockIsActive = true window.DockNodeIsVisible = true @@ -4254,7 +4257,7 @@ function ImGui.BeginDocked(window, p_open) end function ImGui.BeginDockableDragDropSource(window) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(g.ActiveId == window.MoveId) assert(g.MovingWindow == window) assert(g.CurrentWindow == window) @@ -4273,7 +4276,7 @@ function ImGui.BeginDockableDragDropSource(window) g.LastItemData.ID = window.MoveId window = window.RootWindowDockTree assert(bit32.band(window.Flags, 524288 --[[ImGuiWindowFlags.NoDocking]]) == 0) - local is_drag_docking = g.IO.ConfigDockingWithShift or ImRect(0, 0, window.SizeFull.x, ImGui.GetFrameHeight()):Contains(g.ActiveIdClickOffset) -- FIXME-DOCKING: Need to make this stateful and explicit + local is_drag_docking = g.IO.ConfigDockingWithShift or ImRect(0, 0, window.SizeFull.x, ImGui_GetFrameHeight()):Contains(g.ActiveIdClickOffset) -- FIXME-DOCKING: Need to make this stateful and explicit local drag_drop_flags = bit32.bor(1 --[[ImGuiDragDropFlags.SourceNoPreviewTooltip]], 4 --[[ImGuiDragDropFlags.SourceNoHoldToOpenOthers]], 32 --[[ImGuiDragDropFlags.PayloadAutoExpire]], 64 --[[ImGuiDragDropFlags.PayloadNoCrossContext]], 128 --[[ImGuiDragDropFlags.PayloadNoCrossProcess]]) if is_drag_docking and ImGui.BeginDragDropSource(drag_drop_flags) then ImGui.SetDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, window) @@ -4283,7 +4286,7 @@ function ImGui.BeginDockableDragDropSource(window) end function ImGui.BeginDockableDragDropTarget(window) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() --IM_ASSERT(window.RootWindowDockTree == window) -- May also be a DockSpace assert(bit32.band(window.Flags, 524288 --[[ImGuiWindowFlags.NoDocking]]) == 0) @@ -4307,7 +4310,7 @@ function ImGui.BeginDockableDragDropTarget(window) local node = nil if window.DockNodeAsHost then -- Cannot assume that node will ~= nil even though we passed the rectangle test: it depends on padding/spacing handled by DockNodeTreeFindVisibleNodeByPos(). - node = ImGui.DockNodeTreeFindVisibleNodeByPos(window.DockNodeAsHost, g.IO.MousePos) + node = ImGui_DockNodeTreeFindVisibleNodeByPos(window.DockNodeAsHost, g.IO.MousePos) -- There is an edge case when docking into a dockspace which only has _inactive_ nodes (because none of the windows are active) -- In this case we need to fallback into any leaf mode, possibly the central node. @@ -4327,9 +4330,9 @@ function ImGui.BeginDockableDragDropTarget(window) if node and node.TabBar and not node:IsHiddenTabBar() and not node:IsNoTabBar() then explicit_target_rect = node.TabBar.BarRect else - explicit_target_rect = ImRect(window.Pos, window.Pos + ImVec2(window.Size.x, ImGui.GetFrameHeight())) + explicit_target_rect = ImRect(window.Pos, window.Pos + ImVec2(window.Size.x, ImGui_GetFrameHeight())) end - local is_explicit_target = g.IO.ConfigDockingWithShift or ImGui.IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max) + local is_explicit_target = g.IO.ConfigDockingWithShift or ImGui_IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max) -- Preview docking request and find out split direction/ratio --local do_preview = true -- Ignore testing for payload:IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window. @@ -4340,7 +4343,7 @@ function ImGui.BeginDockableDragDropTarget(window) local split_outer = ImGuiDockPreviewData() local split_data = split_inner if node and (node.ParentNode or node:IsCentralNode() or not node:IsLeafNode()) then - local root_node = ImGui.DockNodeGetRootNode(node) + local root_node = ImGui_DockNodeGetRootNode(node) if root_node then ImGui.DockNodePreviewDockSetup(window, root_node, payload_window, nil, split_outer, is_explicit_target, true) if split_outer.IsSplitDirExplicit then split_data = split_outer end @@ -4378,7 +4381,7 @@ end ------------------------------------------------------------------------------- DockSettingsRenameNodeReferences = function(old_node_id, new_node_id) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() for _, window in g.Windows:iter() do if window.DockId == old_node_id and window.DockNode == nil then window.DockId = new_node_id end end @@ -4391,7 +4394,7 @@ end -- Remove references stored in ImGuiWindowSettings to the given ImGuiDockNodeSettings --- @param node_ids table # 1-based array DockSettingsRemoveNodeReferences = function(node_ids, node_ids_count) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local found = 0 ---- FIXME-OPT: We could remove this loop by storing the index in the map for _, settings in g.SettingsWindows:iter() do @@ -4419,7 +4422,7 @@ end DockSettingsHandler_ClearAll = function(ctx, handler) local dc = ctx.DockContext dc.NodesSettings:clear() - ImGui.DockContextClearNodes(ctx, 0, true) + ImGui_DockContextClearNodes(ctx, 0, true) end -- Recreate nodes based on settings data @@ -4587,15 +4590,15 @@ function ImGui.DockNodeGetWindowMenuButtonId(node) end function ImGui.GetWindowDockID() - return ImGui.GetCurrentContext().CurrentWindow.DockId + return ImGui_GetCurrentContext().CurrentWindow.DockId end function ImGui.IsWindowDocked() - return ImGui.GetCurrentContext().CurrentWindow.DockIsActive + return ImGui_GetCurrentContext().CurrentWindow.DockIsActive end function ImGui.SetNextWindowDockID(id, cond) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() g.NextWindowData.HasFlags = bit32.bor(g.NextWindowData.HasFlags, 4096 --[[ImGuiNextWindowDataFlags.HasDock]]) g.NextWindowData.DockCond = (cond and cond ~= 0) and cond or 1 --[[ImGuiCond.Always]] g.NextWindowData.DockId = id @@ -4603,19 +4606,19 @@ end -- We use 'undock == false' when dragging from title bar to allow moving groups of floating nodes without undocking them. function ImGui.StartMouseMovingWindowOrNode(window, node, undock) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local can_undock_node = false if undock and node ~= nil and node.VisibleWindow and bit32.band(node.VisibleWindow.Flags, 4 --[[ImGuiWindowFlags.NoMove]]) == 0 and bit32.band(node.MergedFlags, 128 --[[ImGuiDockNodeFlags.NoUndocking]]) == 0 then -- Can undock if: -- - part of a hierarchy with more than one visible node (if only one is visible, we'll just move the root window) -- - part of a dockspace node hierarchy: so we can undock the last single visible node too. Undocking from a fixed/central node will create a new node and copy windows. - local root_node = ImGui.DockNodeGetRootNode(node) + local root_node = ImGui_DockNodeGetRootNode(node) if root_node.OnlyNodeWithWindows ~= node or root_node.CentralNode ~= nil then can_undock_node = true end end - local clicked = ImGui.IsMouseClicked(0) + local clicked = ImGui_IsMouseClicked(0) local dragging = ImGui.IsMouseDragging(0) if can_undock_node and dragging then ImGui.DockContextQueueUndockNode(g, node) -- Will lead to DockNodeStartMouseMovingWindow() -> StartMouseMovingWindow() being called next frame @@ -4634,17 +4637,17 @@ end -- [Port] Upstream CollapseButton (docking branch): replaces the port's simpler version -- The Collapse button also functions as a Dock Menu button. function ImGui.CollapseButton(id, pos, dock_node) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow - local bb = ImRect(pos, pos + ImVec2(g.FontSize, g.FontSize)) + local bb = ImRect(pos.x, pos.y, pos.x + g.FontSize, pos.y + g.FontSize) -- [Luau] scalar form: no temporary ImVec2 local is_clipped = not ImGui.ItemAdd(bb, id) - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id, 0 --[[ImGuiButtonFlags.None]]) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id, 0 --[[ImGuiButtonFlags.None]]) if is_clipped then return pressed end -- Render - local bg_col = ImGui.GetColorU32((held and hovered) and 24 --[[ImGuiCol.ButtonActive]] or (hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]])) - local text_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) + local bg_col = ImGui_GetColorU32((held and hovered) and 24 --[[ImGuiCol.ButtonActive]] or (hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]])) + local text_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) if hovered or held then window.DrawList:AddRectFilled(bb.Min, bb.Max, bg_col) end @@ -4670,7 +4673,7 @@ function ImGui.SplitterBehavior(bb, id, axis, size1, size2, min_size1, min_size2 hover_extend = hover_extend or 0.0 hover_visibility_delay = hover_visibility_delay or 0.0 bg_col = bg_col or 0 - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow if not ImGui.ItemAdd(bb, id, nil, 2 --[[ImGuiItemFlags.NoNav]]) then return false, size1, size2 end @@ -4682,7 +4685,7 @@ function ImGui.SplitterBehavior(bb, id, axis, size1, size2, min_size1, min_size2 local bb_interact = ImRect(bb.Min, bb.Max) bb_interact:Expand(axis == 2 --[[ImGuiAxis.Y]] and ImVec2(0.0, hover_extend) or ImVec2(hover_extend, 0.0)) - local _, hovered, held = ImGui.ButtonBehavior(bb_interact, id, button_flags) + local _, hovered, held = ImGui_ButtonBehavior(bb_interact, id, button_flags) if hovered then g.LastItemData.StatusFlags = bit32.bor(g.LastItemData.StatusFlags, 1 --[[ImGuiItemStatusFlags.HoveredRect]]) -- for IsItemHovered(), because bb_interact is larger than bb end @@ -4715,7 +4718,7 @@ function ImGui.SplitterBehavior(bb, id, axis, size1, size2, min_size1, min_size2 if bit32.band(bg_col, 4278190080 --[[IM_COL32_A_MASK]]) ~= 0 then window.DrawList:AddRectFilled(bb_render.Min, bb_render.Max, bg_col, 0.0) end - local col = ImGui.GetColorU32(held and 30 --[[ImGuiCol.SeparatorActive]] or ((hovered and g.HoveredIdTimer >= hover_visibility_delay) and 29 --[[ImGuiCol.SeparatorHovered]] or 28 --[[ImGuiCol.Separator]])) + local col = ImGui_GetColorU32(held and 30 --[[ImGuiCol.SeparatorActive]] or ((hovered and g.HoveredIdTimer >= hover_visibility_delay) and 29 --[[ImGuiCol.SeparatorHovered]] or 28 --[[ImGuiCol.Separator]])) window.DrawList:AddRectFilled(bb_render.Min, bb_render.Max, col, 0.0) return held, size1, size2 @@ -5771,7 +5774,7 @@ end --- @param shared_font_atlas? ImFontAtlas function ImGui.CreateContext(shared_font_atlas) - local prev_ctx = ImGui.GetCurrentContext() + local prev_ctx = ImGui_GetCurrentContext() local ctx = ImGuiContext(shared_font_atlas) ImGui.SetCurrentContext(ctx) ImGui.Initialize() @@ -5783,7 +5786,7 @@ end --- @param ctx? ImGuiContext function ImGui.DestroyContext(ctx) - local prev_ctx = ImGui.GetCurrentContext() + local prev_ctx = ImGui_GetCurrentContext() if ctx == nil then ctx = prev_ctx end @@ -5800,7 +5803,7 @@ function ImGui.FindWindowSettingsByWindow(window) if window.SettingsOffset ~= -1 then return g.SettingsWindows[window.SettingsOffset + 1] end - return ImGui.FindWindowSettingsByID(window.ID) + return ImGui_FindWindowSettingsByID(window.ID) end -- We don't provide a FindWindowSettingsByName() because Docking system doesn't always hold on names. @@ -5821,7 +5824,7 @@ end --- @return ImGuiWindow? function ImGui.FindFrontMostVisibleChildWindow(window) for n = window.DC.ChildWindows.Size, 1, -1 do - if ImGui.IsWindowActiveAndVisible(window.DC.ChildWindows.Data[n]) then + if ImGui_IsWindowActiveAndVisible(window.DC.ChildWindows.Data[n]) then return ImGui.FindFrontMostVisibleChildWindow(window.DC.ChildWindows.Data[n]) end end @@ -5847,7 +5850,7 @@ end --- @param settings ImGuiWindowSettings local function ApplyWindowSettings(window, settings) if settings ~= nil then - local main_viewport = ImGui.GetMainViewport() + local main_viewport = ImGui_GetMainViewport() ImVec2_Copy(window.ViewportPos, main_viewport.Pos) if (settings.ViewportId ~= 0) then window.ViewportId = settings.ViewportId @@ -5887,7 +5890,7 @@ end local function InitOrLoadWindowSettings(window, settings) -- Initial window state with e.g. default/arbitrary window position -- Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. - local main_viewport = ImGui.GetMainViewport() + local main_viewport = ImGui_GetMainViewport() ImVec2_Copy(window.Pos, main_viewport.Pos + ImVec2(60, 60)) ImVec2_Copy(window.Size, ImVec2(0, 0)) ImVec2_Copy(window.SizeFull, ImVec2(0, 0)) @@ -6137,15 +6140,15 @@ end -- This will revert window to its initial state, including enabling the ImGuiCond.FirstUseEver/ImGuiCond.Once conditions once more. function ImGui.ClearWindowSettings(name) --IMGUI_DEBUG_LOG("ClearWindowSettings('%s')\n", name) - local window = ImGui.FindWindowByName(name) + local window = ImGui_FindWindowByName(name) if window ~= nil then window.Flags = bit32.bor(window.Flags, 256 --[[ImGuiWindowFlags.NoSavedSettings]]) InitOrLoadWindowSettings(window, nil) - if window.DockId and window.DockId ~= 0 and ImGui.DockContextProcessUndockWindow then - ImGui.DockContextProcessUndockWindow(GImGui, window, true) + if window.DockId and window.DockId ~= 0 and ImGui_DockContextProcessUndockWindow then + ImGui_DockContextProcessUndockWindow(GImGui, window, true) end end - local settings = window and ImGui.FindWindowSettingsByWindow(window) or ImGui.FindWindowSettingsByID(ImHashStr(name)) + local settings = window and ImGui.FindWindowSettingsByWindow(window) or ImGui_FindWindowSettingsByID(ImHashStr(name)) if settings then settings.WantDelete = true end end @@ -6171,14 +6174,14 @@ end local function WindowSettingsHandler_ReadOpen(ctx, handler, name) local id = ImHashStr(name) - local settings = ImGui.FindWindowSettingsByID(id) + local settings = ImGui_FindWindowSettingsByID(id) if settings then -- Clear existing if recycling previous entry local fresh = ImGuiWindowSettings() for k, v in pairs(fresh) do settings[k] = v end settings.Name = name else - settings = ImGui.CreateNewWindowSettings(name) + settings = ImGui_CreateNewWindowSettings(name) end settings.ID = id settings.WantApply = true @@ -6213,7 +6216,7 @@ local function WindowSettingsHandler_ApplyAll(ctx, handler) local g = ctx for _, settings in g.SettingsWindows:iter() do if settings.WantApply then - local window = ImGui.FindWindowByID(settings.ID) + local window = ImGui_FindWindowByID(settings.ID) if window then ApplyWindowSettings(window, settings) end settings.WantApply = false end @@ -6228,7 +6231,7 @@ local function WindowSettingsHandler_WriteAll(ctx, handler, buf) if bit32.band(window.Flags, 256 --[[ImGuiWindowFlags.NoSavedSettings]]) == 0 then local settings = ImGui.FindWindowSettingsByWindow(window) if not settings then - settings = ImGui.CreateNewWindowSettings(window.Name) + settings = ImGui_CreateNewWindowSettings(window.Name) settings.LastUsedDate = g.SessionDate:Unpack() window.SettingsOffset = g.SettingsWindows:index_from_ptr(settings) end @@ -6333,16 +6336,16 @@ function ImGui.LogRenderedText(ref_pos, text, text_end, text_begin) g.LogNextPrefix = nil; g.LogNextSuffix = nil text_begin = text_begin or 1 - if not text_end then text_end = ImGui.FindRenderedTextEnd(text, text_end) end + if not text_end then text_end = ImGui_FindRenderedTextEnd(text, text_end) end local log_new_line = ref_pos and (ref_pos.y > g.LogLinePosY + ImMax(g.Style.FramePadding.y, g.Style.ItemSpacing.y) + 1) if ref_pos then g.LogLinePosY = ref_pos.y end if log_new_line then - ImGui.LogText("\n") + ImGui_LogText("\n") g.LogLineFirstItem = true end - if prefix then ImGui.LogRenderedText(ref_pos, prefix, #prefix + 1) end -- Calculate end ourself to ensure "##" are included here. + if prefix then ImGui_LogRenderedText(ref_pos, prefix, #prefix + 1) end -- Calculate end ourself to ensure "##" are included here. -- Re-adjust padding if we have popped out of our starting depth if g.LogDepthRef > window.DC.TreeDepth then g.LogDepthRef = window.DC.TreeDepth end @@ -6358,10 +6361,10 @@ function ImGui.LogRenderedText(ref_pos, text, text_end, text_begin) local is_last_line = (line_end == text_end) if line_start ~= line_end or not is_last_line then local indentation = g.LogLineFirstItem and tree_depth * 4 or 1 - ImGui.LogText(string.rep(" ", indentation) .. string.sub(text, line_start, line_end - 1)) + ImGui_LogText(string.rep(" ", indentation) .. string.sub(text, line_start, line_end - 1)) g.LogLineFirstItem = false if string.byte(text, line_end) == 10 then - ImGui.LogText("\n") + ImGui_LogText("\n") g.LogLineFirstItem = true end end @@ -6369,7 +6372,7 @@ function ImGui.LogRenderedText(ref_pos, text, text_end, text_begin) text_remaining = line_end + 1 end - if suffix then ImGui.LogRenderedText(ref_pos, suffix, #suffix + 1) end + if suffix then ImGui_LogRenderedText(ref_pos, suffix, #suffix + 1) end end -- Start logging/capturing text output @@ -6424,7 +6427,7 @@ end function ImGui.LogFinish() local g = GImGui if not g.LogEnabled then return end - ImGui.LogText("\n") + ImGui_LogText("\n") local out = bit32.band(g.LogFlags, 15 --[[ImGuiLogFlags.OutputMask_]]) if out == 8 --[[ImGuiLogFlags.OutputClipboard]] then if not g.LogBuffer:empty() then ImGui.SetClipboardText(g.LogBuffer:c_str()) end @@ -6439,15 +6442,15 @@ end -- FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!) function ImGui.LogButtons() local g = GImGui - ImGui.PushID("LogButtons") - local log_to_tty = ImGui.Button("Log To TTY"); ImGui.SameLine() - local log_to_file = ImGui.Button("Log To File"); ImGui.SameLine() - local log_to_clipboard = ImGui.Button("Log To Clipboard"); ImGui.SameLine() + ImGui_PushID("LogButtons") + local log_to_tty = ImGui_Button("Log To TTY"); ImGui_SameLine() + local log_to_file = ImGui_Button("Log To File"); ImGui_SameLine() + local log_to_clipboard = ImGui_Button("Log To Clipboard"); ImGui_SameLine() ImGui.PushItemFlag(1 --[[ImGuiItemFlags.NoTabStop]], true) - ImGui.SetNextItemWidth(ImGui.CalcTextSize("999").x) + ImGui_SetNextItemWidth(ImGui_CalcTextSize("999").x) g.LogDepthToExpandDefault = ImGui.SliderInt("Default Depth", g.LogDepthToExpandDefault, 0, 9, nil) ImGui.PopItemFlag() - ImGui.PopID() + ImGui_PopID() -- Start logging at the end of the function so that the buttons don't appear in the log if log_to_tty then ImGui.LogToTTY() end @@ -6570,7 +6573,7 @@ function ImGui.ItemHandleShortcut(id) g.LastItemData.StatusFlags = bit32.bor(g.LastItemData.StatusFlags, 1024 --[[ImGuiItemStatusFlags.HasShortcut]]) g.LastItemData.Shortcut = g.NextItemData.Shortcut end - if not ImGui.Shortcut(g.NextItemData.Shortcut, bit32.band(flags, 261375 --[[ImGuiInputFlags.SupportedByShortcut]]), id) or g.NavActivateId ~= 0 then + if not ImGui_Shortcut(g.NextItemData.Shortcut, bit32.band(flags, 261375 --[[ImGuiInputFlags.SupportedByShortcut]]), id) or g.NavActivateId ~= 0 then return end @@ -6684,7 +6687,7 @@ end last_item_data.StatusFlags = bit32.bor(last_item_data.StatusFlags, 256 --[[ImGuiItemStatusFlags.Visible]]) end - if ImGui.IsMouseHoveringRect(bb.Min, bb.Max) then + if ImGui_IsMouseHoveringRect(bb.Min, bb.Max) then last_item_data.StatusFlags = bit32.bor(last_item_data.StatusFlags, 1 --[[ImGuiItemStatusFlags.HoveredRect]]) end @@ -6789,7 +6792,7 @@ function ImGui.ItemSize(size_or_bb, text_baseline_y) -- Horizontal layout mode if (dc.LayoutType == 0 --[[ImGuiLayoutType.Horizontal]]) then - ImGui.SameLine() + ImGui_SameLine() end end @@ -6833,7 +6836,7 @@ function ImGui.Indent(indent_w) if indent_w == nil then indent_w = 0.0 end local g = GImGui - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if indent_w ~= 0.0 then window.DC.Indent.x = window.DC.Indent.x + indent_w @@ -6850,7 +6853,7 @@ function ImGui.Unindent(indent_w) if indent_w == nil then indent_w = 0.0 end local g = GImGui - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if indent_w ~= 0.0 then window.DC.Indent.x = window.DC.Indent.x - indent_w @@ -6940,7 +6943,7 @@ end --- @return ImVec2 --- @nodiscard function ImGui.GetCursorScreenPos() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() local ret = ImVec2() ImVec2_Copy(ret, window.DC.CursorPos) return ret @@ -6948,7 +6951,7 @@ end --- @param pos ImVec2 function ImGui.SetCursorScreenPos(pos) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() ImVec2_Copy(window.DC.CursorPos, pos) -- window.DC.CursorMaxPos = ImMax(window.DC.CursorMaxPos, window.DC.CursorPos) window.DC.IsSetPos = true @@ -6958,23 +6961,23 @@ end -- Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'. --- @return ImVec2 function ImGui.GetCursorPos() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() return ImVec2(window.DC.CursorPos.x - window.Pos.x + window.Scroll.x, window.DC.CursorPos.y - window.Pos.y + window.Scroll.y) end function ImGui.GetCursorPosX() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() return window.DC.CursorPos.x - window.Pos.x + window.Scroll.x end function ImGui.GetCursorPosY() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() return window.DC.CursorPos.y - window.Pos.y + window.Scroll.y end --- @param local_pos ImVec2 function ImGui.SetCursorPos(local_pos) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() ImVec2_CopyV(window.DC.CursorPos, window.Pos.x - window.Scroll.x + local_pos.x, window.Pos.y - window.Scroll.y + local_pos.y) -- window.DC.CursorMaxPos = ImMax(window.DC.CursorMaxPos, window.DC.CursorPos) window.DC.IsSetPos = true @@ -6982,7 +6985,7 @@ end --- @param x float function ImGui.SetCursorPosX(x) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() window.DC.CursorPos.x = window.Pos.x - window.Scroll.x + x -- window.DC.CursorMaxPos.x = ImMax(window.DC.CursorMaxPos.x, window.DC.CursorPos.x) window.DC.IsSetPos = true @@ -6990,7 +6993,7 @@ end --- @param y float function ImGui.SetCursorPosY(y) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() window.DC.CursorPos.y = window.Pos.y - window.Scroll.y + y -- window.DC.CursorMaxPos.y = ImMax(window.DC.CursorMaxPos.y, window.DC.CursorPos.y) window.DC.IsSetPos = true @@ -6998,7 +7001,7 @@ end --- @return ImVec2 function ImGui.GetCursorStartPos() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() return window.DC.CursorStartPos - window.Pos end @@ -7049,7 +7052,13 @@ function ImGui.BeginGroup() local g = GImGui local window = g.CurrentWindow - local group_data = ImGuiGroupData() + -- [Luau] C++ copies the ImGuiGroupData into the vector's storage: reuse the entry an EndGroup() left past Size + -- (every field is written below) instead of allocating 7 tables per group + local group_stack = g.GroupStack + local group_data = (group_stack.Size < group_stack.Capacity) and group_stack.Data[group_stack.Size + 1] or nil + if group_data == nil then + group_data = ImGuiGroupData() + end group_data.WindowID = window.ID ImVec2_Copy(group_data.BackupCursorPos, window.DC.CursorPos) ImVec2_Copy(group_data.BackupCursorPosPrevLine, window.DC.CursorPosPrevLine) @@ -7065,7 +7074,7 @@ function ImGui.BeginGroup() group_data.BackupDeactivatedIdIsAlive = g.DeactivatedItemData.IsAlive group_data.EmitItem = true - g.GroupStack:push_back(group_data) + group_stack:push_back(group_data) window.DC.GroupOffset.x = window.DC.CursorPos.x - window.Pos.x - window.DC.ColumnsOffset.x ImVec1_Copy(window.DC.Indent, window.DC.GroupOffset) @@ -7076,6 +7085,7 @@ function ImGui.BeginGroup() end end +local EndGroup_bb = ImRect() -- [Luau] scratch for EndGroup(), never escapes @native function ImGui.EndGroup() local g = GImGui @@ -7090,10 +7100,14 @@ function ImGui.EndGroup() end -- Include LastItemData.Rect.Max as a workaround for e.g. EndTable() undershooting with CursorMaxPos report. (#7543) - local group_bb = ImRect(group_data.BackupCursorPos, ImMax(ImMax(window.DC.CursorMaxPos, g.LastItemData.Rect.Max), group_data.BackupCursorPos)) + -- [Luau] scalar ImMax()es into a scratch rect (ItemAdd() and ImRect_Copy() below copy it) + local bcp, cmp, lmax = group_data.BackupCursorPos, window.DC.CursorMaxPos, g.LastItemData.Rect.Max + local group_bb = EndGroup_bb + group_bb.Min.x = bcp.x; group_bb.Min.y = bcp.y + group_bb.Max.x = math.max(math.max(cmp.x, lmax.x), bcp.x); group_bb.Max.y = math.max(math.max(cmp.y, lmax.y), bcp.y) ImVec2_Copy(window.DC.CursorPos, group_data.BackupCursorPos) ImVec2_Copy(window.DC.CursorPosPrevLine, group_data.BackupCursorPosPrevLine) - ImVec2_Copy(window.DC.CursorMaxPos, ImMax(group_data.BackupCursorMaxPos, group_bb.Max)) + ImVec2_CopyV(window.DC.CursorMaxPos, math.max(group_data.BackupCursorMaxPos.x, group_bb.Max.x), math.max(group_data.BackupCursorMaxPos.y, group_bb.Max.y)) ImVec1_Copy(window.DC.Indent, group_data.BackupIndent) ImVec1_Copy(window.DC.GroupOffset, group_data.BackupGroupOffset) ImVec2_Copy(window.DC.CurrLineSize, group_data.BackupCurrLineSize) @@ -7109,7 +7123,7 @@ function ImGui.EndGroup() end window.DC.CurrLineTextBaseOffset = ImMax(window.DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset) -- FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now. - ImGui.ItemSize(group_bb:GetSize()) + ImGui.ItemSize(group_bb) -- [Luau] == ItemSize(group_bb:GetSize()): ItemSize() takes the rect's size ImGui.ItemAdd(group_bb, 0, nil, 1 --[[ImGuiItemFlags.NoTabStop]]) -- If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group. @@ -7275,7 +7289,7 @@ end --- @param mouse_button? ImGuiMouseButton function ImGui.IsItemClicked(mouse_button) if mouse_button == nil then mouse_button = 0 end - return ImGui.IsMouseClicked(mouse_button) and ImGui.IsItemHovered(0 --[[ImGuiHoveredFlags.None]]) + return ImGui_IsMouseClicked(mouse_button) and ImGui_IsItemHovered(0 --[[ImGuiHoveredFlags.None]]) end function ImGui.IsItemToggledOpen() @@ -7380,7 +7394,7 @@ function ImGui.FocusWindow(window, flags) if window and window == window.RootWindow and bit32.band(window.Flags, 8192 --[[ImGuiWindowFlags.NoBringToFrontOnFocus]]) == 0 then ImGui.BringWindowToDisplayBehind(window, blocking_modal) -- Still bring right under modal. (FIXME: Could move in focus list too?) end - ImGui.ClosePopupsOverWindow(ImGui.GetTopMostPopupModal(), false) -- Note how we need to use GetTopMostPopupModal() aad NOT blocking_modal, to handle nested modals + ImGui_ClosePopupsOverWindow(ImGui_GetTopMostPopupModal(), false) -- Note how we need to use GetTopMostPopupModal() aad NOT blocking_modal, to handle nested modals return end end @@ -7392,18 +7406,18 @@ function ImGui.FocusWindow(window, flags) -- Apply focus if g.NavWindow ~= window then - ImGui.SetNavWindow(window) + ImGui_SetNavWindow(window) if window and g.NavHighlightItemUnderNav then g.NavMousePosDirty = true end g.NavId = window and window.NavLastIds[0] or 0 -- Restore NavId g.NavLayer = 0 --[[ImGuiNavLayer.Main]] - ImGui.SetNavFocusScope(window and window.NavRootFocusScopeId or 0) + ImGui_SetNavFocusScope(window and window.NavRootFocusScopeId or 0) g.NavIdIsAlive = false g.NavLastValidSelectionUserData = (-1) --[[ImGuiSelectionUserData_Invalid]] -- Close popups if any - ImGui.ClosePopupsOverWindow(window, false) + ImGui_ClosePopupsOverWindow(window, false) end -- Move the root window to the top of the pile @@ -7419,7 +7433,7 @@ function ImGui.FocusWindow(window, flags) -- - Using dock host items (tab, collapse button) can trigger this before we redirect the ActiveIdWindow toward the child window. if g.ActiveId ~= 0 and g.ActiveIdWindow and g.ActiveIdWindow.RootWindow ~= focus_front_window then if not g.ActiveIdNoClearOnFocusLoss and not active_id_window_is_dock_node_host then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end end @@ -7437,7 +7451,7 @@ function ImGui.FocusWindow(window, flags) -- Bring to front ImGui.BringWindowToFocusFront(focus_front_window) if bit32.band(bit32.bor(window.Flags, focus_front_window.Flags, display_front_window.Flags), 8192 --[[ImGuiWindowFlags.NoBringToFrontOnFocus]]) == 0 then - ImGui.BringWindowToDisplayFront(display_front_window) + ImGui_BringWindowToDisplayFront(display_front_window) end end @@ -7600,13 +7614,13 @@ function ImGui.FocusTopMostWindowUnderOne(under_this_window, ignore_window, filt -- If A and B are docked into window and B disappear, at the NewFrame() call site window.NavLastChildNavWindow will still point to B. -- We might leverage the tab order implicitly stored in window.DockNodeAsHost.TabBar (essentially the 'most_recently_selected_tab' code in tab bar will do that but on next update) -- to tell which is the "previous" window. Or we may leverage 'LastFrameFocused/LastFrameJustFocused' and have this function handle child window itself? - ImGui.FocusWindow(window, flags) + ImGui_FocusWindow(window, flags) return end until true end - ImGui.FocusWindow(nil, flags) + ImGui_FocusWindow(nil, flags) end --- @param id ImGuiID @@ -7616,7 +7630,7 @@ function ImGui.SetFocusID(id, window) assert(id ~= 0) if g.NavWindow ~= window then - ImGui.SetNavWindow(window) + ImGui_SetNavWindow(window) end -- Assume that SetFocusID() is called in the context where its window.DC.NavLayerCurrent and g.CurrentFocusScopeId are valid. @@ -7624,10 +7638,10 @@ function ImGui.SetFocusID(id, window) local nav_layer = window.DC.NavLayerCurrent g.NavId = id g.NavLayer = nav_layer - ImGui.SetNavFocusScope(g.CurrentFocusScopeId) + ImGui_SetNavFocusScope(g.CurrentFocusScopeId) window.NavLastIds[nav_layer] = id if g.LastItemData.ID == id then - ImRect_Copy(window.NavRectRel[nav_layer], ImGui.WindowRectAbsToRel(window, g.LastItemData.NavRect)) + ImRect_Copy(window.NavRectRel[nav_layer], ImGui_WindowRectAbsToRel(window, g.LastItemData.NavRect)) end g.NavIdItemFlags = (g.LastItemData.ID == id) and g.LastItemData.ItemFlags or 0 --[[ImGuiItemFlags.None]] if id == g.ActiveIdIsAlive then @@ -7641,8 +7655,8 @@ function ImGui.SetFocusID(id, window) end -- Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it) - ImGui.NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) - ImGui.NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) + ImGui_NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) + ImGui_NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) end -- This is not 100% symmetric with StartMouseMovingWindow(). @@ -7745,7 +7759,7 @@ function ImGui.SetActiveID(id, window) end function ImGui.ClearActiveID() - ImGui.SetActiveID(0, nil) -- g.ActiveId = 0 + ImGui_SetActiveID(0, nil) -- g.ActiveId = 0 end ------------------------------------------------------------------------------- @@ -7824,7 +7838,7 @@ end --- @return ImGuiID function MT.ImGuiWindow:GetIDFromRectangle(r_abs) local seed = self.IDStack:back() - local r_rel = ImGui.WindowRectAbsToRel(self, r_abs) + local r_rel = ImGui_WindowRectAbsToRel(self, r_abs) return ImHashData({ math.floor(r_rel.Min.x), math.floor(r_rel.Min.y), math.floor(r_rel.Max.x), math.floor(r_rel.Max.y) }, 4, seed) end @@ -7944,7 +7958,7 @@ function ImGui.IsWindowContentHoverable(window, flags) -- Inhibit hover unless the window is within the stack of our modal/popup if want_inhibit then - if not ImGui.IsWindowWithinBeginStackOf(window.RootWindow, focused_root_window) then + if not ImGui_IsWindowWithinBeginStackOf(window.RootWindow, focused_root_window) then return false end end @@ -8117,7 +8131,7 @@ end return false end - if not ImGui.IsMouseHoveringRect(bb.Min, bb.Max) then + if not ImGui_IsMouseHoveringRect(bb.Min, bb.Max) then return false end @@ -8159,7 +8173,7 @@ end -- Display shortcut (only works with mouse) -- (ImGuiItemStatusFlags.HasShortcut in LastItemData denotes we want a tooltip) if id == g.LastItemData.ID and (bit32.band(g.LastItemData.StatusFlags, 1024 --[[ImGuiItemStatusFlags.HasShortcut]]) ~= 0) and g.ActiveId ~= id then - if ImGui.IsItemHovered(bit32.bor(4096 --[[ImGuiHoveredFlags.ForTooltip]], 65536 --[[ImGuiHoveredFlags.DelayNormal]])) then + if ImGui_IsItemHovered(bit32.bor(4096 --[[ImGuiHoveredFlags.ForTooltip]], 65536 --[[ImGuiHoveredFlags.DelayNormal]])) then ImGui.SetTooltip("%s", ImGui.GetKeyChordName(g.LastItemData.Shortcut)) end end @@ -8169,7 +8183,7 @@ end if bit32.band(item_flags, 64 --[[ImGuiItemFlags.Disabled]]) ~= 0 then -- Release active id if turning disabled if g.ActiveId == id and id ~= 0 then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end g.HoveredIdIsDisabled = true return false @@ -8182,7 +8196,7 @@ if not IMGUI_DISABLE_DEBUG_TOOLS then -- making the cost of this tool near-zero! We could get better call-stack and support picking non-hovered -- items if we performed the test in ItemAdd(), but that would incur a bigger runtime cost. if g.DebugItemPickerActive and g.HoveredIdPreviousFrame == id then - ImGui.GetForegroundDrawList():AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)) + ImGui_GetForegroundDrawList():AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)) end if g.DebugItemPickerBreakId == id then IM_DEBUG_BREAK() @@ -8397,7 +8411,7 @@ function MT.ImGuiIO:AddKeyAnalogEvent(key, down, analog_value) end local g = self.Ctx - assert(ImGui.IsNamedKeyOrMod(key)) -- Backend needs to pass a valid ImGuiKey constant. 0..511 values are legacy native key codes which are not accepted by this API. + assert(ImGui_IsNamedKeyOrMod(key)) -- Backend needs to pass a valid ImGuiKey constant. 0..511 values are legacy native key codes which are not accepted by this API. assert(ImGui.IsAliasKey(key) == false) -- Backend cannot submit ImGuiKey.MouseXXX values they are automatically inferred from AddMouseXXX() events. -- MacOS: swap Cmd(Super) and Ctrl @@ -8413,7 +8427,7 @@ function MT.ImGuiIO:AddKeyAnalogEvent(key, down, analog_value) -- Filter duplicate (in particular: key mods and gamepad analog values are commonly spammed) local latest_event = FindLatestInputEvent(g, 5 --[[ImGuiInputEventType.Key]], key) - local key_data = ImGui.GetKeyData(g, key) + local key_data = ImGui_GetKeyData(g, key) local latest_key_down = latest_event and latest_event.Key.Down or key_data.Down local latest_key_analog = latest_event and latest_event.Key.AnalogValue or key_data.AnalogValue if latest_key_down == down and latest_key_analog == analog_value then @@ -8741,7 +8755,7 @@ function ImGui.GetKeyData(ctx, key) -- Special storage location for mods if bit32.band(key, 61440 --[[ImGuiMod_Mask_]]) ~= 0 then - key = ImGui.ConvertSingleModFlagToKey(key) + key = ImGui_ConvertSingleModFlagToKey(key) end assert(ImGui.IsNamedKey(key), "Support for user key indices was dropped in favor of ImGuiKey. Please update backend & user code.") @@ -8756,8 +8770,8 @@ end --- @param key_down ImGuiKey function ImGui.GetKeyMagnitude2d(key_left, key_right, key_up, key_down) return ImVec2( - ImGui.GetKeyData(nil, key_right).AnalogValue - ImGui.GetKeyData(nil, key_left).AnalogValue, - ImGui.GetKeyData(nil, key_down).AnalogValue - ImGui.GetKeyData(nil, key_up).AnalogValue + ImGui_GetKeyData(nil, key_right).AnalogValue - ImGui_GetKeyData(nil, key_left).AnalogValue, + ImGui_GetKeyData(nil, key_down).AnalogValue - ImGui_GetKeyData(nil, key_up).AnalogValue ) end @@ -8768,7 +8782,7 @@ end --- @param key ImGuiKey --- @param owner_id ImGuiID function ImGui.TestKeyOwner(key, owner_id) - if not ImGui.IsNamedKeyOrMod(key) then + if not ImGui_IsNamedKeyOrMod(key) then return true end @@ -8807,11 +8821,11 @@ end function ImGui.IsKeyDown(key, owner_id) if owner_id == nil then owner_id = 0 --[[ImGuiKeyOwner_Any]] end - local key_data = ImGui.GetKeyData(nil, key) + local key_data = ImGui_GetKeyData(nil, key) if not key_data.Down then return false end - if not ImGui.TestKeyOwner(key, owner_id) then + if not ImGui_TestKeyOwner(key, owner_id) then return false end return true @@ -8822,7 +8836,7 @@ end function ImGui.IsKeyPressed(key, is_repeat) if is_repeat == nil then is_repeat = true end - return ImGui.IsKeyPressedEx(key, is_repeat and 1 --[[ImGuiInputFlags.Repeat]] or 0 --[[ImGuiInputFlags.None]], 0 --[[ImGuiKeyOwner_Any]]) + return ImGui_IsKeyPressedEx(key, is_repeat and 1 --[[ImGuiInputFlags.Repeat]] or 0 --[[ImGuiInputFlags.None]], 0 --[[ImGuiKeyOwner_Any]]) end --- @param key ImGuiKey @@ -8831,11 +8845,11 @@ end function ImGui.IsKeyReleased(key, owner_id) if owner_id == nil then owner_id = 0 --[[ImGuiKeyOwner_Any]] end - local key_data = ImGui.GetKeyData(nil, key) + local key_data = ImGui_GetKeyData(nil, key) if key_data.DownDurationPrev < 0.0 or key_data.Down then return false end - if not ImGui.TestKeyOwner(key, owner_id) then + if not ImGui_TestKeyOwner(key, owner_id) then return false end return true @@ -8849,7 +8863,7 @@ function ImGui.IsKeyPressedEx(key, flags, owner_id) if owner_id == nil then owner_id = 0 end local g = GImGui - local key_data = ImGui.GetKeyData(g, key) + local key_data = ImGui_GetKeyData(g, key) if not key_data.Down then -- In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitates eating mechanism (until we finish work on key ownership) return false @@ -8886,7 +8900,7 @@ function ImGui.IsKeyPressedEx(key, flags, owner_id) if not pressed then return false end - if not ImGui.TestKeyOwner(key, owner_id) then + if not ImGui_TestKeyOwner(key, owner_id) then return false end @@ -8903,7 +8917,7 @@ function ImGui.GetKeyChordName(key_chord) .. ((bit32.band(key_chord, 8192 --[[ImGuiMod_Shift]]) ~= 0) and "Shift+" or "") .. ((bit32.band(key_chord, 16384 --[[ImGuiMod_Alt]]) ~= 0) and "Alt+" or "") .. ((bit32.band(key_chord, 32768 --[[ImGuiMod_Super]]) ~= 0) and "Super+" or "") - .. ((key ~= 0 --[[ImGuiKey.None]] or key_chord == 0 --[[ImGuiKey.None]]) and ImGui.GetKeyName(key) or "") + .. ((key ~= 0 --[[ImGuiKey.None]] or key_chord == 0 --[[ImGuiKey.None]]) and ImGui_GetKeyName(key) or "") if key == 0 --[[ImGuiKey.None]] and key_chord ~= 0 and #s > 0 then s = string.sub(s, 1, #s - 1) -- Remove trailing '+' end @@ -8941,9 +8955,9 @@ function ImGui.GetKeyName(key) if key == 0 --[[ImGuiKey.None]] then return "None" end - assert(ImGui.IsNamedKeyOrMod(key), "Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code.") + assert(ImGui_IsNamedKeyOrMod(key), "Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code.") if bit32.band(key, 61440 --[[ImGuiMod_Mask_]]) ~= 0 then - key = ImGui.ConvertSingleModFlagToKey(key) + key = ImGui_ConvertSingleModFlagToKey(key) end if not ImGui.IsNamedKey(key) then return "Unknown" @@ -8954,7 +8968,7 @@ end --- @param key ImGuiKey --- @return ImGuiID function ImGui.GetKeyOwner(key) - if not ImGui.IsNamedKeyOrMod(key) then + if not ImGui_IsNamedKeyOrMod(key) then return 4294967295 --[[ImGuiKeyOwner_NoOwner]] end @@ -9025,7 +9039,7 @@ end --- @param repeat_rate float function ImGui.GetKeyPressedAmount(key, repeat_delay, repeat_rate) local g = GImGui - local key_data = ImGui.GetKeyData(g, key) + local key_data = ImGui_GetKeyData(g, key) if not key_data.Down then -- In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitates eating mechanism (until we finish work on key ownership) return 0 end @@ -9105,7 +9119,7 @@ function ImGui.GetShortcutRoutingData(key_chord) local key = bit32.band(key_chord, bit32.bnot(61440 --[[ImGuiMod_Mask_]])) local mods = bit32.band(key_chord, 61440 --[[ImGuiMod_Mask_]]) if key == 0 --[[ImGuiKey.None]] then - key = ImGui.ConvertSingleModFlagToKey(mods) + key = ImGui_ConvertSingleModFlagToKey(mods) end assert(ImGui.IsNamedKey(key)) @@ -9282,7 +9296,7 @@ function ImGui.SetShortcutRouting(key_chord, flags, owner_id) if bit32.band(flags, 32768 --[[ImGuiInputFlags.RouteOverActive]]) == 0 and g.ActiveIdUsingAllKeyboardKeys then local key = bit32.band(key_chord, bit32.bnot(61440 --[[ImGuiMod_Mask_]])) if key == 0 --[[ImGuiKey.None]] then - key = ImGui.ConvertSingleModFlagToKey(bit32.band(key_chord, 61440 --[[ImGuiMod_Mask_]])) + key = ImGui_ConvertSingleModFlagToKey(bit32.band(key_chord, 61440 --[[ImGuiMod_Mask_]])) end if key >= 512 --[[ImGuiKey_Keyboard_BEGIN]] and key < 632 --[[ImGuiKey_Keyboard_END]] then return false @@ -9358,7 +9372,7 @@ function ImGui.IsMouseDown(button, owner_id) local g = GImGui assert(button >= 0 and button < 5 --[[ImGuiMouseButton.COUNT]]) -- IM_COUNTOF(g.IO.MouseDown) - return g.IO.MouseDown[button] and ImGui.TestKeyOwner(ImGui.MouseButtonToKey(button), owner_id) -- Should be same as IsKeyDown(MouseButtonToKey(button), owner_id), but this allows legacy code hijacking the io.Mousedown[] array. + return g.IO.MouseDown[button] and ImGui_TestKeyOwner(ImGui_MouseButtonToKey(button), owner_id) -- Should be same as IsKeyDown(MouseButtonToKey(button), owner_id), but this allows legacy code hijacking the io.Mousedown[] array. end --- @param button ImGuiMouseButton @@ -9395,7 +9409,7 @@ function ImGui.IsMouseClickedEx(button, flags, owner_id) return false end - if not ImGui.TestKeyOwner(ImGui.MouseButtonToKey(button), owner_id) then + if not ImGui_TestKeyOwner(ImGui_MouseButtonToKey(button), owner_id) then return false end @@ -9409,7 +9423,7 @@ function ImGui.IsMouseReleased(button, owner_id) local g = GImGui assert(button >= 0 and button < 5 --[[ImGuiMouseButton.COUNT]]) -- IM_COUNTOF(g.IO.MouseDown) - return g.IO.MouseReleased[button] and ImGui.TestKeyOwner(ImGui.MouseButtonToKey(button), owner_id) -- Should be same as IsKeyReleased(MouseButtonToKey(button), owner_id) + return g.IO.MouseReleased[button] and ImGui_TestKeyOwner(ImGui_MouseButtonToKey(button), owner_id) -- Should be same as IsKeyReleased(MouseButtonToKey(button), owner_id) end -- Prefer higher-level helper GetItemClickedCountWithSingleClickDelay() @@ -9438,7 +9452,7 @@ function ImGui.IsMouseDoubleClicked(button, owner_id) if owner_id == nil then owner_id = 0 --[[ImGuiKeyOwner_Any]] end local g = GImGui assert(button >= 0 and button < 5 --[[ImGuiMouseButton.COUNT]]) -- IM_COUNTOF(g.IO.MouseDown) - return g.IO.MouseClickedCount[button] == 2 and ImGui.TestKeyOwner(ImGui.MouseButtonToKey(button), owner_id) + return g.IO.MouseClickedCount[button] == 2 and ImGui_TestKeyOwner(ImGui_MouseButtonToKey(button), owner_id) end --- @param button ImGuiMouseButton @@ -9456,12 +9470,12 @@ local function LastItemOverlayButtonForNullId(mouse_button) local window = g.CurrentWindow local id = window:GetIDFromRectangle(g.LastItemData.Rect) if g.IO.MouseClicked[mouse_button] and ImGui.ItemHoverable(g.LastItemData.Rect, id, g.LastItemData.ItemFlags) then - ImGui.SetActiveID(id, window) - ImGui.FocusWindow(window) + ImGui_SetActiveID(id, window) + ImGui_FocusWindow(window) elseif g.ActiveId == id then - ImGui.KeepAliveID(id) + ImGui_KeepAliveID(id) if not g.IO.MouseDown[mouse_button] then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end end return id @@ -9541,7 +9555,7 @@ function ImGui.GetMouseDragDelta(button, lock_threshold) end if g.IO.MouseDown[button] or g.IO.MouseReleased[button] then if g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold then - if ImGui.IsMousePosValid(g.IO.MousePos) and ImGui.IsMousePosValid(g.IO.MouseClickedPos[button]) then + if ImGui_IsMousePosValid(g.IO.MousePos) and ImGui_IsMousePosValid(g.IO.MouseClickedPos[button]) then return g.IO.MousePos - g.IO.MouseClickedPos[button] end end @@ -9586,7 +9600,7 @@ local function DebugPrintInputEvent(prefix, e) if e.Type == T.MouseButton then IMGUI_DEBUG_LOG_IO("[io] %s: MouseButton %d %s (%s)\n", prefix, e.MouseButton.Button, e.MouseButton.Down and "Down" or "Up", GetMouseSourceName(e.MouseButton.MouseSource)) return end if e.Type == T.MouseWheel then IMGUI_DEBUG_LOG_IO("[io] %s: MouseWheel (%.3f, %.3f) (%s)\n", prefix, e.MouseWheel.WheelX, e.MouseWheel.WheelY, GetMouseSourceName(e.MouseWheel.MouseSource)) return end if e.Type == T.MouseViewport then IMGUI_DEBUG_LOG_IO("[io] %s: MouseViewport (0x%08X)\n", prefix, e.MouseViewport.HoveredViewportID) return end - if e.Type == T.Key then IMGUI_DEBUG_LOG_IO("[io] %s: Key \"%s\" %s\n", prefix, ImGui.GetKeyName(e.Key.Key), e.Key.Down and "Down" or "Up") return end + if e.Type == T.Key then IMGUI_DEBUG_LOG_IO("[io] %s: Key \"%s\" %s\n", prefix, ImGui_GetKeyName(e.Key.Key), e.Key.Down and "Down" or "Up") return end if e.Type == T.Text then IMGUI_DEBUG_LOG_IO("[io] %s: Text: '%s' (U+%08X)\n", prefix, utf8.char(e.Text.Char), e.Text.Char) return end -- [Luau] utf8.char() instead of ImTextCharToUtf8() if e.Type == T.Focus then IMGUI_DEBUG_LOG_IO("[io] %s: AppFocused %d\n", prefix, e.AppFocused.Focused and 1 or 0) return end end @@ -9671,7 +9685,7 @@ function ImGui.UpdateInputEvents(trickle_fast_inputs) assert(key ~= 0 --[[ImGuiKey.None]]) -- [Port] TODO: Also gets 0-based index here, consider making key_data storage 1-based - local key_data, key_data_index = ImGui.GetKeyData(g, key) + local key_data, key_data_index = ImGui_GetKeyData(g, key) if trickle_fast_inputs and key_data.Down ~= e.Key.Down and (key_changed_mask:TestBit(key_data_index + 1) or mouse_button_changed ~= 0) then stop_3231 = true; break @@ -9773,7 +9787,7 @@ function ImGui.SetKeyOwner(key, owner_id, flags) if flags == nil then flags = 0 end local g = GImGui --- @cast g ImGuiContext - assert(ImGui.IsNamedKeyOrMod(key) and (owner_id ~= 0 --[[ImGuiKeyOwner_Any]] or (bit32.band(flags, bit32.bor(1048576 --[[ImGuiInputFlags.LockThisFrame]], 2097152 --[[ImGuiInputFlags.LockUntilRelease]])) ~= 0)), "Can only use _Any with _LockXXX flags (to eat a key away without an ID to retrieve it)") + assert(ImGui_IsNamedKeyOrMod(key) and (owner_id ~= 0 --[[ImGuiKeyOwner_Any]] or (bit32.band(flags, bit32.bor(1048576 --[[ImGuiInputFlags.LockThisFrame]], 2097152 --[[ImGuiInputFlags.LockUntilRelease]])) ~= 0)), "Can only use _Any with _LockXXX flags (to eat a key away without an ID to retrieve it)") assert(bit32.band(flags, bit32.bnot(3145728 --[[ImGuiInputFlags.SupportedBySetKeyOwner]])) == 0, "Passing flags not supported by this function!") -- IMGUI_DEBUG_LOG("SetKeyOwner(%s, owner_id=0x%08X, flags=%08X)\n", GetKeyName(key), owner_id, flags) @@ -9795,19 +9809,19 @@ function ImGui.SetKeyOwnersForKeyChord(key_chord, owner_id, flags) if flags == nil then flags = 0 end if bit32.band(key_chord, 4096 --[[ImGuiMod_Ctrl]]) ~= 0 then - ImGui.SetKeyOwner(4096 --[[ImGuiMod_Ctrl]], owner_id, flags) + ImGui_SetKeyOwner(4096 --[[ImGuiMod_Ctrl]], owner_id, flags) end if bit32.band(key_chord, 8192 --[[ImGuiMod_Shift]]) ~= 0 then - ImGui.SetKeyOwner(8192 --[[ImGuiMod_Shift]], owner_id, flags) + ImGui_SetKeyOwner(8192 --[[ImGuiMod_Shift]], owner_id, flags) end if bit32.band(key_chord, 16384 --[[ImGuiMod_Alt]]) ~= 0 then - ImGui.SetKeyOwner(16384 --[[ImGuiMod_Alt]], owner_id, flags) + ImGui_SetKeyOwner(16384 --[[ImGuiMod_Alt]], owner_id, flags) end if bit32.band(key_chord, 32768 --[[ImGuiMod_Super]]) ~= 0 then - ImGui.SetKeyOwner(32768 --[[ImGuiMod_Super]], owner_id, flags) + ImGui_SetKeyOwner(32768 --[[ImGuiMod_Super]], owner_id, flags) end if bit32.band(key_chord, bit32.bnot(61440 --[[ImGuiMod_Mask_]])) ~= 0 then - ImGui.SetKeyOwner(bit32.band(key_chord, bit32.bnot(61440 --[[ImGuiMod_Mask_]])), owner_id, flags) + ImGui_SetKeyOwner(bit32.band(key_chord, bit32.bnot(61440 --[[ImGuiMod_Mask_]])), owner_id, flags) end end @@ -9832,10 +9846,10 @@ function ImGui.SetItemKeyOwner(key, flags) end if (g.HoveredId == id and bit32.band(flags, 4194304 --[[ImGuiInputFlags.CondHovered]]) ~= 0) or (g.ActiveId == id and bit32.band(flags, 8388608 --[[ImGuiInputFlags.CondActive]]) ~= 0) then assert(bit32.band(flags, bit32.bnot(15728640 --[[ImGuiInputFlags.SupportedBySetItemKeyOwner]])) == 0) -- Passing flags not supported by this function! - if not ImGui.TestKeyOwner(key, id) then + if not ImGui_TestKeyOwner(key, id) then return false end - ImGui.SetKeyOwner(key, id, bit32.band(flags, bit32.bnot(12582912 --[[ImGuiInputFlags.CondMask_]]))) + ImGui_SetKeyOwner(key, id, bit32.band(flags, bit32.bnot(12582912 --[[ImGuiInputFlags.CondMask_]]))) return true end return false @@ -9859,9 +9873,9 @@ function ImGui.IsKeyChordPressed(key_chord, flags, owner_id) -- Special storage location for mods local key = bit32.band(key_chord, bit32.bnot(61440 --[[ImGuiMod_Mask_]])) if key == 0 --[[ImGuiKey.None]] then - key = ImGui.ConvertSingleModFlagToKey(mods) + key = ImGui_ConvertSingleModFlagToKey(mods) end - if not ImGui.IsKeyPressedEx(key, bit32.band(flags, 255 --[[ImGuiInputFlags.RepeatMask_]]), owner_id) then + if not ImGui_IsKeyPressedEx(key, bit32.band(flags, 255 --[[ImGuiInputFlags.RepeatMask_]]), owner_id) then return false end return true @@ -10012,7 +10026,10 @@ local function CalcWindowSizeAfterConstraint(window, size_desired) -- Minimum size local size_min = CalcWindowMinSize(window) - return ImMax(new_size, size_min) + -- [Luau] ImMax(new_size, size_min) written into new_size (a local copy) + new_size.x = math.max(new_size.x, size_min.x) + new_size.y = math.max(new_size.y, size_min.y) + return new_size end --- @param window ImGuiWindow @@ -10058,7 +10075,7 @@ local function CalcWindowAutoFitSize(window, size_contents, axis_mask) local size_max = ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]) if bit32.band(window.Flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) == 0 or bit32.band(window.Flags, 67108864 --[[ImGuiWindowFlags.Popup]]) ~= 0 then if not window.ViewportOwned then - size_max = ImGui.GetMainViewport().WorkSize - style.DisplaySafeAreaPadding * 2.0 + size_max = ImGui_GetMainViewport().WorkSize - style.DisplaySafeAreaPadding * 2.0 end local monitor_idx = window.ViewportAllowPlatformMonitorExtend if monitor_idx >= 1 and monitor_idx <= g.PlatformIO.Monitors.Size then @@ -10206,7 +10223,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c local grip_hover_inner_size = (resize_grip_count > 0) and IM_TRUNC(grip_draw_size * 0.75) or 0.0 local grip_hover_outer_size = g.WindowsBorderHoverPadding + 1 - ImGui.PushID("#RESIZE") + ImGui_PushID("#RESIZE") local pos_target = ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]) local size_target = ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]) @@ -10219,7 +10236,9 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c -- We only clip interaction so we overwrite window.ClipRect, cannot call PushClipRect() yet as DrawList is not yet setup. local clip_with_viewport_rect = bit32.band(g.IO.BackendFlags, 4096 --[[ImGuiBackendFlags.HasMouseHoveredViewport]]) == 0 or g.IO.MouseHoveredViewport ~= window.ViewportId or bit32.band(window.Viewport.Flags, 8 --[[ImGuiViewportFlags.NoDecoration]]) == 0 if (clip_with_viewport_rect) then - ImRect_Copy(window.ClipRect, window.Viewport:GetMainRect()) + -- [Luau] ImRect_Copy(window.ClipRect, window.Viewport:GetMainRect()) without the temporary ImRect + local vp, cr = window.Viewport, window.ClipRect + cr.Min.x = vp.Pos.x; cr.Min.y = vp.Pos.y; cr.Max.x = vp.Pos.x + vp.Size.x; cr.Max.y = vp.Pos.y + vp.Size.y end local clamp_rect = ImRect() @@ -10248,7 +10267,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c local resize_grip_id = window:GetID(resize_grip_n) -- == GetWindowResizeCornerID() ImGui.ItemAdd(resize_rect, resize_grip_id, nil, 2 --[[ImGuiItemFlags.NoNav]]) - local _, hovered, held = ImGui.ButtonBehavior(resize_rect, resize_grip_id, bit32.bor(2048 --[[ImGuiButtonFlags.FlattenChildren]], 262144 --[[ImGuiButtonFlags.NoNavFocus]])) + local _, hovered, held = ImGui_ButtonBehavior(resize_rect, resize_grip_id, bit32.bor(2048 --[[ImGuiButtonFlags.FlattenChildren]], 262144 --[[ImGuiButtonFlags.NoNavFocus]])) -- GetForegroundDrawList(window):AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255)) if hovered or held then @@ -10260,7 +10279,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c local size_auto_fit = CalcWindowAutoFitSize(window, window.ContentSizeIdeal, -1) size_target = CalcWindowSizeAfterConstraint(window, size_auto_fit) ret_auto_fit_mask = 0x03 -- Both axes - ImGui.ClearActiveID() + ImGui_ClearActiveID() elseif held then -- 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 @@ -10278,12 +10297,12 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c if resize_grip_visible then local color if held then - color = ImGui.GetColorU32(33 --[[ImGuiCol.ResizeGripActive]]) + color = ImGui_GetColorU32(33 --[[ImGuiCol.ResizeGripActive]]) else if hovered then - color = ImGui.GetColorU32(32 --[[ImGuiCol.ResizeGripHovered]]) + color = ImGui_GetColorU32(32 --[[ImGuiCol.ResizeGripHovered]]) else - color = ImGui.GetColorU32(31 --[[ImGuiCol.ResizeGrip]]) + color = ImGui_GetColorU32(31 --[[ImGuiCol.ResizeGrip]]) end end resize_grip_col[resize_grip_n + 1] = color @@ -10316,7 +10335,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c local border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, g.WindowsBorderHoverPadding, UpdateWindowManualResize_rect) local border_id = window:GetID(border_n + 4) -- == GetWindowResizeBorderID() ImGui.ItemAdd(border_rect, border_id, nil, 2 --[[ImGuiItemFlags.NoNav]]) - local _, hovered, held = ImGui.ButtonBehavior(border_rect, border_id, bit32.bor(2048 --[[ImGuiButtonFlags.FlattenChildren]], 262144 --[[ImGuiButtonFlags.NoNavFocus]])) + local _, hovered, held = ImGui_ButtonBehavior(border_rect, border_id, bit32.bor(2048 --[[ImGuiButtonFlags.FlattenChildren]], 262144 --[[ImGuiButtonFlags.NoNavFocus]])) -- GetForegroundDrawList(window):AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255)) if hovered and g.HoveredIdTimer <= WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER then @@ -10335,12 +10354,12 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c hovered = false held = false -- So border doesn't show highlighted at new position end - ImGui.ClearActiveID() + ImGui_ClearActiveID() elseif held then -- Switch to relative resizing mode when border geometry moved (e.g. resizing a child altering parent scroll), in order to avoid resizing feedback loop. -- Currently only using relative mode on resizable child windows, as the problem to solve is more likely noticeable for them, but could apply for all windows eventually. -- FIXME: May want to generalize this idiom at lower-level, so more widgets can use it! - local just_scrolled_manually_while_resizing = (g.WheelingWindow ~= nil and g.WheelingWindowScrolledFrame == g.FrameCount and ImGui.IsWindowChildOf(window, g.WheelingWindow, false, true)) + local just_scrolled_manually_while_resizing = (g.WheelingWindow ~= nil and g.WheelingWindowScrolledFrame == g.FrameCount and ImGui_IsWindowChildOf(window, g.WheelingWindow, false, true)) if g.ActiveIdIsJustActivated or just_scrolled_manually_while_resizing then g.WindowResizeBorderExpectedRect = ImRect(border_rect.Min, border_rect.Max) -- [Luau] copy: border_rect is scratch g.WindowResizeRelativeMode = false @@ -10389,7 +10408,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c until true end - ImGui.PopID() + ImGui_PopID() -- Restore nav layer window.DC.NavLayerCurrent = 0 --[[ImGuiNavLayer.Main]] @@ -10494,7 +10513,7 @@ function ImGui.RenderText(pos, text, text_begin, text_end, hide_text_after_hash) -- Hide anything after a '##' string local text_display_end if hide_text_after_hash then - text_display_end = ImGui.FindRenderedTextEnd(text, text_end) + text_display_end = ImGui_FindRenderedTextEnd(text, text_end) else if text_end == nil then text_end = #text + 1 -- FIXME-OPT (not reached by our internal calls) @@ -10503,9 +10522,9 @@ function ImGui.RenderText(pos, text, text_begin, text_end, hide_text_after_hash) end if text ~= "" and text_display_end > 1 then - window.DrawList:AddText(g.Font, g.FontSize, pos, ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), text, text_begin, text_display_end, 0.0) + window.DrawList:AddText(g.Font, g.FontSize, pos, ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), text, text_begin, text_display_end, 0.0) if g.LogEnabled then - ImGui.LogRenderedText(pos, text, text_display_end, text_begin) + ImGui_LogRenderedText(pos, text, text_display_end, text_begin) end end end @@ -10524,9 +10543,9 @@ function ImGui.RenderTextWrapped(pos, text, text_end, wrap_width) end if text ~= "" then - window.DrawList:AddText(g.Font, g.FontSize, pos, ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), text, 1, text_end, wrap_width) + window.DrawList:AddText(g.Font, g.FontSize, pos, ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), text, 1, text_end, wrap_width) if g.LogEnabled then - ImGui.LogRenderedText(pos, text, text_end) + ImGui_LogRenderedText(pos, text, text_end) end end end @@ -10562,7 +10581,7 @@ function ImGui.RenderTextClippedEx(draw_list, pos_min, pos_max, text, text_begin if text_size_if_known then text_size_x, text_size_y = text_size_if_known.x, text_size_if_known.y else - text_size_x, text_size_y = ImGui.CalcTextSizeXY(text, 1, text_display_end, false, 0.0) + text_size_x, text_size_y = ImGui_CalcTextSizeXY(text, 1, text_display_end, false, 0.0) end local clip_min = clip_rect and clip_rect.Min or pos_min @@ -10580,9 +10599,9 @@ function ImGui.RenderTextClippedEx(draw_list, pos_min, pos_max, text, text_begin if (need_clipping) then local fine_clip_rect = RenderTextClippedEx_fine_clip fine_clip_rect.x = clip_min.x; fine_clip_rect.y = clip_min.y; fine_clip_rect.z = clip_max.x; fine_clip_rect.w = clip_max.y - draw_list:AddText(nil, 0.0, pos, ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), text, text_begin, text_display_end, 0.0, fine_clip_rect) + draw_list:AddText(nil, 0.0, pos, ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), text, text_begin, text_display_end, 0.0, fine_clip_rect) else - draw_list:AddText(nil, 0.0, pos, ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), text, text_begin, text_display_end, 0.0, nil) + draw_list:AddText(nil, 0.0, pos, ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), text, text_begin, text_display_end, 0.0, nil) end end @@ -10598,7 +10617,7 @@ function ImGui.RenderTextClipped(pos_min, pos_max, text, text_end, text_size_if_ if not align then align = RenderTextClipped_align0 end -- Hide anything after a '##' string - local text_display_end = ImGui.FindRenderedTextEnd(text, text_end) + local text_display_end = ImGui_FindRenderedTextEnd(text, text_end) local text_len = text_display_end - 1 if text_len == 0 then @@ -10609,7 +10628,7 @@ function ImGui.RenderTextClipped(pos_min, pos_max, text, text_end, text_size_if_ local window = g.CurrentWindow ImGui.RenderTextClippedEx(window.DrawList, pos_min, pos_max, text, 1, text_display_end, text_size_if_known, align, clip_rect) if g.LogEnabled then - ImGui.LogRenderedText(pos_min, text, text_display_end) + ImGui_LogRenderedText(pos_min, text, text_display_end) end end @@ -10650,7 +10669,7 @@ function ImGui.RenderNavCursor(bb, id, flags, rounding) local scale_factor = ImGui.GetScale() -- FIXME-DPI local thickness = ImTrunc(ImMax(2.0, 1.5 * scale_factor)) if bit32.band(flags, 2 --[[ImGuiNavRenderCursorFlags.Compact]]) ~= 0 then - window.DrawList:AddRect(display_rect.Min, display_rect.Max, ImGui.GetColorU32(59 --[[ImGuiCol.NavCursor]]), rounding, thickness) + window.DrawList:AddRect(display_rect.Min, display_rect.Max, ImGui_GetColorU32(59 --[[ImGuiCol.NavCursor]]), rounding, thickness) else local distance = ImTrunc(3.0 + thickness * 0.5) display_rect:Expand(ImVec2(distance, distance)) @@ -10658,7 +10677,7 @@ function ImGui.RenderNavCursor(bb, id, flags, rounding) if not fully_visible then window.DrawList:PushClipRect(display_rect.Min, display_rect.Max) end - window.DrawList:AddRect(display_rect.Min, display_rect.Max, ImGui.GetColorU32(59 --[[ImGuiCol.NavCursor]]), rounding, thickness) + window.DrawList:AddRect(display_rect.Min, display_rect.Max, ImGui_GetColorU32(59 --[[ImGuiCol.NavCursor]]), rounding, thickness) if not fully_visible then window.DrawList:PopClipRect() end @@ -10698,7 +10717,7 @@ function ImGui.RenderMouseCursor(base_pos, base_scale, mouse_cursor, col_fill, c break end - local draw_list = ImGui.GetForegroundDrawList(viewport) + local draw_list = ImGui_GetForegroundDrawList(viewport) local tex_ref = font_atlas.TexRef draw_list:PushTexture(tex_ref); draw_list:AddImage(tex_ref, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv_fill[1], uv_fill[2], col_shadow) @@ -10734,7 +10753,7 @@ function ImGui.RenderTextEllipsis(draw_list, pos_min, pos_max, ellipsis_max_x, t local g = GImGui if text_end_full == nil then - text_end_full = ImGui.FindRenderedTextEnd(text) + text_end_full = ImGui_FindRenderedTextEnd(text) end local text_size @@ -10742,7 +10761,7 @@ function ImGui.RenderTextEllipsis(draw_list, pos_min, pos_max, ellipsis_max_x, t text_size = ImVec2() ImVec2_Copy(text_size, text_size_if_known) else - text_size = ImGui.CalcTextSize(text, text_end_full, false, 0.0) + text_size = ImGui_CalcTextSize(text, text_end_full, false, 0.0) end -- draw_list:AddLineV(pos_max.x, pos_min.y - 4, pos_max.y + 6, IM_COL32(0, 0, 255, 255)) @@ -10772,13 +10791,13 @@ function ImGui.RenderTextEllipsis(draw_list, pos_min, pos_max, ellipsis_max_x, t ImGui.RenderTextClippedEx(draw_list, pos_min, pos_max, text, 1, text_end_ellipsis, text_size, ImVec2(0.0, 0.0)) local cpu_fine_clip_rect = ImVec4(pos_min.x, pos_min.y, pos_max.x, pos_max.y) local ellipsis_pos = ImTrunc(ImVec2(pos_min.x + text_size_clipped_x, pos_min.y)) - font:RenderChar(draw_list, font_size, ellipsis_pos, ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), font.EllipsisChar, cpu_fine_clip_rect) + font:RenderChar(draw_list, font_size, ellipsis_pos, ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), font.EllipsisChar, cpu_fine_clip_rect) else ImGui.RenderTextClippedEx(draw_list, pos_min, pos_max, text, 1, text_end_full, text_size, ImVec2(0.0, 0.0)) end if g.LogEnabled then - ImGui.LogRenderedText(pos_min, text, text_end_full) + ImGui_LogRenderedText(pos_min, text, text_end_full) end end @@ -10800,8 +10819,8 @@ function ImGui.RenderFrame(p_min, p_max, fill_col, borders, rounding) local border_size = g.Style.FrameBorderSize if borders and border_size > 0 then - window.DrawList:AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), ImGui.GetColorU32(6 --[[ImGuiCol.BorderShadow]]), rounding, border_size, 0) - window.DrawList:AddRect(p_min, p_max, ImGui.GetColorU32(5 --[[ImGuiCol.Border]]), rounding, border_size, 0) + window.DrawList:AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), ImGui_GetColorU32(6 --[[ImGuiCol.BorderShadow]]), rounding, border_size, 0) + window.DrawList:AddRect(p_min, p_max, ImGui_GetColorU32(5 --[[ImGuiCol.Border]]), rounding, border_size, 0) end end @@ -10814,8 +10833,8 @@ function ImGui.RenderFrameBorder(p_min, p_max, rounding) local window = g.CurrentWindow local border_size = g.Style.FrameBorderSize if border_size > 0.0 then - window.DrawList:AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), ImGui.GetColorU32(6 --[[ImGuiCol.BorderShadow]]), rounding, border_size, 0) - window.DrawList:AddRect(p_min, p_max, ImGui.GetColorU32(5 --[[ImGuiCol.Border]]), rounding, border_size, 0) + window.DrawList:AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), ImGui_GetColorU32(6 --[[ImGuiCol.BorderShadow]]), rounding, border_size, 0) + window.DrawList:AddRect(p_min, p_max, ImGui_GetColorU32(5 --[[ImGuiCol.Border]]), rounding, border_size, 0) end end @@ -10841,7 +10860,7 @@ local function ClampWindowPos(window, visibility_rect) local size_for_clamping = ImVec2(window.Size.x, window.Size.y) local move_from_title_bar_only = bit32.band(window.BgClickFlags, 1 --[[ImGuiWindowBgClickFlags.Move]]) == 0 if move_from_title_bar_only and window.DockNodeAsHost then - size_for_clamping.y = ImGui.GetFrameHeight() -- Not using window->TitleBarHeight() as DockNodeAsHost will report 0.0f here. + size_for_clamping.y = ImGui_GetFrameHeight() -- Not using window->TitleBarHeight() as DockNodeAsHost will report 0.0f here. elseif move_from_title_bar_only and bit32.band(window.Flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) == 0 then size_for_clamping.y = window.TitleBarHeight end @@ -10862,7 +10881,7 @@ end local function RenderWindowOuterBorders(window) local g = GImGui local border_size = window.WindowBorderSize - local border_col = ImGui.GetColorU32(5 --[[ImGuiCol.Border]]) + local border_col = ImGui_GetColorU32(5 --[[ImGuiCol.Border]]) if border_size > 0.0 and (bit32.band(window.Flags, 128 --[[ImGuiWindowFlags.NoBackground]]) == 0) then window.DrawList:AddRect(window.Pos, window.Pos + window.Size, border_col, window.WindowRounding, window.WindowBorderSize, 0) elseif border_size > 0.0 then @@ -10876,7 +10895,7 @@ local function RenderWindowOuterBorders(window) if window.ResizeBorderHovered ~= -1 or window.ResizeBorderHeld ~= -1 then local border_n = (window.ResizeBorderHeld ~= -1) and window.ResizeBorderHeld or window.ResizeBorderHovered - local border_col_resizing = ImGui.GetColorU32((window.ResizeBorderHeld ~= -1) and 30 --[[ImGuiCol.SeparatorActive]] or 29 --[[ImGuiCol.SeparatorHovered]]) + local border_col_resizing = ImGui_GetColorU32((window.ResizeBorderHeld ~= -1) and 30 --[[ImGuiCol.SeparatorActive]] or 29 --[[ImGuiCol.SeparatorHovered]]) RenderWindowOuterSingleBorder(window, border_n, border_col_resizing, ImMax(2.0, window.WindowBorderSize)) -- Thicker than usual end @@ -10912,13 +10931,13 @@ local function RenderWindowDecorations(window, title_bar_rect, title_bar_is_high local backup_border_size = style.FrameBorderSize g.Style.FrameBorderSize = window.WindowBorderSize - local title_bar_col = ImGui.GetColorU32((title_bar_is_highlight and g.NavCursorVisible) and 11 --[[ImGuiCol.TitleBgActive]] or 12 --[[ImGuiCol.TitleBgCollapsed]]) + local title_bar_col = ImGui_GetColorU32((title_bar_is_highlight and g.NavCursorVisible) and 11 --[[ImGuiCol.TitleBgActive]] or 12 --[[ImGuiCol.TitleBgCollapsed]]) ImGui.RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding) g.Style.FrameBorderSize = backup_border_size else -- Window background if bit32.band(flags, 128 --[[ImGuiWindowFlags.NoBackground]]) == 0 then - local bg_col = ImGui.GetColorU32(GetWindowBgColorIdx(window)) + local bg_col = ImGui_GetColorU32(GetWindowBgColorIdx(window)) -- Adjust alpha. For docking local override_alpha = false local alpha = 1.0 @@ -10941,7 +10960,7 @@ local function RenderWindowDecorations(window, title_bar_rect, title_bar_is_high bg_rect.Min.x, bg_rect.Min.y, bg_rect.Max.x, bg_rect.Max.y = window.Pos.x + 0, window.Pos.y + window.TitleBarHeight, window.Pos.x + window.Size.x, window.Pos.y + window.Size.y local bg_rounding_flags if window.DockIsActive then - bg_rounding_flags = ImGui.CalcRoundingFlagsForRectInRect(bg_rect, window.DockNode.HostWindow:Rect(), 0.0) + bg_rounding_flags = ImGui_CalcRoundingFlagsForRectInRect(bg_rect, window.DockNode.HostWindow:Rect(), 0.0) else bg_rounding_flags = (bit32.band(flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) ~= 0) and 240 --[[ImDrawFlags.RoundAll]] or 192 --[[ImDrawFlags.RoundBottom]] end @@ -10957,7 +10976,7 @@ local function RenderWindowDecorations(window, title_bar_rect, title_bar_is_high -- (when docked, DockNode are drawing their own title bar. Individual windows however do NOT set the _NoTitleBar flag, -- in order for their pos/size to be matching their undocking state.) if bit32.band(flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) == 0 and not window.DockIsActive then - local title_bar_col = ImGui.GetColorU32(title_bar_is_highlight and 11 --[[ImGuiCol.TitleBgActive]] or 10 --[[ImGuiCol.TitleBg]]) + local title_bar_col = ImGui_GetColorU32(title_bar_is_highlight and 11 --[[ImGuiCol.TitleBgActive]] or 10 --[[ImGuiCol.TitleBg]]) window.DrawList:AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, 48 --[[ImDrawFlags.RoundTop]]) end @@ -10965,9 +10984,9 @@ local function RenderWindowDecorations(window, title_bar_rect, title_bar_is_high if bit32.band(flags, 1024 --[[ImGuiWindowFlags.MenuBar]]) ~= 0 then local menu_bar_rect = window:MenuBarRect() menu_bar_rect:ClipWith(window:Rect()) -- Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them. - window.DrawList:AddRectFilled(menu_bar_rect.Min, menu_bar_rect.Max, ImGui.GetColorU32(13 --[[ImGuiCol.MenuBarBg]]), (bit32.band(flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) ~= 0) and window_rounding or 0.0, 48 --[[ImDrawFlags.RoundTop]]) + window.DrawList:AddRectFilled(menu_bar_rect.Min, menu_bar_rect.Max, ImGui_GetColorU32(13 --[[ImGuiCol.MenuBarBg]]), (bit32.band(flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) ~= 0) and window_rounding or 0.0, 48 --[[ImDrawFlags.RoundTop]]) if style.FrameBorderSize > 0.0 and menu_bar_rect.Max.y < window.Pos.y + window.Size.y then - window.DrawList:AddLineH(menu_bar_rect.Min.x + window_border_size, menu_bar_rect.Max.x - window_border_size, menu_bar_rect.Max.y, ImGui.GetColorU32(5 --[[ImGuiCol.Border]]), style.FrameBorderSize, 393216 --[[ImDrawFlags.StrokeCenterBiased]]) + window.DrawList:AddLineH(menu_bar_rect.Min.x + window_border_size, menu_bar_rect.Max.x - window_border_size, menu_bar_rect.Max.y, ImGui_GetColorU32(5 --[[ImGuiCol.Border]]), style.FrameBorderSize, 393216 --[[ImDrawFlags.StrokeCenterBiased]]) end end @@ -10979,8 +10998,8 @@ local function RenderWindowDecorations(window, title_bar_rect, title_bar_is_high local p = node.Pos local r = ImRect(p, p + ImVec2(unhide_sz_hit, unhide_sz_hit)) local unhide_id = window:GetID("#UNHIDE") - ImGui.KeepAliveID(unhide_id) - local pressed, hovered, held = ImGui.ButtonBehavior(r, unhide_id, 2048 --[[ImGuiButtonFlags.FlattenChildren]]) + ImGui_KeepAliveID(unhide_id) + local pressed, hovered, held = ImGui_ButtonBehavior(r, unhide_id, 2048 --[[ImGuiButtonFlags.FlattenChildren]]) if pressed then node.WantHiddenTabBarToggle = true elseif held and ImGui.IsMouseDragging(0) then @@ -10988,7 +11007,7 @@ local function RenderWindowDecorations(window, title_bar_rect, title_bar_is_high end -- FIXME-DOCK: Ideally we'd use ImGuiCol.TitleBgActive/ImGuiCol.TitleBg here, but neither is guaranteed to be visible enough at this sort of size.. - local col = ImGui.GetColorU32(((held and hovered) or (node.IsFocused and not hovered)) and 24 --[[ImGuiCol.ButtonActive]] or (hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]])) + local col = ImGui_GetColorU32(((held and hovered) or (node.IsFocused and not hovered)) and 24 --[[ImGuiCol.ButtonActive]] or (hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]])) window.DrawList:AddTriangleFilled(p, p + ImVec2(unhide_sz_draw, 0.0), p + ImVec2(0.0, unhide_sz_draw), col) end @@ -11107,7 +11126,7 @@ local function RenderWindowTitleBarContents(window, title_bar_rect, name, open) -- FIXME: Refactor text alignment facilities along with RenderText helpers, this is WAY too much messy code.. local marker_size_x = (bit32.band(flags, 262144 --[[ImGuiWindowFlags.UnsavedDocument]]) ~= 0) and (button_sz * 0.80) or 0.0 local text_size = WindowDecoScratch.text_size -- [Luau] scratch: only read below (RenderTextClipped text_size_if_known) - local text_size_x, text_size_y = ImGui.CalcTextSizeXY(name, 1, nil, true) + local text_size_x, text_size_y = ImGui_CalcTextSizeXY(name, 1, nil, true) text_size.x = text_size_x + marker_size_x; text_size.y = text_size_y + 0.0 -- As a nice touch we try to ensure that centered title text doesn't get affected by visibility of Close/Collapse button, @@ -11134,7 +11153,7 @@ local function RenderWindowTitleBarContents(window, title_bar_rect, name, open) marker_pos.x = ImClamp(layout_r.Min.x + (layout_r:GetWidth() - text_size.x) * style.WindowTitleAlign.x + text_size.x, layout_r.Min.x, layout_r.Max.x) marker_pos.y = (layout_r.Min.y + layout_r.Max.y) * 0.5 if marker_pos.x > layout_r.Min.x then - ImGui.RenderBullet(window.DrawList, marker_pos, ImGui.GetColorU32(58 --[[ImGuiCol.UnsavedMarker]])) + ImGui.RenderBullet(window.DrawList, marker_pos, ImGui_GetColorU32(58 --[[ImGuiCol.UnsavedMarker]])) clip_r.Max.x = ImMin(clip_r.Max.x, marker_pos.x - math.floor(marker_size_x * 0.5)) end end @@ -11189,7 +11208,7 @@ function ImGui.UpdateWindowSkipRefresh(window) if bit32.band(g.NextWindowData.RefreshFlagsVal, 1 --[[ImGuiWindowRefreshFlags.TryToAvoidRefresh]]) ~= 0 then -- [Port] SetNextWindowCached(): refresh on any change since the last refresh (and one frame after being busy) if g.NextWindowData.CacheKeySet then - local function related(w) return w ~= nil and (w.RootWindow == window.RootWindow or ImGui.IsWindowWithinBeginStackOf(w.RootWindow, window)) end + local function related(w) return w ~= nil and (w.RootWindow == window.RootWindow or ImGui_IsWindowWithinBeginStackOf(w.RootWindow, window)) end local busy = window.Appearing or window.Hidden or window.DockIsActive or related(g.HoveredWindow) or related(g.NavWindow) or related(g.ActiveIdWindow) or (g.MovingWindow ~= nil and related(g.MovingWindow)) local c, key, ds, tex = window.CacheSnap, g.NextWindowData.CacheKeyVal, g.IO.DisplaySize, g.IO.Fonts.TexData if busy or c == nil or c.Busy or c.Key ~= key or c.Tex ~= tex or c.Collapsed ~= window.Collapsed @@ -11215,12 +11234,12 @@ function ImGui.UpdateWindowSkipRefresh(window) return end if bit32.band(g.NextWindowData.RefreshFlagsVal, 2 --[[ImGuiWindowRefreshFlags.RefreshOnHover]]) ~= 0 and g.HoveredWindow then - if window.RootWindow == g.HoveredWindow.RootWindow or ImGui.IsWindowWithinBeginStackOf(g.HoveredWindow.RootWindow, window) then + if window.RootWindow == g.HoveredWindow.RootWindow or ImGui_IsWindowWithinBeginStackOf(g.HoveredWindow.RootWindow, window) then return end end if bit32.band(g.NextWindowData.RefreshFlagsVal, 4 --[[ImGuiWindowRefreshFlags.RefreshOnFocus]]) ~= 0 and g.NavWindow then - if window.RootWindow == g.NavWindow.RootWindow or ImGui.IsWindowWithinBeginStackOf(g.NavWindow.RootWindow, window) then + if window.RootWindow == g.NavWindow.RootWindow or ImGui_IsWindowWithinBeginStackOf(g.NavWindow.RootWindow, window) then return end end @@ -11315,10 +11334,10 @@ end function ImGui.SetWindowPos(window, pos, cond) -- [Port] Overloads: SetWindowPos(pos, cond) / SetWindowPos(name, pos, cond) / SetWindowPos(window, pos, cond) if type(window) == "string" then - window = ImGui.FindWindowByName(window) + window = ImGui_FindWindowByName(window) if window == nil then return end elseif window.SetWindowPosAllowFlags == nil then - window, pos, cond = ImGui.GetCurrentWindowRead(), window, pos + window, pos, cond = ImGui_GetCurrentWindowRead(), window, pos end if cond == nil then cond = 0 end @@ -11343,7 +11362,7 @@ function ImGui.SetWindowPos(window, pos, cond) if offset.x == 0 and offset.y == 0 then return end - ImGui.MarkIniSettingsDirty(window) + ImGui_MarkIniSettingsDirty(window) -- FIXME: share code with TranslateWindow(), need to confirm whether the 3 rect modified by TranslateWindow() are desirable here. ImVec2_Copy(window.DC.CursorPos, window.DC.CursorPos + offset) -- As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor ImVec2_Copy(window.DC.CursorMaxPos, window.DC.CursorMaxPos + offset) -- And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. @@ -11357,7 +11376,7 @@ end function ImGui.SetWindowSize(window, size, cond) -- Overloads: SetWindowSize(size, cond) / SetWindowSize(name, size, cond) / SetWindowSize(window, size, cond) if type(window) == "string" then - window = ImGui.FindWindowByName(window) + window = ImGui_FindWindowByName(window) if window == nil then return end elseif window.SetWindowSizeAllowFlags == nil then window, size, cond = GImGui.CurrentWindow, window, size @@ -11394,14 +11413,14 @@ function ImGui.SetWindowSize(window, size, cond) window.SizeFull.y = IM_TRUNC(size.y) end if old_size_x ~= window.SizeFull.x or old_size_y ~= window.SizeFull.y then - ImGui.MarkIniSettingsDirty(window) + ImGui_MarkIniSettingsDirty(window) end end --- Overloads: SetWindowCollapsed(collapsed, cond) / SetWindowCollapsed(name, collapsed, cond) / SetWindowCollapsed(window, collapsed, cond) function ImGui.SetWindowCollapsed(window, collapsed, cond) if type(window) == "string" then - window = ImGui.FindWindowByName(window) + window = ImGui_FindWindowByName(window) if window == nil then return end elseif type(window) == "boolean" then window, collapsed, cond = GImGui.CurrentWindow, window, collapsed @@ -11430,11 +11449,11 @@ function ImGui.SetWindowHitTestHole(window, pos, size) end function ImGui.IsWindowCollapsed() - return ImGui.GetCurrentWindowRead().Collapsed + return ImGui_GetCurrentWindowRead().Collapsed end function ImGui.IsWindowAppearing() - return ImGui.GetCurrentWindowRead().Appearing + return ImGui_GetCurrentWindowRead().Appearing end function ImGui.GetWindowHeight() @@ -11448,24 +11467,24 @@ end --- @return ImVec2 # Ref, do not modify function ImGui.GetWindowSize() - return ImGui.GetCurrentWindowRead().Size + return ImGui_GetCurrentWindowRead().Size end -- [Port] Overloads: SetWindowFocus() / SetWindowFocus(name). Passing nil name removes focus. --- @param name? string function ImGui.SetWindowFocus(...) if select("#", ...) == 0 then - ImGui.FocusWindow(GImGui.CurrentWindow) + ImGui_FocusWindow(GImGui.CurrentWindow) return end local name = ... if name then - local window = ImGui.FindWindowByName(name) + local window = ImGui_FindWindowByName(name) if window then - ImGui.FocusWindow(window) + ImGui_FocusWindow(window) end else - ImGui.FocusWindow(nil) + ImGui_FocusWindow(nil) end end @@ -11530,7 +11549,7 @@ function ImGui.SetNextWindowBgAlpha(alpha) end function ImGui.GetWindowDrawList() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() return window.DrawList end @@ -11621,10 +11640,10 @@ function ImGui.BeginChildEx(name, id, size_arg, child_flags, window_flags) -- Special framed style if bit32.band(child_flags, 128 --[[ImGuiChildFlags.FrameStyle]]) ~= 0 then - ImGui.PushStyleColor(3 --[[ImGuiCol.ChildBg]], g.Style.Colors[7 --[[ImGuiCol.FrameBg]]]) - ImGui.PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], g.Style.FrameRounding) - ImGui.PushStyleVar(8 --[[ImGuiStyleVar.ChildBorderSize]], g.Style.FrameBorderSize) - ImGui.PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], g.Style.FramePadding) + ImGui_PushStyleColor(3 --[[ImGuiCol.ChildBg]], g.Style.Colors[7 --[[ImGuiCol.FrameBg]]]) + ImGui_PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], g.Style.FrameRounding) + ImGui_PushStyleVar(8 --[[ImGuiStyleVar.ChildBorderSize]], g.Style.FrameBorderSize) + ImGui_PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], g.Style.FramePadding) child_flags = bit32.bor(child_flags, 1 --[[ImGuiChildFlags.Borders]], 2 --[[ImGuiChildFlags.AlwaysUseWindowPadding]]) window_flags = bit32.bor(window_flags, 4 --[[ImGuiWindowFlags.NoMove]]) end @@ -11649,7 +11668,7 @@ function ImGui.BeginChildEx(name, id, size_arg, child_flags, window_flags) child_flags = bit32.band(child_flags, bit32.bnot(8 --[[ImGuiChildFlags.ResizeY]])) end end - ImGui.SetNextWindowSize(size) + ImGui_SetNextWindowSize(size) ImGui.SetNextWindowChildFlags(child_flags, true) -- Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value. @@ -11678,8 +11697,8 @@ function ImGui.BeginChildEx(name, id, size_arg, child_flags, window_flags) g.Style.ChildBorderSize = backup_border_size if bit32.band(child_flags, 128 --[[ImGuiChildFlags.FrameStyle]]) ~= 0 then - ImGui.PopStyleVar(3) - ImGui.PopStyleColor() + ImGui_PopStyleVar(3) + ImGui_PopStyleColor() end local child_window = g.CurrentWindow @@ -11695,12 +11714,12 @@ function ImGui.BeginChildEx(name, id, size_arg, child_flags, window_flags) -- Can enter a child if (A) it has navigable items or (B) it can be scrolled. local temp_id_for_activation = ImHashStr("##Child", nil, id) if g.ActiveId == temp_id_for_activation then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end if g.NavActivateId == id and bit32.band(child_flags, 256 --[[ImGuiChildFlags.NavFlattened]]) == 0 and (child_window.DC.NavLayersActiveMask ~= 0 or child_window.DC.NavWindowHasScrollY) then - ImGui.FocusWindow(child_window) - ImGui.NavInitWindow(child_window, false) - ImGui.SetActiveID(temp_id_for_activation, child_window) -- Steal ActiveId with another arbitrary id so that key-press won't activate child item + ImGui_FocusWindow(child_window) + ImGui_NavInitWindow(child_window, false) + ImGui_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 end @@ -11720,7 +11739,7 @@ function ImGui.BeginChild(str_id_or_id, size_arg, child_flags, window_flags) if type(str_id_or_id) == "number" then return ImGui.BeginChildEx(nil, str_id_or_id, size_arg, child_flags, window_flags) end - local id = ImGui.GetCurrentWindow():GetID(str_id_or_id) + local id = ImGui_GetCurrentWindow():GetID(str_id_or_id) return ImGui.BeginChildEx(str_id_or_id, id, size_arg, child_flags, window_flags) end @@ -11890,14 +11909,14 @@ end function ImGui.GetWindowViewport() local g = GImGui - return g.CurrentViewport or ImGui.GetMainViewport() + return g.CurrentViewport or ImGui_GetMainViewport() end -- Prefer using PushFont(nil, style.FontSizeBase * factor), or use style.FontScaleMain to scale all windows. --- @param scale float function ImGui.SetWindowFontScale(scale) assert(scale > 0.0) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() window.FontWindowScale = scale ImGui.UpdateCurrentFontSize(0.0) end @@ -11908,8 +11927,8 @@ function ImGui.StartMouseMovingWindow(window) -- We _also_ call this when clicking in a window empty space when io.ConfigWindowsMoveFromTitleBarOnly is set, but clear g.MovingWindow afterward. -- This is because we want ActiveId to be set even when the window is not permitted to move. local g = GImGui - ImGui.FocusWindow(window) - ImGui.SetActiveID(window.MoveId, window) + ImGui_FocusWindow(window) + ImGui_SetActiveID(window.MoveId, window) if (g.IO.ConfigNavCursorVisibleAuto) then g.NavCursorVisible = false end @@ -11941,34 +11960,34 @@ function ImGui.UpdateMouseMovingWindowNewFrame() if g.MovingWindow then -- We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window). -- We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow.MoveId for consistency. - ImGui.KeepAliveID(g.ActiveId) + ImGui_KeepAliveID(g.ActiveId) assert(g.MovingWindow and g.MovingWindow.RootWindowDockTree) local moving_window = g.MovingWindow.RootWindowDockTree -- When a window stop being submitted while being dragged, it may will its viewport until next Begin() local window_disappeared = (not moving_window.WasActive and not moving_window.Active) - if g.IO.MouseDown[0] and ImGui.IsMousePosValid(g.IO.MousePos) and not window_disappeared then + if g.IO.MouseDown[0] and ImGui_IsMousePosValid(g.IO.MousePos) and not window_disappeared then local pos = g.IO.MousePos - g.ActiveIdClickOffset if moving_window.Pos.x ~= pos.x or moving_window.Pos.y ~= pos.y then - ImGui.SetWindowPos(moving_window, pos, 1 --[[ImGuiCond.Always]]) + ImGui_SetWindowPos(moving_window, pos, 1 --[[ImGuiCond.Always]]) if moving_window.Viewport and moving_window.ViewportOwned then -- Synchronize viewport immediately because some overlays may relies on clipping rectangle before we Begin() into the window. ImVec2_Copy(moving_window.Viewport.Pos, pos) moving_window.Viewport:UpdateWorkRect() end end - ImGui.FocusWindow(g.MovingWindow) + ImGui_FocusWindow(g.MovingWindow) else ImGui.StopMouseMovingWindow() - ImGui.ClearActiveID() + ImGui_ClearActiveID() end else -- When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others. if (g.ActiveIdWindow and g.ActiveIdWindow.MoveId == g.ActiveId) then - ImGui.KeepAliveID(g.ActiveId) + ImGui_KeepAliveID(g.ActiveId) if not g.IO.MouseDown[0] then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end end end @@ -12057,7 +12076,7 @@ function ImGui.UpdateMouseMovingWindowEndFrame() else hovered_root = nil end - local is_closed_popup = hovered_root and (bit32.band(hovered_root.Flags, 67108864 --[[ImGuiWindowFlags.Popup]]) ~= 0) and not ImGui.IsPopupOpen(hovered_root.PopupId, 2048 --[[ImGuiPopupFlags.AnyPopupLevel]]) + local is_closed_popup = hovered_root and (bit32.band(hovered_root.Flags, 67108864 --[[ImGuiWindowFlags.Popup]]) ~= 0) and not ImGui_IsPopupOpen(hovered_root.PopupId, 2048 --[[ImGuiPopupFlags.AnyPopupLevel]]) local is_queued_focus_request = g.NavMoveSubmitted and (bit32.band(g.NavMoveFlags, 512 --[[ImGuiNavMoveFlags.FocusApi]]) ~= 0) if hovered_window ~= nil and not is_closed_popup and not is_queued_focus_request then @@ -12083,7 +12102,7 @@ function ImGui.UpdateMouseMovingWindowEndFrame() end elseif hovered_window == nil and g.NavWindow ~= nil then -- Clicking on void disable focus - ImGui.FocusWindow(nil, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) + ImGui_FocusWindow(nil, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) end end @@ -12093,9 +12112,9 @@ function ImGui.UpdateMouseMovingWindowEndFrame() if g.HoveredId == 0 and ImGui.IsMouseClickedEx(1, 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then -- Find the top-most window between HoveredWindow and the top-most Modal Window. -- This is where we can trim the popup stack. - local modal = ImGui.GetTopMostPopupModal() + local modal = ImGui_GetTopMostPopupModal() local hovered_window_above_modal = hovered_window and (modal == nil or ImGui.IsWindowAbove(hovered_window, modal)) - ImGui.ClosePopupsOverWindow(hovered_window_above_modal and hovered_window or modal, true) + ImGui_ClosePopupsOverWindow(hovered_window_above_modal and hovered_window or modal, true) end end @@ -12127,7 +12146,7 @@ end --- @return ImGuiWindow? function ImGui.FindWindowByName(name) local id = ImHashStr(name) - return ImGui.FindWindowByID(id) + return ImGui_FindWindowByID(id) end -- Push a new Dear ImGui window to add widgets to. @@ -12153,7 +12172,7 @@ function ImGui.Begin(name, open, flags) assert(g.FrameCountEnded ~= g.FrameCount) -- Called ImGui.Render() or ImGui.EndFrame() and haven't called ImGui.NewFrame() again yet -- Find or create - local window = ImGui.FindWindowByName(name) + local window = ImGui_FindWindowByName(name) local window_just_created = (window == nil) if window_just_created then window = CreateNewWindow(name, flags) --- @cast window ImGuiWindow @@ -12301,7 +12320,7 @@ function ImGui.Begin(name, open, flags) end -- Override with SetNextWindowClass() field or direct call to SetWindowParentWindowForFocusRoute() if window.WindowClass and window.WindowClass.FocusRouteParentWindowId ~= nil and window.WindowClass.FocusRouteParentWindowId ~= 0 then - window.ParentWindowForFocusRoute = ImGui.FindWindowByID(window.WindowClass.FocusRouteParentWindowId) + window.ParentWindowForFocusRoute = ImGui_FindWindowByID(window.WindowClass.FocusRouteParentWindowId) end -- Inherit SetWindowFontScale() from parent until we fix this system... @@ -12339,7 +12358,7 @@ function ImGui.Begin(name, open, flags) ImVec2_Copy(window.SetWindowPosPivot, g.NextWindowData.PosPivotVal) window.SetWindowPosAllowFlags = bit32.band(window.SetWindowPosAllowFlags, bit32.bnot(bit32.bor(2 --[[ImGuiCond.Once]], 4 --[[ImGuiCond.FirstUseEver]], 8 --[[ImGuiCond.Appearing]]))) else - ImGui.SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond) + ImGui_SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond) end end if bit32.band(g.NextWindowData.HasFlags, 2 --[[ImGuiNextWindowDataFlags.HasSize]]) ~= 0 then @@ -12375,7 +12394,7 @@ function ImGui.Begin(name, open, flags) ImGui.SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond) end if bit32.band(g.NextWindowData.HasFlags, 32 --[[ImGuiNextWindowDataFlags.HasFocus]]) ~= 0 then - ImGui.FocusWindow(window) + ImGui_FocusWindow(window) end if window.Appearing then SetWindowConditionAllowFlags(window, 8 --[[ImGuiCond.Appearing]], false) @@ -12461,7 +12480,7 @@ function ImGui.Begin(name, open, flags) -- We need to do this before using any style/font sizes, as viewport with a different DPI may affect font sizes. ImGui.WindowSelectViewport(window) - ImGui.SetCurrentViewport(window, window.Viewport) + ImGui_SetCurrentViewport(window, window.Viewport) SetCurrentWindow(window) flags = window.Flags @@ -12518,11 +12537,14 @@ function ImGui.Begin(name, open, flags) if bit32.band(flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) == 0 and bit32.band(flags, 32 --[[ImGuiWindowFlags.NoCollapse]]) == 0 and not window.DockIsActive then -- We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), -- so verify that we don't have items over the title bar. - local title_bar_rect = window:TitleBarRect() - if g.HoveredWindow == window and g.HoveredId == 0 and g.HoveredIdPreviousFrame == 0 and g.ActiveId == 0 and ImGui.IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) then - if g.IO.MouseClickedCount[0] == 2 and ImGui.GetKeyOwner(656 --[[ImGuiKey.MouseLeft]]) == 4294967295 --[[ImGuiKeyOwner_NoOwner]] then - window.WantCollapseToggle = true - ImGui.SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], window.MoveId) -- Claim input the same way ButtonBehavior() does. Prevent a same-frame move from triggering other items. (#9439) + -- [Luau] title bar rect only built when the cheaper tests pass + if g.HoveredWindow == window and g.HoveredId == 0 and g.HoveredIdPreviousFrame == 0 and g.ActiveId == 0 then + local title_bar_rect = window:TitleBarRect() + if ImGui_IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) then + if g.IO.MouseClickedCount[0] == 2 and ImGui.GetKeyOwner(656 --[[ImGuiKey.MouseLeft]]) == 4294967295 --[[ImGuiKeyOwner_NoOwner]] then + window.WantCollapseToggle = true + ImGui_SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], window.MoveId) -- Claim input the same way ButtonBehavior() does. Prevent a same-frame move from triggering other items. (#9439) + end end end if window.WantCollapseToggle then @@ -12530,7 +12552,7 @@ function ImGui.Begin(name, open, flags) if not window.Collapsed then use_current_size_for_scrollbar_y = true end - ImGui.MarkIniSettingsDirty(window) + ImGui_MarkIniSettingsDirty(window) end else window.Collapsed = false @@ -12597,7 +12619,7 @@ function ImGui.Begin(name, open, flags) end if old_size.x ~= window.SizeFull.x or old_size.y ~= window.SizeFull.y then - ImGui.MarkIniSettingsDirty(window) + ImGui_MarkIniSettingsDirty(window) end end @@ -12627,7 +12649,7 @@ function ImGui.Begin(name, open, flags) local window_pos_with_pivot = (window.SetWindowPosVal.x ~= 3.4028234663853e+38 --[[FLT_MAX]] and window.HiddenFramesCannotSkipItems == 0) if window_pos_with_pivot then - ImGui.SetWindowPos(window, window.SetWindowPosVal - window.Size * window.SetWindowPosPivot, 0) -- Position given a pivot (e.g. for centering) + ImGui_SetWindowPos(window, window.SetWindowPosVal - window.Size * window.SetWindowPosPivot, 0) -- Position given a pivot (e.g. for centering) elseif (bit32.band(flags, 268435456 --[[ImGuiWindowFlags.ChildMenu]]) ~= 0) then ImVec2_Copy(window.Pos, ImGui.FindBestWindowPosForPopup(window)) elseif (bit32.band(flags, 67108864 --[[ImGuiWindowFlags.Popup]]) ~= 0) and not window_pos_set_by_api and window_just_appearing_after_hidden_for_resize then @@ -12638,14 +12660,16 @@ function ImGui.Begin(name, open, flags) -- Late create viewport if we don't fit within our current host viewport. if window.ViewportAllowPlatformMonitorExtend >= 0 and not window.ViewportOwned and bit32.band(window.Viewport.Flags, 4096 --[[ImGuiViewportFlags.IsMinimized]]) == 0 then - if not window.Viewport:GetMainRect():Contains(window:Rect()) then + -- [Luau] scalar version of: if not window.Viewport:GetMainRect():Contains(window:Rect()) then + local vp, wp, ws = window.Viewport, window.Pos, window.Size + if not (wp.x >= vp.Pos.x and wp.x + ws.x <= vp.Pos.x + vp.Size.x and wp.y >= vp.Pos.y and wp.y + ws.y <= vp.Pos.y + vp.Size.y) then -- This is based on the assumption that the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport) -- local old_viewport = window.Viewport - window.Viewport = ImGui.AddUpdateViewport(window, window.ID, window.Pos, window.Size, 32 --[[ImGuiViewportFlags.NoFocusOnAppearing]]) + window.Viewport = ImGui_AddUpdateViewport(window, window.ID, window.Pos, window.Size, 32 --[[ImGuiViewportFlags.NoFocusOnAppearing]]) -- FIXME-DPI -- IM_ASSERT(old_viewport.DpiScale == window.Viewport.DpiScale) -- FIXME-DPI: Something went wrong - ImGui.SetCurrentViewport(window, window.Viewport) + ImGui_SetCurrentViewport(window, window.Viewport) SetCurrentWindow(window) end end @@ -12659,7 +12683,7 @@ function ImGui.Begin(name, open, flags) local viewport_rect = window.Viewport:GetMainRect() local viewport_work_rect = window.Viewport:GetWorkRect() local visibility_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding) - local visibility_rect = ImRect(viewport_work_rect.Min + visibility_padding, viewport_work_rect.Max - visibility_padding) + local visibility_rect = ImRect(viewport_work_rect.Min.x + visibility_padding.x, viewport_work_rect.Min.y + visibility_padding.y, viewport_work_rect.Max.x - visibility_padding.x, viewport_work_rect.Max.y - visibility_padding.y) -- [Luau] scalar form: no temporary ImVec2s -- Clamp position/size so window stays visible within its viewport or monitor -- Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing. @@ -13038,17 +13062,17 @@ function ImGui.Begin(name, open, flags) -- - 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 then - ImGui.FocusWindow(window, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) + ImGui_FocusWindow(window, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) end if want_focus and window == g.NavWindow then - ImGui.NavInitWindow(window, false) -- <-- this is in the way for us to be able to defer and sort reappearing FocusWindow() calls + ImGui_NavInitWindow(window, false) -- <-- this is in the way for us to be able to defer and sort reappearing FocusWindow() calls end -- Pressing Ctrl+C copy window content into the clipboard -- [EXPERIMENTAL] Breaks on nested Begin/End pairs. We need to work that out and add better logging scope. -- [EXPERIMENTAL] Text outputs has many issues. if g.IO.ConfigWindowsCopyContentsWithCtrlC then - if g.NavWindow and g.NavWindow.RootWindow == window and g.ActiveId == 0 and ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 548 --[[ImGuiKey.C]])) then + if g.NavWindow and g.NavWindow.RootWindow == window and g.ActiveId == 0 and ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 548 --[[ImGuiKey.C]])) then ImGui.LogToClipboard(0) end end @@ -13059,7 +13083,7 @@ function ImGui.Begin(name, open, flags) r.Min.x, r.Min.y, r.Max.x, r.Max.y = title_bar_rect.Min.x + window.WindowBorderSize, title_bar_rect.Min.y, title_bar_rect.Max.x - window.WindowBorderSize, title_bar_rect.Max.y open = RenderWindowTitleBarContents(window, r, name, open) elseif bit32.band(flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) == 0 and window.DockIsActive then - ImGui.LogText("%s\n", string.sub(window.Name, 1, ImGui.FindRenderedTextEnd(window.Name) - 1)) + ImGui_LogText("%s\n", string.sub(window.Name, 1, ImGui_FindRenderedTextEnd(window.Name) - 1)) end -- Clear hit test shape every frame @@ -13099,7 +13123,7 @@ function ImGui.Begin(name, open, flags) -- This is useful to allow creating context menus on title bar only, etc. window.DC.WindowItemStatusFlags = 0 --[[ImGuiItemStatusFlags.None]] - if ImGui.IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) then + if ImGui_IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) then window.DC.WindowItemStatusFlags = bit32.bor(window.DC.WindowItemStatusFlags, 1 --[[ImGuiItemStatusFlags.HoveredRect]]) end ImGui.SetLastItemDataForWindow(window, title_bar_rect) @@ -13117,7 +13141,7 @@ end end -- Append - ImGui.SetCurrentViewport(window, window.Viewport) + ImGui_SetCurrentViewport(window, window.Viewport) SetCurrentWindow(window) g.NextWindowData:ClearFlags() ImGui.SetLastItemDataForWindow(window, window:TitleBarRect()) @@ -13307,7 +13331,7 @@ function ImGui.End() SetCurrentWindow(g.CurrentWindowStack:back().Window) end if g.CurrentWindow then - ImGui.SetCurrentViewport(g.CurrentWindow, g.CurrentWindow.Viewport) + ImGui_SetCurrentViewport(g.CurrentWindow, g.CurrentWindow.Viewport) end end @@ -13507,8 +13531,8 @@ function ImGui.UpdateHoveredWindowAndCaptureFlags(mouse_pos) g.HoveredWindowBeforeClear = g.HoveredWindow -- Modal windows prevents mouse from hovering behind them. - local modal_window = ImGui.GetTopMostPopupModal() - if modal_window and g.HoveredWindow and not ImGui.IsWindowWithinBeginStackOf(g.HoveredWindow.RootWindow, modal_window) then -- FIXME-MERGE: RootWindowDockTree ? + local modal_window = ImGui_GetTopMostPopupModal() + if modal_window and g.HoveredWindow and not ImGui_IsWindowWithinBeginStackOf(g.HoveredWindow.RootWindow, modal_window) then -- FIXME-MERGE: RootWindowDockTree ? clear_hovered_windows = true end @@ -13585,7 +13609,7 @@ end --- @param analog_value float function ImGui.UpdateAliasKey(key, v, analog_value) assert(ImGui.IsAliasKey(key)) - local key_data = ImGui.GetKeyData(nil, key) + local key_data = ImGui_GetKeyData(nil, key) key_data.Down = v key_data.AnalogValue = analog_value end @@ -13596,10 +13620,10 @@ function ImGui.GetMergedModsFromKeys() -- Bypass IsKeyDown() for the unlikely case where user used a ImGuiInputFlags.LockXXXX on those. local mods = 0 - if ImGui.GetKeyData(g, 4096 --[[ImGuiMod_Ctrl]]).Down then mods = bit32.bor(mods, 4096 --[[ImGuiMod_Ctrl]]) end - if ImGui.GetKeyData(g, 8192 --[[ImGuiMod_Shift]]).Down then mods = bit32.bor(mods, 8192 --[[ImGuiMod_Shift]]) end - if ImGui.GetKeyData(g, 16384 --[[ImGuiMod_Alt]]).Down then mods = bit32.bor(mods, 16384 --[[ImGuiMod_Alt]]) end - if ImGui.GetKeyData(g, 32768 --[[ImGuiMod_Super]]).Down then mods = bit32.bor(mods, 32768 --[[ImGuiMod_Super]]) end + if ImGui_GetKeyData(g, 4096 --[[ImGuiMod_Ctrl]]).Down then mods = bit32.bor(mods, 4096 --[[ImGuiMod_Ctrl]]) end + if ImGui_GetKeyData(g, 8192 --[[ImGuiMod_Shift]]).Down then mods = bit32.bor(mods, 8192 --[[ImGuiMod_Shift]]) end + if ImGui_GetKeyData(g, 16384 --[[ImGuiMod_Alt]]).Down then mods = bit32.bor(mods, 16384 --[[ImGuiMod_Alt]]) end + if ImGui_GetKeyData(g, 32768 --[[ImGuiMod_Super]]).Down then mods = bit32.bor(mods, 32768 --[[ImGuiMod_Super]]) end return mods end @@ -13615,7 +13639,7 @@ function ImGui.UpdateKeyboardInputs() -- Update aliases for n = 0, 5 --[[ImGuiMouseButton.COUNT]] - 1 do - ImGui.UpdateAliasKey(ImGui.MouseButtonToKey(n), io.MouseDown[n], io.MouseDown[n] and 1.0 or 0.0) + ImGui.UpdateAliasKey(ImGui_MouseButtonToKey(n), io.MouseDown[n], io.MouseDown[n] and 1.0 or 0.0) end ImGui.UpdateAliasKey(661 --[[ImGuiKey.MouseWheelX]], io.MouseWheelH ~= 0.0, io.MouseWheelH) ImGui.UpdateAliasKey(662 --[[ImGuiKey.MouseWheelY]], io.MouseWheel ~= 0.0, io.MouseWheel) @@ -13697,7 +13721,7 @@ function ImGui.UpdateMouseInputs() io.MouseWheelRequestAxisSwap = io.KeyShift and not io.ConfigMacOSXBehaviors -- Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well) - if (ImGui.IsMousePosValid(io.MousePos)) then + if (ImGui_IsMousePosValid(io.MousePos)) then local x_val = ImFloor(io.MousePos.x) local y_val = ImFloor(io.MousePos.y) @@ -13706,7 +13730,7 @@ function ImGui.UpdateMouseInputs() end -- If mouse just appeared or disappeared (usually denoted by -FLT_MAX components) we cancel out movement in MouseDelta - if (ImGui.IsMousePosValid(io.MousePos) and ImGui.IsMousePosValid(io.MousePosPrev)) then + if (ImGui_IsMousePosValid(io.MousePos) and ImGui_IsMousePosValid(io.MousePosPrev)) then io.MouseDelta = io.MousePos - io.MousePosPrev else io.MouseDelta = ImVec2(0.0, 0.0) @@ -13746,7 +13770,7 @@ function ImGui.UpdateMouseInputs() local is_repeated_click = false if (g.Time - io.MouseClickedTime[i]) < io.MouseDoubleClickTime then local delta_from_click_pos - if ImGui.IsMousePosValid(io.MousePos) then + if ImGui_IsMousePosValid(io.MousePos) then delta_from_click_pos = io.MousePos - io.MouseClickedPos[i] else delta_from_click_pos = ImVec2(0.0, 0.0) @@ -13771,7 +13795,7 @@ function ImGui.UpdateMouseInputs() elseif io.MouseDown[i] then -- Maintain the maximum distance we reaching from the initial click position, which is used with dragging threshold local delta_from_click_pos - if ImGui.IsMousePosValid(io.MousePos) then + if ImGui_IsMousePosValid(io.MousePos) then delta_from_click_pos = (io.MousePos - io.MouseClickedPos[i]) else delta_from_click_pos = ImVec2(0.0, 0.0) @@ -13870,7 +13894,7 @@ function ImGui.UpdateMouseWheel() local g = GImGui if g.WheelingWindow ~= nil then g.WheelingWindowReleaseTimer = g.WheelingWindowReleaseTimer - g.IO.DeltaTime - if ImGui.IsMousePosValid() and ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold then + if ImGui_IsMousePosValid() and ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold then g.WheelingWindowReleaseTimer = 0.0 end @@ -13886,12 +13910,12 @@ function ImGui.UpdateMouseWheel() local owner_id = mouse_window.ID local wheel = ImVec2() - wheel.x = ImGui.TestKeyOwner(661 --[[ImGuiKey.MouseWheelX]], owner_id) and g.IO.MouseWheelH or 0.0 - wheel.y = ImGui.TestKeyOwner(662 --[[ImGuiKey.MouseWheelY]], owner_id) and g.IO.MouseWheel or 0.0 + wheel.x = ImGui_TestKeyOwner(661 --[[ImGuiKey.MouseWheelX]], owner_id) and g.IO.MouseWheelH or 0.0 + wheel.y = ImGui_TestKeyOwner(662 --[[ImGuiKey.MouseWheelY]], owner_id) and g.IO.MouseWheel or 0.0 -- IMGUI_DEBUG_LOG("MouseWheel X:%.3f Y:%.3f\n", wheel_x, wheel_y) if g.WheelingWindow ~= nil then - ImGui.SetKeyOwner(661 --[[ImGuiKey.MouseWheelX]], owner_id) - ImGui.SetKeyOwner(662 --[[ImGuiKey.MouseWheelY]], owner_id) + ImGui_SetKeyOwner(661 --[[ImGuiKey.MouseWheelX]], owner_id) + ImGui_SetKeyOwner(662 --[[ImGuiKey.MouseWheelY]], owner_id) end -- Zoom / Scale window @@ -13904,7 +13928,7 @@ function ImGui.UpdateMouseWheel() window.FontWindowScale = new_font_scale if window == window.RootWindow then local offset = window.Size * (1.0 - scale) * (g.IO.MousePos - window.Pos) / window.Size - ImGui.SetWindowPos(window, window.Pos + offset, 0) + ImGui_SetWindowPos(window, window.Pos + offset, 0) end return end @@ -13959,7 +13983,7 @@ function ImGui.UpdateMouseWheel() LockWheelingWindow(window, wheel.y) local max_step = window.InnerRect:GetHeight() * 0.67 local scroll_step = ImTrunc(ImMin(5 * window.FontRefSize, max_step)) - ImGui.SetScrollY(window, window.Scroll.y - wheel.y * scroll_step) + ImGui_SetScrollY(window, window.Scroll.y - wheel.y * scroll_step) g.WheelingWindowScrolledFrame = g.FrameCount end end @@ -14183,7 +14207,7 @@ local function AddWindowToDrawData(window, layer) end ImGui.AddDrawListToDrawDataEx(viewport.DrawDataP, viewport.DrawDataBuilder.Layers[layer], window.DrawList) for _, child in window.DC.ChildWindows:iter() do - if (ImGui.IsWindowActiveAndVisible(child)) then -- Clipped children may have been marked not active + if (ImGui_IsWindowActiveAndVisible(child)) then -- Clipped children may have been marked not active AddWindowToDrawData(child, layer) end end @@ -14237,7 +14261,7 @@ function ImGui.NewFrame() end end - ImGui.CallContextHooks(g, 0 --[[ImGuiContextHookType.NewFramePre]]) + ImGui_CallContextHooks(g, 0 --[[ImGuiContextHookType.NewFramePre]]) -- Check and assert for various common IO and Configuration mistakes g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame @@ -14290,7 +14314,7 @@ function ImGui.NewFrame() -- Drag and drop keep the source ID alive so even if the source disappear our state is consistent if g.DragDropActive and g.DragDropPayload.SourceId == g.ActiveId then - ImGui.KeepAliveID(g.DragDropPayload.SourceId) + ImGui_KeepAliveID(g.DragDropPayload.SourceId) end -- [DEBUG] @@ -14326,7 +14350,7 @@ function ImGui.NewFrame() if (g.ActiveId ~= 0 and g.ActiveIdIsAlive ~= g.ActiveId and g.ActiveIdPreviousFrame == g.ActiveId) then IMGUI_DEBUG_LOG_ACTIVEID("NewFrame(): ClearActiveID() 0x%08X because it isn't marked alive anymore!", g.ActiveId) - ImGui.ClearActiveID() + ImGui_ClearActiveID() end -- Update ActiveId data (clear reference to active widget if the widget isn't alive anymore) @@ -14419,9 +14443,9 @@ function ImGui.NewFrame() -- 'if (GetDragDropPayload() ~= nil) then Shortcut(ImGuiKey.Escape, ImGuiInputFlags.RouteGlobal | ImGuiInputFlags.RouteOverActive) end -- but you will not get a return value from Shortcut() due to ActiveIdUsingAllKeyboardKeys logic. You can however poll IsKeyPressed(ImGuiKey.Escape) afterwards. local owner_id = (g.ActiveId ~= 0) and g.ActiveId or ImHashStr("##DragDropCancelHandler") - if ImGui.Shortcut(526 --[[ImGuiKey.Escape]], 4096 --[[ImGuiInputFlags.RouteGlobal]], owner_id) then - ImGui.ClearActiveID() - ImGui.ClearDragDrop() + if ImGui_Shortcut(526 --[[ImGuiKey.Escape]], 4096 --[[ImGuiInputFlags.RouteGlobal]], owner_id) then + ImGui_ClearActiveID() + ImGui_ClearDragDrop() end end g.TooltipPreviousWindow = nil @@ -14463,7 +14487,7 @@ function ImGui.NewFrame() ImGui.UpdateMouseMovingWindowNewFrame() -- Background darkening/whitening - if ImGui.GetTopMostPopupModal() ~= nil or (g.NavWindowingTarget ~= nil and g.NavWindowingHighlightAlpha > 0.0) then + if ImGui_GetTopMostPopupModal() ~= nil or (g.NavWindowingTarget ~= nil and g.NavWindowingHighlightAlpha > 0.0) then g.DimBgRatio = ImMin(g.DimBgRatio + g.IO.DeltaTime * 6.0, 1.0) else g.DimBgRatio = ImMax(g.DimBgRatio - g.IO.DeltaTime * 10.0, 0.0) @@ -14543,7 +14567,7 @@ end -- We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. -- This fallback is particularly important as it prevents ImGui:: calls from crashing. g.WithinFrameScopeWithImplicitWindow = true - ImGui.SetNextWindowSize(ImVec2(400, 400), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(400, 400), 4 --[[ImGuiCond.FirstUseEver]]) ImGui.Begin("Debug##Default") assert(g.CurrentWindow.IsFallbackWindow == true) @@ -14560,7 +14584,7 @@ end g.DebugBeginReturnValueCullDepth = -1 end - ImGui.CallContextHooks(g, 1 --[[ImGuiContextHookType.NewFramePost]]) + ImGui_CallContextHooks(g, 1 --[[ImGuiContextHookType.NewFramePost]]) end -- This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal. @@ -14574,7 +14598,7 @@ function ImGui.EndFrame() end IM_ASSERT_USER_ERROR(g.WithinFrameScope, "Forgot to call ImGui::NewFrame()?") - ImGui.CallContextHooks(g, 2 --[[ImGuiContextHookType.EndFramePre]]) + ImGui_CallContextHooks(g, 2 --[[ImGuiContextHookType.EndFramePre]]) -- [EXPERIMENTAL] Recover from errors if g.IO.ConfigErrorRecovery and g.StackSizesInNewFrame then @@ -14586,9 +14610,9 @@ function ImGui.EndFrame() -- Notify Platform/OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) local ime_data = g.PlatformImeData if g.PlatformIO.Platform_SetImeDataFn ~= nil and not ImGuiPlatformImeData_Compare(ime_data, g.PlatformImeDataPrev) then - local viewport = ImGui.FindViewportByID(ime_data.ViewportId) + local viewport = ImGui_FindViewportByID(ime_data.ViewportId) if viewport == nil then - viewport = ImGui.GetMainViewport() + viewport = ImGui_GetMainViewport() end -- [Port] IMGUI_DEBUG_LOG_IO("[io] Calling Platform_SetImeDataFn(): WantVisible: %d, InputPos (%.2f,%.2f) for Viewport 0x%08X", ime_data.WantVisible, ime_data.InputPos.x, ime_data.InputPos.y, viewport.ID) g.PlatformIO.Platform_SetImeDataFn(g, viewport, ime_data) @@ -14608,13 +14632,13 @@ function ImGui.EndFrame() -- Update docking ImGui.DockContextEndFrame(g) - ImGui.SetCurrentViewport(nil, nil) + ImGui_SetCurrentViewport(nil, nil) -- Drag and Drop: Elapse payload (if delivered, or if source stops being submitted) if g.DragDropActive then local is_delivered = g.DragDropPayload.Delivery local is_elapsed = (g.DragDropSourceFrameCount + 1 < g.FrameCount) and (bit32.band(g.DragDropSourceFlags, 32 --[[ImGuiDragDropFlags.PayloadAutoExpire]]) ~= 0 or g.DragDropMouseButton == -1 or not ImGui.IsMouseDown(g.DragDropMouseButton)) - if is_delivered or is_elapsed then ImGui.ClearDragDrop() end + if is_delivered or is_elapsed then ImGui_ClearDragDrop() end end -- Drag and Drop: Fallback for missing source tooltip. This is not ideal but better than nothing. @@ -14673,7 +14697,7 @@ function ImGui.EndFrame() g.IO.MouseWheelH = 0.0 g.IO.InputQueueCharacters:resize(0) - ImGui.CallContextHooks(g, 3 --[[ImGuiContextHookType.EndFramePost]]) + ImGui_CallContextHooks(g, 3 --[[ImGuiContextHookType.EndFramePost]]) end -- Prepare the data for rendering so you can call GetDrawData() @@ -14690,7 +14714,7 @@ function ImGui.Render() g.FrameCountRendered = g.FrameCount g.IO.MetricsRenderWindows = 0 - ImGui.CallContextHooks(g, 4 --[[ImGuiContextHookType.RenderPre]]) + ImGui_CallContextHooks(g, 4 --[[ImGuiContextHookType.RenderPre]]) -- Add background ImDrawList (for each active viewport) for _, viewport in g.Viewports:iter() do @@ -14708,12 +14732,12 @@ function ImGui.Render() windows_to_render_top_most[1] = (g.NavWindowingTarget and (bit32.band(g.NavWindowingTarget.Flags, 8192 --[[ImGuiWindowFlags.NoBringToFrontOnFocus]]) == 0)) and g.NavWindowingTarget.RootWindowDockTree or nil windows_to_render_top_most[2] = g.NavWindowingTarget and g.NavWindowingListWindow or nil for _, window in g.Windows:iter() do - if ImGui.IsWindowActiveAndVisible(window) and (bit32.band(window.Flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) == 0) and window ~= windows_to_render_top_most[1] and window ~= windows_to_render_top_most[2] then + if ImGui_IsWindowActiveAndVisible(window) and (bit32.band(window.Flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) == 0) and window ~= windows_to_render_top_most[1] and window ~= windows_to_render_top_most[2] then AddRootWindowToDrawData(window) end end for n = 1, 2 do - if windows_to_render_top_most[n] and ImGui.IsWindowActiveAndVisible(windows_to_render_top_most[n]) then -- NavWindowingTarget is always temporarily displayed as the top-most window + if windows_to_render_top_most[n] and ImGui_IsWindowActiveAndVisible(windows_to_render_top_most[n]) then -- NavWindowingTarget is always temporarily displayed as the top-most window AddRootWindowToDrawData(windows_to_render_top_most[n]) end end @@ -14731,7 +14755,7 @@ function ImGui.Render() -- Add foreground ImDrawList (for each active viewport) if viewport.BgFgDrawLists[2] ~= nil and viewport.BgFgDrawListsLastFrameActive[2] == g.FrameCount then - ImGui.AddDrawListToDrawDataEx(viewport.DrawDataP, viewport.DrawDataBuilder.Layers[1], ImGui.GetForegroundDrawList(viewport)) + ImGui.AddDrawListToDrawDataEx(viewport.DrawDataP, viewport.DrawDataBuilder.Layers[1], ImGui_GetForegroundDrawList(viewport)) end -- We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch). @@ -14744,7 +14768,7 @@ function ImGui.Render() g.IO.MetricsRenderIndices = g.IO.MetricsRenderIndices + draw_data.TotalIdxCount end - ImGui.CallContextHooks(g, 5 --[[ImGuiContextHookType.RenderPost]]) + ImGui_CallContextHooks(g, 5 --[[ImGuiContextHookType.RenderPost]]) end -- Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. @@ -14756,7 +14780,7 @@ end --- @return ImVec2 @native function ImGui.CalcTextSize(text, text_end, hide_text_after_double_hash, wrap_width) - local x, y = ImGui.CalcTextSizeXY(text, 1, text_end, hide_text_after_double_hash, wrap_width) -- [Luau] inline CalcTextSizeEx() + local x, y = ImGui_CalcTextSizeXY(text, 1, text_end, hide_text_after_double_hash, wrap_width) -- [Luau] inline CalcTextSizeEx() return ImVec2(x, y) end @@ -14775,7 +14799,7 @@ function ImGui.CalcTextSizeXY(text, text_begin, text_end, hide_text_after_double local text_display_end if hide_text_after_double_hash then - text_display_end = ImGui.FindRenderedTextEnd(text, text_end) -- Hide anything after a '##' string + text_display_end = ImGui_FindRenderedTextEnd(text, text_end) -- Hide anything after a '##' string else text_display_end = text_end end @@ -14794,7 +14818,7 @@ end @native function ImGui.CalcTextSizeEx(text, text_begin, text_end, hide_text_after_double_hash, wrap_width) - local x, y = ImGui.CalcTextSizeXY(text, text_begin, text_end, hide_text_after_double_hash, wrap_width) + local x, y = ImGui_CalcTextSizeXY(text, text_begin, text_end, hide_text_after_double_hash, wrap_width) return ImVec2(x, y) end @@ -14838,7 +14862,7 @@ function ImGui.Shutdown() -- Shutdown extensions ImGui.DockContextShutdown(g) - ImGui.CallContextHooks(g, 6 --[[ImGuiContextHookType.Shutdown]]) + ImGui_CallContextHooks(g, 6 --[[ImGuiContextHookType.Shutdown]]) -- Clear everything else -- [Luau] clear_delete()/clear_destruct() are plain clear(): the GC frees the elements @@ -15162,14 +15186,22 @@ end @native function ImGui.PushStyleColor(idx, col) local g = GImGui - local backup = ImGuiColorMod(idx, g.Style.Colors[idx]) - -- [Luau] inline g.ColorStack:push_back(backup) + -- [Luau] inline g.ColorStack:push_back(backup); C++ copies the ImGuiColorMod into the vector's storage: reuse the + -- entry a PopStyleColor() left past Size instead of allocating one per push local stack = g.ColorStack local n = stack.Size + 1 - if n > stack.Capacity then stack:push_back(backup) else stack.Data[n] = backup; stack.Size = n end + local backup = (n <= stack.Capacity) and stack.Data[n] or nil + if backup then + backup.Col = idx + ImVec4_Copy(backup.BackupValue, g.Style.Colors[idx]) + stack.Size = n + else + backup = ImGuiColorMod(idx, g.Style.Colors[idx]) + if n > stack.Capacity then stack:push_back(backup) else stack.Data[n] = backup; stack.Size = n end + end if g.DebugFlashStyleColorIdx ~= idx then if type(col) == "number" then - ImGui.ColorConvertU32ToFloat4(col, g.Style.Colors[idx]) + ImGui_ColorConvertU32ToFloat4(col, g.Style.Colors[idx]) else --- @cast col ImVec4 ImVec4_Copy(g.Style.Colors[idx], col) end @@ -15252,6 +15284,25 @@ function ImGui.GetStyleVarInfo(idx) return GStyleVarsInfo[idx + 1] end +-- [Luau] g.StyleVarStack:push_back(ImGuiStyleMod(idx, v)); C++ copies the ImGuiStyleMod into the vector's storage: +-- reuse the entry a PopStyleVar() left past Size instead of allocating two tables per push +local function PushStyleMod(g, idx, v) + local stack = g.StyleVarStack + local n = stack.Size + 1 + local mod = (n <= stack.Capacity) and stack.Data[n] or nil + if mod then + mod.VarIdx = idx + if type(v) == "number" then + mod.BackupVal[1] = v; mod.BackupVal[2] = nil + else -- ImVec2 + mod.BackupVal[1] = v.x; mod.BackupVal[2] = v.y + end + stack.Size = n + else + stack:push_back(ImGuiStyleMod(idx, v)) + end +end + --- @param idx ImGuiStyleVar --- @param val float|ImVec2 function ImGui.PushStyleVar(idx, val) @@ -15263,7 +15314,7 @@ function ImGui.PushStyleVar(idx, val) IM_ASSERT_USER_ERROR_RET(var_info.DataType == 8 --[[ImGuiDataType.Float]] and var_info.Count == 2, "Calling PushStyleVar() with wrong type!") end local var = g.Style[var_info.Key] - g.StyleVarStack:push_back(ImGuiStyleMod(idx, var)) + PushStyleMod(g, idx, var) if type(val) == "number" then g.Style[var_info.Key] = val else -- [Port] copy into the style's own ImVec2: storing the caller's vector would alias it into the style forever @@ -15278,7 +15329,7 @@ function ImGui.PushStyleVarX(idx, val_x) local var_info = ImGui.GetStyleVarInfo(idx) IM_ASSERT_USER_ERROR_RET(var_info.DataType == 8 --[[ImGuiDataType.Float]] and var_info.Count == 2, "Calling PushStyleVarX() with wrong type!") local pvar = g.Style[var_info.Key] - g.StyleVarStack:push_back(ImGuiStyleMod(idx, pvar)) + PushStyleMod(g, idx, pvar) pvar.x = val_x end @@ -15289,7 +15340,7 @@ function ImGui.PushStyleVarY(idx, val_y) local var_info = ImGui.GetStyleVarInfo(idx) IM_ASSERT_USER_ERROR_RET(var_info.DataType == 8 --[[ImGuiDataType.Float]] and var_info.Count == 2, "Calling PushStyleVarY() with wrong type!") local pvar = g.Style[var_info.Key] - g.StyleVarStack:push_back(ImGuiStyleMod(idx, pvar)) + PushStyleMod(g, idx, pvar) pvar.y = val_y end @@ -15460,7 +15511,7 @@ function ImGui.IsWindowHovered(flags) local result if bit32.band(flags, 1 --[[ImGuiHoveredFlags.ChildWindows]]) ~= 0 then - result = ImGui.IsWindowChildOf(ref_window, cur_window, popup_hierarchy, dock_hierarchy) + result = ImGui_IsWindowChildOf(ref_window, cur_window, popup_hierarchy, dock_hierarchy) else result = (ref_window == cur_window) end @@ -15516,7 +15567,7 @@ function ImGui.IsWindowFocused(flags) end if bit32.band(flags, 1 --[[ImGuiFocusedFlags.ChildWindows]]) ~= 0 then - return ImGui.IsWindowChildOf(ref_window, cur_window, popup_hierarchy, dock_hierarchy) + return ImGui_IsWindowChildOf(ref_window, cur_window, popup_hierarchy, dock_hierarchy) else return ref_window == cur_window end @@ -15636,29 +15687,29 @@ function ImGui.ScrollToRectEx(window, item_rect, flags) if bit32.band(flags, 1 --[[ImGuiScrollFlags.KeepVisibleEdgeX]]) ~= 0 and not fully_visible_x then if item_rect.Min.x < scroll_rect.Min.x or not can_be_fully_visible_x then - ImGui.SetScrollFromPosX(window, item_rect.Min.x - g.Style.ItemSpacing.x - window.Pos.x, 0.0) + ImGui_SetScrollFromPosX(window, item_rect.Min.x - g.Style.ItemSpacing.x - window.Pos.x, 0.0) elseif item_rect.Max.x >= scroll_rect.Max.x then - ImGui.SetScrollFromPosX(window, item_rect.Max.x + g.Style.ItemSpacing.x - window.Pos.x, 1.0) + ImGui_SetScrollFromPosX(window, item_rect.Max.x + g.Style.ItemSpacing.x - window.Pos.x, 1.0) end elseif (bit32.band(flags, 4 --[[ImGuiScrollFlags.KeepVisibleCenterX]]) ~= 0 and not fully_visible_x) or bit32.band(flags, 16 --[[ImGuiScrollFlags.AlwaysCenterX]]) ~= 0 then if can_be_fully_visible_x then - ImGui.SetScrollFromPosX(window, ImTrunc((item_rect.Min.x + item_rect.Max.x) * 0.5) - window.Pos.x, 0.5) + ImGui_SetScrollFromPosX(window, ImTrunc((item_rect.Min.x + item_rect.Max.x) * 0.5) - window.Pos.x, 0.5) else - ImGui.SetScrollFromPosX(window, item_rect.Min.x - window.Pos.x, 0.0) + ImGui_SetScrollFromPosX(window, item_rect.Min.x - window.Pos.x, 0.0) end end if bit32.band(flags, 2 --[[ImGuiScrollFlags.KeepVisibleEdgeY]]) ~= 0 and not fully_visible_y then if item_rect.Min.y < scroll_rect.Min.y or not can_be_fully_visible_y then - ImGui.SetScrollFromPosY(window, item_rect.Min.y - g.Style.ItemSpacing.y - window.Pos.y, 0.0) + ImGui_SetScrollFromPosY(window, item_rect.Min.y - g.Style.ItemSpacing.y - window.Pos.y, 0.0) elseif item_rect.Max.y >= scroll_rect.Max.y then - ImGui.SetScrollFromPosY(window, item_rect.Max.y + g.Style.ItemSpacing.y - window.Pos.y, 1.0) + ImGui_SetScrollFromPosY(window, item_rect.Max.y + g.Style.ItemSpacing.y - window.Pos.y, 1.0) end elseif (bit32.band(flags, 8 --[[ImGuiScrollFlags.KeepVisibleCenterY]]) ~= 0 and not fully_visible_y) or bit32.band(flags, 32 --[[ImGuiScrollFlags.AlwaysCenterY]]) ~= 0 then if can_be_fully_visible_y then - ImGui.SetScrollFromPosY(window, ImTrunc((item_rect.Min.y + item_rect.Max.y) * 0.5) - window.Pos.y, 0.5) + ImGui_SetScrollFromPosY(window, ImTrunc((item_rect.Min.y + item_rect.Max.y) * 0.5) - window.Pos.y, 0.5) else - ImGui.SetScrollFromPosY(window, item_rect.Min.y - window.Pos.y, 0.0) + ImGui_SetScrollFromPosY(window, item_rect.Min.y - window.Pos.y, 0.0) end end @@ -15674,7 +15725,7 @@ function ImGui.ScrollToRectEx(window, item_rect, flags) if bit32.band(in_flags, bit32.bor(32 --[[ImGuiScrollFlags.AlwaysCenterY]], 8 --[[ImGuiScrollFlags.KeepVisibleCenterY]])) ~= 0 then in_flags = bit32.bor(bit32.band(in_flags, bit32.bnot(42 --[[ImGuiScrollFlags.MaskY_]])), 2 --[[ImGuiScrollFlags.KeepVisibleEdgeY]]) end - local parent_delta = ImGui.ScrollToRectEx(window.ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll), in_flags) + local parent_delta = ImGui_ScrollToRectEx(window.ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll), in_flags) delta_scroll = delta_scroll + parent_delta end @@ -15702,14 +15753,14 @@ end --- @param flags? ImGuiScrollFlags function ImGui.ScrollToItem(flags) local g = GImGui - ImGui.ScrollToRectEx(g.CurrentWindow, g.LastItemData.NavRect, flags or 0) + ImGui_ScrollToRectEx(g.CurrentWindow, g.LastItemData.NavRect, flags or 0) end --- @param window ImGuiWindow --- @param item_rect ImRect --- @param flags? ImGuiScrollFlags function ImGui.ScrollToRect(window, item_rect, flags) - ImGui.ScrollToRectEx(window, item_rect, flags or 0) + ImGui_ScrollToRectEx(window, item_rect, flags or 0) end -- center_x_ratio: 0.0 left of last item, 0.5 horizontal center of last item, 1.0 right of last item. @@ -15720,7 +15771,7 @@ function ImGui.SetScrollHereX(center_x_ratio) local window = g.CurrentWindow local spacing_x = ImMax(window.WindowPadding.x, g.Style.ItemSpacing.x) local target_pos_x = ImLerp(g.LastItemData.Rect.Min.x - spacing_x, g.LastItemData.Rect.Max.x + spacing_x, center_x_ratio) - ImGui.SetScrollFromPosX(window, target_pos_x - window.Pos.x, center_x_ratio) -- Convert from absolute to local pos + ImGui_SetScrollFromPosX(window, target_pos_x - window.Pos.x, center_x_ratio) -- Convert from absolute to local pos -- Tweak: snap on edges when aiming at an item very close to the edge window.ScrollTargetEdgeSnapDist.x = ImMax(0.0, window.WindowPadding.x - spacing_x) @@ -15734,7 +15785,7 @@ function ImGui.SetScrollHereY(center_y_ratio) local window = g.CurrentWindow local spacing_y = ImMax(window.WindowPadding.y, g.Style.ItemSpacing.y) local target_pos_y = ImLerp(window.DC.CursorPosPrevLine.y - spacing_y, window.DC.CursorPosPrevLine.y + window.DC.PrevLineSize.y + spacing_y, center_y_ratio) - ImGui.SetScrollFromPosY(window, target_pos_y - window.Pos.y, center_y_ratio) -- Convert from absolute to local pos + ImGui_SetScrollFromPosY(window, target_pos_y - window.Pos.y, center_y_ratio) -- Convert from absolute to local pos -- Tweak: snap on edges when aiming at an item very close to the edge window.ScrollTargetEdgeSnapDist.y = ImMax(0.0, window.WindowPadding.y - spacing_y) @@ -15821,7 +15872,7 @@ function ImGui.BeginTooltipEx(tooltip_flags, extra_window_flags) end local tooltip_pivot = is_touchscreen and TOOLTIP_DEFAULT_PIVOT_TOUCH or ImVec2(0.0, 0.0) - ImGui.SetNextWindowPos(tooltip_pos, 0 --[[ImGuiCond.None]], tooltip_pivot) + ImGui_SetNextWindowPos(tooltip_pos, 0 --[[ImGuiCond.None]], tooltip_pivot) end local bg_alpha = g.Style.Colors[4 --[[ImGuiCol.PopupBg]]].w * 0.60 @@ -15857,14 +15908,14 @@ function ImGui.BeginTooltip() end function ImGui.BeginItemTooltip() - if not ImGui.IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then + if not ImGui_IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then return false end return ImGui.BeginTooltipEx(0 --[[ImGuiTooltipFlags.None]], 0 --[[ImGuiWindowFlags.None]]) end function ImGui.EndTooltip() - assert(bit32.band(ImGui.GetCurrentWindowRead().Flags, 33554432 --[[ImGuiWindowFlags.Tooltip]]) ~= 0) -- Mismatched BeginTooltip()/EndTooltip() calls + assert(bit32.band(ImGui_GetCurrentWindowRead().Flags, 33554432 --[[ImGuiWindowFlags.Tooltip]]) ~= 0) -- Mismatched BeginTooltip()/EndTooltip() calls ImGui.End() end @@ -15880,7 +15931,7 @@ function ImGui.SetTooltipV(fmt, ...) return end ImGui.TextV(fmt, ...) - ImGui.EndTooltip() + ImGui_EndTooltip() end -- Shortcut to use 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav'. @@ -15892,7 +15943,7 @@ function ImGui.SetItemTooltip(fmt, ...) end function ImGui.SetItemTooltipV(fmt, ...) - if ImGui.IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then + if ImGui_IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then ImGui.SetTooltipV(fmt, ...) end end @@ -15935,7 +15986,7 @@ function ImGui.FindBlockingModal(window) if window == nil then -- FindBlockingModal(nil) test for if FocusWindow(nil) is naturally possible via a mouse click. return popup_window end - if ImGui.IsWindowWithinBeginStackOf(window, popup_window) then -- Window may be over modal + if ImGui_IsWindowWithinBeginStackOf(window, popup_window) then -- Window may be over modal break end @@ -15952,12 +16003,12 @@ function ImGui.OpenPopup(id, popup_flags) if popup_flags == nil then popup_flags = 0 end if type(id) == "number" then - return ImGui.OpenPopupEx(id, popup_flags) + return ImGui_OpenPopupEx(id, popup_flags) else --- @cast id string local g = GImGui local _id = g.CurrentWindow:GetID(id) IMGUI_DEBUG_LOG_POPUP("[popup] OpenPopup(\"%s\" -> 0x%08X)", id, _id) - return ImGui.OpenPopupEx(_id, popup_flags) + return ImGui_OpenPopupEx(_id, popup_flags) end end @@ -15975,7 +16026,7 @@ function ImGui.OpenPopupEx(id, popup_flags) local current_stack_size = g.BeginPopupStack.Size if bit32.band(popup_flags, 128 --[[ImGuiPopupFlags.NoOpenOverExistingPopup]]) ~= 0 then - if ImGui.IsPopupOpen(0, 1024 --[[ImGuiPopupFlags.AnyPopupId]]) then + if ImGui_IsPopupOpen(0, 1024 --[[ImGuiPopupFlags.AnyPopupId]]) then return false end end @@ -15987,7 +16038,7 @@ function ImGui.OpenPopupEx(id, popup_flags) popup_ref.OpenFrameCount = g.FrameCount popup_ref.OpenParentId = parent_window.IDStack:back() ImVec2_Copy(popup_ref.OpenPopupPos, ImGui.NavCalcPreferredRefPos(67108864 --[[ImGuiWindowFlags.Popup]])) - if ImGui.IsMousePosValid(g.IO.MousePos) then + if ImGui_IsMousePosValid(g.IO.MousePos) then ImVec2_Copy(popup_ref.OpenMousePos, g.IO.MousePos) else ImVec2_Copy(popup_ref.OpenMousePos, popup_ref.OpenPopupPos) @@ -16015,7 +16066,7 @@ function ImGui.OpenPopupEx(id, popup_flags) g.OpenPopupStack.Data[current_stack_size + 1].OpenFrameCount = popup_ref.OpenFrameCount else -- Reopen: close child popups if any, then flag popup for open/reopen (set position, focus, init navigation) - ImGui.ClosePopupToLevel(current_stack_size, true) + ImGui_ClosePopupToLevel(current_stack_size, true) g.OpenPopupStack:push_back(popup_ref) end @@ -16066,7 +16117,7 @@ function ImGui.ClosePopupsOverWindow(ref_window, restore_focus_to_window_under_p for n = popup_count_to_keep, g.OpenPopupStack.Size - 1 do local popup_window = g.OpenPopupStack.Data[n + 1].Window -- if (popup_window.RootWindowDockTree == ref_window.RootWindowDockTree) -- FIXME-MERGE - if popup_window and ImGui.IsWindowWithinBeginStackOf(ref_window, popup_window) then + if popup_window and ImGui_IsWindowWithinBeginStackOf(ref_window, popup_window) then ref_window_is_descendent_of_popup = true break end @@ -16084,7 +16135,7 @@ function ImGui.ClosePopupsOverWindow(ref_window, restore_focus_to_window_under_p end if popup_count_to_keep < g.OpenPopupStack.Size then -- This test is not required but it allows to set a convenient breakpoint on the statement below -- [Port] IMGUI_DEBUG_LOG_POPUP("[popup] ClosePopupsOverWindow(\"%s\")\n", ref_window and ref_window.Name or "") - ImGui.ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup) + ImGui_ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup) end end @@ -16119,7 +16170,7 @@ function ImGui.ClosePopupToLevel(remaining, restore_focus_to_window_under_popup) ImGui.FocusTopMostWindowUnderOne(popup_window, nil, nil, 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) -- Fallback else local focus_flags = (g.NavLayer == 0 --[[ImGuiNavLayer.Main]]) and 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]] or 0 --[[ImGuiFocusRequestFlags.None]] - ImGui.FocusWindow(focus_window, focus_flags) + ImGui_FocusWindow(focus_window, focus_flags) end end end @@ -16151,7 +16202,7 @@ function ImGui.CloseCurrentPopup() end -- [Port] IMGUI_DEBUG_LOG_POPUP("[popup] CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size, popup_idx) - ImGui.ClosePopupToLevel(popup_idx - 1, true) + ImGui_ClosePopupToLevel(popup_idx - 1, true) -- A common pattern is to close a popup when selecting a menu item/selectable that will open another window. -- To improve this usage pattern, we avoid nav highlight for a single frame in the parent window. @@ -16167,7 +16218,7 @@ end --- @param extra_window_flags ImGuiWindowFlags function ImGui.BeginPopupEx(id, extra_window_flags) local g = GImGui - if not ImGui.IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then + if not ImGui_IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then g.NextWindowData:ClearFlags() -- We behave like Begin() and need to consume those values return false end @@ -16179,7 +16230,7 @@ function ImGui.BeginPopupEx(id, extra_window_flags) _, is_open = ImGui.Begin(name, nil, bit32.bor(extra_window_flags, 67108864 --[[ImGuiWindowFlags.Popup]], 524288 --[[ImGuiWindowFlags.NoDocking]])) if not is_open then -- NB: Begin can return false when the popup is completely clipped (e.g. zero size display) - ImGui.EndPopup() + ImGui_EndPopup() end -- g.CurrentWindow.FocusRouteParentWindow = g.CurrentWindow.ParentWindowInBeginStack return is_open @@ -16190,7 +16241,7 @@ end --- @param extra_window_flags ImGuiWindowFlags function ImGui.BeginPopupMenuEx(id, label, extra_window_flags) local g = GImGui - if not ImGui.IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then + if not ImGui_IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then g.NextWindowData:ClearFlags() -- We behave like Begin() and need to consume those values return false end @@ -16206,7 +16257,7 @@ function ImGui.BeginPopupMenuEx(id, label, extra_window_flags) local is_open _, is_open = ImGui.Begin(name, nil, bit32.bor(extra_window_flags, 67108864 --[[ImGuiWindowFlags.Popup]])) if not is_open then -- NB: Begin can return false when the popup is completely clipped (e.g. zero size display) - ImGui.EndPopup() + ImGui_EndPopup() end -- g.CurrentWindow.FocusRouteParentWindow = g.CurrentWindow.ParentWindowInBeginStack return is_open @@ -16224,7 +16275,7 @@ function ImGui.BeginPopup(str_id, flags) end flags = bit32.bor(flags, 64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]]) local id = g.CurrentWindow:GetID(str_id) - return ImGui.BeginPopupEx(id, flags) + return ImGui_BeginPopupEx(id, flags) end function ImGui.EndPopup() @@ -16463,7 +16514,7 @@ end function ImGui.IsPopupOpenRequestForItem(popup_flags, id) local g = GImGui local mouse_button = ImGui.GetMouseButtonFromPopupFlags(popup_flags) - if ImGui.IsMouseReleased(mouse_button) and ImGui.IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]) then + if ImGui.IsMouseReleased(mouse_button) and ImGui_IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]) then return true end if g.NavOpenContextMenuItemId == id and (ImGui.IsItemFocused() or id == g.CurrentWindow.MoveId) then @@ -16486,7 +16537,7 @@ function ImGui.OpenPopupOnItemClick(str_id, popup_flags) local id if str_id then id = window:GetID(str_id) else id = g.LastItemData.ID end -- If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! assert(id ~= 0) -- You cannot pass a nil str_id if the last item has no identifier (e.g. a Text() item) - return ImGui.OpenPopupEx(id, popup_flags) + return ImGui_OpenPopupEx(id, popup_flags) end return false @@ -16523,9 +16574,9 @@ function ImGui.BeginPopupContextItem(str_id, popup_flags) if str_id then id = window:GetID(str_id) else id = g.LastItemData.ID end -- If user hasn't passed an ID, we can use the LastItem ID. Using LastItem ID as a Popup ID won't conflict! assert(id ~= 0) -- You cannot pass a nil str_id if the last item has no identifier (e.g. a Text() item) if ImGui.IsPopupOpenRequestForItem(popup_flags, g.LastItemData.ID) then - ImGui.OpenPopupEx(id, popup_flags) + ImGui_OpenPopupEx(id, popup_flags) end - return ImGui.BeginPopupEx(id, bit32.bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) + return ImGui_BeginPopupEx(id, bit32.bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) end ------------------------------------------------------------------------------- @@ -16623,12 +16674,12 @@ function ImGui.SetItemDefaultFocus() end g.NavInitRequest = false - ImGui.NavApplyItemToResult(g.NavInitResult) - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavApplyItemToResult(g.NavInitResult) + ImGui_NavUpdateAnyRequestFlag() -- Scroll could be done in NavInitRequestApplyResult() via an opt-in flag (we however don't want regular init requests to scroll) if not window.ClipRect:Contains(g.LastItemData.Rect) then - ImGui.ScrollToRectEx(window, g.LastItemData.Rect, 0 --[[ImGuiScrollFlags.None]]) + ImGui_ScrollToRectEx(window, g.LastItemData.Rect, 0 --[[ImGuiScrollFlags.None]]) end end @@ -16659,7 +16710,7 @@ function ImGui.SetNavWindow(window) g.NavInitRequest = false g.NavMoveSubmitted = false g.NavMoveScoringItems = false - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavUpdateAnyRequestFlag() end --- @param axis ImGuiAxis @@ -16678,13 +16729,13 @@ function ImGui.SetNavID(id, nav_layer, focus_scope_id, rect_rel) assert(nav_layer == 0 --[[ImGuiNavLayer.Main]] or nav_layer == 1 --[[ImGuiNavLayer.Menu]]) g.NavId = id g.NavLayer = nav_layer - ImGui.SetNavFocusScope(focus_scope_id) + ImGui_SetNavFocusScope(focus_scope_id) g.NavWindow.NavLastIds[nav_layer] = id ImRect_Copy(g.NavWindow.NavRectRel[nav_layer], rect_rel) -- Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it) - ImGui.NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) - ImGui.NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) + ImGui_NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) + ImGui_NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) end -- FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0). @@ -16721,10 +16772,10 @@ function ImGui.NavRestoreLayer(layer) end local window = g.NavWindow if window.NavLastIds[layer] ~= 0 then - ImGui.SetNavID(window.NavLastIds[layer], layer, 0, window.NavRectRel[layer]) + ImGui_SetNavID(window.NavLastIds[layer], layer, 0, window.NavRectRel[layer]) else g.NavLayer = layer - ImGui.NavInitWindow(window, true) + ImGui_NavInitWindow(window, true) end end @@ -16753,7 +16804,7 @@ function ImGui.NavInitWindow(window, force_reinit) if bit32.band(window.Flags, 65536 --[[ImGuiWindowFlags.NoNavInputs]]) ~= 0 then g.NavId = 0 - ImGui.SetNavFocusScope(window.NavRootFocusScopeId) + ImGui_SetNavFocusScope(window.NavRootFocusScopeId) return end @@ -16763,14 +16814,14 @@ function ImGui.NavInitWindow(window, force_reinit) end -- [Port] IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: from NavInitWindow(), init_for_nav=%d, window=\"%s\", layer=%d", init_for_nav, window->Name, g.NavLayer) if init_for_nav then - ImGui.SetNavID(0, g.NavLayer, window.NavRootFocusScopeId, ImRect()) + ImGui_SetNavID(0, g.NavLayer, window.NavRootFocusScopeId, ImRect()) g.NavInitRequest = true g.NavInitRequestFromMove = false g.NavInitResult.ID = 0 - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavUpdateAnyRequestFlag() else g.NavId = window.NavLastIds[0] - ImGui.SetNavFocusScope(window.NavRootFocusScopeId) + ImGui_SetNavFocusScope(window.NavRootFocusScopeId) end end @@ -16806,7 +16857,7 @@ function ImGui.NavCalcPreferredRefPos(window_type) -- Mouse (we need a fallback in case the mouse becomes invalid after being used) -- The +1.0f offset when stored by OpenPopupEx() allows reopening this or another popup (same or another mouse button) while not moving the mouse, it is pretty standard. -- In theory we could move that +1.0f offset in OpenPopupEx() - local p = ImGui.IsMousePosValid(g.IO.MousePos) and g.IO.MousePos or g.MouseLastValidPos + local p = ImGui_IsMousePosValid(g.IO.MousePos) and g.IO.MousePos or g.MouseLastValidPos return ImVec2(p.x + 1.0, p.y) else -- When navigation is active and mouse is disabled, pick a position around the bottom left of the currently navigated item @@ -16854,7 +16905,7 @@ function ImGui.GetNavTweakPressedAmount(axis) local amount = ImGui.GetKeyPressedAmount(key_more, repeat_delay, repeat_rate) - ImGui.GetKeyPressedAmount(key_less, repeat_delay, repeat_rate) - if amount ~= 0.0 and ImGui.IsKeyDown(key_less) and ImGui.IsKeyDown(key_more) then -- Cancel when opposite directions are held, regardless of repeat phase + if amount ~= 0.0 and ImGui_IsKeyDown(key_less) and ImGui_IsKeyDown(key_more) then -- Cancel when opposite directions are held, regardless of repeat phase amount = 0.0 end @@ -16896,14 +16947,14 @@ function ImGui.NavUpdateWindowingApplyFocus(apply_focus_window) local g = GImGui if g.NavWindow == nil or apply_focus_window ~= g.NavWindow.RootWindow then local previous_viewport = g.NavWindow and g.NavWindow.Viewport or nil - ImGui.ClearActiveID() - ImGui.SetNavCursorVisibleAfterMove() - ImGui.ClosePopupsOverWindow(apply_focus_window, false) - ImGui.FocusWindow(apply_focus_window, 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) + ImGui_ClearActiveID() + ImGui_SetNavCursorVisibleAfterMove() + ImGui_ClosePopupsOverWindow(apply_focus_window, false) + ImGui_FocusWindow(apply_focus_window, 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) assert(g.NavWindow ~= nil) apply_focus_window = g.NavWindow if apply_focus_window.NavLastIds[0 --[[ImGuiNavLayer.Main]]] == 0 then -- FIXME: This is the equivalent of the 'if (g.NavId == 0) { NavInitWindow() }' in DockNodeUpdateTabBar(). - ImGui.NavInitWindow(apply_focus_window, false) + ImGui_NavInitWindow(apply_focus_window, false) end -- If the window has ONLY a menu layer (no main layer), select it directly @@ -16935,7 +16986,7 @@ function ImGui.NavUpdateWindowing() local apply_focus_window = nil local apply_toggle_layer = false - local modal_window = ImGui.GetTopMostPopupModal() + local modal_window = ImGui_GetTopMostPopupModal() local allow_windowing = (modal_window == nil) -- FIXME: This prevent Ctrl+Tab from being usable with windows that are inside the Begin-stack of that modal. if not allow_windowing then g.NavWindowingTarget = nil @@ -16954,9 +17005,9 @@ function ImGui.NavUpdateWindowing() local owner_id = ImHashStr("##NavUpdateWindowing") local nav_gamepad_active = bit32.band(io.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0 and bit32.band(io.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0 local nav_keyboard_active = bit32.band(io.ConfigFlags, 1 --[[ImGuiConfigFlags.NavEnableKeyboard]]) ~= 0 - local keyboard_next_window = allow_windowing and g.ConfigNavWindowingKeyNext ~= 0 and ImGui.Shortcut(g.ConfigNavWindowingKeyNext, bit32.bor(1 --[[ImGuiInputFlags.Repeat]], 8192 --[[ImGuiInputFlags.RouteAlways]]), owner_id) - local keyboard_prev_window = allow_windowing and g.ConfigNavWindowingKeyPrev ~= 0 and ImGui.Shortcut(g.ConfigNavWindowingKeyPrev, bit32.bor(1 --[[ImGuiInputFlags.Repeat]], 8192 --[[ImGuiInputFlags.RouteAlways]]), owner_id) - local start_toggling_with_gamepad = nav_gamepad_active and g.NavWindowingTarget == nil and ImGui.Shortcut(634 --[[ImGuiKey.NavGamepadMenu]], 8192 --[[ImGuiInputFlags.RouteAlways]], owner_id) + local keyboard_next_window = allow_windowing and g.ConfigNavWindowingKeyNext ~= 0 and ImGui_Shortcut(g.ConfigNavWindowingKeyNext, bit32.bor(1 --[[ImGuiInputFlags.Repeat]], 8192 --[[ImGuiInputFlags.RouteAlways]]), owner_id) + local keyboard_prev_window = allow_windowing and g.ConfigNavWindowingKeyPrev ~= 0 and ImGui_Shortcut(g.ConfigNavWindowingKeyPrev, bit32.bor(1 --[[ImGuiInputFlags.Repeat]], 8192 --[[ImGuiInputFlags.RouteAlways]]), owner_id) + local start_toggling_with_gamepad = nav_gamepad_active and g.NavWindowingTarget == nil and ImGui_Shortcut(634 --[[ImGuiKey.NavGamepadMenu]], 8192 --[[ImGuiInputFlags.RouteAlways]], owner_id) local start_windowing_with_gamepad = allow_windowing and start_toggling_with_gamepad local start_windowing_with_keyboard = allow_windowing and g.NavWindowingTarget == nil and (keyboard_next_window or keyboard_prev_window) -- Note: enabled even without NavEnableKeyboard! local just_started_windowing_from_null_focus = false @@ -16999,7 +17050,7 @@ function ImGui.NavUpdateWindowing() g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - 0.5 --[[NAV_WINDOWING_HIGHLIGHT_DELAY]]) / 0.05)) -- Select window to focus - local focus_change_dir = (ImGui.IsKeyPressedEx(642 --[[ImGuiKey.GamepadL1]], 0 --[[ImGuiInputFlags.None]], 0 --[[ImGuiKeyOwner_Any]]) and 1 or 0) - (ImGui.IsKeyPressedEx(643 --[[ImGuiKey.GamepadR1]], 0 --[[ImGuiInputFlags.None]], 0 --[[ImGuiKeyOwner_Any]]) and 1 or 0) + local focus_change_dir = (ImGui_IsKeyPressedEx(642 --[[ImGuiKey.GamepadL1]], 0 --[[ImGuiInputFlags.None]], 0 --[[ImGuiKeyOwner_Any]]) and 1 or 0) - (ImGui_IsKeyPressedEx(643 --[[ImGuiKey.GamepadR1]], 0 --[[ImGuiInputFlags.None]], 0 --[[ImGuiKeyOwner_Any]]) and 1 or 0) if focus_change_dir ~= 0 and not just_started_windowing_from_null_focus then ImGui.NavUpdateWindowingTarget(focus_change_dir) g.NavWindowingHighlightAlpha = 1.0 @@ -17007,7 +17058,7 @@ function ImGui.NavUpdateWindowing() end -- Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered top-most) - if not ImGui.IsKeyDown(634 --[[ImGuiKey.NavGamepadMenu]]) then + if not ImGui_IsKeyDown(634 --[[ImGuiKey.NavGamepadMenu]]) then g.NavWindowingToggleLayer = g.NavWindowingToggleLayer and (g.NavWindowingHighlightAlpha < 1.0) -- Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore. if g.NavWindowingToggleLayer and g.NavWindow then apply_toggle_layer = true @@ -17040,7 +17091,7 @@ function ImGui.NavUpdateWindowing() local windowing_toggle_layer_start = false if g.NavWindow and bit32.band(g.NavWindow.Flags, 65536 --[[ImGuiWindowFlags.NoNavInputs]]) == 0 then for _, windowing_toggle_key in ipairs(windowing_toggle_keys) do - if nav_keyboard_active and ImGui.IsKeyPressedEx(windowing_toggle_key, 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then + if nav_keyboard_active and ImGui_IsKeyPressedEx(windowing_toggle_key, 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then windowing_toggle_layer_start = true g.NavWindowingToggleLayer = true g.NavWindowingToggleKey = windowing_toggle_key @@ -17059,7 +17110,7 @@ function ImGui.NavUpdateWindowing() g.NavWindowingToggleLayer = false elseif windowing_toggle_layer_start == false and g.LastKeyboardKeyPressTime == g.Time then g.NavWindowingToggleLayer = false - elseif ImGui.TestKeyOwner(g.NavWindowingToggleKey, 4294967295 --[[ImGuiKeyOwner_NoOwner]]) == false or ImGui.TestKeyOwner(16384 --[[ImGuiMod_Alt]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) == false then + elseif ImGui_TestKeyOwner(g.NavWindowingToggleKey, 4294967295 --[[ImGuiKeyOwner_NoOwner]]) == false or ImGui_TestKeyOwner(16384 --[[ImGuiMod_Alt]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) == false then g.NavWindowingToggleLayer = false end @@ -17067,12 +17118,12 @@ function ImGui.NavUpdateWindowing() -- Important: as before version <18314 we lacked an explicit IO event for focus gain/loss, we also compare mouse validity to detect old backends clearing mouse pos on focus loss. if ImGui.IsKeyReleased(g.NavWindowingToggleKey) and g.NavWindowingToggleLayer then if g.ActiveId == 0 or g.ActiveIdAllowOverlap then - if ImGui.IsMousePosValid(io.MousePos) == ImGui.IsMousePosValid(io.MousePosPrev) then + if ImGui_IsMousePosValid(io.MousePos) == ImGui_IsMousePosValid(io.MousePosPrev) then apply_toggle_layer = true end end end - if not ImGui.IsKeyDown(g.NavWindowingToggleKey) then + if not ImGui_IsKeyDown(g.NavWindowingToggleKey) then g.NavWindowingToggleLayer = false end end @@ -17094,7 +17145,7 @@ function ImGui.NavUpdateWindowing() local accum_floored = ImTrunc(g.NavWindowingAccumDeltaPos) if accum_floored.x ~= 0.0 or accum_floored.y ~= 0.0 then local moving_window = g.NavWindowingTarget.RootWindowDockTree - ImGui.SetWindowPos(moving_window, moving_window.Pos + accum_floored, 1 --[[ImGuiCond.Always]]) + ImGui_SetWindowPos(moving_window, moving_window.Pos + accum_floored, 1 --[[ImGuiCond.Always]]) ImVec2_Copy(g.NavWindowingAccumDeltaPos, g.NavWindowingAccumDeltaPos - accum_floored) end end @@ -17107,7 +17158,7 @@ function ImGui.NavUpdateWindowing() -- Apply menu/layer toggle if apply_toggle_layer and g.NavWindow then - ImGui.ClearActiveID() + ImGui_ClearActiveID() -- Move to parent menu if necessary local new_nav_window = g.NavWindow @@ -17119,7 +17170,7 @@ function ImGui.NavUpdateWindowing() end if new_nav_window ~= g.NavWindow then local old_nav_window = g.NavWindow - ImGui.FocusWindow(new_nav_window) + ImGui_FocusWindow(new_nav_window) new_nav_window.NavLastChildNavWindow = old_nav_window end @@ -17132,7 +17183,7 @@ function ImGui.NavUpdateWindowing() g.NavWindow.NavLastIds[new_nav_layer] = 0 end ImGui.NavRestoreLayer(new_nav_layer) - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() end end end @@ -17149,8 +17200,8 @@ function ImGui.NavUpdateContextMenuRequest() end local request = false - request = request or (nav_keyboard_active and (ImGui.IsKeyReleased(535 --[[ImGuiKey.Menu]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) or (ImGui.IsKeyPressedEx(581 --[[ImGuiKey.F10]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) and io.KeyMods == 8192 --[[ImGuiMod_Shift]]))) - request = request or (nav_gamepad_active and ImGui.IsKeyPressedEx(636 --[[ImGuiKey.NavGamepadContextMenu]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) + request = request or (nav_keyboard_active and (ImGui.IsKeyReleased(535 --[[ImGuiKey.Menu]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) or (ImGui_IsKeyPressedEx(581 --[[ImGuiKey.F10]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) and io.KeyMods == 8192 --[[ImGuiMod_Shift]]))) + request = request or (nav_gamepad_active and ImGui_IsKeyPressedEx(636 --[[ImGuiKey.NavGamepadContextMenu]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) if not request then return end @@ -17164,7 +17215,7 @@ function ImGui.NavUpdateContextMenuRequest() end g.NavInputSource = 2 --[[ImGuiInputSource.Keyboard]] - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() end -- FIXME: ScoringRect is not set @@ -17193,7 +17244,7 @@ function ImGui.NavMoveRequestSubmit(move_dir, clip_dir, move_flags, scroll_flags g.NavMoveResultOther:Clear() g.NavTabbingCounter = 0 g.NavTabbingResultFirst:Clear() - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavUpdateAnyRequestFlag() end -- Bias scoring rect ahead of scoring + update preferred pos (if missing) using source position @@ -17240,10 +17291,10 @@ function ImGui.NavUpdatePageUpPageDown() return 0.0 end - local page_up_held = ImGui.IsKeyDown(517 --[[ImGuiKey.PageUp]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) - local page_down_held = ImGui.IsKeyDown(518 --[[ImGuiKey.PageDown]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) - local home_pressed = ImGui.IsKeyPressedEx(519 --[[ImGuiKey.Home]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) - local end_pressed = ImGui.IsKeyPressedEx(520 --[[ImGuiKey.End]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) + local page_up_held = ImGui_IsKeyDown(517 --[[ImGuiKey.PageUp]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) + local page_down_held = ImGui_IsKeyDown(518 --[[ImGuiKey.PageDown]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) + local home_pressed = ImGui_IsKeyPressedEx(519 --[[ImGuiKey.Home]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) + local end_pressed = ImGui_IsKeyPressedEx(520 --[[ImGuiKey.End]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) if page_up_held == page_down_held and home_pressed == end_pressed then -- Proceed if either (not both) are pressed, otherwise early out return 0.0 end @@ -17254,25 +17305,25 @@ function ImGui.NavUpdatePageUpPageDown() if bit32.band(window.DC.NavLayersActiveMask, bit32.lshift(1, 0 --[[ImGuiNavLayer.Main]])) == 0 and window.DC.NavWindowHasScrollY then -- Fallback manual-scroll when window has no navigable item - if ImGui.IsKeyPressedEx(517 --[[ImGuiKey.PageUp]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then - ImGui.SetScrollY(window, window.Scroll.y - window.InnerRect:GetHeight()) - elseif ImGui.IsKeyPressedEx(518 --[[ImGuiKey.PageDown]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then - ImGui.SetScrollY(window, window.Scroll.y + window.InnerRect:GetHeight()) + if ImGui_IsKeyPressedEx(517 --[[ImGuiKey.PageUp]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then + ImGui_SetScrollY(window, window.Scroll.y - window.InnerRect:GetHeight()) + elseif ImGui_IsKeyPressedEx(518 --[[ImGuiKey.PageDown]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then + ImGui_SetScrollY(window, window.Scroll.y + window.InnerRect:GetHeight()) elseif home_pressed then - ImGui.SetScrollY(window, 0.0) + ImGui_SetScrollY(window, 0.0) elseif end_pressed then - ImGui.SetScrollY(window, window.ScrollMax.y) + ImGui_SetScrollY(window, window.ScrollMax.y) end else local nav_rect_rel = window.NavRectRel[g.NavLayer] local page_offset_y = ImMax(0.0, window.InnerRect:GetHeight() - window.FontRefSize * 1.0 + nav_rect_rel:GetHeight()) local nav_scoring_rect_offset_y = 0.0 - if ImGui.IsKeyPressedEx(517 --[[ImGuiKey.PageUp]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then + if ImGui_IsKeyPressedEx(517 --[[ImGuiKey.PageUp]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then nav_scoring_rect_offset_y = -page_offset_y g.NavMoveDir = 3 --[[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 = 2 --[[ImGuiDir.Up]] g.NavMoveFlags = bit32.bor(16 --[[ImGuiNavMoveFlags.AllowCurrentNavId]], 2048 --[[ImGuiNavMoveFlags.IsPageMove]]) -- ImGuiNavMoveFlags.AlsoScoreVisibleSet may be added later - elseif ImGui.IsKeyPressedEx(518 --[[ImGuiKey.PageDown]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then + elseif ImGui_IsKeyPressedEx(518 --[[ImGuiKey.PageDown]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) then nav_scoring_rect_offset_y = page_offset_y g.NavMoveDir = 2 --[[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 = 3 --[[ImGuiDir.Down]] @@ -17322,10 +17373,10 @@ function ImGui.NavUpdateCreateMoveRequest() g.NavMoveScrollFlags = 0 --[[ImGuiScrollFlags.None]] if window and not g.NavWindowingTarget and bit32.band(window.Flags, 65536 --[[ImGuiWindowFlags.NoNavInputs]]) == 0 then local repeat_mode = bit32.bor(1 --[[ImGuiInputFlags.Repeat]], 4 --[[ImGuiInputFlags.RepeatRateNavMove]]) - if not ImGui.IsActiveIdUsingNavDir(0 --[[ImGuiDir.Left]]) and ((nav_gamepad_active and ImGui.IsKeyPressedEx(638 --[[ImGuiKey.GamepadDpadLeft]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui.IsKeyPressedEx(513 --[[ImGuiKey.LeftArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 0 --[[ImGuiDir.Left]] end - if not ImGui.IsActiveIdUsingNavDir(1 --[[ImGuiDir.Right]]) and ((nav_gamepad_active and ImGui.IsKeyPressedEx(639 --[[ImGuiKey.GamepadDpadRight]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui.IsKeyPressedEx(514 --[[ImGuiKey.RightArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 1 --[[ImGuiDir.Right]] end - if not ImGui.IsActiveIdUsingNavDir(2 --[[ImGuiDir.Up]]) and ((nav_gamepad_active and ImGui.IsKeyPressedEx(640 --[[ImGuiKey.GamepadDpadUp]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui.IsKeyPressedEx(515 --[[ImGuiKey.UpArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 2 --[[ImGuiDir.Up]] end - if not ImGui.IsActiveIdUsingNavDir(3 --[[ImGuiDir.Down]]) and ((nav_gamepad_active and ImGui.IsKeyPressedEx(641 --[[ImGuiKey.GamepadDpadDown]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui.IsKeyPressedEx(516 --[[ImGuiKey.DownArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 3 --[[ImGuiDir.Down]] end + if not ImGui.IsActiveIdUsingNavDir(0 --[[ImGuiDir.Left]]) and ((nav_gamepad_active and ImGui_IsKeyPressedEx(638 --[[ImGuiKey.GamepadDpadLeft]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui_IsKeyPressedEx(513 --[[ImGuiKey.LeftArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 0 --[[ImGuiDir.Left]] end + if not ImGui.IsActiveIdUsingNavDir(1 --[[ImGuiDir.Right]]) and ((nav_gamepad_active and ImGui_IsKeyPressedEx(639 --[[ImGuiKey.GamepadDpadRight]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui_IsKeyPressedEx(514 --[[ImGuiKey.RightArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 1 --[[ImGuiDir.Right]] end + if not ImGui.IsActiveIdUsingNavDir(2 --[[ImGuiDir.Up]]) and ((nav_gamepad_active and ImGui_IsKeyPressedEx(640 --[[ImGuiKey.GamepadDpadUp]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui_IsKeyPressedEx(515 --[[ImGuiKey.UpArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 2 --[[ImGuiDir.Up]] end + if not ImGui.IsActiveIdUsingNavDir(3 --[[ImGuiDir.Down]]) and ((nav_gamepad_active and ImGui_IsKeyPressedEx(641 --[[ImGuiKey.GamepadDpadDown]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_keyboard_active and ImGui_IsKeyPressedEx(516 --[[ImGuiKey.DownArrow]], repeat_mode, 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) then g.NavMoveDir = 3 --[[ImGuiDir.Down]] end end g.NavMoveClipDir = g.NavMoveDir ImRect_Copy(g.NavScoringNoClipRect, ImRect(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]], -3.4028234663853e+38 --[[FLT_MAX]], -3.4028234663853e+38 --[[FLT_MAX]])) @@ -17360,7 +17411,7 @@ function ImGui.NavUpdateCreateMoveRequest() if g.NavMoveSubmitted and g.NavInputSource == 3 --[[ImGuiInputSource.Gamepad]] and g.NavLayer == 0 --[[ImGuiNavLayer.Main]] and window ~= nil then -- and (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded)) local clamp_x = bit32.band(g.NavMoveFlags, bit32.bor(1 --[[ImGuiNavMoveFlags.LoopX]], 4 --[[ImGuiNavMoveFlags.WrapX]])) == 0 local clamp_y = bit32.band(g.NavMoveFlags, bit32.bor(2 --[[ImGuiNavMoveFlags.LoopY]], 8 --[[ImGuiNavMoveFlags.WrapY]])) == 0 - local inner_rect_rel = ImGui.WindowRectAbsToRel(window, ImRect(ImVec2(window.InnerRect.Min.x - 1, window.InnerRect.Min.y - 1), ImVec2(window.InnerRect.Max.x + 1, window.InnerRect.Max.y + 1))) + local inner_rect_rel = ImGui_WindowRectAbsToRel(window, ImRect(ImVec2(window.InnerRect.Min.x - 1, window.InnerRect.Min.y - 1), ImVec2(window.InnerRect.Max.x + 1, window.InnerRect.Max.y + 1))) -- Take account of changing scroll to handle triggering a new move request on a scrolling frame. (#6171) -- Otherwise 'inner_rect_rel' would be off on the move result frame. @@ -17420,7 +17471,7 @@ function ImGui.NavUpdateCreateTabbingRequest() return end - local tab_pressed = ImGui.IsKeyPressedEx(512 --[[ImGuiKey.Tab]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) and not g.IO.KeyCtrl and not g.IO.KeyAlt + local tab_pressed = ImGui_IsKeyPressedEx(512 --[[ImGuiKey.Tab]], 1 --[[ImGuiInputFlags.Repeat]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) and not g.IO.KeyCtrl and not g.IO.KeyAlt if not tab_pressed then return end @@ -17453,7 +17504,7 @@ function ImGui.NavUpdate() local nav_gamepad_active = bit32.band(io.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0 and bit32.band(io.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0 if nav_gamepad_active and g.NavInputSource ~= 3 --[[ImGuiInputSource.Gamepad]] then for _, key in ipairs(nav_gamepad_keys_to_change_source) do - if ImGui.IsKeyDown(key) then + if ImGui_IsKeyDown(key) then g.NavInputSource = 3 --[[ImGuiInputSource.Gamepad]] end end @@ -17462,7 +17513,7 @@ function ImGui.NavUpdate() local nav_keyboard_active = bit32.band(io.ConfigFlags, 1 --[[ImGuiConfigFlags.NavEnableKeyboard]]) ~= 0 if nav_keyboard_active and g.NavInputSource ~= 2 --[[ImGuiInputSource.Keyboard]] then for _, key in ipairs(nav_keyboard_keys_to_change_source) do - if ImGui.IsKeyDown(key) then + if ImGui_IsKeyDown(key) then g.NavInputSource = 2 --[[ImGuiInputSource.Keyboard]] end end @@ -17529,12 +17580,12 @@ function ImGui.NavUpdate() g.NavActivateFlags = 0 --[[ImGuiActivateFlags.None]] if g.NavId ~= 0 and g.NavCursorVisible and not g.NavWindowingTarget and g.NavWindow and bit32.band(g.NavWindow.Flags, 65536 --[[ImGuiWindowFlags.NoNavInputs]]) == 0 then - local activate_down = (nav_keyboard_active and ImGui.IsKeyDown(524 --[[ImGuiKey.Space]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_gamepad_active and ImGui.IsKeyDown(ImGuiKey.NavGamepadActivate, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) - local activate_pressed = activate_down and ((nav_keyboard_active and ImGui.IsKeyPressedEx(524 --[[ImGuiKey.Space]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_gamepad_active and ImGui.IsKeyPressedEx(ImGuiKey.NavGamepadActivate, 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) - local input_pressed_keyboard = nav_keyboard_active and (ImGui.IsKeyPressedEx(525 --[[ImGuiKey.Enter]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) or ImGui.IsKeyPressedEx(627 --[[ImGuiKey.KeypadEnter]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) + local activate_down = (nav_keyboard_active and ImGui_IsKeyDown(524 --[[ImGuiKey.Space]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_gamepad_active and ImGui_IsKeyDown(ImGuiKey.NavGamepadActivate, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) + local activate_pressed = activate_down and ((nav_keyboard_active and ImGui_IsKeyPressedEx(524 --[[ImGuiKey.Space]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) or (nav_gamepad_active and ImGui_IsKeyPressedEx(ImGuiKey.NavGamepadActivate, 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]))) + local input_pressed_keyboard = nav_keyboard_active and (ImGui_IsKeyPressedEx(525 --[[ImGuiKey.Enter]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) or ImGui_IsKeyPressedEx(627 --[[ImGuiKey.KeypadEnter]], 0 --[[ImGuiInputFlags.None]], 4294967295 --[[ImGuiKeyOwner_NoOwner]])) local input_pressed_gamepad = false - if activate_down and nav_gamepad_active and ImGui.IsKeyDown(ImGuiKey.NavGamepadActivate, 4294967295 --[[ImGuiKeyOwner_NoOwner]]) and bit32.band(g.NavIdItemFlags, 1048576 --[[ImGuiItemFlags.Inputable]]) ~= 0 then -- requires ImGuiItemFlags.Inputable to avoid retriggering regular buttons. - if ImGui.GetKeyData(g, ImGuiKey.NavGamepadActivate).DownDurationPrev < 0.6 --[[NAV_ACTIVATE_INPUT_WITH_GAMEPAD_DELAY]] and ImGui.GetKeyData(g, ImGuiKey.NavGamepadActivate).DownDuration >= 0.6 --[[NAV_ACTIVATE_INPUT_WITH_GAMEPAD_DELAY]] then + if activate_down and nav_gamepad_active and ImGui_IsKeyDown(ImGuiKey.NavGamepadActivate, 4294967295 --[[ImGuiKeyOwner_NoOwner]]) and bit32.band(g.NavIdItemFlags, 1048576 --[[ImGuiItemFlags.Inputable]]) ~= 0 then -- requires ImGuiItemFlags.Inputable to avoid retriggering regular buttons. + if ImGui_GetKeyData(g, ImGuiKey.NavGamepadActivate).DownDurationPrev < 0.6 --[[NAV_ACTIVATE_INPUT_WITH_GAMEPAD_DELAY]] and ImGui_GetKeyData(g, ImGuiKey.NavGamepadActivate).DownDuration >= 0.6 --[[NAV_ACTIVATE_INPUT_WITH_GAMEPAD_DELAY]] then input_pressed_gamepad = true end end @@ -17587,7 +17638,7 @@ function ImGui.NavUpdate() if g.NavMoveDir == (-1) --[[ImGuiDir.None]] then ImGui.NavUpdateCreateTabbingRequest() end - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavUpdateAnyRequestFlag() g.NavIdIsAlive = false -- Scrolling @@ -17603,7 +17654,7 @@ function ImGui.NavUpdate() end if move_dir == 2 --[[ImGuiDir.Up]] or move_dir == 3 --[[ImGuiDir.Down]] then local delta = (move_dir == 2 --[[ImGuiDir.Up]]) and -1.0 or 1.0 - ImGui.SetScrollY(window, ImTrunc(window.Scroll.y + delta * scroll_speed)) + ImGui_SetScrollY(window, ImTrunc(window.Scroll.y + delta * scroll_speed)) end end @@ -17612,16 +17663,16 @@ function ImGui.NavUpdate() if nav_gamepad_active then local scroll_dir = ImGui.GetKeyMagnitude2d(648 --[[ImGuiKey.GamepadLStickLeft]], 649 --[[ImGuiKey.GamepadLStickRight]], 650 --[[ImGuiKey.GamepadLStickUp]], 651 --[[ImGuiKey.GamepadLStickDown]]) local tweak_factor = 1.0 - if ImGui.IsKeyDown(642 --[[ImGuiKey.NavGamepadTweakSlow]]) then + if ImGui_IsKeyDown(642 --[[ImGuiKey.NavGamepadTweakSlow]]) then tweak_factor = 1.0 / 10.0 - elseif ImGui.IsKeyDown(643 --[[ImGuiKey.NavGamepadTweakFast]]) then + elseif ImGui_IsKeyDown(643 --[[ImGuiKey.NavGamepadTweakFast]]) then tweak_factor = 10.0 end if scroll_dir.x ~= 0.0 and window.ScrollbarX then ImGui.SetScrollX(window, ImTrunc(window.Scroll.x + scroll_dir.x * scroll_speed * tweak_factor)) end if scroll_dir.y ~= 0.0 then - ImGui.SetScrollY(window, ImTrunc(window.Scroll.y + scroll_dir.y * scroll_speed * tweak_factor)) + ImGui_SetScrollY(window, ImTrunc(window.Scroll.y + scroll_dir.y * scroll_speed * tweak_factor)) end end end @@ -17653,28 +17704,28 @@ function ImGui.NavUpdateCancelRequest() local g = GImGui local nav_gamepad_active = bit32.band(g.IO.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0 and bit32.band(g.IO.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0 local nav_keyboard_active = bit32.band(g.IO.ConfigFlags, 1 --[[ImGuiConfigFlags.NavEnableKeyboard]]) ~= 0 - if not (nav_keyboard_active and ImGui.IsKeyPressedEx(526 --[[ImGuiKey.Escape]], 0, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) and not (nav_gamepad_active and ImGui.IsKeyPressedEx(ImGuiKey.NavGamepadCancel, 0, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) then + if not (nav_keyboard_active and ImGui_IsKeyPressedEx(526 --[[ImGuiKey.Escape]], 0, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) and not (nav_gamepad_active and ImGui_IsKeyPressedEx(ImGuiKey.NavGamepadCancel, 0, 4294967295 --[[ImGuiKeyOwner_NoOwner]])) then return end -- IMGUI_DEBUG_LOG_NAV("[nav] NavUpdateCancelRequest()") if g.ActiveId ~= 0 then - ImGui.ClearActiveID() + ImGui_ClearActiveID() elseif g.NavLayer ~= 0 --[[ImGuiNavLayer.Main]] then -- Leave the "menu" layer ImGui.NavRestoreLayer(0 --[[ImGuiNavLayer.Main]]) - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() elseif g.NavWindow and g.NavWindow ~= g.NavWindow.RootWindow and bit32.band(g.NavWindow.RootWindowForNav.Flags, 67108864 --[[ImGuiWindowFlags.Popup]]) == 0 and g.NavWindow.RootWindowForNav.ParentWindow then -- Exit child window local child_window = g.NavWindow.RootWindowForNav local parent_window = child_window.ParentWindow assert(child_window.ChildId ~= 0) - ImGui.FocusWindow(parent_window) - ImGui.SetNavID(child_window.ChildId, 0 --[[ImGuiNavLayer.Main]], 0, ImGui.WindowRectAbsToRel(parent_window, child_window:Rect())) - ImGui.SetNavCursorVisibleAfterMove() + ImGui_FocusWindow(parent_window) + ImGui_SetNavID(child_window.ChildId, 0 --[[ImGuiNavLayer.Main]], 0, ImGui_WindowRectAbsToRel(parent_window, child_window:Rect())) + ImGui_SetNavCursorVisibleAfterMove() elseif g.OpenPopupStack.Size > 0 and g.OpenPopupStack:back().Window ~= nil and bit32.band(g.OpenPopupStack:back().Window.Flags, 134217728 --[[ImGuiWindowFlags.Modal]]) == 0 then -- Close open popup/menu - ImGui.ClosePopupToLevel(g.OpenPopupStack.Size - 1, true) + ImGui_ClosePopupToLevel(g.OpenPopupStack.Size - 1, true) else -- Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were -- FIXME-NAV: This should happen on window appearing. @@ -17689,7 +17740,7 @@ function ImGui.NavUpdateCancelRequest() g.NavId = 0 end if g.IO.ConfigNavEscapeClearFocusWindow then - ImGui.FocusWindow(nil) + ImGui_FocusWindow(nil) end end end @@ -17833,7 +17884,7 @@ function ImGui.NavApplyItemToResult(result) result.ID = g.LastItemData.ID result.FocusScopeId = g.CurrentFocusScopeId result.ItemFlags = g.LastItemData.ItemFlags - ImRect_Copy(result.RectRel, ImGui.WindowRectAbsToRel(window, g.LastItemData.NavRect)) + ImRect_Copy(result.RectRel, ImGui_WindowRectAbsToRel(window, g.LastItemData.NavRect)) if bit32.band(result.ItemFlags, 2097152 --[[ImGuiItemFlags.HasSelectionUserData]]) ~= 0 then assert(g.NextItemData.SelectionUserData ~= (-1) --[[ImGuiSelectionUserData_Invalid]]) result.SelectionUserData = g.NextItemData.SelectionUserData -- INTENTIONAL: At this point this field is not cleared in NextItemData. Avoid unnecessary copy to LastItemData. @@ -17844,8 +17895,8 @@ end function ImGui.NavMoveRequestResolveWithLastItem(result) local g = GImGui g.NavMoveScoringItems = false -- Ensure request doesn't need more processing - ImGui.NavApplyItemToResult(result) - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavApplyItemToResult(result) + ImGui_NavUpdateAnyRequestFlag() end -- Handle "scoring" of an item for a tabbing/focusing request initiated by NavUpdateCreateTabbingRequest(). @@ -17885,7 +17936,7 @@ function ImGui.NavProcessItemForTabbingRequest(id, item_flags, move_flags) if g.NavTabbingDir == 1 then -- Tab Forward or SetKeyboardFocusHere() with >= 0 if can_stop and g.NavTabbingResultFirst.ID == 0 then - ImGui.NavApplyItemToResult(g.NavTabbingResultFirst) + ImGui_NavApplyItemToResult(g.NavTabbingResultFirst) end if can_stop and g.NavTabbingCounter > 0 then g.NavTabbingCounter = g.NavTabbingCounter - 1 @@ -17900,18 +17951,18 @@ function ImGui.NavProcessItemForTabbingRequest(id, item_flags, move_flags) if g.NavId == id then if result.ID ~= 0 then g.NavMoveScoringItems = false - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavUpdateAnyRequestFlag() end elseif can_stop then -- Keep applying until reaching NavId - ImGui.NavApplyItemToResult(result) + ImGui_NavApplyItemToResult(result) end elseif g.NavTabbingDir == 0 then if can_stop and g.NavId == id then ImGui.NavMoveRequestResolveWithLastItem(result) end if can_stop and g.NavTabbingResultFirst.ID == 0 then -- Tab init - ImGui.NavApplyItemToResult(g.NavTabbingResultFirst) + ImGui_NavApplyItemToResult(g.NavTabbingResultFirst) end end end @@ -17937,11 +17988,11 @@ function ImGui.NavProcessItem() -- Even if 'ImGuiItemFlags.NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback local candidate_for_nav_default_focus = bit32.band(item_flags, 4 --[[ImGuiItemFlags.NoNavDefaultFocus]]) == 0 if candidate_for_nav_default_focus or g.NavInitResult.ID == 0 then - ImGui.NavApplyItemToResult(g.NavInitResult) + ImGui_NavApplyItemToResult(g.NavInitResult) end if candidate_for_nav_default_focus then g.NavInitRequest = false -- Found a match, clear request - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavUpdateAnyRequestFlag() end end @@ -17955,7 +18006,7 @@ function ImGui.NavProcessItem() elseif g.NavId ~= id or bit32.band(g.NavMoveFlags, 16 --[[ImGuiNavMoveFlags.AllowCurrentNavId]]) ~= 0 then local result = (window == g.NavWindow) and g.NavMoveResultLocal or g.NavMoveResultOther if ImGui.NavScoreItem(result, nav_bb) then - ImGui.NavApplyItemToResult(result) + ImGui_NavApplyItemToResult(result) end -- Features like PageUp/PageDown need to maintain a separate score for the visible set of items. @@ -17965,7 +18016,7 @@ function ImGui.NavProcessItem() if r:Overlaps(nav_bb) then if ImClamp(nav_bb.Max.y, r.Min.y, r.Max.y) - ImClamp(nav_bb.Min.y, r.Min.y, r.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO then if ImGui.NavScoreItem(g.NavMoveResultLocalVisible, nav_bb) then - ImGui.NavApplyItemToResult(g.NavMoveResultLocalVisible) + ImGui_NavApplyItemToResult(g.NavMoveResultLocalVisible) end end end @@ -17977,10 +18028,10 @@ function ImGui.NavProcessItem() -- Update information for currently focused/navigated item if g.NavId == id then if g.NavWindow ~= window then - ImGui.SetNavWindow(window) -- Always refresh g.NavWindow, because some operations such as FocusItem() may not have a window. + ImGui_SetNavWindow(window) -- Always refresh g.NavWindow, because some operations such as FocusItem() may not have a window. end g.NavLayer = window.DC.NavLayerCurrent - ImGui.SetNavFocusScope(g.CurrentFocusScopeId) -- Will set g.NavFocusScopeId AND store g.NavFocusScopePath + ImGui_SetNavFocusScope(g.CurrentFocusScopeId) -- Will set g.NavFocusScopeId AND store g.NavFocusScopePath g.NavFocusScopeId = g.CurrentFocusScopeId g.NavIdIsAlive = true g.NavIdItemFlags = item_flags @@ -17988,7 +18039,7 @@ function ImGui.NavProcessItem() assert(g.NextItemData.SelectionUserData ~= (-1) --[[ImGuiSelectionUserData_Invalid]]) g.NavLastValidSelectionUserData = g.NextItemData.SelectionUserData -- INTENTIONAL: At this point this field is not cleared in NextItemData. Avoid unnecessary copy to LastItemData. end - window.NavRectRel[window.DC.NavLayerCurrent] = ImGui.WindowRectAbsToRel(window, nav_bb) -- Store item bounding box (relative to window position) + window.NavRectRel[window.DC.NavLayerCurrent] = ImGui_WindowRectAbsToRel(window, nav_bb) -- Store item bounding box (relative to window position) end end @@ -18013,13 +18064,13 @@ function ImGui.NavInitRequestApplyResult() -- 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. -- [Port] IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: ApplyResult: NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name) - ImGui.SetNavID(result.ID, g.NavLayer, result.FocusScopeId, result.RectRel) + ImGui_SetNavID(result.ID, g.NavLayer, result.FocusScopeId, result.RectRel) g.NavIdIsAlive = true -- Mark as alive from previous frame as we got a result if result.SelectionUserData ~= (-1) --[[ImGuiSelectionUserData_Invalid]] then g.NavLastValidSelectionUserData = result.SelectionUserData end if g.NavInitRequestFromMove then - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() end end @@ -18051,9 +18102,9 @@ function ImGui.NavMoveRequestApplyResult() g.NavMoveFlags = bit32.bor(g.NavMoveFlags, 16384 --[[ImGuiNavMoveFlags.NoSetNavCursorVisible]]) end if g.NavId ~= 0 and bit32.band(g.NavMoveFlags, 16384 --[[ImGuiNavMoveFlags.NoSetNavCursorVisible]]) == 0 then - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() end - ImGui.NavClearPreferredPosForAxis(axis) -- On a failed move, clear preferred pos for this axis. + ImGui_NavClearPreferredPosForAxis(axis) -- On a failed move, clear preferred pos for this axis. -- [Port] IMGUI_DEBUG_LOG_NAV("[nav] NavMoveSubmitted but not led to a result!\n") return end @@ -18076,12 +18127,12 @@ function ImGui.NavMoveRequestApplyResult() -- Scroll to keep newly navigated item fully into view. if g.NavLayer == 0 --[[ImGuiNavLayer.Main]] then local rect_abs = ImGui.WindowRectRelToAbs(result.Window, result.RectRel) - ImGui.ScrollToRectEx(result.Window, rect_abs, g.NavMoveScrollFlags) + ImGui_ScrollToRectEx(result.Window, rect_abs, g.NavMoveScrollFlags) if bit32.band(g.NavMoveFlags, 64 --[[ImGuiNavMoveFlags.ScrollToEdgeY]]) ~= 0 then -- FIXME: Should remove this? Or make more precise: use ScrollToRectEx() with edge? local scroll_target = (g.NavMoveDir == 2 --[[ImGuiDir.Up]]) and result.Window.ScrollMax.y or 0.0 - ImGui.SetScrollY(result.Window, scroll_target) + ImGui_SetScrollY(result.Window, scroll_target) end end @@ -18095,7 +18146,7 @@ function ImGui.NavMoveRequestApplyResult() -- FIXME: ImGuiNavMoveFlags.NoClearActiveId is currently unused as we don't have a clear strategy to preserve active id after interaction, -- so this is mostly provided as a gateway for further experiments (see #1418, #2890) if g.ActiveId ~= result.ID and bit32.band(g.NavMoveFlags, 32768 --[[ImGuiNavMoveFlags.NoClearActiveId]]) == 0 then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end -- Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags.AllowCurrentNavId) @@ -18117,7 +18168,7 @@ function ImGui.NavMoveRequestApplyResult() local root_for_nav = g.NavWindow.RootWindowForNav local preferred_scoring_pos_rel = ImVec2() ImVec2_Copy(preferred_scoring_pos_rel, root_for_nav.NavPreferredScoringPosRel[g.NavLayer]) - ImGui.SetNavID(result.ID, g.NavLayer, result.FocusScopeId, result.RectRel) + ImGui_SetNavID(result.ID, g.NavLayer, result.FocusScopeId, result.RectRel) if result.SelectionUserData ~= (-1) --[[ImGuiSelectionUserData_Invalid]] then g.NavLastValidSelectionUserData = result.SelectionUserData end @@ -18149,7 +18200,7 @@ function ImGui.NavMoveRequestApplyResult() -- Make nav cursor visible if bit32.band(g.NavMoveFlags, 16384 --[[ImGuiNavMoveFlags.NoSetNavCursorVisible]]) == 0 then - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() end end @@ -18170,16 +18221,16 @@ function ImGui.NavMoveRequestResolveWithPastTreeNode(result, tree_node_data) g.LastItemData.ID = tree_node_data.ID g.LastItemData.ItemFlags = bit32.band(tree_node_data.ItemFlags, bit32.bnot(2097152 --[[ImGuiItemFlags.HasSelectionUserData]])) -- Losing SelectionUserData, recovered next-frame (cheaper). ImRect_Copy(g.LastItemData.NavRect, tree_node_data.NavRect) - ImGui.NavApplyItemToResult(result) -- Result this instead of implementing a NavApplyPastTreeNodeToResult() - ImGui.NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavApplyItemToResult(result) -- Result this instead of implementing a NavApplyPastTreeNodeToResult() + ImGui_NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) + ImGui_NavUpdateAnyRequestFlag() end function ImGui.NavMoveRequestCancel() local g = GImGui g.NavMoveSubmitted = false g.NavMoveScoringItems = false - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavUpdateAnyRequestFlag() end -- Forward will reuse the move request again on the next frame (generally with modifications done to it) @@ -18463,7 +18514,7 @@ function ImGui.UpdateTryMergeWindowIntoHostViewport(window, viewport_dst) ImGui.SetWindowViewport(window, viewport_dst) if bit32.band(window.Flags, 8192 --[[ImGuiWindowFlags.NoBringToFrontOnFocus]]) == 0 then - ImGui.BringWindowToDisplayFront(window) + ImGui_BringWindowToDisplayFront(window) end return true @@ -18568,7 +18619,7 @@ function ImGui.UpdateViewportsNewFrame() -- Focused viewport has changed? if focused_viewport and g.PlatformLastFocusedViewportId ~= focused_viewport.ID then IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Focused viewport changed %08X -> %08X '%s', attempting to apply our focus.", g.PlatformLastFocusedViewportId, focused_viewport.ID, focused_viewport.Window and focused_viewport.Window.Name or "n/a") - local prev_focused_viewport = ImGui.FindViewportByID(g.PlatformLastFocusedViewportId) + local prev_focused_viewport = ImGui_FindViewportByID(g.PlatformLastFocusedViewportId) local prev_focused_has_been_destroyed = (prev_focused_viewport == nil) or (not prev_focused_viewport.PlatformWindowCreated) -- Store a tag so we can infer z-order easily from all our windows @@ -18590,11 +18641,11 @@ function ImGui.UpdateViewportsNewFrame() local focus_request_flags = bit32.bor(2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]], 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) if focused_viewport.Window ~= nil then - ImGui.FocusWindow(focused_viewport.Window, focus_request_flags) + ImGui_FocusWindow(focused_viewport.Window, focus_request_flags) elseif focused_viewport.LastFocusedHadNavWindow then ImGui.FocusTopMostWindowUnderOne(nil, nil, focused_viewport, focus_request_flags) -- Focus top most in viewport else - ImGui.FocusWindow(nil, focus_request_flags) -- No window had focus last time viewport was focused + ImGui_FocusWindow(nil, focus_request_flags) -- No window had focus last time viewport was focused end end end @@ -18625,7 +18676,7 @@ function ImGui.UpdateViewportsNewFrame() main_viewport_framebuffer_scale = main_viewport.FramebufferScale end - ImGui.AddUpdateViewport(nil, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_pos, main_viewport_size, bit32.bor(4 --[[ImGuiViewportFlags.OwnedByApp]], 2048 --[[ImGuiViewportFlags.CanHostOtherWindows]])) + ImGui_AddUpdateViewport(nil, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_pos, main_viewport_size, bit32.bor(4 --[[ImGuiViewportFlags.OwnedByApp]], 2048 --[[ImGuiViewportFlags.CanHostOtherWindows]])) local memory_compact_start_time = (g.GcCompactAll or g.IO.ConfigMemoryCompactTimer < 0.0) and 3.4028234663853e+38 --[[FLT_MAX]] or (g.Time - g.IO.ConfigMemoryCompactTimer) @@ -18767,7 +18818,7 @@ function ImGui.UpdateViewportsNewFrame() local viewport_hovered = nil if bit32.band(g.IO.BackendFlags, 4096 --[[ImGuiBackendFlags.HasMouseHoveredViewport]]) ~= 0 then - viewport_hovered = g.IO.MouseHoveredViewport and ImGui.FindViewportByID(g.IO.MouseHoveredViewport) or nil + viewport_hovered = g.IO.MouseHoveredViewport and ImGui_FindViewportByID(g.IO.MouseHoveredViewport) or nil if viewport_hovered and (bit32.band(viewport_hovered.Flags, 128 --[[ImGuiViewportFlags.NoInputs]]) ~= 0) then viewport_hovered = ImGui.FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos) -- Backend failed to handle _NoInputs viewport: revert to our fallback. end @@ -18827,7 +18878,7 @@ function ImGui.UpdateViewportsEndFrame() if (viewport.LastFrameActive < g.FrameCount or viewport.Size.x <= 0.0 or viewport.Size.y <= 0.0) and (i > 1) then -- Always include main viewport in the list break end - if viewport.Window and not ImGui.IsWindowActiveAndVisible(viewport.Window) then + if viewport.Window and not ImGui_IsWindowActiveAndVisible(viewport.Window) then break end if i > 1 then @@ -18866,7 +18917,7 @@ function ImGui.AddUpdateViewport(window, id, pos, size, flags) end end - local viewport = ImGui.FindViewportByID(id) + local viewport = ImGui_FindViewportByID(id) if viewport then --- @cast viewport ImGuiViewportP @@ -18966,7 +19017,7 @@ function ImGui.WindowSelectViewport(window) window.ViewportAllowPlatformMonitorExtend = -1 -- Restore main viewport if multi-viewport is not supported by the backend - local main_viewport = ImGui.GetMainViewport() --[[@as ImGuiViewportP]] + local main_viewport = ImGui_GetMainViewport() --[[@as ImGuiViewportP]] if bit32.band(g.ConfigFlagsCurrFrame, 1024 --[[ImGuiConfigFlags.ViewportsEnable]]) == 0 then ImGui.SetWindowViewport(window, main_viewport) return @@ -18987,9 +19038,9 @@ function ImGui.WindowSelectViewport(window) -- Attempt to restore saved viewport id (= window that hasn't been activated yet), try to restore the viewport based on saved 'window->ViewportPos' restored from .ini file if window.Viewport == nil and window.ViewportId ~= 0 then - window.Viewport = ImGui.FindViewportByID(window.ViewportId) --[[@as ImGuiViewportP]] + window.Viewport = ImGui_FindViewportByID(window.ViewportId) --[[@as ImGuiViewportP]] if window.Viewport == nil and window.ViewportPos.x ~= 3.4028234663853e+38 --[[FLT_MAX]] and window.ViewportPos.y ~= 3.4028234663853e+38 --[[FLT_MAX]] then - window.Viewport = ImGui.AddUpdateViewport(window, window.ID, window.ViewportPos, window.Size, 0 --[[ImGuiViewportFlags.None]]) + window.Viewport = ImGui_AddUpdateViewport(window, window.ID, window.ViewportPos, window.Size, 0 --[[ImGuiViewportFlags.None]]) end end end @@ -18997,7 +19048,7 @@ function ImGui.WindowSelectViewport(window) local lock_viewport = false if bit32.band(g.NextWindowData.HasFlags, 2048 --[[ImGuiNextWindowDataFlags.HasViewport]]) ~= 0 then -- Code explicitly request a viewport - window.Viewport = ImGui.FindViewportByID(g.NextWindowData.ViewportId) --[[@as ImGuiViewportP]] + window.Viewport = ImGui_FindViewportByID(g.NextWindowData.ViewportId) --[[@as ImGuiViewportP]] window.ViewportId = g.NextWindowData.ViewportId -- Store ID even if Viewport isn't resolved yet. if window.Viewport and bit32.band(window.Flags, 8388608 --[[ImGuiWindowFlags.DockNodeHost]]) ~= 0 and window.Viewport.Window ~= nil then window.Viewport.Window = window @@ -19017,10 +19068,10 @@ function ImGui.WindowSelectViewport(window) elseif bit32.band(flags, 33554432 --[[ImGuiWindowFlags.Tooltip]]) ~= 0 then window.Viewport = g.MouseViewport elseif ImGui.GetWindowAlwaysWantOwnViewport(window) then - window.Viewport = ImGui.AddUpdateViewport(window, window.ID, window.Pos, window.Size, 0 --[[ImGuiViewportFlags.None]]) - elseif g.MovingWindow and g.MovingWindow.RootWindowDockTree == window and ImGui.IsMousePosValid() then + window.Viewport = ImGui_AddUpdateViewport(window, window.ID, window.Pos, window.Size, 0 --[[ImGuiViewportFlags.None]]) + elseif g.MovingWindow and g.MovingWindow.RootWindowDockTree == window and ImGui_IsMousePosValid() then if window.Viewport ~= nil and window.Viewport.Window == window then - window.Viewport = ImGui.AddUpdateViewport(window, window.ID, window.Pos, window.Size, 0 --[[ImGuiViewportFlags.None]]) + window.Viewport = ImGui_AddUpdateViewport(window, window.ID, window.Pos, window.Size, 0 --[[ImGuiViewportFlags.None]]) end else -- Merge into host viewport? @@ -19036,7 +19087,7 @@ function ImGui.WindowSelectViewport(window) if window.Viewport == nil then --- @cast main_viewport ImGuiViewportP if not ImGui.UpdateTryMergeWindowIntoHostViewport(window, main_viewport) then - window.Viewport = ImGui.AddUpdateViewport(window, window.ID, window.Pos, window.Size, 0 --[[ImGuiViewportFlags.None]]) + window.Viewport = ImGui_AddUpdateViewport(window, window.ID, window.Pos, window.Size, 0 --[[ImGuiViewportFlags.None]]) end end @@ -19047,7 +19098,7 @@ function ImGui.WindowSelectViewport(window) -- Popups/Tooltip always set ViewportAllowPlatformMonitorExtend so GetWindowAllowedExtentRect() will return full monitor bounds. local mouse_ref = bit32.band(flags, 33554432 --[[ImGuiWindowFlags.Tooltip]]) ~= 0 and g.IO.MousePos or g.BeginPopupStack.Data[g.BeginPopupStack.Size].OpenMousePos local use_mouse_ref = not g.NavCursorVisible or not g.NavHighlightItemUnderNav or not g.NavWindow - local mouse_valid = ImGui.IsMousePosValid(mouse_ref) + local mouse_valid = ImGui_IsMousePosValid(mouse_ref) if (window.Appearing or bit32.band(flags, bit32.bor(33554432 --[[ImGuiWindowFlags.Tooltip]], 268435456 --[[ImGuiWindowFlags.ChildMenu]])) ~= 0) and (not use_mouse_ref or mouse_valid) then local pos_to_use = (use_mouse_ref and mouse_valid) and mouse_ref or ImGui.NavCalcPreferredRefPos(window.Flags) window.ViewportAllowPlatformMonitorExtend = ImGui.FindPlatformMonitorForPos(pos_to_use) @@ -19065,7 +19116,7 @@ function ImGui.WindowSelectViewport(window) window.Viewport.LastNameHash = 0 elseif not ImGui.UpdateTryMergeWindowIntoHostViewports(window) then -- Merge? -- New viewport - window.Viewport = ImGui.AddUpdateViewport(window, window.ID, window.Pos, window.Size, 32 --[[ImGuiViewportFlags.NoFocusOnAppearing]]) + window.Viewport = ImGui_AddUpdateViewport(window, window.ID, window.Pos, window.Size, 32 --[[ImGuiViewportFlags.NoFocusOnAppearing]]) end elseif window.ViewportAllowPlatformMonitorExtend < 0 and bit32.band(flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) == 0 then -- Regular (non-child, non-popup) windows by default are also allowed to protrude @@ -19173,7 +19224,7 @@ function ImGui.WindowSyncOwnedViewport(window, parent_window_in_stack) local old_parent_viewport_id = window.Viewport.ParentViewportId window.Viewport.ParentViewportId = window.WindowClass.ParentViewportId if window.Viewport.ParentViewportId ~= old_parent_viewport_id then - window.Viewport.ParentViewport = ImGui.FindViewportByID(window.Viewport.ParentViewportId) --[[@as ImGuiViewport]] + window.Viewport.ParentViewport = ImGui_FindViewportByID(window.Viewport.ParentViewportId) --[[@as ImGuiViewport]] end elseif bit32.band(window_flags, bit32.bor(67108864 --[[ImGuiWindowFlags.Popup]], 33554432 --[[ImGuiWindowFlags.Tooltip]])) ~= 0 and parent_window_in_stack and (not parent_window_in_stack.IsFallbackWindow or parent_window_in_stack.WasActive) then window.Viewport.ParentViewport = parent_window_in_stack.Viewport @@ -19182,7 +19233,7 @@ function ImGui.WindowSyncOwnedViewport(window, parent_window_in_stack) if g.IO.ConfigViewportsNoDefaultParent then window.Viewport.ParentViewport = nil else - window.Viewport.ParentViewport = ImGui.GetMainViewport() + window.Viewport.ParentViewport = ImGui_GetMainViewport() end window.Viewport.ParentViewportId = g.IO.ConfigViewportsNoDefaultParent and 0 or IMGUI_VIEWPORT_DEFAULT_ID end @@ -19209,7 +19260,7 @@ function ImGui.UpdatePlatformWindows() -- (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy DestroyPlatformWindow to be made each frame) local destroy_platform_window = false destroy_platform_window = destroy_platform_window or (viewport.LastFrameActive < g.FrameCount - 1) - destroy_platform_window = destroy_platform_window or (viewport.Window and not ImGui.IsWindowActiveAndVisible(viewport.Window)) --[[@as bool]] + destroy_platform_window = destroy_platform_window or (viewport.Window and not ImGui_IsWindowActiveAndVisible(viewport.Window)) --[[@as bool]] if destroy_platform_window then ImGui.DestroyPlatformWindow(viewport) break @@ -19255,7 +19306,7 @@ function ImGui.UpdatePlatformWindows() if window_for_title ~= nil then local title = window_for_title.Name local title_begin = 1 - local title_end = ImGui.FindRenderedTextEnd(title) + local title_end = ImGui_FindRenderedTextEnd(title) local title_hash = ImHashStr(title, title_end - title_begin) if viewport.LastNameHash ~= title_hash then -- [Port] This still creates new strings @@ -19470,7 +19521,7 @@ function ImGui.DebugRenderViewportThumbnail(draw_list, viewport, bb) local scale = bb:GetSize() / viewport.Size local off = bb.Min - viewport.Pos * scale local alpha_mul = (bit32.band(viewport.Flags, 4096 --[[ImGuiViewportFlags.IsMinimized]]) ~= 0) and 0.30 or 1.00 - window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui.GetColorU32(5 --[[ImGuiCol.Border]], alpha_mul * 0.40)) + window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui_GetColorU32(5 --[[ImGuiCol.Border]], alpha_mul * 0.40)) for _, thumb_window in g.Windows:iter() do repeat @@ -19488,15 +19539,15 @@ function ImGui.DebugRenderViewportThumbnail(draw_list, viewport, bb) thumb_r:ClipWithFull(bb) title_r:ClipWithFull(bb) local window_is_focused = g.NavWindow and thumb_window.RootWindowForTitleBarHighlight == g.NavWindow.RootWindowForTitleBarHighlight - window.DrawList:AddRectFilled(thumb_r.Min, thumb_r.Max, ImGui.GetColorU32(2 --[[ImGuiCol.WindowBg]], alpha_mul)) - window.DrawList:AddRectFilled(title_r.Min, title_r.Max, ImGui.GetColorU32(window_is_focused and 11 --[[ImGuiCol.TitleBgActive]] or 10 --[[ImGuiCol.TitleBg]], alpha_mul)) - window.DrawList:AddRect(thumb_r.Min, thumb_r.Max, ImGui.GetColorU32(5 --[[ImGuiCol.Border]], alpha_mul)) - window.DrawList:AddText(g.Font, g.FontSize * 1.0, title_r.Min, ImGui.GetColorU32(0 --[[ImGuiCol.Text]], alpha_mul), thumb_window.Name, 1, ImGui.FindRenderedTextEnd(thumb_window.Name)) + window.DrawList:AddRectFilled(thumb_r.Min, thumb_r.Max, ImGui_GetColorU32(2 --[[ImGuiCol.WindowBg]], alpha_mul)) + window.DrawList:AddRectFilled(title_r.Min, title_r.Max, ImGui_GetColorU32(window_is_focused and 11 --[[ImGuiCol.TitleBgActive]] or 10 --[[ImGuiCol.TitleBg]], alpha_mul)) + window.DrawList:AddRect(thumb_r.Min, thumb_r.Max, ImGui_GetColorU32(5 --[[ImGuiCol.Border]], alpha_mul)) + window.DrawList:AddText(g.Font, g.FontSize * 1.0, title_r.Min, ImGui_GetColorU32(0 --[[ImGuiCol.Text]], alpha_mul), thumb_window.Name, 1, ImGui_FindRenderedTextEnd(thumb_window.Name)) until true end - draw_list:AddRect(bb.Min, bb.Max, ImGui.GetColorU32(5 --[[ImGuiCol.Border]], alpha_mul)) + draw_list:AddRect(bb.Min, bb.Max, ImGui_GetColorU32(5 --[[ImGuiCol.Border]], alpha_mul)) if viewport.ID == g.DebugMetricsConfig.HighlightViewportID then window.DrawList:AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)) end @@ -19517,8 +19568,8 @@ function ImGui.RenderViewportsThumbnails() local off = p - bb_full.Min * SCALE for _, monitor in g.PlatformIO.Monitors:iter() do local monitor_draw_bb = ImRect(off + monitor.MainPos * SCALE, off + (monitor.MainPos + monitor.MainSize) * SCALE) - window.DrawList:AddRect(monitor_draw_bb.Min, monitor_draw_bb.Max, (g.DebugMetricsConfig.HighlightMonitorIdx == g.PlatformIO.Monitors:index_from_ptr(monitor)) and IM_COL32(255, 255, 0, 255) or ImGui.GetColorU32(5 --[[ImGuiCol.Border]]), 4.0) - window.DrawList:AddRectFilled(monitor_draw_bb.Min, monitor_draw_bb.Max, ImGui.GetColorU32(5 --[[ImGuiCol.Border]], 0.10), 4.0) + window.DrawList:AddRect(monitor_draw_bb.Min, monitor_draw_bb.Max, (g.DebugMetricsConfig.HighlightMonitorIdx == g.PlatformIO.Monitors:index_from_ptr(monitor)) and IM_COL32(255, 255, 0, 255) or ImGui_GetColorU32(5 --[[ImGuiCol.Border]]), 4.0) + window.DrawList:AddRectFilled(monitor_draw_bb.Min, monitor_draw_bb.Max, ImGui_GetColorU32(5 --[[ImGuiCol.Border]], 0.10), 4.0) end -- Draw viewports @@ -19595,8 +19646,8 @@ function ImGui.FindBottomMostVisibleWindowWithinBeginStack(parent_window) for i = ImGui.FindWindowDisplayIndex(parent_window), 0, -1 do local window = g.Windows.Data[i + 1] if bit32.band(window.Flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) == 0 then - if not ImGui.IsWindowWithinBeginStackOf(window, parent_window) then break end - if ImGui.IsWindowActiveAndVisible(window) and GetWindowDisplayLayer(window) <= GetWindowDisplayLayer(parent_window) then + if not ImGui_IsWindowWithinBeginStackOf(window, parent_window) then break end + if ImGui_IsWindowActiveAndVisible(window) and GetWindowDisplayLayer(window) <= GetWindowDisplayLayer(parent_window) then bottom_most_visible_window = window end end @@ -19609,7 +19660,7 @@ function ImGui.GetTopMostAndVisiblePopupModal() local g = GImGui for n = g.OpenPopupStack.Size, 1, -1 do local popup = g.OpenPopupStack.Data[n].Window - if popup and bit32.band(popup.Flags, 134217728 --[[ImGuiWindowFlags.Modal]]) ~= 0 and ImGui.IsWindowActiveAndVisible(popup) then + if popup and bit32.band(popup.Flags, 134217728 --[[ImGuiWindowFlags.Modal]]) ~= 0 and ImGui_IsWindowActiveAndVisible(popup) then return popup end end @@ -19648,12 +19699,12 @@ function ImGui.RenderDimmedBackgrounds() if dim_bg_for_modal then -- Draw dimming behind modal or a begin stack child, whichever comes first in draw order. local dim_behind_window = ImGui.FindBottomMostVisibleWindowWithinBeginStack(modal_window) - ImGui.RenderDimmedBackgroundBehindWindow(dim_behind_window, ImGui.GetColorU32(modal_window.DC.ModalDimBgColor, g.DimBgRatio, true)) + ImGui.RenderDimmedBackgroundBehindWindow(dim_behind_window, ImGui_GetColorU32(modal_window.DC.ModalDimBgColor, g.DimBgRatio, true)) elseif dim_bg_for_window_list then -- Draw dimming behind Ctrl+Tab target window and behind Ctrl+Tab UI window - ImGui.RenderDimmedBackgroundBehindWindow(g.NavWindowingTargetAnim, ImGui.GetColorU32(61 --[[ImGuiCol.NavWindowingDimBg]], g.DimBgRatio)) + ImGui.RenderDimmedBackgroundBehindWindow(g.NavWindowingTargetAnim, ImGui_GetColorU32(61 --[[ImGuiCol.NavWindowingDimBg]], g.DimBgRatio)) if g.NavWindowingListWindow ~= nil and g.NavWindowingListWindow.Active and g.NavWindowingListWindow.Viewport and g.NavWindowingListWindow.Viewport ~= g.NavWindowingTargetAnim.Viewport then - ImGui.RenderDimmedBackgroundBehindWindow(g.NavWindowingListWindow, ImGui.GetColorU32(61 --[[ImGuiCol.NavWindowingDimBg]], g.DimBgRatio)) + ImGui.RenderDimmedBackgroundBehindWindow(g.NavWindowingListWindow, ImGui_GetColorU32(61 --[[ImGuiCol.NavWindowingDimBg]], g.DimBgRatio)) end -- Draw border around Ctrl+Tab target window @@ -19666,7 +19717,7 @@ function ImGui.RenderDimmedBackgrounds() window.DrawList:ChannelsMerge() if window.DrawList.CmdBuffer.Size == 0 then window.DrawList:AddDrawCmd() end window.DrawList:PushClipRect(viewport.Pos, viewport.Pos + viewport.Size) - window.DrawList:AddRect(bb.Min, bb.Max, ImGui.GetColorU32(60 --[[ImGuiCol.NavWindowingHighlight]], g.NavWindowingHighlightAlpha), window.WindowRounding, 3.0) -- FIXME-DPI + window.DrawList:AddRect(bb.Min, bb.Max, ImGui_GetColorU32(60 --[[ImGuiCol.NavWindowingHighlight]], g.NavWindowingHighlightAlpha), window.WindowRounding, 3.0) -- FIXME-DPI window.DrawList:PopClipRect() end end @@ -19680,7 +19731,7 @@ function ImGui.ClosePopupsExceptModals() popup_count_to_keep = popup_count_to_keep - 1 end if popup_count_to_keep < g.OpenPopupStack.Size then -- This test is not required but it allows to set a convenient breakpoint on the statement below - ImGui.ClosePopupToLevel(popup_count_to_keep, true) + ImGui_ClosePopupToLevel(popup_count_to_keep, true) end end @@ -19694,7 +19745,7 @@ function ImGui.BeginPopupModal(name, p_open, flags) local g = GImGui local window = g.CurrentWindow local id = window:GetID(name) - if not ImGui.IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then + if not ImGui_IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then g.NextWindowData:ClearFlags() -- We behave like Begin() and need to consume those values if p_open then p_open = false end return false, p_open @@ -19704,16 +19755,16 @@ function ImGui.BeginPopupModal(name, p_open, flags) -- (this won't really last as settings will kick in, and is mostly for backward compatibility. user may do the same themselves) -- FIXME: Should test for (PosCond & window.SetWindowPosAllowFlags) with the upcoming window. if bit32.band(g.NextWindowData.HasFlags, 1 --[[ImGuiNextWindowDataFlags.HasPos]]) == 0 then - local viewport = window.WasActive and window.Viewport or ImGui.GetMainViewport() -- FIXME-VIEWPORT: What may be our reference viewport? - ImGui.SetNextWindowPos(viewport:GetCenter(), 4 --[[ImGuiCond.FirstUseEver]], ImVec2(0.5, 0.5)) + local viewport = window.WasActive and window.Viewport or ImGui_GetMainViewport() -- FIXME-VIEWPORT: What may be our reference viewport? + ImGui_SetNextWindowPos(viewport:GetCenter(), 4 --[[ImGuiCond.FirstUseEver]], ImVec2(0.5, 0.5)) end flags = bit32.bor(flags, 67108864 --[[ImGuiWindowFlags.Popup]], 134217728 --[[ImGuiWindowFlags.Modal]], 32 --[[ImGuiWindowFlags.NoCollapse]], 524288 --[[ImGuiWindowFlags.NoDocking]]) local is_open p_open, is_open = ImGui.Begin(name, p_open, flags) if not is_open or (p_open ~= nil and not p_open) then -- NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display) - ImGui.EndPopup() - if is_open then ImGui.ClosePopupToLevel(g.BeginPopupStack.Size, true) end + ImGui_EndPopup() + if is_open then ImGui_ClosePopupToLevel(g.BeginPopupStack.Size, true) end return false, p_open end return is_open, p_open @@ -19728,7 +19779,7 @@ function ImGui.IsPopupOpenRequestForWindow(popup_flags) end end if g.NavOpenContextMenuWindowId and g.NavOpenContextMenuWindowId ~= 0 and g.CurrentWindow.ID ~= 0 then - if ImGui.IsWindowChildOf(g.NavWindow, g.CurrentWindow, false, false) then return true end -- This enable ordering to be used to disambiguate item vs window (#8803) + if ImGui_IsWindowChildOf(g.NavWindow, g.CurrentWindow, false, false) then return true end -- This enable ordering to be used to disambiguate item vs window (#8803) end return false end @@ -19739,8 +19790,8 @@ function ImGui.BeginPopupContextWindow(str_id, popup_flags) local window = g.CurrentWindow if not str_id then str_id = "window_context" end local id = window:GetID(str_id) - if ImGui.IsPopupOpenRequestForWindow(popup_flags) then ImGui.OpenPopupEx(id, popup_flags) end - return ImGui.BeginPopupEx(id, bit32.bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) + if ImGui.IsPopupOpenRequestForWindow(popup_flags) then ImGui_OpenPopupEx(id, popup_flags) end + return ImGui_BeginPopupEx(id, bit32.bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) end function ImGui.BeginPopupContextVoid(str_id, popup_flags) @@ -19751,9 +19802,9 @@ function ImGui.BeginPopupContextVoid(str_id, popup_flags) local id = window:GetID(str_id) -- FIXME: Use a global ID? local mouse_button = ImGui.GetMouseButtonFromPopupFlags(popup_flags) if ImGui.IsMouseReleased(mouse_button, id) and not ImGui.IsWindowHovered(4 --[[ImGuiHoveredFlags.AnyWindow]]) then - if ImGui.GetTopMostPopupModal() == nil then ImGui.OpenPopupEx(id, popup_flags) end + if ImGui_GetTopMostPopupModal() == nil then ImGui_OpenPopupEx(id, popup_flags) end end - return ImGui.BeginPopupEx(id, bit32.bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) + return ImGui_BeginPopupEx(id, bit32.bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) end function ImGui.BeginTooltipHidden() @@ -19771,8 +19822,8 @@ end function ImGui.NavMoveRequestResolveWithLastItem(result) local g = GImGui g.NavMoveScoringItems = false -- Ensure request doesn't need more processing - ImGui.NavApplyItemToResult(result) - ImGui.NavUpdateAnyRequestFlag() + ImGui_NavApplyItemToResult(result) + ImGui_NavUpdateAnyRequestFlag() end -- Note: this will likely be called ActivateItem() once we rework our Focus/Activation system! @@ -19791,7 +19842,7 @@ function ImGui.SetKeyboardFocusHere(offset) return end - ImGui.SetNavWindow(window) + ImGui_SetNavWindow(window) local move_flags = bit32.bor(1024 --[[ImGuiNavMoveFlags.IsTabbing]], 4096 --[[ImGuiNavMoveFlags.Activate]], 512 --[[ImGuiNavMoveFlags.FocusApi]], 16384 --[[ImGuiNavMoveFlags.NoSetNavCursorVisible]]) local scroll_flags = window.Appearing and bit32.bor(1 --[[ImGuiScrollFlags.KeepVisibleEdgeX]], 32 --[[ImGuiScrollFlags.AlwaysCenterY]]) or bit32.bor(1 --[[ImGuiScrollFlags.KeepVisibleEdgeX]], 2 --[[ImGuiScrollFlags.KeepVisibleEdgeY]]) @@ -19813,7 +19864,7 @@ function ImGui.FocusItem() end local move_flags = bit32.bor(1024 --[[ImGuiNavMoveFlags.IsTabbing]], 512 --[[ImGuiNavMoveFlags.FocusApi]], 16384 --[[ImGuiNavMoveFlags.NoSetNavCursorVisible]], 8192 --[[ImGuiNavMoveFlags.NoSelect]]) local scroll_flags = window.Appearing and bit32.bor(1 --[[ImGuiScrollFlags.KeepVisibleEdgeX]], 32 --[[ImGuiScrollFlags.AlwaysCenterY]]) or bit32.bor(1 --[[ImGuiScrollFlags.KeepVisibleEdgeX]], 2 --[[ImGuiScrollFlags.KeepVisibleEdgeY]]) - ImGui.SetNavWindow(window) + ImGui_SetNavWindow(window) ImGui.NavMoveRequestSubmit((-1) --[[ImGuiDir.None]], 2 --[[ImGuiDir.Up]], move_flags, scroll_flags) ImGui.NavMoveRequestResolveWithLastItem(g.NavMoveResultLocal) end @@ -19882,10 +19933,10 @@ function ImGui.NavUpdateWindowingOverlay() return end - local viewport = ImGui.GetMainViewport() + local viewport = ImGui_GetMainViewport() ImGui.SetNextWindowSizeConstraints(ImVec2(viewport.Size.x * 0.20, viewport.Size.y * 0.20), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]])) - ImGui.SetNextWindowPos(viewport:GetCenter(), 1 --[[ImGuiCond.Always]], ImVec2(0.5, 0.5)) - ImGui.PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], g.Style.WindowPadding * 2.0) + ImGui_SetNextWindowPos(viewport:GetCenter(), 1 --[[ImGuiCond.Always]], ImVec2(0.5, 0.5)) + ImGui_PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], g.Style.WindowPadding * 2.0) ImGui.Begin("##NavWindowingOverlay", nil, bit32.bor(1 --[[ImGuiWindowFlags.NoTitleBar]], 4096 --[[ImGuiWindowFlags.NoFocusOnAppearing]], 2 --[[ImGuiWindowFlags.NoResize]], 4 --[[ImGuiWindowFlags.NoMove]], 197120 --[[ImGuiWindowFlags.NoInputs]], 64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) g.NavWindowingListWindow = g.CurrentWindow for n = g.WindowsFocusOrder.Size, 1, -1 do @@ -19893,14 +19944,14 @@ function ImGui.NavUpdateWindowingOverlay() assert(window ~= nil) -- Fix static analyzers if ImGui.IsWindowNavFocusable(window) then local label = window.Name - if ImGui.FindRenderedTextEnd(label) == 1 then + if ImGui_FindRenderedTextEnd(label) == 1 then label = GetFallbackWindowNameForWindowingList(window) end - ImGui.Selectable(label, g.NavWindowingTarget == window) + ImGui_Selectable(label, g.NavWindowingTarget == window) end end ImGui.End() - ImGui.PopStyleVar() + ImGui_PopStyleVar() end local function NavUpdateCreateWrappingRequest() @@ -19954,8 +20005,8 @@ local function NavUpdateCreateWrappingRequest() return end window.NavRectRel[g.NavLayer] = bb_rel - ImGui.NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) - ImGui.NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) + ImGui_NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) + ImGui_NavClearPreferredPosForAxis(2 --[[ImGuiAxis.Y]]) ImGui.NavMoveRequestForward(g.NavMoveDir, clip_dir, move_flags, g.NavMoveScrollFlags) end @@ -19997,7 +20048,7 @@ end function MT.ImGuiTextFilter:Draw(label, width) if label == nil then label = "Filter (inc,-exc)" end - if width ~= nil and width ~= 0.0 then ImGui.SetNextItemWidth(width) end + if width ~= nil and width ~= 0.0 then ImGui_SetNextItemWidth(width) end return self:DrawWithHint(label, "incl -excl") end @@ -20188,7 +20239,7 @@ end --- @param items_height? float function MT.ImGuiListClipper:Begin(items_count, items_height) if items_height == nil then items_height = -1.0 end - self.Ctx = ImGui.GetCurrentContext() + self.Ctx = ImGui_GetCurrentContext() local g = self.Ctx local window = g.CurrentWindow @@ -20558,7 +20609,7 @@ function ImGui.ErrorRecoveryTryToRecoverState(state_in) if bit32.band(window.Flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) ~= 0 then if g.CurrentTable ~= nil and g.CurrentTable.InnerWindow == g.CurrentWindow then IM_ASSERT_USER_ERROR(false, "Missing EndTable()") - ImGui.EndTable() + ImGui_EndTable() else IM_ASSERT_USER_ERROR(false, "Missing EndChild()") ImGui.EndChild() @@ -20580,7 +20631,7 @@ function ImGui.ErrorRecoveryTryToRecoverWindowState(state_in) while g.CurrentTable ~= nil and g.CurrentTable.InnerWindow == g.CurrentWindow do IM_ASSERT_USER_ERROR(false, "Missing EndTable()") - ImGui.EndTable() + ImGui_EndTable() end local window = g.CurrentWindow @@ -20600,7 +20651,7 @@ function ImGui.ErrorRecoveryTryToRecoverWindowState(state_in) end while window.DC.TreeDepth > state_in.SizeOfTreeStack do IM_ASSERT_USER_ERROR(false, "Missing TreePop()") - ImGui.TreePop() + ImGui_TreePop() end while g.GroupStack.Size > state_in.SizeOfGroupStack do IM_ASSERT_USER_ERROR(false, "Missing EndGroup()") @@ -20609,12 +20660,12 @@ function ImGui.ErrorRecoveryTryToRecoverWindowState(state_in) assert(g.GroupStack.Size == state_in.SizeOfGroupStack) while window.IDStack.Size > state_in.SizeOfIDStack do IM_ASSERT_USER_ERROR(false, "Missing PopID()") - ImGui.PopID() + ImGui_PopID() end while g.DisabledStackSize > state_in.SizeOfDisabledStack do IM_ASSERT_USER_ERROR(false, "Missing EndDisabled()") if bit32.band(g.CurrentItemFlags, 64 --[[ImGuiItemFlags.Disabled]]) ~= 0 then - ImGui.EndDisabled() + ImGui_EndDisabled() else ImGui.EndDisabledOverrideReenable() g.CurrentWindowStack:back().DisabledOverrideReenable = false @@ -20623,7 +20674,7 @@ function ImGui.ErrorRecoveryTryToRecoverWindowState(state_in) assert(g.DisabledStackSize == state_in.SizeOfDisabledStack) while g.ColorStack.Size > state_in.SizeOfColorStack do IM_ASSERT_USER_ERROR(false, "Missing PopStyleColor()") - ImGui.PopStyleColor() + ImGui_PopStyleColor() end while g.ItemFlagsStack.Size > state_in.SizeOfItemFlagsStack do IM_ASSERT_USER_ERROR(false, "Missing PopItemFlag()") @@ -20631,7 +20682,7 @@ function ImGui.ErrorRecoveryTryToRecoverWindowState(state_in) end while g.StyleVarStack.Size > state_in.SizeOfStyleVarStack do IM_ASSERT_USER_ERROR(false, "Missing PopStyleVar()") - ImGui.PopStyleVar() + ImGui_PopStyleVar() end while g.FontStack.Size > state_in.SizeOfFontStack do IM_ASSERT_USER_ERROR(false, "Missing PopFont()") @@ -20692,13 +20743,13 @@ function ImGui.ErrorLog(msg) if g.IO.ConfigErrorRecoveryEnableTooltip then if g.WithinFrameScope and ImGui.BeginErrorTooltip() then if g.ErrorCountCurrentFrame < 20 then - ImGui.Text("In window '%s': %s", window and window.Name or "NULL", tostring(msg)) + ImGui_Text("In window '%s': %s", window and window.Name or "NULL", tostring(msg)) if window and (not window.IsFallbackWindow or window.WasActive) then - ImGui.GetForegroundDrawList(window.Viewport):AddRect(window.Pos, window.Pos + window.Size, IM_COL32(255, 0, 0, 255)) + ImGui_GetForegroundDrawList(window.Viewport):AddRect(window.Pos, window.Pos + window.Size, IM_COL32(255, 0, 0, 255)) end end if g.ErrorCountCurrentFrame == 20 then - ImGui.Text("(and more errors)") + ImGui_Text("(and more errors)") end -- EndFrame() will amend debug buttons to this window, after all errors have been submitted. ImGui.EndErrorTooltip() @@ -20723,43 +20774,43 @@ function ImGui.ErrorCheckEndFrameFinalizeErrorTooltip() g.DebugDrawIdConflictsCount = g.HoveredIdPreviousFrameItemCount end if g.DebugDrawIdConflictsId ~= 0 and not g.DebugItemPickerActive and ImGui.BeginErrorTooltip() then - ImGui.Text("Programmer error: %d visible items with conflicting ID!", g.DebugDrawIdConflictsCount) - ImGui.BulletText("Code should use PushID()/PopID() in loops, or append \"##xx\" to same-label identifiers!") - ImGui.BulletText("Empty label e.g. Button(\"\") == same ID as parent widget/node. Use Button(\"##xx\") instead!") + ImGui_Text("Programmer error: %d visible items with conflicting ID!", g.DebugDrawIdConflictsCount) + ImGui_BulletText("Code should use PushID()/PopID() in loops, or append \"##xx\" to same-label identifiers!") + ImGui_BulletText("Empty label e.g. Button(\"\") == same ID as parent widget/node. Use Button(\"##xx\") instead!") -- ImGui.BulletText("Code intending to use duplicate ID may use e.g. PushItemFlag(ImGuiItemFlags.AllowDuplicateId, true); ... PopItemFlag()") -- Not making this too visible for fear of it being abused. - ImGui.BulletText("Set io.ConfigDebugHighlightIdConflicts=false to disable this warning in non-programmers builds.") - ImGui.Separator() + ImGui_BulletText("Set io.ConfigDebugHighlightIdConflicts=false to disable this warning in non-programmers builds.") + ImGui_Separator() if g.IO.ConfigDebugHighlightIdConflictsShowItemPicker then - ImGui.Text("(Hold Ctrl to: use ") - ImGui.SameLine(0.0, 0.0) - if ImGui.SmallButton("Item Picker") then + ImGui_Text("(Hold Ctrl to: use ") + ImGui_SameLine(0.0, 0.0) + if ImGui_SmallButton("Item Picker") then ImGui.DebugStartItemPicker() end - ImGui.SameLine(0.0, 0.0) - ImGui.Text(" to break in item call-stack, or ") + ImGui_SameLine(0.0, 0.0) + ImGui_Text(" to break in item call-stack, or ") else - ImGui.Text("(Hold Ctrl to: ") + ImGui_Text("(Hold Ctrl to: ") end - ImGui.SameLine(0.0, 0.0) + ImGui_SameLine(0.0, 0.0) ImGui.TextLinkOpenURL("read FAQ \"About ID Stack System\"", "https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#qa-usage") - ImGui.SameLine(0.0, 0.0) - ImGui.Text(")") + ImGui_SameLine(0.0, 0.0) + ImGui_Text(")") ImGui.EndErrorTooltip() end if g.ErrorCountCurrentFrame > 0 and ImGui.BeginErrorTooltip() then -- Amend at end of frame - ImGui.Separator() - ImGui.Text("(Hold Ctrl to: ") - ImGui.SameLine(0.0, 0.0) - if ImGui.SmallButton("Enable Asserts") then + ImGui_Separator() + ImGui_Text("(Hold Ctrl to: ") + ImGui_SameLine(0.0, 0.0) + if ImGui_SmallButton("Enable Asserts") then g.IO.ConfigErrorRecoveryEnableAssert = true end -- ImGui.SameLine() -- if ImGui.SmallButton("Hide Error Tooltips") then -- g.IO.ConfigErrorRecoveryEnableTooltip = false -- Too dangerous -- end - ImGui.SameLine(0, 0) - ImGui.Text(")") + ImGui_SameLine(0, 0) + ImGui_Text(")") ImGui.EndErrorTooltip() end end @@ -20767,18 +20818,18 @@ end -- Pseudo-tooltip. Follow mouse until Ctrl is held. When Ctrl is held we lock position, allowing to click it. function ImGui.BeginErrorTooltip() local g = GImGui - local window = ImGui.FindWindowByName("##Tooltip_Error") + local window = ImGui_FindWindowByName("##Tooltip_Error") local use_locked_pos = g.IO.KeyCtrl and window ~= nil and window.WasActive local c = g.Style.Colors[4 --[[ImGuiCol.PopupBg]]] - ImGui.PushStyleColor(4 --[[ImGuiCol.PopupBg]], ImVec4(ImLerp(c.x, 1.0, 0.15), ImLerp(c.y, 0.0, 0.15), ImLerp(c.z, 0.0, 0.15), ImLerp(c.w, 1.0, 0.15))) + ImGui_PushStyleColor(4 --[[ImGuiCol.PopupBg]], ImVec4(ImLerp(c.x, 1.0, 0.15), ImLerp(c.y, 0.0, 0.15), ImLerp(c.z, 0.0, 0.15), ImLerp(c.w, 1.0, 0.15))) if use_locked_pos then - ImGui.SetNextWindowPos(g.ErrorTooltipLockedPos) + ImGui_SetNextWindowPos(g.ErrorTooltipLockedPos) end local _, is_visible = ImGui.Begin("##Tooltip_Error", nil, bit32.bor(33554432 --[[ImGuiWindowFlags.Tooltip]], 43 --[[ImGuiWindowFlags.NoDecoration]], 4 --[[ImGuiWindowFlags.NoMove]], 2 --[[ImGuiWindowFlags.NoResize]], 256 --[[ImGuiWindowFlags.NoSavedSettings]], 64 --[[ImGuiWindowFlags.AlwaysAutoResize]])) - ImGui.PopStyleColor() + ImGui_PopStyleColor() if is_visible and g.CurrentWindow.BeginCount == 1 then - ImGui.SeparatorText("MESSAGE FROM DEAR IMGUI") - ImGui.BringWindowToDisplayFront(g.CurrentWindow) + ImGui_SeparatorText("MESSAGE FROM DEAR IMGUI") + ImGui_BringWindowToDisplayFront(g.CurrentWindow) ImGui.BringWindowToFocusFront(g.CurrentWindow) g.ErrorTooltipLockedPos = ImGui.GetWindowPos() elseif not is_visible then @@ -20817,10 +20868,10 @@ end local function MetricsHelpMarker(desc) ImGui.TextDisabled("(?)") if ImGui.BeginItemTooltip() then - ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35.0) - ImGui.TextUnformatted(desc) + ImGui.PushTextWrapPos(ImGui_GetFontSize() * 35.0) + ImGui_TextUnformatted(desc) ImGui.PopTextWrapPos() - ImGui.EndTooltip() + ImGui_EndTooltip() end end ImGui.MetricsHelpMarker = MetricsHelpMarker @@ -20837,7 +20888,7 @@ end -- Draw an arbitrary US keyboard layout to visualize translated keys --- @param draw_list ImDrawList function ImGui.DebugRenderKeyboardPreview(draw_list) - local scale = ImGui.GetFontSize() / 13.0 + local scale = ImGui_GetFontSize() / 13.0 local key_size = ImVec2(35.0, 35.0) * scale local key_rounding = 3.0 * scale local key_face_size = ImVec2(25.0, 25.0) * scale @@ -20877,7 +20928,7 @@ function ImGui.DebugRenderKeyboardPreview(draw_list) draw_list:AddRectFilled(face_min, face_max, IM_COL32(252, 252, 252, 255), key_face_rounding) local 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[3]) - if ImGui.IsKeyDown(key_data[4]) then + if ImGui_IsKeyDown(key_data[4]) then draw_list:AddRectFilled(key_min, key_max, IM_COL32(255, 0, 0, 128), key_rounding) end end @@ -20944,34 +20995,34 @@ function ImGui.ShowFontSelector(label) local font_current = ImGui.GetFont() if ImGui.BeginCombo(label, font_current:GetDebugName()) then for i, font in io.Fonts.Fonts:iter() do - ImGui.PushID(i) - if ImGui.Selectable(font:GetDebugName(), font == font_current, 64 --[[ImGuiSelectableFlags.SelectOnNav]]) then io.FontDefault = font end + ImGui_PushID(i) + if ImGui_Selectable(font:GetDebugName(), font == font_current, 64 --[[ImGuiSelectableFlags.SelectOnNav]]) then io.FontDefault = font end if font == font_current then ImGui.SetItemDefaultFocus() end - ImGui.PopID() + ImGui_PopID() end ImGui.EndCombo() end - ImGui.SameLine() + ImGui_SameLine() MetricsHelpMarker("- Load additional fonts with io.Fonts->AddFontXXX() functions.\n- On Roblox: register the .ttf bytes with ImGui_ImplRoblox.AddFile() first.\n- Read FAQ and docs/FONTS.md for more details.") end function ImGui.DebugNodeFontGlyph(font, glyph) - ImGui.Text("Codepoint: U+%04X", glyph.Codepoint) - ImGui.Separator() - ImGui.Text("Visible: %d", glyph.Visible and 1 or 0) - ImGui.Text("AdvanceX: %.1f", glyph.AdvanceX) - ImGui.Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph.X0, glyph.Y0, glyph.X1, glyph.Y1) - ImGui.Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph.U0, glyph.V0, glyph.U1, glyph.V1) + ImGui_Text("Codepoint: U+%04X", glyph.Codepoint) + ImGui_Separator() + ImGui_Text("Visible: %d", glyph.Visible and 1 or 0) + ImGui_Text("AdvanceX: %.1f", glyph.AdvanceX) + ImGui_Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph.X0, glyph.Y0, glyph.X1, glyph.Y1) + ImGui_Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph.U0, glyph.V0, glyph.U1, glyph.V1) if glyph.PackId >= 0 then local r = { uv0 = ImVec2(), uv1 = ImVec2() } - if font.OwnerAtlas:GetCustomRect(glyph.PackId, r) then ImGui.Text("PackId: 0x%X (%dx%d rect at %d,%d)", glyph.PackId, r.w, r.h, r.x, r.y) end + if font.OwnerAtlas:GetCustomRect(glyph.PackId, r) then ImGui_Text("PackId: 0x%X (%dx%d rect at %d,%d)", glyph.PackId, r.w, r.h, r.x, r.y) end end - ImGui.Text("SourceIdx: %d", glyph.SourceIdx) + ImGui_Text("SourceIdx: %d", glyph.SourceIdx) end function ImGui.DebugNodeFontGlyphsForSrcMask(font, baked, src_mask) - local draw_list = ImGui.GetWindowDrawList() - local glyph_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) + local draw_list = ImGui_GetWindowDrawList() + local glyph_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) local cell_size = baked.Size * 1 local cell_spacing = ImGui.GetStyle().ItemSpacing.y -- [Port] only scans loaded codepoints (IndexLookup range) instead of the whole 0..0xFFFF range @@ -21010,14 +21061,14 @@ function ImGui.DebugNodeFontGlyphsForSrcMask(font, baked, src_mask) draw_list:AddRect(cell_p1, cell_p2, glyph and IM_COL32(255, 255, 255, 100) or IM_COL32(255, 255, 255, 50)) if glyph and bit32.band(src_mask, bit32.lshift(1, glyph.SourceIdx)) ~= 0 then font:RenderChar(draw_list, cell_size, cell_p1, glyph_col, c) - if ImGui.IsMouseHoveringRect(cell_p1, cell_p2) and ImGui.BeginTooltip() then + if ImGui_IsMouseHoveringRect(cell_p1, cell_p2) and ImGui.BeginTooltip() then ImGui.DebugNodeFontGlyph(font, glyph) - ImGui.EndTooltip() + ImGui_EndTooltip() end end end ImGui.Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16)) - ImGui.TreePop() + ImGui_TreePop() end base = base + 256 end @@ -21041,53 +21092,53 @@ local function CalcFontGlyphSrcOverlapMask(atlas, font, codepoint) end function ImGui.DebugNodeFont(font) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local cfg = g.DebugMetricsConfig local atlas = font.OwnerAtlas local opened = ImGui.TreeNode(tostring(font), "Font: \"%s\": %d sources(s)", font:GetDebugName(), font.Sources.Size) -- Display preview text - if not opened then ImGui.Indent() end - ImGui.Indent() + if not opened then ImGui_Indent() end + ImGui_Indent() if cfg.ShowFontPreview then ImGui.PushFont(font, 0.0) - ImGui.Text("The quick brown fox jumps over the lazy dog") + ImGui_Text("The quick brown fox jumps over the lazy dog") ImGui.PopFont() end if not opened then - ImGui.Unindent() - ImGui.Unindent() + ImGui_Unindent() + ImGui_Unindent() return end - if ImGui.SmallButton("Set as default") then ImGui.GetIO().FontDefault = font end - ImGui.SameLine() - ImGui.BeginDisabled(atlas.Fonts.Size <= 1 or atlas.Locked == true or atlas.RemoveFont == nil) - if ImGui.SmallButton("Remove") and atlas.RemoveFont then atlas:RemoveFont(font) end - ImGui.EndDisabled() - ImGui.SameLine() - if ImGui.SmallButton("Clear bakes") then ImFontAtlasFontDiscardBakes(atlas, font, 0) end - ImGui.SameLine() - if ImGui.SmallButton("Clear unused") then ImFontAtlasFontDiscardBakes(atlas, font, 2) end + if ImGui_SmallButton("Set as default") then ImGui.GetIO().FontDefault = font end + ImGui_SameLine() + ImGui_BeginDisabled(atlas.Fonts.Size <= 1 or atlas.Locked == true or atlas.RemoveFont == nil) + if ImGui_SmallButton("Remove") and atlas.RemoveFont then atlas:RemoveFont(font) end + ImGui_EndDisabled() + ImGui_SameLine() + if ImGui_SmallButton("Clear bakes") then ImFontAtlasFontDiscardBakes(atlas, font, 0) end + ImGui_SameLine() + if ImGui_SmallButton("Clear unused") then ImFontAtlasFontDiscardBakes(atlas, font, 2) end -- Display details - ImGui.Text("Fallback character: '%s' (U+%04X)", U8(font.FallbackChar), font.FallbackChar or 0) - ImGui.Text("Ellipsis character: '%s' (U+%04X)", U8(font.EllipsisChar), font.EllipsisChar or 0) + ImGui_Text("Fallback character: '%s' (U+%04X)", U8(font.FallbackChar), font.FallbackChar or 0) + ImGui_Text("Ellipsis character: '%s' (U+%04X)", U8(font.EllipsisChar), font.EllipsisChar or 0) for src_n, src in font.Sources:iter() do if ImGui.TreeNode(tostring(src), "Input %d: '%s' [%d], Oversample: %d,%d, PixelSnapH: %d, Offset: (%.1f,%.1f)", src_n - 1, src.Name or "", src.FontNo or 0, src.OversampleH or 0, src.OversampleV or 0, src.PixelSnapH and 1 or 0, src.GlyphOffset.x, src.GlyphOffset.y) then local loader = src.FontLoader or atlas.FontLoader - ImGui.Text("Loader: '%s'", (loader and loader.Name) or "N/A") + ImGui_Text("Loader: '%s'", (loader and loader.Name) or "N/A") -- if ImGui.DragFloat("ExtraSizeScale", src.ExtraSizeScale, 0.01, 0.10, 2.0) then -- ImFontAtlasFontRebuildOutput(atlas, font) -- end - ImGui.TreePop() + ImGui_TreePop() end end if font.Sources.Size > 1 and ImGui.TreeNode("Input Glyphs Overlap Detection Tool") then ImGui.TextWrapped("- First Input that contains the glyph is used.\n" .. "- Use ImFontConfig::GlyphExcludeRanges[] to specify ranges to ignore glyph in given Input.\n- Prefer using a small number of ranges as the list is scanned every time a new glyph is loaded,\n - e.g. GlyphExcludeRanges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };\n- This tool doesn't cache results and is slow, don't keep it open!") - if ImGui.BeginTable("table", 2) then + if ImGui_BeginTable("table", 2) then local c = 0 while c < 0x10000 do local overlap_mask = CalcFontGlyphSrcOverlapMask(atlas, font, c) @@ -21096,26 +21147,26 @@ function ImGui.DebugNodeFont(font) while c_end < 0x10000 and CalcFontGlyphSrcOverlapMask(atlas, font, c_end) == overlap_mask do c_end = c_end + 1 end - if ImGui.TableNextColumn() and ImGui.TreeNode(c, "U+%04X-U+%04X: %d codepoints in %d inputs", c, c_end - 1, c_end - c, ImCountSetBits(overlap_mask)) then + if ImGui_TableNextColumn() and ImGui.TreeNode(c, "U+%04X-U+%04X: %d codepoints in %d inputs", c, c_end - 1, c_end - c, ImCountSetBits(overlap_mask)) then for n = c, c_end - 1 do - ImGui.BulletText("Codepoint U+%04X (%s)", n, U8(n)) + ImGui_BulletText("Codepoint U+%04X (%s)", n, U8(n)) end - ImGui.TreePop() + ImGui_TreePop() end - ImGui.TableNextColumn() + ImGui_TableNextColumn() for src_n = 0, font.Sources.Size - 1 do if bit32.band(overlap_mask, bit32.lshift(1, src_n)) ~= 0 then - ImGui.Text("%d ", src_n) - ImGui.SameLine() + ImGui_Text("%d ", src_n) + ImGui_SameLine() end end c = c_end - 1 end c = c + 1 end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end -- Display all glyphs of the fonts in separate pages of 256 characters @@ -21123,40 +21174,40 @@ function ImGui.DebugNodeFont(font) if builder then for _, baked in builder.BakedPool:iter() do if baked.OwnerFont == font then - ImGui.PushID(baked.BakedId) + ImGui_PushID(baked.BakedId) if ImGui.TreeNode("Glyphs", "Baked at { %.2fpx, d.%.2f }: %d glyphs%s", baked.Size, baked.RasterizerDensity, baked.Glyphs.Size, (baked.LastUsedFrame < (builder.FrameCount or 0) - 1) and " *Unused*" or "") then - if ImGui.SmallButton("Load all") then + if ImGui_SmallButton("Load all") then for c = 0, 0x7F do baked:FindGlyph(c) end -- [Port] ASCII only: loading the whole BMP in Luau stalls for seconds end local surface_sqrt = math.floor(math.sqrt(baked.MetricsTotalSurface)) - ImGui.Text("Ascent: %f, Descent: %f, Ascent-Descent: %f", baked.Ascent, baked.Descent, baked.Ascent - baked.Descent) - ImGui.Text("Texture Area: about %d px ~%dx%d px", baked.MetricsTotalSurface, surface_sqrt, surface_sqrt) + ImGui_Text("Ascent: %f, Descent: %f, Ascent-Descent: %f", baked.Ascent, baked.Descent, baked.Ascent - baked.Descent) + ImGui_Text("Texture Area: about %d px ~%dx%d px", baked.MetricsTotalSurface, surface_sqrt, surface_sqrt) for src_n, src in font.Sources:iter() do - ImGui.BulletText("Input %d: '%s', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)", + ImGui_BulletText("Input %d: '%s', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)", src_n - 1, src.Name or "", src.OversampleH or 0, src.OversampleV or 0, src.PixelSnapH and 1 or 0, src.GlyphOffset.x, src.GlyphOffset.y) end ImGui.DebugNodeFontGlyphsForSrcMask(font, baked, bit32.bnot(0)) - ImGui.TreePop() + ImGui_TreePop() end - ImGui.PopID() + ImGui_PopID() end end end - ImGui.TreePop() - ImGui.Unindent() + ImGui_TreePop() + ImGui_Unindent() end local StatusNames = { [0] = "OK", "Destroyed", "WantCreate", "WantUpdates", "WantDestroy" } local FormatNames = { [0] = "RGBA32", "Alpha8" } function ImGui.DebugNodeTexture(tex, int_id, highlight_rect) - local g = ImGui.GetCurrentContext() - ImGui.PushID(int_id) + local g = ImGui_GetCurrentContext() + ImGui_PushID(int_id) if ImGui.TreeNode("", "Texture #%03d (%dx%d pixels)", tex.UniqueID or 0, tex.Width, tex.Height) then local cfg = g.DebugMetricsConfig - _, cfg.ShowTextureUsedRect = ImGui.Checkbox("Show used rect", cfg.ShowTextureUsedRect) - ImGui.PushStyleVar(24 --[[ImGuiStyleVar.ImageBorderSize]], math.max(1.0, g.Style.ImageBorderSize)) + _, cfg.ShowTextureUsedRect = ImGui_Checkbox("Show used rect", cfg.ShowTextureUsedRect) + ImGui_PushStyleVar(24 --[[ImGuiStyleVar.ImageBorderSize]], math.max(1.0, g.Style.ImageBorderSize)) local p = ImGui.GetCursorScreenPos() if tex.Status == 4 --[[ImTextureStatus.WantDestroy]] or tex.Status == 1 --[[ImTextureStatus.Destroyed]] then ImGui.Dummy(ImVec2(tex.Width, tex.Height)) @@ -21166,81 +21217,81 @@ function ImGui.DebugNodeTexture(tex, int_id, highlight_rect) end if cfg.ShowTextureUsedRect and tex.UsedRect then local u = tex.UsedRect - ImGui.GetWindowDrawList():AddRect(ImVec2(p.x + u.x, p.y + u.y), ImVec2(p.x + u.x + u.w, p.y + u.y + u.h), IM_COL32(255, 0, 255, 255)) + ImGui_GetWindowDrawList():AddRect(ImVec2(p.x + u.x, p.y + u.y), ImVec2(p.x + u.x + u.w, p.y + u.y + u.h), IM_COL32(255, 0, 255, 255)) end if highlight_rect ~= nil then local r_outer = ImRect(p.x, p.y, p.x + tex.Width, p.y + tex.Height) local r_inner = ImRect(p.x + highlight_rect.x, p.y + highlight_rect.y, p.x + highlight_rect.x + highlight_rect.w, p.y + highlight_rect.y + highlight_rect.h) - ImGui.RenderRectFilledWithHole(ImGui.GetWindowDrawList(), r_outer, r_inner, IM_COL32(0, 0, 0, 100), 0.0) - ImGui.GetWindowDrawList():AddRect(r_inner.Min - ImVec2(1, 1), r_inner.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255)) + ImGui.RenderRectFilledWithHole(ImGui_GetWindowDrawList(), r_outer, r_inner, IM_COL32(0, 0, 0, 100), 0.0) + ImGui_GetWindowDrawList():AddRect(r_inner.Min - ImVec2(1, 1), r_inner.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255)) end - ImGui.PopStyleVar() - ImGui.Text("Status = %s (%d), Format = %s (%d), UseColors = %d", StatusNames[tex.Status] or "?", tex.Status, FormatNames[tex.Format] or "?", tex.Format, tex.UseColors and 1 or 0) - ImGui.Text("TexRef = %s, BackendUserData = %s", FormatTextureRefForDebugDisplay(tex:GetTexRef()), tostring(tex.BackendUserData)) - ImGui.TreePop() + ImGui_PopStyleVar() + ImGui_Text("Status = %s (%d), Format = %s (%d), UseColors = %d", StatusNames[tex.Status] or "?", tex.Status, FormatNames[tex.Format] or "?", tex.Format, tex.UseColors and 1 or 0) + ImGui_Text("TexRef = %s, BackendUserData = %s", FormatTextureRefForDebugDisplay(tex:GetTexRef()), tostring(tex.BackendUserData)) + ImGui_TreePop() end - ImGui.PopID() + ImGui_PopID() end -- [DEBUG] List fonts in a font atlas and display its texture function ImGui.ShowFontAtlas(atlas) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local io = g.IO local style = g.Style - ImGui.BeginDisabled() - ImGui.CheckboxFlags("io.BackendFlags: RendererHasTextures", io.BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) - ImGui.EndDisabled() + ImGui_BeginDisabled() + ImGui_CheckboxFlags("io.BackendFlags: RendererHasTextures", io.BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) + ImGui_EndDisabled() ImGui.ShowFontSelector("Font") local changed style.FontSizeBase, changed = ImGui.DragFloat("FontSizeBase", style.FontSizeBase, 0.20, 5.0, 100.0, "%.0f") if changed then style._NextFrameFontSizeBase = style.FontSizeBase end -- FIXME: Temporary hack until we finish remaining work. - ImGui.SameLine(0.0, 0.0); ImGui.Text(" (out %.2f)", ImGui.GetFontSize()) - ImGui.SameLine(); MetricsHelpMarker("- This is scaling font only. General scaling will come later.") + ImGui_SameLine(0.0, 0.0); ImGui_Text(" (out %.2f)", ImGui_GetFontSize()) + ImGui_SameLine(); MetricsHelpMarker("- This is scaling font only. General scaling will come later.") style.FontScaleMain = ImGui.DragFloat("FontScaleMain", style.FontScaleMain, 0.02, 0.5, 4.0) style.FontScaleDpi = ImGui.DragFloat("FontScaleDpi", style.FontScaleDpi, 0.02, 0.5, 4.0) - ImGui.BulletText("Load a nice font for better results!") - ImGui.BulletText("Please submit feedback:") - ImGui.SameLine(); ImGui.TextLinkOpenURL("#8465", "https://github.com/ocornut/imgui/issues/8465") - ImGui.BulletText("Read FAQ for more details:") - ImGui.SameLine(); ImGui.TextLinkOpenURL("dearimgui.com/faq", "https://www.dearimgui.com/faq/") + ImGui_BulletText("Load a nice font for better results!") + ImGui_BulletText("Please submit feedback:") + ImGui_SameLine(); ImGui.TextLinkOpenURL("#8465", "https://github.com/ocornut/imgui/issues/8465") + ImGui_BulletText("Read FAQ for more details:") + ImGui_SameLine(); ImGui.TextLinkOpenURL("dearimgui.com/faq", "https://www.dearimgui.com/faq/") - ImGui.SeparatorText("Font List") + ImGui_SeparatorText("Font List") local cfg = g.DebugMetricsConfig - _, cfg.ShowFontPreview = ImGui.Checkbox("Show font preview", cfg.ShowFontPreview) + _, cfg.ShowFontPreview = ImGui_Checkbox("Show font preview", cfg.ShowFontPreview) -- Font loaders if ImGui.TreeNode("Loader", "Loader: '%s'", atlas.FontLoaderName or "NULL") then - ImGui.BeginDisabled() + ImGui_BeginDisabled() ImGui.RadioButtonEx("stb_truetype", true) - ImGui.SameLine() + ImGui_SameLine() ImGui.RadioButtonEx("FreeType", false) ImGui.SetItemTooltip("Not available on Roblox.") - ImGui.EndDisabled() - ImGui.TreePop() + ImGui_EndDisabled() + ImGui_TreePop() end -- Font list for i, font in atlas.Fonts:iter() do - ImGui.PushID(i) + ImGui_PushID(i) ImGui.DebugNodeFont(font) - ImGui.PopID() + ImGui_PopID() end - ImGui.SeparatorText("Font Atlas") - if ImGui.Button("Compact") then atlas:CompactCache() end - ImGui.SameLine() - if ImGui.Button("Grow") then ImFontAtlasTextureGrow(atlas) end - ImGui.SameLine() - if ImGui.Button("Clear All") then ImFontAtlasBuildClear(atlas) end + ImGui_SeparatorText("Font Atlas") + if ImGui_Button("Compact") then atlas:CompactCache() end + ImGui_SameLine() + if ImGui_Button("Grow") then ImFontAtlasTextureGrow(atlas) end + ImGui_SameLine() + if ImGui_Button("Clear All") then ImFontAtlasBuildClear(atlas) end ImGui.SetItemTooltip("Destroy cache and custom rectangles.") for tex_n, tex in atlas.TexList:iter() do - if tex_n > 1 then ImGui.SameLine() end - ImGui.Text("Tex: %dx%d", tex.Width, tex.Height) + if tex_n > 1 then ImGui_SameLine() end + ImGui_Text("Tex: %dx%d", tex.Width, tex.Height) end local b = atlas.Builder if b then local packed_sqrt = math.floor(math.sqrt(b.RectsPackedSurface or 0)) local discarded_sqrt = math.floor(math.sqrt(b.RectsDiscardedSurface or 0)) - ImGui.Text("Packed rects: %d, area: about %d px ~%dx%d px", b.RectsPackedCount or 0, b.RectsPackedSurface or 0, packed_sqrt, packed_sqrt) - ImGui.Text("incl. Discarded rects: %d, area: about %d px ~%dx%d px", b.RectsDiscardedCount or 0, b.RectsDiscardedSurface or 0, discarded_sqrt, discarded_sqrt) + ImGui_Text("Packed rects: %d, area: about %d px ~%dx%d px", b.RectsPackedCount or 0, b.RectsPackedSurface or 0, packed_sqrt, packed_sqrt) + ImGui_Text("incl. Discarded rects: %d, area: about %d px ~%dx%d px", b.RectsDiscardedCount or 0, b.RectsDiscardedSurface or 0, discarded_sqrt, discarded_sqrt) end -- Texture list -- (ensure the last texture always use the same ID, so we can keep it open neatly) @@ -21256,18 +21307,18 @@ end -- FIXME-LAYOUT: To be done automatically via layout mode once we rework ItemSize/ItemAdd into ItemLayout. local function SameLineOrWrap(size) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow local pos = ImVec2(window.DC.CursorPosPrevLine.x + g.Style.ItemSpacing.x, window.DC.CursorPosPrevLine.y) - if window.WorkRect:Contains(ImRect(pos, pos + size)) then ImGui.SameLine() end + if window.WorkRect:Contains(ImRect(pos, pos + size)) then ImGui_SameLine() end end local function ShowDebugLogFlag(name, flags) - local g = ImGui.GetCurrentContext() - local size = ImVec2(ImGui.GetFrameHeight() + g.Style.ItemInnerSpacing.x + ImGui.CalcTextSize(name).x, ImGui.GetFrameHeight()) + local g = ImGui_GetCurrentContext() + local size = ImVec2(ImGui_GetFrameHeight() + g.Style.ItemInnerSpacing.x + ImGui_CalcTextSize(name).x, ImGui_GetFrameHeight()) SameLineOrWrap(size) -- FIXME-LAYOUT: To be done automatically once we rework ItemSize/ItemAdd into ItemLayout. local pressed - pressed, g.DebugLogFlags = ImGui.CheckboxFlags(name, g.DebugLogFlags, flags) + pressed, g.DebugLogFlags = ImGui_CheckboxFlags(name, g.DebugLogFlags, flags) if pressed and g.IO.KeyShift and bit32.band(g.DebugLogFlags, flags) ~= 0 then g.DebugLogAutoDisableFrames = 2 g.DebugLogAutoDisableFlags = bit32.bor(g.DebugLogAutoDisableFlags or 0, flags) @@ -21276,40 +21327,40 @@ local function ShowDebugLogFlag(name, flags) end function ImGui.ShowDebugLogWindow(p_open) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if bit32.band(g.NextWindowData.HasFlags, 2 --[[ImGuiNextWindowDataFlags.HasSize]]) == 0 then - ImGui.SetNextWindowSize(ImVec2(0.0, ImGui.GetFontSize() * 12.0), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(0.0, ImGui_GetFontSize() * 12.0), 4 --[[ImGuiCond.FirstUseEver]]) end local visible p_open, visible = ImGui.Begin("Dear ImGui Debug Log", p_open) - if not visible or ImGui.GetCurrentWindow().BeginCount > 1 then + if not visible or ImGui_GetCurrentWindow().BeginCount > 1 then ImGui.End() return p_open end local L = ImGuiDebugLogFlags local all_enable_flags = bit32.band(L.EventMask_, bit32.bnot(L.EventInputRouting)) - _, g.DebugLogFlags = ImGui.CheckboxFlags("All", g.DebugLogFlags, all_enable_flags) + _, g.DebugLogFlags = ImGui_CheckboxFlags("All", g.DebugLogFlags, all_enable_flags) ImGui.SetItemTooltip("(except InputRouting which is spammy)") for _, e in ipairs({ { "Errors", L.EventError }, { "ActiveId", L.EventActiveId }, { "Clipper", L.EventClipper }, { "Docking", L.EventDocking }, { "Focus", L.EventFocus }, { "IO", L.EventIO }, { "Font", L.EventFont }, { "Nav", L.EventNav }, { "Popup", L.EventPopup }, { "Selection", L.EventSelection }, { "Table", L.EventTable }, { "Viewport", L.EventViewport }, { "InputRouting", L.EventInputRouting } }) do ShowDebugLogFlag(e[1], e[2]) end - if ImGui.SmallButton("Clear") then + if ImGui_SmallButton("Clear") then g.DebugLogBuf:clear() g.DebugLogLines = { "" } end - ImGui.SameLine() - if ImGui.SmallButton("Copy") then ImGui.SetClipboardText(g.DebugLogBuf:c_str()) end - ImGui.SameLine() - if ImGui.SmallButton("Configure Outputs..") then ImGui.OpenPopup("Outputs") end + ImGui_SameLine() + if ImGui_SmallButton("Copy") then ImGui.SetClipboardText(g.DebugLogBuf:c_str()) end + ImGui_SameLine() + if ImGui_SmallButton("Configure Outputs..") then ImGui.OpenPopup("Outputs") end if ImGui.BeginPopup("Outputs") then - _, g.DebugLogFlags = ImGui.CheckboxFlags("OutputToTTY", g.DebugLogFlags, L.OutputToTTY) - ImGui.BeginDisabled() - _, g.DebugLogFlags = ImGui.CheckboxFlags("OutputToDebugger", g.DebugLogFlags, L.OutputToDebugger) - _, g.DebugLogFlags = ImGui.CheckboxFlags("OutputToTestEngine", g.DebugLogFlags, L.OutputToTestEngine) - ImGui.EndDisabled() - ImGui.EndPopup() + _, g.DebugLogFlags = ImGui_CheckboxFlags("OutputToTTY", g.DebugLogFlags, L.OutputToTTY) + ImGui_BeginDisabled() + _, g.DebugLogFlags = ImGui_CheckboxFlags("OutputToDebugger", g.DebugLogFlags, L.OutputToDebugger) + _, g.DebugLogFlags = ImGui_CheckboxFlags("OutputToTestEngine", g.DebugLogFlags, L.OutputToTestEngine) + ImGui_EndDisabled() + ImGui_EndPopup() end ImGui.BeginChild("##log", ImVec2(0.0, 0.0), 1 --[[ImGuiChildFlags.Borders]], bit32.bor(16384 --[[ImGuiWindowFlags.AlwaysVerticalScrollbar]], 32768 --[[ImGuiWindowFlags.AlwaysHorizontalScrollbar]])) @@ -21334,8 +21385,8 @@ end -- [Luau] line_begin is the line string, line_end its optional exclusive end byte position (default: whole string). function ImGui.DebugTextUnformattedWithLocateItem(line_begin, line_end) if line_end == nil then line_end = #line_begin + 1 end - ImGui.TextUnformatted(line_begin, line_end) - if not ImGui.IsItemHovered(bit32.bor(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]], 128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]])) then + ImGui_TextUnformatted(line_begin, line_end) + if not ImGui_IsItemHovered(bit32.bor(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]], 128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]])) then return end local g = GImGui @@ -21352,8 +21403,8 @@ function ImGui.DebugTextUnformattedWithLocateItem(line_begin, line_end) local p0 = ImGui.CalcTextSizeEx(line_begin, 1, p) local p1 = ImGui.CalcTextSizeEx(line_begin, p, p + 10) g.LastItemData.Rect = ImRect(text_rect.Min + ImVec2(p0.x, 0.0), text_rect.Min + ImVec2(p0.x + p1.x, p1.y)) - if ImGui.IsMouseHoveringRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, true) then - ImGui.DebugLocateItemOnHover(id) + if ImGui_IsMouseHoveringRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, true) then + ImGui_DebugLocateItemOnHover(id) end p = p + 11 -- [Port] p += 10, then the loop's p++ until true end @@ -21394,7 +21445,7 @@ function ImGui.DebugDrawItemRect(col) if col == nil then col = IM_COL32(255, 0, 0, 255) end local g = GImGui local window = g.CurrentWindow - ImGui.GetForegroundDrawList(window.Viewport):AddRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, col) + ImGui_GetForegroundDrawList(window.Viewport):AddRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, col) end -- [DEBUG] Locate item position/rectangle given an ID. @@ -21411,12 +21462,12 @@ end -- FIXME: Doesn't work over through a modal window, because they clear HoveredWindow. --- @param target_id ImGuiID function ImGui.DebugLocateItemOnHover(target_id) - if target_id == 0 or not ImGui.IsItemHovered(bit32.bor(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]], 32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]])) then + if target_id == 0 or not ImGui_IsItemHovered(bit32.bor(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]], 32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]])) then return end local g = GImGui ImGui.DebugLocateItem(target_id) - ImGui.GetForegroundDrawList(g.CurrentWindow.Viewport):AddRect(g.LastItemData.Rect.Min - ImVec2(3.0, 3.0), g.LastItemData.Rect.Max + ImVec2(3.0, 3.0), DEBUG_LOCATE_ITEM_COLOR) + ImGui_GetForegroundDrawList(g.CurrentWindow.Viewport):AddRect(g.LastItemData.Rect.Min - ImVec2(3.0, 3.0), g.LastItemData.Rect.Max + ImVec2(3.0, 3.0), DEBUG_LOCATE_ITEM_COLOR) -- Can't easily use a context menu here because it will mess with focus, active id etc. if g.IO.ConfigDebugIsDebuggerPresent and g.MouseStationaryTimer > 1.0 then @@ -21437,7 +21488,7 @@ function ImGui.DebugLocateItemResolveWithLastItem() local item_data = g.LastItemData g.DebugLocateId = 0 - local draw_list = ImGui.GetForegroundDrawList(g.CurrentWindow.Viewport) + local draw_list = ImGui_GetForegroundDrawList(g.CurrentWindow.Viewport) local r = ImRect(item_data.Rect.Min, item_data.Rect.Max) -- [Luau] copy r:Expand(3.0) local p1 = g.IO.MousePos @@ -21465,12 +21516,12 @@ function ImGui.UpdateDebugToolItemPicker() g.DebugItemPickerActive = false end local change_mapping = g.IO.KeyMods == bit32.bor(4096 --[[ImGuiMod_Ctrl]], 8192 --[[ImGuiMod_Shift]]) - if not change_mapping and ImGui.IsMouseClicked(g.DebugItemPickerMouseButton) and hovered_id ~= 0 then + if not change_mapping and ImGui_IsMouseClicked(g.DebugItemPickerMouseButton) and hovered_id ~= 0 then g.DebugItemPickerBreakId = hovered_id g.DebugItemPickerActive = false end for mouse_button = 0, 2 do - if change_mapping and ImGui.IsMouseClicked(mouse_button) then + if change_mapping and ImGui_IsMouseClicked(mouse_button) then g.DebugItemPickerMouseButton = mouse_button end end @@ -21478,15 +21529,15 @@ function ImGui.UpdateDebugToolItemPicker() if not ImGui.BeginTooltip() then return end - ImGui.Text("HoveredId: 0x%08X", hovered_id) - ImGui.Text("Press ESC to abort picking.") + ImGui_Text("HoveredId: 0x%08X", hovered_id) + ImGui_Text("Press ESC to abort picking.") local mouse_button_names = { "Left", "Right", "Middle" } if change_mapping then - ImGui.Text("Remap w/ Ctrl+Shift: click anywhere to select new mouse button.") + ImGui_Text("Remap w/ Ctrl+Shift: click anywhere to select new mouse button.") else ImGui.TextColored(ImGui.GetStyleColorVec4((hovered_id ~= 0) and 0 --[[ImGuiCol.Text]] or 1 --[[ImGuiCol.TextDisabled]]), "Click %s Button to break in debugger! (remap w/ Ctrl+Shift)", mouse_button_names[g.DebugItemPickerMouseButton + 1]) end - ImGui.EndTooltip() + ImGui_EndTooltip() end local function PathQuery(g) @@ -21525,7 +21576,7 @@ end -- [DEBUG] ID Stack Tool: update query. Called by NewFrame() function ImGui.UpdateDebugToolItemPathQuery() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local q = PathQuery(g) local id = 0 if g.DebugIDStackTool.LastActiveFrame + 1 == g.FrameCount then @@ -21537,7 +21588,7 @@ end -- [DEBUG] ID Stack tool: hooks called by GetID() family functions -- [Port] `data_id` is the string/number that was hashed. function ImGui.DebugHookIdInfo(id, data_type, data_id) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local query = PathQuery(g) if not query.Active then return end local window = g.CurrentWindow @@ -21575,7 +21626,7 @@ end local function DebugItemPathQuery_FormatLevelInfo(query, n, format_for_ui) local info = query.Results[n + 1] - local window = (info.Desc == nil and n == 0) and ImGui.FindWindowByID(info.ID) or nil + local window = (info.Desc == nil and n == 0) and ImGui_FindWindowByID(info.ID) or nil if window then return string.format(format_for_ui and "\"%s\" [window]" or "%s", SkipUncontributingPrefix(window.Name)) end -- Source: window name (because the root ID don't call GetID() and so doesn't get hooked) if info.QuerySuccess then return string.format((format_for_ui and info.DataType == 11 --[[ImGuiDataType.String]]) and "\"%s\"" or "%s", SkipUncontributingPrefix(info.Desc)) end -- Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id) if query.Step < #query.Results then return "" end -- Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers. @@ -21598,13 +21649,13 @@ end -- ID Stack Tool: Display UI function ImGui.ShowIDStackToolWindow(p_open) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if bit32.band(g.NextWindowData.HasFlags, 2 --[[ImGuiNextWindowDataFlags.HasSize]]) == 0 then - ImGui.SetNextWindowSize(ImVec2(0.0, ImGui.GetFontSize() * 8.0), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(0.0, ImGui_GetFontSize() * 8.0), 4 --[[ImGuiCond.FirstUseEver]]) end local visible p_open, visible = ImGui.Begin("Dear ImGui ID Stack Tool", p_open) - if not visible or ImGui.GetCurrentWindow().BeginCount > 1 then + if not visible or ImGui_GetCurrentWindow().BeginCount > 1 then ImGui.End() return p_open end @@ -21612,44 +21663,44 @@ function ImGui.ShowIDStackToolWindow(p_open) local tool = g.DebugIDStackTool tool.LastActiveFrame = g.FrameCount local result_path = DebugItemPathQuery_GetResultAsPath(query, tool.OptHexEncodeNonAsciiChars) - ImGui.Text("0x%08X", query.MainID) - ImGui.SameLine() + ImGui_Text("0x%08X", query.MainID) + ImGui_SameLine() MetricsHelpMarker("Hover an item with the mouse to display elements of the ID Stack leading to the item's final ID.\nEach level of the stack correspond to a PushID() call.\nAll levels of the stack are hashed together to make the final ID of a widget (ID displayed at the bottom level of the stack).\nRead FAQ entry about the ID stack for details.") -- Ctrl+C to copy path local time_since_copy = g.Time - tool.CopyToClipboardLastTime ImGui.PushStyleVarY(11 --[[ImGuiStyleVar.FramePadding]], 0.0) - _, tool.OptHexEncodeNonAsciiChars = ImGui.Checkbox("Hex-encode non-ASCII", tool.OptHexEncodeNonAsciiChars) - ImGui.SameLine() - _, tool.OptCopyToClipboardOnCtrlC = ImGui.Checkbox("Ctrl+C: copy path", tool.OptCopyToClipboardOnCtrlC) - ImGui.PopStyleVar() - ImGui.SameLine() + _, tool.OptHexEncodeNonAsciiChars = ImGui_Checkbox("Hex-encode non-ASCII", tool.OptHexEncodeNonAsciiChars) + ImGui_SameLine() + _, tool.OptCopyToClipboardOnCtrlC = ImGui_Checkbox("Ctrl+C: copy path", tool.OptCopyToClipboardOnCtrlC) + ImGui_PopStyleVar() + ImGui_SameLine() ImGui.TextColored((time_since_copy >= 0.0 and time_since_copy < 0.75 and math.fmod(time_since_copy, 0.25) < 0.25 * 0.5) and ImVec4(1.0, 1.0, 0.3, 1.0) or ImVec4(), "*COPIED*") - if tool.OptCopyToClipboardOnCtrlC and ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 548 --[[ImGuiKey.C]]), bit32.bor(4096 --[[ImGuiInputFlags.RouteGlobal]], 16384 --[[ImGuiInputFlags.RouteOverFocused]])) then + if tool.OptCopyToClipboardOnCtrlC and ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 548 --[[ImGuiKey.C]]), bit32.bor(4096 --[[ImGuiInputFlags.RouteGlobal]], 16384 --[[ImGuiInputFlags.RouteOverFocused]])) then tool.CopyToClipboardLastTime = g.Time ImGui.SetClipboardText(result_path) end - ImGui.Text("- Path \"%s\"", query.Complete and result_path or "") - ImGui.Separator() + ImGui_Text("- Path \"%s\"", query.Complete and result_path or "") + ImGui_Separator() -- Display decorated stack - if #query.Results > 0 and ImGui.BeginTable("##table", 3, 1920 --[[ImGuiTableFlags.Borders]]) then - local id_width = ImGui.CalcTextSize("0xDDDDDDDD").x - ImGui.TableSetupColumn("Seed", 16 --[[ImGuiTableColumnFlags.WidthFixed]], id_width) - ImGui.TableSetupColumn("PushID", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) - ImGui.TableSetupColumn("Result", 16 --[[ImGuiTableColumnFlags.WidthFixed]], id_width) + if #query.Results > 0 and ImGui_BeginTable("##table", 3, 1920 --[[ImGuiTableFlags.Borders]]) then + local id_width = ImGui_CalcTextSize("0xDDDDDDDD").x + ImGui_TableSetupColumn("Seed", 16 --[[ImGuiTableColumnFlags.WidthFixed]], id_width) + ImGui_TableSetupColumn("PushID", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) + ImGui_TableSetupColumn("Result", 16 --[[ImGuiTableColumnFlags.WidthFixed]], id_width) ImGui.TableHeadersRow() for n = 0, #query.Results - 1 do local info = query.Results[n + 1] - ImGui.TableNextColumn() - ImGui.Text("0x%08X", (n > 0) and query.Results[n].ID or 0) - ImGui.TableNextColumn() - ImGui.TextUnformatted(DebugItemPathQuery_FormatLevelInfo(query, n, true)) - ImGui.TableNextColumn() - ImGui.Text("0x%08X", info.ID) - if n == #query.Results - 1 then ImGui.TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], ImGui.GetColorU32(25 --[[ImGuiCol.Header]])) end + ImGui_TableNextColumn() + ImGui_Text("0x%08X", (n > 0) and query.Results[n].ID or 0) + ImGui_TableNextColumn() + ImGui_TextUnformatted(DebugItemPathQuery_FormatLevelInfo(query, n, true)) + ImGui_TableNextColumn() + ImGui_Text("0x%08X", info.ID) + if n == #query.Results - 1 then ImGui.TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], ImGui_GetColorU32(25 --[[ImGuiCol.Header]])) end end - ImGui.EndTable() + ImGui_EndTable() end ImGui.End() return p_open @@ -21675,17 +21726,17 @@ end ------------------------------------------------------------------------------- local function B(v) return v and 1 or 0 end -local function FG(window) return ImGui.GetForegroundDrawList(window and window.Viewport or ImGui.GetMainViewport()) end +local function FG(window) return ImGui_GetForegroundDrawList(window and window.Viewport or ImGui_GetMainViewport()) end local function YellowRect(window, min, max) FG(window):AddRect(min, max, IM_COL32(255, 255, 0, 255)) end -- [DEBUG] Display contents of Columns function ImGui.DebugNodeColumns(columns) if not ImGui.TreeNode(columns.ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns.ID, columns.Count, columns.Flags) then return end - ImGui.BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns.OffMaxX - columns.OffMinX, columns.OffMinX, columns.OffMaxX) + ImGui_BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns.OffMaxX - columns.OffMinX, columns.OffMinX, columns.OffMaxX) for i, column in columns.Columns:iter() do - ImGui.BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", i - 1, column.OffsetNorm, ImGui.GetColumnOffsetFromNorm(columns, column.OffsetNorm)) + ImGui_BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", i - 1, column.OffsetNorm, ImGui.GetColumnOffsetFromNorm(columns, column.OffsetNorm)) end - ImGui.TreePop() + ImGui_TreePop() end -- [DEBUG] Display contents of ImGuiStorage @@ -21694,30 +21745,30 @@ function ImGui.DebugNodeStorage(storage, label) for _ in pairs(storage) do n = n + 1 end if not ImGui.TreeNode(label, "%s: %d entries", label, n) then return end for k, v in pairs(storage) do - ImGui.BulletText("Key 0x%08X Value { %s }", tonumber(k) or 0, tostring(v)) - ImGui.DebugLocateItemOnHover(tonumber(k) or 0) + ImGui_BulletText("Key 0x%08X Value { %s }", tonumber(k) or 0, tostring(v)) + ImGui_DebugLocateItemOnHover(tonumber(k) or 0) end - ImGui.TreePop() + ImGui_TreePop() end -- [DEBUG] Display contents of ImDrawList -- Note that both 'window' and 'viewport' may be nil here. Viewport is generally nil of destroyed popups which previously owned a viewport. function ImGui.DebugNodeDrawList(window, viewport, draw_list, label) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local cfg = g.DebugMetricsConfig local cmd_count = draw_list.CmdBuffer.Size if cmd_count > 0 and draw_list.CmdBuffer.Data[cmd_count].ElemCount == 0 and draw_list.CmdBuffer.Data[cmd_count].UserCallback == nil then cmd_count = cmd_count - 1 end local node_open = ImGui.TreeNode(tostring(draw_list), "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list._OwnerName or "", draw_list.VtxBuffer.Size, draw_list.IdxBuffer.Size, cmd_count) - if draw_list == ImGui.GetWindowDrawList() then - ImGui.SameLine() + if draw_list == ImGui_GetWindowDrawList() then + ImGui_SameLine() ImGui.TextColored(ImVec4(1.0, 0.4, 0.4, 1.0), "CURRENTLY APPENDING") -- Can't display stats for active draw list! (we don't have the data double-buffered) - if node_open then ImGui.TreePop() end + if node_open then ImGui_TreePop() end return end - local fg_draw_list = viewport and ImGui.GetForegroundDrawList(viewport) or nil -- Render additional visuals into the top-most draw list - if window and ImGui.IsItemHovered() and fg_draw_list then + local fg_draw_list = viewport and ImGui_GetForegroundDrawList(viewport) or nil -- Render additional visuals into the top-most draw list + if window and ImGui_IsItemHovered() and fg_draw_list then fg_draw_list:AddRect(window.Pos, window.Pos + window.Size, IM_COL32(255, 255, 0, 255)) end if not node_open then return end @@ -21726,7 +21777,7 @@ function ImGui.DebugNodeDrawList(window, viewport, draw_list, label) for cmd_n = 1, cmd_count do repeat local pcmd = draw_list.CmdBuffer.Data[cmd_n] if pcmd.UserCallback then - ImGui.BulletText("Callback %s, user_data %s", tostring(pcmd.UserCallback), tostring(pcmd.UserCallbackData)) + ImGui_BulletText("Callback %s, user_data %s", tostring(pcmd.UserCallback), tostring(pcmd.UserCallbackData)) break -- [Port] continue end @@ -21735,7 +21786,7 @@ function ImGui.DebugNodeDrawList(window, viewport, draw_list, label) local buf = string.format("DrawCmd:%5d tris, Tex %s, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", math.floor(pcmd.ElemCount / 3), texid_desc, cr.x, cr.y, cr.z, cr.w) local pcmd_node_open = ImGui.TreeNode(cmd_n - 1, "%s", buf) - if ImGui.IsItemHovered() and (cfg.ShowDrawCmdMesh or cfg.ShowDrawCmdBoundingBoxes) and fg_draw_list then + if ImGui_IsItemHovered() and (cfg.ShowDrawCmdMesh or cfg.ShowDrawCmdBoundingBoxes) and fg_draw_list then ImGui.DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg.ShowDrawCmdMesh, cfg.ShowDrawCmdBoundingBoxes) end if not pcmd_node_open then @@ -21760,8 +21811,8 @@ function ImGui.DebugNodeDrawList(window, viewport, draw_list, label) -- Display vertex information summary. Hover to get all triangles drawn in wire-frame buf = string.format("Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd.ElemCount, pcmd.VtxOffset, pcmd.IdxOffset, total_area) - ImGui.Selectable(buf) - if ImGui.IsItemHovered() and fg_draw_list then + ImGui_Selectable(buf) + if ImGui_IsItemHovered() and fg_draw_list then ImGui.DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, true, false) end @@ -21783,17 +21834,17 @@ function ImGui.DebugNodeDrawList(window, viewport, draw_list, label) idx_i = idx_i + 1 end - ImGui.Selectable(table.concat(lines), false) - if fg_draw_list and ImGui.IsItemHovered() then + ImGui_Selectable(table.concat(lines), false) + if fg_draw_list and ImGui_IsItemHovered() then fg_draw_list:PushDrawFlag(8192 --[[ImDrawFlags.AALines]], false) -- Disable AA on triangle outlines is more readable for very large and thin triangles. fg_draw_list:AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), 1.0, 512 --[[ImDrawFlags.Closed]]) fg_draw_list:PopDrawFlag() end end end - ImGui.TreePop() + ImGui_TreePop() until true end - ImGui.TreePop() + ImGui_TreePop() end -- [DEBUG] Display mesh/aabb of a ImDrawCmd @@ -21836,18 +21887,18 @@ end -- [DEBUG] Display contents of ImGuiTabBar function ImGui.DebugNodeTabBar(tab_bar, label) -- Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings. - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local is_active = (tab_bar.PrevFrameVisible >= ImGui.GetFrameCount() - 2) local names = {} for tab_n = 1, math.min(tab_bar.Tabs.Size, 3) do local tab = tab_bar.Tabs.Data[tab_n] - names[#names + 1] = "'" .. (ImGui.TabBarGetTabName and ImGui.TabBarGetTabName(tab_bar, tab) or "?") .. "'" + names[#names + 1] = "'" .. (ImGui_TabBarGetTabName and ImGui_TabBarGetTabName(tab_bar, tab) or "?") .. "'" end local buf = string.format("%s 0x%08X (%d tabs)%s { %s%s", label, tab_bar.ID, tab_bar.Tabs.Size, is_active and "" or " *Inactive*", table.concat(names, ", "), (tab_bar.Tabs.Size > 3) and " ... }" or " } ") - if not is_active then ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end + if not is_active then ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end local open = ImGui.TreeNode(label, "%s", buf) - if not is_active then ImGui.PopStyleColor() end - if is_active and ImGui.IsItemHovered() then + if not is_active then ImGui_PopStyleColor() end + if is_active and ImGui_IsItemHovered() then local dl = FG(tab_bar.Window) dl:AddRect(tab_bar.BarRect.Min, tab_bar.BarRect.Max, IM_COL32(255, 255, 0, 255)) dl:AddLineV(tab_bar.ScrollingRectMinX, tab_bar.BarRect.Min.y, tab_bar.BarRect.Max.y, IM_COL32(0, 255, 0, 255)) @@ -21855,53 +21906,53 @@ function ImGui.DebugNodeTabBar(tab_bar, label) end if open then for tab_n, tab in tab_bar.Tabs:iter() do - ImGui.PushID(tab_n) - if ImGui.SmallButton("<") and ImGui.TabBarQueueReorder then ImGui.TabBarQueueReorder(tab_bar, tab, -1) end ImGui.SameLine(0, 2) - if ImGui.SmallButton(">") and ImGui.TabBarQueueReorder then ImGui.TabBarQueueReorder(tab_bar, tab, 1) end ImGui.SameLine() - ImGui.Text("%02d%s Tab 0x%08X '%s' Offset: %.2f, Width: %.2f/%.2f", tab_n - 1, (tab.ID == tab_bar.SelectedTabId) and "*" or " ", tab.ID, - ImGui.TabBarGetTabName and ImGui.TabBarGetTabName(tab_bar, tab) or "?", tab.Offset, tab.Width, tab.ContentWidth) - ImGui.PopID() + ImGui_PushID(tab_n) + if ImGui_SmallButton("<") and ImGui.TabBarQueueReorder then ImGui.TabBarQueueReorder(tab_bar, tab, -1) end ImGui_SameLine(0, 2) + if ImGui_SmallButton(">") and ImGui.TabBarQueueReorder then ImGui.TabBarQueueReorder(tab_bar, tab, 1) end ImGui_SameLine() + ImGui_Text("%02d%s Tab 0x%08X '%s' Offset: %.2f, Width: %.2f/%.2f", tab_n - 1, (tab.ID == tab_bar.SelectedTabId) and "*" or " ", tab.ID, + ImGui_TabBarGetTabName and ImGui_TabBarGetTabName(tab_bar, tab) or "?", tab.Offset, tab.Width, tab.ContentWidth) + ImGui_PopID() end - ImGui.TreePop() + ImGui_TreePop() end end function ImGui.DebugNodeTableSettings(settings, tbl) local open = ImGui.TreeNode(tostring(settings), "Settings 0x%08X (%d columns)", settings.ID, settings.ColumnsCount) - local hovered = ImGui.IsItemHovered() + local hovered = ImGui_IsItemHovered() if hovered and tbl == nil and settings.ID ~= 0 then tbl = ImGui.TableFindByID(settings.ID) end if hovered and tbl ~= nil then YellowRect(tbl.OuterWindow, tbl.OuterRect.Min, tbl.OuterRect.Max) end if open then - ImGui.BulletText("SaveFlags: 0x%08X", settings.SaveFlags) - ImGui.BulletText("ColumnsCount: %d (max %d)", settings.ColumnsCount, settings.ColumnsCountMax) + ImGui_BulletText("SaveFlags: 0x%08X", settings.SaveFlags) + ImGui_BulletText("ColumnsCount: %d (max %d)", settings.ColumnsCount, settings.ColumnsCountMax) for n = 0, settings.ColumnsCount - 1 do local c = settings.Columns[n] local dir = (c.SortOrder ~= -1) and c.SortDirection or 0 --[[ImGuiSortDirection.None]] - ImGui.BulletText("Column %d Order %d SortOrder %2d %s Vis %d %s %7.3f ID 0x%08X", n, c.DisplayOrder, c.SortOrder, + ImGui_BulletText("Column %d Order %d SortOrder %2d %s Vis %d %s %7.3f ID 0x%08X", n, c.DisplayOrder, c.SortOrder, (dir == 1 --[[ImGuiSortDirection.Ascending]]) and "Asc" or ((dir == 2 --[[ImGuiSortDirection.Descending]]) and "Des" or "---"), c.IsEnabled, (c.IsStretch ~= 0) and "Weight" or "Width ", c.WidthOrWeight, c.ID) end - ImGui.TreePop() + ImGui_TreePop() end end function ImGui.DebugNodeTable(tbl) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local is_active = (tbl.LastFrameActive >= g.FrameCount - 2) -- Note that fully clipped early out scrolling tables will appear as inactive here. - if not is_active then ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end + if not is_active then ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end local open = ImGui.TreeNode(tostring(tbl), "Table 0x%08X (%d columns, in '%s')%s", tbl.ID, tbl.ColumnsCount, tbl.OuterWindow and tbl.OuterWindow.Name or "?", is_active and "" or " *Inactive*") - if not is_active then ImGui.PopStyleColor() end - if ImGui.IsItemHovered() then YellowRect(tbl.OuterWindow, tbl.OuterRect.Min, tbl.OuterRect.Max) end + if not is_active then ImGui_PopStyleColor() end + if ImGui_IsItemHovered() then YellowRect(tbl.OuterWindow, tbl.OuterRect.Min, tbl.OuterRect.Max) end if not open then return end - if tbl.InstanceCurrent > 0 then ImGui.Text("** %d instances of same table! Some data below will refer to last instance.", tbl.InstanceCurrent + 1) end - local clear_settings = ImGui.SmallButton("Clear settings") - ImGui.BulletText("OuterRect: Pos: (%.1f,%.1f) Size: (%.1f,%.1f) Sizing: '%s'", tbl.OuterRect.Min.x, tbl.OuterRect.Min.y, tbl.OuterRect:GetWidth(), tbl.OuterRect:GetHeight(), DebugNodeTableGetSizingPolicyDesc(tbl.Flags)) - ImGui.BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", tbl.ColumnsGivenWidth, tbl.ColumnsAutoFitWidth, tbl.InnerWidth, (tbl.InnerWidth == 0.0) and " (auto)" or "") - ImGui.BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", tbl.CellPaddingX, tbl.CellSpacingX1, tbl.CellSpacingX2, tbl.OuterPaddingX) - ImGui.BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", tbl.HoveredColumnBody, tbl.HoveredColumnBorder) - ImGui.BulletText("ResizedColumn: %d, HeldHeaderColumn: %d, ReorderColumn: %d", tbl.LastResizedColumn, tbl.LastHeldHeaderColumn, tbl.ReorderColumn) + if tbl.InstanceCurrent > 0 then ImGui_Text("** %d instances of same table! Some data below will refer to last instance.", tbl.InstanceCurrent + 1) end + local clear_settings = ImGui_SmallButton("Clear settings") + ImGui_BulletText("OuterRect: Pos: (%.1f,%.1f) Size: (%.1f,%.1f) Sizing: '%s'", tbl.OuterRect.Min.x, tbl.OuterRect.Min.y, tbl.OuterRect:GetWidth(), tbl.OuterRect:GetHeight(), DebugNodeTableGetSizingPolicyDesc(tbl.Flags)) + ImGui_BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", tbl.ColumnsGivenWidth, tbl.ColumnsAutoFitWidth, tbl.InnerWidth, (tbl.InnerWidth == 0.0) and " (auto)" or "") + ImGui_BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", tbl.CellPaddingX, tbl.CellSpacingX1, tbl.CellSpacingX2, tbl.OuterPaddingX) + ImGui_BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", tbl.HoveredColumnBody, tbl.HoveredColumnBorder) + ImGui_BulletText("ResizedColumn: %d, HeldHeaderColumn: %d, ReorderColumn: %d", tbl.LastResizedColumn, tbl.LastHeldHeaderColumn, tbl.ReorderColumn) for n = 0, tbl.InstanceCurrent do local inst = ImGui.TableGetInstanceData(tbl, n) - ImGui.BulletText("Instance %d: HoveredRow: %d, LastOuterHeight: %.2f", n, inst.HoveredRowLast, inst.LastOuterHeight) + ImGui_BulletText("Instance %d: HoveredRow: %d, LastOuterHeight: %.2f", n, inst.HoveredRowLast, inst.LastOuterHeight) end local sum_weights = 0.0 for n = 0, tbl.ColumnsCount - 1 do @@ -21922,37 +21973,37 @@ function ImGui.DebugNodeTable(tbl) c.SortOrder, (c.SortDirection == 1 --[[ImGuiSortDirection.Ascending]]) and " (Asc)" or ((c.SortDirection == 2 --[[ImGuiSortDirection.Descending]]) and " (Des)" or ""), tonumber(c.UserData) or 0, c.Flags, (bit32.band(c.Flags, CF.WidthStretch) ~= 0) and "WidthStretch " or "", (bit32.band(c.Flags, CF.WidthFixed) ~= 0) and "WidthFixed " or "", (bit32.band(c.Flags, CF.NoResize) ~= 0) and "NoResize " or "") ImGui.Bullet() - ImGui.Selectable(buf) - if ImGui.IsItemHovered() then YellowRect(tbl.OuterWindow, ImVec2(c.MinX, tbl.OuterRect.Min.y), ImVec2(c.MaxX, tbl.OuterRect.Max.y)) end + ImGui_Selectable(buf) + if ImGui_IsItemHovered() then YellowRect(tbl.OuterWindow, ImVec2(c.MinX, tbl.OuterRect.Min.y), ImVec2(c.MaxX, tbl.OuterRect.Max.y)) end end local settings = ImGui.TableGetBoundSettings(tbl) if settings then ImGui.DebugNodeTableSettings(settings, tbl) end if clear_settings then tbl.IsResetAllRequest = true end -- Queue a call to TableResetSettings() - ImGui.TreePop() + ImGui_TreePop() end local function DebugNodeDockNodeFlags(flags, label, enabled) local D = ImGuiDockNodeFlags - ImGui.PushID(label) - ImGui.PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0.0, 0.0)) - ImGui.Text("%s:", label) - if not enabled then ImGui.BeginDisabled() end + ImGui_PushID(label) + ImGui_PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0.0, 0.0)) + ImGui_Text("%s:", label) + if not enabled then ImGui_BeginDisabled() end for _, n in ipairs({ "NoResize", "NoResizeX", "NoResizeY", "NoTabBar", "HiddenTabBar", "NoWindowMenuButton", "NoCloseButton", "DockedWindowsInFocusRoute", "NoDocking", "NoDockingSplit", "NoDockingSplitOther", "NoDockingOverMe", "NoDockingOverOther", "NoDockingOverEmpty", "NoUndocking" }) do - if D[n] then _, flags = ImGui.CheckboxFlags(n, flags, D[n]) end + if D[n] then _, flags = ImGui_CheckboxFlags(n, flags, D[n]) end end - if not enabled then ImGui.EndDisabled() end - ImGui.PopStyleVar() - ImGui.PopID() + if not enabled then ImGui_EndDisabled() end + ImGui_PopStyleVar() + ImGui_PopID() return flags end -- [DEBUG] Display contents of ImDockNode function ImGui.DebugNodeDockNode(node, label) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local is_alive = (g.FrameCount - node.LastFrameAlive < 2) -- Submitted with ImGuiDockNodeFlags.KeepAliveOnly local is_active = (g.FrameCount - node.LastFrameActive < 2) -- Submitted - if not is_alive then ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end + if not is_alive then ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end local tree_node_flags = node.IsFocused and 1 --[[ImGuiTreeNodeFlags.Selected]] or 0 --[[ImGuiTreeNodeFlags.None]] local open if node.Windows.Size > 0 then @@ -21961,49 +22012,49 @@ function ImGui.DebugNodeDockNode(node, label) local kind = (node.SplitAxis == 1 --[[ImGuiAxis.X]]) and "horizontal split" or ((node.SplitAxis == 2 --[[ImGuiAxis.Y]]) and "vertical split" or "empty") open = ImGui.TreeNodeEx(node.ID, tree_node_flags, "%s 0x%04X%s: %s (vis: '%s')", label, node.ID, node.IsVisible and "" or " (hidden)", kind, node.VisibleWindow and node.VisibleWindow.Name or "NULL") end - if not is_alive then ImGui.PopStyleColor() end - if is_active and ImGui.IsItemHovered() then + if not is_alive then ImGui_PopStyleColor() end + if is_active and ImGui_IsItemHovered() then local window = node.HostWindow or node.VisibleWindow if window then YellowRect(window, node.Pos, node.Pos + node.Size) end end if open then - ImGui.BulletText("Pos (%.0f,%.0f), Size (%.0f, %.0f) Ref (%.0f, %.0f)", node.Pos.x, node.Pos.y, node.Size.x, node.Size.y, node.SizeRef.x, node.SizeRef.y) - ImGui.DebugNodeWindow(node.HostWindow, "HostWindow") - ImGui.DebugNodeWindow(node.VisibleWindow, "VisibleWindow") - ImGui.BulletText("SelectedTabID: 0x%08X, LastFocusedNodeID: 0x%08X", node.SelectedTabId, node.LastFocusedNodeId) - ImGui.BulletText("Misc:%s%s%s%s%s%s%s", node:IsDockSpace() and " IsDockSpace" or "", node:IsCentralNode() and " IsCentralNode" or "", + ImGui_BulletText("Pos (%.0f,%.0f), Size (%.0f, %.0f) Ref (%.0f, %.0f)", node.Pos.x, node.Pos.y, node.Size.x, node.Size.y, node.SizeRef.x, node.SizeRef.y) + ImGui_DebugNodeWindow(node.HostWindow, "HostWindow") + ImGui_DebugNodeWindow(node.VisibleWindow, "VisibleWindow") + ImGui_BulletText("SelectedTabID: 0x%08X, LastFocusedNodeID: 0x%08X", node.SelectedTabId, node.LastFocusedNodeId) + ImGui_BulletText("Misc:%s%s%s%s%s%s%s", node:IsDockSpace() and " IsDockSpace" or "", node:IsCentralNode() and " IsCentralNode" or "", is_alive and " IsAlive" or "", is_active and " IsActive" or "", node.IsFocused and " IsFocused" or "", node.WantLockSizeOnce and " WantLockSizeOnce" or "", node.HasCentralNodeChild and " HasCentralNodeChild" or "") if ImGui.TreeNode("flags", "Flags Merged: 0x%04X, Local: 0x%04X, InWindows: 0x%04X, Shared: 0x%04X", node.MergedFlags, node.LocalFlags, node.LocalFlagsInWindows, node.SharedFlags) then - if ImGui.BeginTable("flags", 4) then - ImGui.TableNextColumn(); DebugNodeDockNodeFlags(node.MergedFlags, "MergedFlags", false) - ImGui.TableNextColumn(); node.LocalFlags = DebugNodeDockNodeFlags(node.LocalFlags, "LocalFlags", true) - ImGui.TableNextColumn(); DebugNodeDockNodeFlags(node.LocalFlagsInWindows, "LocalFlagsInWindows", false) - ImGui.TableNextColumn(); node.SharedFlags = DebugNodeDockNodeFlags(node.SharedFlags, "SharedFlags", true) - ImGui.EndTable() + if ImGui_BeginTable("flags", 4) then + ImGui_TableNextColumn(); DebugNodeDockNodeFlags(node.MergedFlags, "MergedFlags", false) + ImGui_TableNextColumn(); node.LocalFlags = DebugNodeDockNodeFlags(node.LocalFlags, "LocalFlags", true) + ImGui_TableNextColumn(); DebugNodeDockNodeFlags(node.LocalFlagsInWindows, "LocalFlagsInWindows", false) + ImGui_TableNextColumn(); node.SharedFlags = DebugNodeDockNodeFlags(node.SharedFlags, "SharedFlags", true) + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end - if node.ParentNode then ImGui.DebugNodeDockNode(node.ParentNode, "ParentNode") end - if node.ChildNodes[0] then ImGui.DebugNodeDockNode(node.ChildNodes[0], "Child[0]") end - if node.ChildNodes[1] then ImGui.DebugNodeDockNode(node.ChildNodes[1], "Child[1]") end + if node.ParentNode then ImGui_DebugNodeDockNode(node.ParentNode, "ParentNode") end + if node.ChildNodes[0] then ImGui_DebugNodeDockNode(node.ChildNodes[0], "Child[0]") end + if node.ChildNodes[1] then ImGui_DebugNodeDockNode(node.ChildNodes[1], "Child[1]") end if node.TabBar then ImGui.DebugNodeTabBar(node.TabBar, "TabBar") end - ImGui.DebugNodeWindowsList(node.Windows, "Windows") - ImGui.TreePop() + ImGui_DebugNodeWindowsList(node.Windows, "Windows") + ImGui_TreePop() end end function ImGui.DebugNodeWindow(window, label) if window == nil then - ImGui.BulletText("%s: NULL", label) + ImGui_BulletText("%s: NULL", label) return end - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local is_active = window.WasActive local tree_node_flags = (window == g.NavWindow) and 1 --[[ImGuiTreeNodeFlags.Selected]] or 0 --[[ImGuiTreeNodeFlags.None]] - if not is_active then ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end + if not is_active then ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) end local open = ImGui.TreeNodeEx(label, tree_node_flags, "%s '%s'%s", label, window.Name, is_active and "" or " *Inactive*") - if not is_active then ImGui.PopStyleColor() end - if ImGui.IsItemHovered() and is_active then YellowRect(window, window.Pos, window.Pos + window.Size) end + if not is_active then ImGui_PopStyleColor() end + if ImGui_IsItemHovered() and is_active then YellowRect(window, window.Pos, window.Pos + window.Size) end if not open then return end if window.MemoryCompacted then ImGui.TextDisabled("Note: some memory buffers have been compacted/freed.") end @@ -22015,61 +22066,61 @@ function ImGui.DebugNodeWindow(window, label) local flags = window.Flags local function F(f, s) return (bit32.band(flags, f) ~= 0) and s or "" end ImGui.DebugNodeDrawList(window, window.Viewport, window.DrawList, "DrawList") - ImGui.BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f) Ideal (%.1f,%.1f)", window.Pos.x, window.Pos.y, window.Size.x, window.Size.y, window.ContentSize.x, window.ContentSize.y, window.ContentSizeIdeal.x, window.ContentSizeIdeal.y) - ImGui.BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, F(W.ChildWindow, "Child "), F(W.Tooltip, "Tooltip "), F(W.Popup, "Popup "), F(W.Modal, "Modal "), F(W.ChildMenu, "ChildMenu "), + ImGui_BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f) Ideal (%.1f,%.1f)", window.Pos.x, window.Pos.y, window.Size.x, window.Size.y, window.ContentSize.x, window.ContentSize.y, window.ContentSizeIdeal.x, window.ContentSizeIdeal.y) + ImGui_BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, F(W.ChildWindow, "Child "), F(W.Tooltip, "Tooltip "), F(W.Popup, "Popup "), F(W.Modal, "Modal "), F(W.ChildMenu, "ChildMenu "), F(W.NoSavedSettings, "NoSavedSettings "), F(W.NoMouseInputs, "NoMouseInputs"), F(W.NoNavInputs, "NoNavInputs"), F(W.AlwaysAutoResize, "AlwaysAutoResize")) if bit32.band(flags, W.ChildWindow) ~= 0 then local cf = window.ChildFlags or 0 local C = ImGuiChildFlags - ImGui.BulletText("ChildFlags: 0x%08X (%s%s%s%s..)", cf, (bit32.band(cf, C.Borders) ~= 0) and "Borders " or "", (bit32.band(cf, C.ResizeX) ~= 0) and "ResizeX " or "", + ImGui_BulletText("ChildFlags: 0x%08X (%s%s%s%s..)", cf, (bit32.band(cf, C.Borders) ~= 0) and "Borders " or "", (bit32.band(cf, C.ResizeX) ~= 0) and "ResizeX " or "", (bit32.band(cf, C.ResizeY) ~= 0) and "ResizeY " or "", (bit32.band(cf, C.NavFlattened) ~= 0) and "NavFlattened " or "") end - ImGui.BulletText("WindowClassId: 0x%08X", window.WindowClass and window.WindowClass.ClassId or 0) - ImGui.BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window.Scroll.x, window.ScrollMax.x, window.Scroll.y, window.ScrollMax.y, window.ScrollbarX and "X" or "", window.ScrollbarY and "Y" or "") - ImGui.BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", B(window.Active), B(window.WasActive), B(window.WriteAccessed), (window.Active or window.WasActive) and window.BeginOrderWithinContext or -1) - ImGui.BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", B(window.Appearing), B(window.Hidden), window.HiddenFramesCanSkipItems, window.HiddenFramesCannotSkipItems, B(window.SkipItems)) + ImGui_BulletText("WindowClassId: 0x%08X", window.WindowClass and window.WindowClass.ClassId or 0) + ImGui_BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window.Scroll.x, window.ScrollMax.x, window.Scroll.y, window.ScrollMax.y, window.ScrollbarX and "X" or "", window.ScrollbarY and "Y" or "") + ImGui_BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", B(window.Active), B(window.WasActive), B(window.WriteAccessed), (window.Active or window.WasActive) and window.BeginOrderWithinContext or -1) + ImGui_BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", B(window.Appearing), B(window.Hidden), window.HiddenFramesCanSkipItems, window.HiddenFramesCannotSkipItems, B(window.SkipItems)) for layer = 0, 1 do local r = window.NavRectRel[layer] if r.Min.x >= r.Max.x and r.Min.y >= r.Max.y then - ImGui.BulletText("NavLastIds[%d]: 0x%08X", layer, window.NavLastIds[layer]) + ImGui_BulletText("NavLastIds[%d]: 0x%08X", layer, window.NavLastIds[layer]) else - ImGui.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) + ImGui_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) end - ImGui.DebugLocateItemOnHover(window.NavLastIds[layer]) + ImGui_DebugLocateItemOnHover(window.NavLastIds[layer]) end - ImGui.BulletText("NavLayersActiveMask: %X, NavLastChildNavWindow: %s", window.DC.NavLayersActiveMask, window.NavLastChildNavWindow and window.NavLastChildNavWindow.Name or "NULL") - ImGui.BulletText("Viewport: %d%s, ViewportId: 0x%08X, ViewportPos: (%.1f,%.1f)", window.Viewport and (window.Viewport.Idx or 0) or -1, window.ViewportOwned and " (Owned)" or "", window.ViewportId or 0, window.ViewportPos.x, window.ViewportPos.y) - ImGui.BulletText("DockId: 0x%04X, DockOrder: %d, Act: %d, Vis: %d", window.DockId or 0, window.DockOrder or -1, B(window.DockIsActive), B(window.DockTabIsVisible)) + ImGui_BulletText("NavLayersActiveMask: %X, NavLastChildNavWindow: %s", window.DC.NavLayersActiveMask, window.NavLastChildNavWindow and window.NavLastChildNavWindow.Name or "NULL") + ImGui_BulletText("Viewport: %d%s, ViewportId: 0x%08X, ViewportPos: (%.1f,%.1f)", window.Viewport and (window.Viewport.Idx or 0) or -1, window.ViewportOwned and " (Owned)" or "", window.ViewportId or 0, window.ViewportPos.x, window.ViewportPos.y) + ImGui_BulletText("DockId: 0x%04X, DockOrder: %d, Act: %d, Vis: %d", window.DockId or 0, window.DockOrder or -1, B(window.DockIsActive), B(window.DockTabIsVisible)) if window.DockNode or window.DockNodeAsHost then - ImGui.DebugNodeDockNode(window.DockNodeAsHost or window.DockNode, window.DockNodeAsHost and "DockNodeAsHost" or "DockNode") + ImGui_DebugNodeDockNode(window.DockNodeAsHost or window.DockNode, window.DockNodeAsHost and "DockNodeAsHost" or "DockNode") end - if window.RootWindow ~= window then ImGui.DebugNodeWindow(window.RootWindow, "RootWindow") end - if window.RootWindowDockTree and window.RootWindowDockTree ~= window.RootWindow then ImGui.DebugNodeWindow(window.RootWindowDockTree, "RootWindowDockTree") end - if window.ParentWindow ~= nil then ImGui.DebugNodeWindow(window.ParentWindow, "ParentWindow") end - if window.ParentWindowForFocusRoute ~= nil then ImGui.DebugNodeWindow(window.ParentWindowForFocusRoute, "ParentWindowForFocusRoute") end - if window.DC.ChildWindows.Size > 0 then ImGui.DebugNodeWindowsList(window.DC.ChildWindows, "ChildWindows") end + if window.RootWindow ~= window then ImGui_DebugNodeWindow(window.RootWindow, "RootWindow") end + if window.RootWindowDockTree and window.RootWindowDockTree ~= window.RootWindow then ImGui_DebugNodeWindow(window.RootWindowDockTree, "RootWindowDockTree") end + if window.ParentWindow ~= nil then ImGui_DebugNodeWindow(window.ParentWindow, "ParentWindow") end + if window.ParentWindowForFocusRoute ~= nil then ImGui_DebugNodeWindow(window.ParentWindowForFocusRoute, "ParentWindowForFocusRoute") end + if window.DC.ChildWindows.Size > 0 then ImGui_DebugNodeWindowsList(window.DC.ChildWindows, "ChildWindows") end if window.ColumnsStorage.Size > 0 and ImGui.TreeNode("Columns", "Columns sets (%d)", window.ColumnsStorage.Size) then for _, columns in window.ColumnsStorage:iter() do ImGui.DebugNodeColumns(columns) end - ImGui.TreePop() + ImGui_TreePop() end ImGui.DebugNodeStorage(window.StateStorage, "Storage") - ImGui.TreePop() + ImGui_TreePop() end function ImGui.DebugNodeWindowSettings(settings) - if settings.WantDelete then ImGui.BeginDisabled() end - ImGui.BulletText("0x%08X \"%s\" Pos (%d,%d) Size (%d,%d) Collapsed=%d", settings.ID, settings.Name or "", settings.Pos.x, settings.Pos.y, settings.Size.x, settings.Size.y, B(settings.Collapsed)) - if settings.WantDelete then ImGui.EndDisabled() end + if settings.WantDelete then ImGui_BeginDisabled() end + ImGui_BulletText("0x%08X \"%s\" Pos (%d,%d) Size (%d,%d) Collapsed=%d", settings.ID, settings.Name or "", settings.Pos.x, settings.Pos.y, settings.Size.x, settings.Size.y, B(settings.Collapsed)) + if settings.WantDelete then ImGui_EndDisabled() end end function ImGui.DebugNodeWindowsList(windows, label) if not ImGui.TreeNode(label, "%s (%d)", label, windows.Size) then return end for i = windows.Size, 1, -1 do -- Iterate front to back - ImGui.PushID(tostring(windows.Data[i])) - ImGui.DebugNodeWindow(windows.Data[i], "Window") - ImGui.PopID() + ImGui_PushID(tostring(windows.Data[i])) + ImGui_DebugNodeWindow(windows.Data[i], "Window") + ImGui_PopID() end - ImGui.TreePop() + ImGui_TreePop() end -- FIXME-OPT: This is technically suboptimal, but it is simpler this way. @@ -22079,28 +22130,28 @@ function ImGui.DebugNodeWindowsListByBeginStackParent(windows, first, last, pare if window.ParentWindowInBeginStack == parent_in_begin_stack then local buf = string.format("[%04d] Window", window.BeginOrderWithinContext) -- ImGui.BulletText("[%04d] Window '%s'", window.BeginOrderWithinContext, window.Name) - ImGui.DebugNodeWindow(window, buf) + ImGui_DebugNodeWindow(window, buf) ImGui.TreePush(buf) ImGui.DebugNodeWindowsListByBeginStackParent(windows, i + 1, last, window) - ImGui.TreePop() + ImGui_TreePop() end end end function ImGui.DebugNodeViewport(viewport) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() ImGui.SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) local open = ImGui.TreeNode(viewport.ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport.Idx or 0, viewport.ID, viewport.ParentViewportId or 0, viewport.Window and viewport.Window.Name or "N/A") - if ImGui.IsItemHovered() then g.DebugMetricsConfig.HighlightViewportID = viewport.ID end + if ImGui_IsItemHovered() then g.DebugMetricsConfig.HighlightViewportID = viewport.ID end if open then - ImGui.BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nFrameBufferScale: (%.2f,%.2f)\nWorkArea Inset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f\nMonitor: %d, DpiScale: %.0f%%", + ImGui_BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nFrameBufferScale: (%.2f,%.2f)\nWorkArea Inset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f\nMonitor: %d, DpiScale: %.0f%%", viewport.Pos.x, viewport.Pos.y, viewport.Size.x, viewport.Size.y, viewport.FramebufferScale and viewport.FramebufferScale.x or 1, viewport.FramebufferScale and viewport.FramebufferScale.y or 1, viewport.WorkInsetMin.x, viewport.WorkInsetMin.y, viewport.WorkInsetMax.x, viewport.WorkInsetMax.y, viewport.PlatformMonitor or 0, (viewport.DpiScale or 1) * 100.0) - ImGui.BulletText("Flags: 0x%04X", viewport.Flags or 0) + ImGui_BulletText("Flags: 0x%04X", viewport.Flags or 0) if viewport.DrawDataP then for _, draw_list in viewport.DrawDataP.CmdLists:iter() do ImGui.DebugNodeDrawList(nil, viewport, draw_list, "DrawList") end end - ImGui.TreePop() + ImGui_TreePop() end end @@ -22108,7 +22159,7 @@ end --- @param label string --- @param idx int function ImGui.DebugNodePlatformMonitor(monitor, label, idx) - ImGui.BulletText("%s %d: DPI %.0f%%\n MainMin (%.0f,%.0f), MainMax (%.0f,%.0f), MainSize (%.0f,%.0f)\n WorkMin (%.0f,%.0f), WorkMax (%.0f,%.0f), WorkSize (%.0f,%.0f)", + ImGui_BulletText("%s %d: DPI %.0f%%\n MainMin (%.0f,%.0f), MainMax (%.0f,%.0f), MainSize (%.0f,%.0f)\n WorkMin (%.0f,%.0f), WorkMax (%.0f,%.0f), WorkSize (%.0f,%.0f)", label, idx, monitor.DpiScale * 100.0, monitor.MainPos.x, monitor.MainPos.y, monitor.MainPos.x + monitor.MainSize.x, monitor.MainPos.y + monitor.MainSize.y, monitor.MainSize.x, monitor.MainSize.y, monitor.WorkPos.x, monitor.WorkPos.y, monitor.WorkPos.x + monitor.WorkSize.x, monitor.WorkPos.y + monitor.WorkSize.y, monitor.WorkSize.x, monitor.WorkSize.y) @@ -22116,28 +22167,28 @@ end -- Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct. function ImGui.DebugTextEncoding(str) - ImGui.Text("Text: \"%s\"", str) - if not ImGui.BeginTable("##DebugTextEncoding", 4, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 64 --[[ImGuiTableFlags.RowBg]], 8192 --[[ImGuiTableFlags.SizingFixedFit]], 1 --[[ImGuiTableFlags.Resizable]])) then return end - ImGui.TableSetupColumn("Offset") - ImGui.TableSetupColumn("UTF-8") - ImGui.TableSetupColumn("Glyph") - ImGui.TableSetupColumn("Codepoint") + ImGui_Text("Text: \"%s\"", str) + if not ImGui_BeginTable("##DebugTextEncoding", 4, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 64 --[[ImGuiTableFlags.RowBg]], 8192 --[[ImGuiTableFlags.SizingFixedFit]], 1 --[[ImGuiTableFlags.Resizable]])) then return end + ImGui_TableSetupColumn("Offset") + ImGui_TableSetupColumn("UTF-8") + ImGui_TableSetupColumn("Glyph") + ImGui_TableSetupColumn("Codepoint") ImGui.TableHeadersRow() for pos, c in utf8.codes(str) do local nxt = utf8.offset(str, 2, pos) or (#str + 1) - ImGui.TableNextColumn() - ImGui.Text("%d", pos - 1) - ImGui.TableNextColumn() + ImGui_TableNextColumn() + ImGui_Text("%d", pos - 1) + ImGui_TableNextColumn() for b = pos, nxt - 1 do - if b > pos then ImGui.SameLine() end - ImGui.Text("0x%02X", string.byte(str, b)) + if b > pos then ImGui_SameLine() end + ImGui_Text("0x%02X", string.byte(str, b)) end - ImGui.TableNextColumn() - ImGui.TextUnformatted(string.sub(str, pos, nxt - 1)) - ImGui.TableNextColumn() - ImGui.Text("U+%04X", c) + ImGui_TableNextColumn() + ImGui_TextUnformatted(string.sub(str, pos, nxt - 1)) + ImGui_TableNextColumn() + ImGui_Text("U+%04X", c) end - ImGui.EndTable() + ImGui_EndTable() end -- Debugging enums @@ -22181,7 +22232,7 @@ end local MetricsEncodingBuf = nil local MetricsDockRootOnly = true function ImGui.ShowMetricsWindow(p_open) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local io = g.IO local cfg = g.DebugMetricsConfig if cfg.ShowDebugLog then cfg.ShowDebugLog = ImGui.ShowDebugLogWindow(cfg.ShowDebugLog) end @@ -22189,7 +22240,7 @@ function ImGui.ShowMetricsWindow(p_open) local visible p_open, visible = ImGui.Begin("Dear ImGui Metrics/Debugger", p_open) - if not visible or ImGui.GetCurrentWindow().BeginCount > 1 then + if not visible or ImGui_GetCurrentWindow().BeginCount > 1 then ImGui.End() return p_open end @@ -22198,15 +22249,15 @@ function ImGui.ShowMetricsWindow(p_open) ImGui.DebugBreakClearData() -- Basic info - ImGui.Text("Dear ImGui %s (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) + ImGui_Text("Dear ImGui %s (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) if g.ContextName ~= nil and g.ContextName ~= "" then - ImGui.SameLine() - ImGui.Text("(Context Name: \"%s\")", g.ContextName) + ImGui_SameLine() + ImGui_Text("(Context Name: \"%s\")", g.ContextName) end - ImGui.Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / math.max(io.Framerate, 0.0001), io.Framerate) - ImGui.Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, math.floor(io.MetricsRenderIndices / 3)) - ImGui.Text("%d visible windows, %d current allocations", io.MetricsRenderWindows, g.DebugAllocInfo.TotalAllocCount - g.DebugAllocInfo.TotalFreeCount) - ImGui.Separator() + ImGui_Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / math.max(io.Framerate, 0.0001), io.Framerate) + ImGui_Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, math.floor(io.MetricsRenderIndices / 3)) + ImGui_Text("%d visible windows, %d current allocations", io.MetricsRenderWindows, g.DebugAllocInfo.TotalAllocCount - g.DebugAllocInfo.TotalFreeCount) + ImGui_Separator() if cfg.ShowWindowsRectsType < 0 then cfg.ShowWindowsRectsType = 4 end if cfg.ShowTablesRectsType < 0 then cfg.ShowTablesRectsType = 2 end @@ -22215,64 +22266,64 @@ function ImGui.ShowMetricsWindow(p_open) if ImGui.TreeNode("Tools") then -- Debug Break features -- The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted. - ImGui.SeparatorTextEx(0, "Debug breaks", nil, ImGui.CalcTextSize("(?)").x + g.Style.SeparatorTextPadding.x) - ImGui.SameLine() + ImGui.SeparatorTextEx(0, "Debug breaks", nil, ImGui_CalcTextSize("(?)").x + g.Style.SeparatorTextPadding.x) + ImGui_SameLine() MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash.") local picker_toggled - picker_toggled, g.DebugItemPickerActive = ImGui.Checkbox("Show Item Picker", g.DebugItemPickerActive) + picker_toggled, g.DebugItemPickerActive = ImGui_Checkbox("Show Item Picker", g.DebugItemPickerActive) if picker_toggled and g.DebugItemPickerActive then ImGui.DebugStartItemPicker() end - _, io.ConfigDebugIsDebuggerPresent = ImGui.Checkbox("Show \"Debug Break\" buttons in other sections (io.ConfigDebugIsDebuggerPresent)", io.ConfigDebugIsDebuggerPresent) + _, io.ConfigDebugIsDebuggerPresent = ImGui_Checkbox("Show \"Debug Break\" buttons in other sections (io.ConfigDebugIsDebuggerPresent)", io.ConfigDebugIsDebuggerPresent) - ImGui.SeparatorText("Visualize") - _, cfg.ShowDebugLog = ImGui.Checkbox("Show Debug Log", cfg.ShowDebugLog == true) - ImGui.SameLine(); MetricsHelpMarker("You can also call ImGui::ShowDebugLogWindow() from your code.") - _, cfg.ShowIDStackTool = ImGui.Checkbox("Show ID Stack Tool", cfg.ShowIDStackTool == true) - ImGui.SameLine(); MetricsHelpMarker("You can also call ImGui::ShowIDStackToolWindow() from your code.") - _, cfg.ShowWindowsBeginOrder = ImGui.Checkbox("Show windows begin order", cfg.ShowWindowsBeginOrder == true) - _, cfg.ShowWindowsRects = ImGui.Checkbox("Show windows rectangles", cfg.ShowWindowsRects == true) - ImGui.SameLine() - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 12) + ImGui_SeparatorText("Visualize") + _, cfg.ShowDebugLog = ImGui_Checkbox("Show Debug Log", cfg.ShowDebugLog == true) + ImGui_SameLine(); MetricsHelpMarker("You can also call ImGui::ShowDebugLogWindow() from your code.") + _, cfg.ShowIDStackTool = ImGui_Checkbox("Show ID Stack Tool", cfg.ShowIDStackTool == true) + ImGui_SameLine(); MetricsHelpMarker("You can also call ImGui::ShowIDStackToolWindow() from your code.") + _, cfg.ShowWindowsBeginOrder = ImGui_Checkbox("Show windows begin order", cfg.ShowWindowsBeginOrder == true) + _, cfg.ShowWindowsRects = ImGui_Checkbox("Show windows rectangles", cfg.ShowWindowsRects == true) + ImGui_SameLine() + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 12) local changed cfg.ShowWindowsRectsType, changed = ImGui.Combo("##show_windows_rect_type", cfg.ShowWindowsRectsType, WRT_Names, #WRT_Names, #WRT_Names) cfg.ShowWindowsRects = cfg.ShowWindowsRects or changed if cfg.ShowWindowsRects and g.NavWindow ~= nil then - ImGui.BulletText("'%s':", g.NavWindow.Name) - ImGui.Indent() + ImGui_BulletText("'%s':", g.NavWindow.Name) + ImGui_Indent() for rect_n = 0, #WRT_Names - 1 do local r = GetWindowRect(g.NavWindow, rect_n) - ImGui.Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r:GetWidth(), r:GetHeight(), WRT_Names[rect_n + 1]) + ImGui_Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r:GetWidth(), r:GetHeight(), WRT_Names[rect_n + 1]) end - ImGui.Unindent() + ImGui_Unindent() end - _, cfg.ShowTablesRects = ImGui.Checkbox("Show tables rectangles", cfg.ShowTablesRects == true) - ImGui.SameLine() - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 12) + _, cfg.ShowTablesRects = ImGui_Checkbox("Show tables rectangles", cfg.ShowTablesRects == true) + ImGui_SameLine() + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 12) cfg.ShowTablesRectsType, changed = ImGui.Combo("##show_table_rects_type", cfg.ShowTablesRectsType, TRT_Names, #TRT_Names, #TRT_Names) cfg.ShowTablesRects = cfg.ShowTablesRects or changed - _, g.DebugShowGroupRects = ImGui.Checkbox("Show groups rectangles", g.DebugShowGroupRects == true) -- Storing in context as this is used by group code and prefers to be in hot-data + _, g.DebugShowGroupRects = ImGui_Checkbox("Show groups rectangles", g.DebugShowGroupRects == true) -- Storing in context as this is used by group code and prefers to be in hot-data - ImGui.SeparatorText("Validate") - _, io.ConfigDebugBeginReturnValueLoop = ImGui.Checkbox("Debug Begin/BeginChild return value", io.ConfigDebugBeginReturnValueLoop) - ImGui.SameLine(); MetricsHelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.") - _, cfg.ShowTextEncodingViewer = ImGui.Checkbox("UTF-8 Encoding viewer", cfg.ShowTextEncodingViewer == true) - ImGui.SameLine(); MetricsHelpMarker("You can also call ImGui::DebugTextEncoding() from your code with a given string to test that your UTF-8 encoding settings are correct.") + ImGui_SeparatorText("Validate") + _, io.ConfigDebugBeginReturnValueLoop = ImGui_Checkbox("Debug Begin/BeginChild return value", io.ConfigDebugBeginReturnValueLoop) + ImGui_SameLine(); MetricsHelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.") + _, cfg.ShowTextEncodingViewer = ImGui_Checkbox("UTF-8 Encoding viewer", cfg.ShowTextEncodingViewer == true) + ImGui_SameLine(); MetricsHelpMarker("You can also call ImGui::DebugTextEncoding() from your code with a given string to test that your UTF-8 encoding settings are correct.") if cfg.ShowTextEncodingViewer then MetricsEncodingBuf = MetricsEncodingBuf or DemoBuf("", 64) - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) ImGui.InputText("##DebugTextEncodingBuf", MetricsEncodingBuf, 64) local str = DemoBufStr(MetricsEncodingBuf) if str ~= "" then ImGui.DebugTextEncoding(str) end end - ImGui.TreePop() + ImGui_TreePop() end -- Windows if ImGui.TreeNode("Windows", "Windows (%d)", g.Windows.Size) then -- ImGui.SetNextItemOpen(true, ImGuiCond.Once) - ImGui.DebugNodeWindowsList(g.Windows, "By display order") - ImGui.DebugNodeWindowsList(g.WindowsFocusOrder, "By focus order (root windows)") + ImGui_DebugNodeWindowsList(g.Windows, "By display order") + ImGui_DebugNodeWindowsList(g.WindowsFocusOrder, "By focus order (root windows)") if ImGui.TreeNode("By submission order (begin stack)") then -- Here we display windows in their submitted order/hierarchy, however note that the Begin stack doesn't constitute a Parent<>Child relationship! local tmp = {} @@ -22281,53 +22332,53 @@ function ImGui.ShowMetricsWindow(p_open) end table.sort(tmp, function(a, b) return a.BeginOrderWithinContext < b.BeginOrderWithinContext end) ImGui.DebugNodeWindowsListByBeginStackParent(tmp, 1, #tmp, nil) - ImGui.TreePop() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end -- DrawLists local drawlist_count = 0 for _, viewport in g.Viewports:iter() do drawlist_count = drawlist_count + viewport.DrawDataP.CmdLists.Size end if ImGui.TreeNode("DrawLists", "DrawLists (%d)", drawlist_count) then - _, cfg.ShowDrawCmdMesh = ImGui.Checkbox("Show ImDrawCmd mesh when hovering", cfg.ShowDrawCmdMesh) - _, cfg.ShowDrawCmdBoundingBoxes = ImGui.Checkbox("Show ImDrawCmd bounding boxes when hovering", cfg.ShowDrawCmdBoundingBoxes) + _, cfg.ShowDrawCmdMesh = ImGui_Checkbox("Show ImDrawCmd mesh when hovering", cfg.ShowDrawCmdMesh) + _, cfg.ShowDrawCmdBoundingBoxes = ImGui_Checkbox("Show ImDrawCmd bounding boxes when hovering", cfg.ShowDrawCmdBoundingBoxes) for _, viewport in g.Viewports:iter() do local has = false for _, draw_list in viewport.DrawDataP.CmdLists:iter() do - if not has then ImGui.Text("Active DrawLists in Viewport #%d, ID: 0x%08X", viewport.Idx or 0, viewport.ID) end + if not has then ImGui_Text("Active DrawLists in Viewport #%d, ID: 0x%08X", viewport.Idx or 0, viewport.ID) end has = true ImGui.DebugNodeDrawList(nil, viewport, draw_list, "DrawList") end end - ImGui.TreePop() + ImGui_TreePop() end -- Viewports if ImGui.TreeNode("Viewports", "Viewports (%d)", g.Viewports.Size) then cfg.HighlightMonitorIdx = -1 local open = ImGui.TreeNode("Monitors", "Monitors (%d)", g.PlatformIO.Monitors.Size) - ImGui.SameLine() + ImGui_SameLine() MetricsHelpMarker("Dear ImGui uses monitor data:\n- to query DPI settings on a per monitor basis\n- to position popup/tooltips so they don't straddle monitors.") if open then for i = 1, g.PlatformIO.Monitors.Size do ImGui.DebugNodePlatformMonitor(g.PlatformIO.Monitors.Data[i], "Monitor", i - 1) - if ImGui.IsItemHovered() then + if ImGui_IsItemHovered() then cfg.HighlightMonitorIdx = i - 1 -- [Port] 0-based, like Monitors:index_from_ptr() end end if g.FallbackMonitor then ImGui.DebugNodePlatformMonitor(g.FallbackMonitor, "Fallback", 0) end - ImGui.TreePop() + ImGui_TreePop() end ImGui.SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) if ImGui.TreeNode("Windows Minimap") then ImGui.RenderViewportsThumbnails() - ImGui.TreePop() + ImGui_TreePop() end cfg.HighlightViewportID = 0 - ImGui.BulletText("MouseViewport: 0x%08X (UserHovered 0x%08X, LastHovered 0x%08X)", g.MouseViewport and g.MouseViewport.ID or 0, g.IO.MouseHoveredViewport or 0, g.MouseLastHoveredViewport and g.MouseLastHoveredViewport.ID or 0) + ImGui_BulletText("MouseViewport: 0x%08X (UserHovered 0x%08X, LastHovered 0x%08X)", g.MouseViewport and g.MouseViewport.ID or 0, g.IO.MouseHoveredViewport or 0, g.MouseLastHoveredViewport and g.MouseLastHoveredViewport.ID or 0) if ImGui.TreeNode("Inferred Z order (front-to-back)") then local viewports = {} for n = 1, g.Viewports.Size do viewports[n] = g.Viewports.Data[n] end @@ -22335,26 +22386,26 @@ function ImGui.ShowMetricsWindow(p_open) table.sort(viewports, ViewportComparerByLastFocusedStampCount) end for _, viewport in ipairs(viewports) do - ImGui.BulletText("Viewport #%d, ID: 0x%08X, LastFocused = %08d, PlatformFocused = %s, Window: \"%s\"", + ImGui_BulletText("Viewport #%d, ID: 0x%08X, LastFocused = %08d, PlatformFocused = %s, Window: \"%s\"", viewport.Idx, viewport.ID, viewport.LastFocusedStampCount, (g.PlatformIO.Platform_GetWindowFocus and viewport.PlatformWindowCreated) and (g.PlatformIO.Platform_GetWindowFocus(viewport) and "1" or "0") or "N/A", viewport.Window and viewport.Window.Name or "N/A") - if ImGui.IsItemHovered() then + if ImGui_IsItemHovered() then cfg.HighlightViewportID = viewport.ID end end - ImGui.TreePop() + ImGui_TreePop() end for _, viewport in g.Viewports:iter() do ImGui.DebugNodeViewport(viewport) end - ImGui.TreePop() + ImGui_TreePop() end -- Details for Fonts for i, atlas in g.FontAtlases:iter() do if ImGui.TreeNode(tostring(atlas), "Fonts (%d), Textures (%d)", atlas.Fonts.Size, atlas.TexList.Size) then ImGui.ShowFontAtlas(atlas) - ImGui.TreePop() + ImGui_TreePop() end end @@ -22364,11 +22415,11 @@ function ImGui.ShowMetricsWindow(p_open) -- As it's difficult to interact with tree nodes while popups are open, we display everything inline. local window = popup_data.Window local W = ImGuiWindowFlags - ImGui.BulletText("PopupID: %08x, Window: '%s' (%s%s), RestoreNavWindow '%s', ParentWindow '%s'", popup_data.PopupId, window and window.Name or "NULL", + ImGui_BulletText("PopupID: %08x, Window: '%s' (%s%s), RestoreNavWindow '%s', ParentWindow '%s'", popup_data.PopupId, window and window.Name or "NULL", (window and bit32.band(window.Flags, W.ChildWindow) ~= 0) and "Child;" or "", (window and bit32.band(window.Flags, W.ChildMenu) ~= 0) and "Menu;" or "", popup_data.RestoreNavWindow and popup_data.RestoreNavWindow.Name or "NULL", (window and window.ParentWindow) and window.ParentWindow.Name or "NULL") end - ImGui.TreePop() + ImGui_TreePop() end -- Details for TabBars @@ -22376,234 +22427,234 @@ function ImGui.ShowMetricsWindow(p_open) for n = 0, g.TabBars:GetMapSize() - 1 do local tab_bar = g.TabBars:GetByIndex(n) if tab_bar then - ImGui.PushID(n) + ImGui_PushID(n) ImGui.DebugNodeTabBar(tab_bar, "TabBar") - ImGui.PopID() + ImGui_PopID() end end - ImGui.TreePop() + ImGui_TreePop() end -- Details for Tables if ImGui.TreeNode("Tables", "Tables (%d)", g.Tables.AliveCount) then ForEachTable(g, ImGui.DebugNodeTable) - ImGui.TreePop() + ImGui_TreePop() end -- Details for InputText if ImGui.TreeNode("InputText") then ImGui.DebugNodeInputTextState(g.InputTextState) - ImGui.TreePop() + ImGui_TreePop() end -- Details for TypingSelect if ImGui.TreeNode("TypingSelect", "TypingSelect (%d)", (#g.TypingSelectState.SearchBuffer ~= 0) and 1 or 0) then ImGui.DebugNodeTypingSelectState(g.TypingSelectState) - ImGui.TreePop() + ImGui_TreePop() end -- Details for MultiSelect if ImGui.TreeNode("MultiSelect", "MultiSelect (%d)", g.MultiSelectStorage.AliveCount) then local bs = g.BoxSelectState - ImGui.BulletText("BoxSelect ID=0x%08X, Starting = %d, Active %d", bs.ID, B(bs.IsStarting), B(bs.IsActive)) + ImGui_BulletText("BoxSelect ID=0x%08X, Starting = %d, Active %d", bs.ID, B(bs.IsStarting), B(bs.IsActive)) for n = 0, g.MultiSelectStorage:GetMapSize() - 1 do local state = g.MultiSelectStorage:GetByIndex(n) if state then ImGui.DebugNodeMultiSelectState(state) end end - ImGui.TreePop() + ImGui_TreePop() end -- Details for Docking if ImGui.TreeNode("Docking") then local dc = g.DockContext - _, MetricsDockRootOnly = ImGui.Checkbox("List root nodes", MetricsDockRootOnly) - _, cfg.ShowDockingNodes = ImGui.Checkbox("Ctrl shows window dock info", cfg.ShowDockingNodes == true) - if ImGui.SmallButton("Clear nodes") then ImGui.DockContextClearNodes(g, 0, true) end - ImGui.SameLine() - if ImGui.SmallButton("Rebuild all") then dc.WantFullRebuild = true end + _, MetricsDockRootOnly = ImGui_Checkbox("List root nodes", MetricsDockRootOnly) + _, cfg.ShowDockingNodes = ImGui_Checkbox("Ctrl shows window dock info", cfg.ShowDockingNodes == true) + if ImGui_SmallButton("Clear nodes") then ImGui_DockContextClearNodes(g, 0, true) end + ImGui_SameLine() + if ImGui_SmallButton("Rebuild all") then dc.WantFullRebuild = true end local ids = {} for id in pairs(dc.Nodes) do ids[#ids + 1] = id end table.sort(ids) for _, id in ipairs(ids) do local node = dc.Nodes[id] - if node and (not MetricsDockRootOnly or node:IsRootNode()) then ImGui.DebugNodeDockNode(node, "Node") end + if node and (not MetricsDockRootOnly or node:IsRootNode()) then ImGui_DebugNodeDockNode(node, "Node") end end - ImGui.TreePop() + ImGui_TreePop() end -- Settings if ImGui.TreeNode("Settings") then - if ImGui.SmallButton("Clear") then ImGui.ClearIniSettings() end - ImGui.SameLine() - if ImGui.SmallButton("Save to memory") then ImGui.SaveIniSettingsToMemory() end - ImGui.SameLine() - if ImGui.SmallButton("Save to disk") then ImGui.SaveIniSettingsToDisk(g.IO.IniFilename) end - ImGui.SameLine() - ImGui.TextUnformatted(io.IniFilename and ("\"" .. io.IniFilename .. "\"") or "") - ImGui.Text("SettingsDirtyTimer %.2f", g.SettingsDirtyTimer) + if ImGui_SmallButton("Clear") then ImGui.ClearIniSettings() end + ImGui_SameLine() + if ImGui_SmallButton("Save to memory") then ImGui.SaveIniSettingsToMemory() end + ImGui_SameLine() + if ImGui_SmallButton("Save to disk") then ImGui.SaveIniSettingsToDisk(g.IO.IniFilename) end + ImGui_SameLine() + ImGui_TextUnformatted(io.IniFilename and ("\"" .. io.IniFilename .. "\"") or "") + ImGui_Text("SettingsDirtyTimer %.2f", g.SettingsDirtyTimer) local platform_io = g.PlatformIO local highlight_older_than_date = 0 - ImGui.Text("SessionDate: %d", platform_io.Platform_SessionDate) - ImGui.BeginDisabled(platform_io.Platform_SessionDate == 0) - _, cfg.SettingsHighlightOldEntries = ImGui.Checkbox("Highlight Entries Older Than", cfg.SettingsHighlightOldEntries) - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - ImGui.SameLine() + ImGui_Text("SessionDate: %d", platform_io.Platform_SessionDate) + ImGui_BeginDisabled(platform_io.Platform_SessionDate == 0) + _, cfg.SettingsHighlightOldEntries = ImGui_Checkbox("Highlight Entries Older Than", cfg.SettingsHighlightOldEntries) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + ImGui_SameLine() cfg.SettingsDiscardMonths = ImGui.SliderInt("Months", cfg.SettingsDiscardMonths, 1, 24) if cfg.SettingsHighlightOldEntries and cfg.SettingsDiscardMonths > 0 then local cutoff_date = ImGuiPackedDate(platform_io.Platform_SessionDate) cutoff_date:SubtractMonths(cfg.SettingsDiscardMonths) highlight_older_than_date = cutoff_date:Unpack() - ImGui.SameLine() + ImGui_SameLine() local cleanup_args = ImGuiSettingsCleanupArgs() cleanup_args.DiscardOlderThanMonths = cfg.SettingsDiscardMonths - if ImGui.Button("Discard") then + if ImGui_Button("Discard") then ImGui.CleanupIniSettings(cleanup_args) end end - ImGui.EndDisabled() - _, io.ConfigDebugIniSettings = ImGui.Checkbox("io.ConfigDebugIniSettings", io.ConfigDebugIniSettings) + ImGui_EndDisabled() + _, io.ConfigDebugIniSettings = ImGui_Checkbox("io.ConfigDebugIniSettings", io.ConfigDebugIniSettings) -- [Luau] struct ScopedHighlightOlderThan: push in the loop body, pop after (settings.LastUsedDate is unpacked) local function HighlightOlderThan(cutoff_date, in_date) local highlight = cutoff_date ~= 0 and in_date < cutoff_date - if highlight then ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImVec4(1.0, 0.4, 0.4, 1.0)) end + if highlight then ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImVec4(1.0, 0.4, 0.4, 1.0)) end return highlight end if ImGui.TreeNode("SettingsHandlers", "Settings handlers: (%d)", g.SettingsHandlers.Size) then - for _, handler in g.SettingsHandlers:iter() do ImGui.BulletText("\"%s\"", handler.TypeName) end - ImGui.TreePop() + for _, handler in g.SettingsHandlers:iter() do ImGui_BulletText("\"%s\"", handler.TypeName) end + ImGui_TreePop() end if ImGui.TreeNode("SettingsWindows", "Settings packed data: Windows: %d entries", g.SettingsWindows.Size) then for _, settings in g.SettingsWindows:iter() do local highlight = HighlightOlderThan(highlight_older_than_date, settings.LastUsedDate) ImGui.DebugNodeWindowSettings(settings) - if highlight then ImGui.PopStyleColor() end + if highlight then ImGui_PopStyleColor() end end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("SettingsTables", "Settings packed data: Tables: %d entries", g.SettingsTables.Size) then for _, settings in g.SettingsTables:iter() do local highlight = HighlightOlderThan(highlight_older_than_date, settings.LastUsedDate) ImGui.DebugNodeTableSettings(settings, nil) - if highlight then ImGui.PopStyleColor() end + if highlight then ImGui_PopStyleColor() end end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("SettingsDocking", "Settings packed data: Docking") then local dc = g.DockContext - ImGui.Text("In SettingsWindows:") + ImGui_Text("In SettingsWindows:") for _, settings in g.SettingsWindows:iter() do - if (settings.DockId or 0) ~= 0 then ImGui.BulletText("Window '%s' -> DockId %08X DockOrder=%d", settings.Name or "", settings.DockId, settings.DockOrder or -1) end + if (settings.DockId or 0) ~= 0 then ImGui_BulletText("Window '%s' -> DockId %08X DockOrder=%d", settings.Name or "", settings.DockId, settings.DockOrder or -1) end end - ImGui.Text("In SettingsNodes:") + ImGui_Text("In SettingsNodes:") for _, settings in dc.NodesSettings:iter() do local selected_tab_name = nil if (settings.SelectedTabId or 0) ~= 0 then - local window = ImGui.FindWindowByID(settings.SelectedTabId) + local window = ImGui_FindWindowByID(settings.SelectedTabId) selected_tab_name = window and window.Name or nil end - ImGui.BulletText("Node %08X, Parent %08X, SelectedTab %08X ('%s')", settings.ID, settings.ParentNodeId or 0, settings.SelectedTabId or 0, selected_tab_name or ((settings.SelectedTabId or 0) ~= 0 and "N/A" or "")) + ImGui_BulletText("Node %08X, Parent %08X, SelectedTab %08X ('%s')", settings.ID, settings.ParentNodeId or 0, settings.SelectedTabId or 0, selected_tab_name or ((settings.SelectedTabId or 0) ~= 0 and "N/A" or "")) end - ImGui.TreePop() + ImGui_TreePop() end local ini = g.SettingsIniData or "" if ImGui.TreeNode("SettingsIniData", "Settings unpacked data (.ini): %d bytes", #ini) then ImGui.InputTextMultiline("##Ini", DemoBuf(ini, #ini + 1), #ini + 1, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetTextLineHeight() * 20), 512 --[[ImGuiInputTextFlags.ReadOnly]]) - ImGui.TreePop() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end -- Inputs if ImGui.TreeNode("Inputs") then - ImGui.Text("KEYBOARD/GAMEPAD/MOUSE KEYS") + ImGui_Text("KEYBOARD/GAMEPAD/MOUSE KEYS") -- User code should never have to go through such hoops! You can generally iterate between ImGuiKey.NamedKey_BEGIN and ImGuiKey.NamedKey_END. - ImGui.Indent() - ImGui.Text("Keys down:") + ImGui_Indent() + ImGui_Text("Keys down:") for key = 512 --[[ImGuiKey.NamedKey_BEGIN]], 667 --[[ImGuiKey.NamedKey_END]] - 1 do - if ImGui.IsKeyDown(key) then ImGui.SameLine(); ImGui.Text("\"%s\"", ImGui.GetKeyName(key)) end + if ImGui_IsKeyDown(key) then ImGui_SameLine(); ImGui_Text("\"%s\"", ImGui_GetKeyName(key)) end end - ImGui.Text("Keys pressed:") + ImGui_Text("Keys pressed:") for key = 512 --[[ImGuiKey.NamedKey_BEGIN]], 667 --[[ImGuiKey.NamedKey_END]] - 1 do - if ImGui.IsKeyPressed(key) then ImGui.SameLine(); ImGui.Text("\"%s\"", ImGui.GetKeyName(key)) end + if ImGui.IsKeyPressed(key) then ImGui_SameLine(); ImGui_Text("\"%s\"", ImGui_GetKeyName(key)) end end - ImGui.Text("Keys released:") + ImGui_Text("Keys released:") for key = 512 --[[ImGuiKey.NamedKey_BEGIN]], 667 --[[ImGuiKey.NamedKey_END]] - 1 do - if ImGui.IsKeyReleased(key) then ImGui.SameLine(); ImGui.Text("\"%s\"", ImGui.GetKeyName(key)) end + if ImGui.IsKeyReleased(key) then ImGui_SameLine(); ImGui_Text("\"%s\"", ImGui_GetKeyName(key)) end end - ImGui.Text("Keys mods: %s%s%s%s", io.KeyCtrl and "Ctrl " or "", io.KeyShift and "Shift " or "", io.KeyAlt and "Alt " or "", io.KeySuper and "Super " or "") - ImGui.Text("Chars queue:") + ImGui_Text("Keys mods: %s%s%s%s", io.KeyCtrl and "Ctrl " or "", io.KeyShift and "Shift " or "", io.KeyAlt and "Alt " or "", io.KeySuper and "Super " or "") + ImGui_Text("Chars queue:") for i = 1, io.InputQueueCharacters.Size do local c = io.InputQueueCharacters.Data[i] - ImGui.SameLine(); ImGui.Text("'%s' (0x%04X)", (c > 32 and c <= 255) and string.char(c) or "?", c) -- FIXME: We should convert 'c' to UTF-8 here but the functions are not public. + ImGui_SameLine(); ImGui_Text("'%s' (0x%04X)", (c > 32 and c <= 255) and string.char(c) or "?", c) -- FIXME: We should convert 'c' to UTF-8 here but the functions are not public. end - ImGui.DebugRenderKeyboardPreview(ImGui.GetWindowDrawList()) - ImGui.Unindent() - ImGui.Text("MOUSE STATE") - ImGui.Indent() - if ImGui.IsMousePosValid() then ImGui.Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y) else ImGui.Text("Mouse pos: ") end - ImGui.Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y) - ImGui.Text("Mouse down:") + ImGui.DebugRenderKeyboardPreview(ImGui_GetWindowDrawList()) + ImGui_Unindent() + ImGui_Text("MOUSE STATE") + ImGui_Indent() + if ImGui_IsMousePosValid() then ImGui_Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y) else ImGui_Text("Mouse pos: ") end + ImGui_Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y) + ImGui_Text("Mouse down:") local count = 5 --[[ImGuiMouseButton.COUNT]] -- [Port] IM_COUNTOF(io.MouseDown) - for i = 0, count - 1 do if ImGui.IsMouseDown(i) then ImGui.SameLine(); ImGui.Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]) end end - ImGui.Text("Mouse clicked:") - for i = 0, count - 1 do if ImGui.IsMouseClicked(i) then ImGui.SameLine(); ImGui.Text("b%d (%d)", i, io.MouseClickedCount[i]) end end - ImGui.Text("Mouse released:") - for i = 0, count - 1 do if ImGui.IsMouseReleased(i) then ImGui.SameLine(); ImGui.Text("b%d", i) end end - ImGui.Text("Mouse wheel: %.1f", io.MouseWheel) - ImGui.Text("MouseStationaryTimer: %.2f", g.MouseStationaryTimer) - ImGui.Text("Mouse source: %s", GetMouseSourceName(io.MouseSource)) - ImGui.Text("Pen Pressure: %.1f", io.PenPressure) -- Note: currently unused - ImGui.Unindent() - ImGui.Text("MOUSE WHEELING") - ImGui.Indent() - ImGui.Text("WheelingWindow: '%s'", g.WheelingWindow and g.WheelingWindow.Name or "NULL") - ImGui.Text("WheelingWindowReleaseTimer: %.2f", g.WheelingWindowReleaseTimer or 0) - ImGui.Text("WheelingAxisAvg[] = { %.3f, %.3f }", g.WheelingAxisAvg.x, g.WheelingAxisAvg.y) - ImGui.Unindent() - ImGui.TreePop() + for i = 0, count - 1 do if ImGui.IsMouseDown(i) then ImGui_SameLine(); ImGui_Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]) end end + ImGui_Text("Mouse clicked:") + for i = 0, count - 1 do if ImGui_IsMouseClicked(i) then ImGui_SameLine(); ImGui_Text("b%d (%d)", i, io.MouseClickedCount[i]) end end + ImGui_Text("Mouse released:") + for i = 0, count - 1 do if ImGui.IsMouseReleased(i) then ImGui_SameLine(); ImGui_Text("b%d", i) end end + ImGui_Text("Mouse wheel: %.1f", io.MouseWheel) + ImGui_Text("MouseStationaryTimer: %.2f", g.MouseStationaryTimer) + ImGui_Text("Mouse source: %s", GetMouseSourceName(io.MouseSource)) + ImGui_Text("Pen Pressure: %.1f", io.PenPressure) -- Note: currently unused + ImGui_Unindent() + ImGui_Text("MOUSE WHEELING") + ImGui_Indent() + ImGui_Text("WheelingWindow: '%s'", g.WheelingWindow and g.WheelingWindow.Name or "NULL") + ImGui_Text("WheelingWindowReleaseTimer: %.2f", g.WheelingWindowReleaseTimer or 0) + ImGui_Text("WheelingAxisAvg[] = { %.3f, %.3f }", g.WheelingAxisAvg.x, g.WheelingAxisAvg.y) + ImGui_Unindent() + ImGui_TreePop() end -- Internal state if ImGui.TreeNode("Internal state") then local function N(w) return w and w.Name or "NULL" end - ImGui.Text("WINDOWING") - ImGui.Indent() - ImGui.Text("HoveredWindow: '%s'", N(g.HoveredWindow)) - ImGui.Text("HoveredWindow->Root: '%s'", g.HoveredWindow and N(g.HoveredWindow.RootWindowDockTree) or "NULL") - ImGui.Text("HoveredWindowUnderMovingWindow: '%s'", N(g.HoveredWindowUnderMovingWindow)) - ImGui.Text("HoveredDockNode: 0x%08X", g.DebugHoveredDockNode and g.DebugHoveredDockNode.ID or 0) - ImGui.Text("MovingWindow: '%s'", N(g.MovingWindow)) - ImGui.Unindent() - ImGui.Text("ITEMS") - ImGui.Indent() - ImGui.Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, B(g.ActiveIdAllowOverlap), GetInputSourceName(g.ActiveIdSource)) - ImGui.DebugLocateItemOnHover(g.ActiveId) - ImGui.Text("ActiveIdWindow: '%s'", N(g.ActiveIdWindow)) - ImGui.Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, B(g.HoveredIdAllowOverlap)) -- Not displaying g.HoveredId as it is update mid-frame - ImGui.Text("HoverItemDelayId: 0x%08X, Timer: %.2f, ClearTimer: %.2f", g.HoverItemDelayId or 0, g.HoverItemDelayTimer or 0, g.HoverItemDelayClearTimer or 0) - ImGui.Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\"", B(g.DragDropActive), g.DragDropPayload.SourceId or 0, tostring(g.DragDropPayload.DataType or "")) - ImGui.DebugLocateItemOnHover(g.DragDropPayload.SourceId or 0) - ImGui.Unindent() - ImGui.Text("NAV,FOCUS") - ImGui.Indent() - ImGui.Text("NavWindow: '%s'", N(g.NavWindow)) - ImGui.Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer) - ImGui.DebugLocateItemOnHover(g.NavId) - ImGui.Text("NavInputSource: %s", GetInputSourceName(g.NavInputSource or 0 --[[ImGuiInputSource.None]])) - ImGui.Text("NavLastValidSelectionUserData = %s", tostring(g.NavLastValidSelectionUserData)) -- [Port] any Lua value: tostring() instead of %lld (0x%llX) - ImGui.Text("NavActive: %d, NavVisible: %d", B(io.NavActive), B(io.NavVisible)) - ImGui.Text("NavActivateId/DownId/PressedId: %08X/%08X/%08X", g.NavActivateId, g.NavActivateDownId or 0, g.NavActivatePressedId or 0) - ImGui.Text("NavActivateFlags: %04X", g.NavActivateFlags or 0) - ImGui.Text("NavCursorVisible: %d, NavHighlightItemUnderNav: %d", B(g.NavCursorVisible), B(g.NavHighlightItemUnderNav)) - ImGui.Text("NavFocusScopeId = 0x%08X", g.NavFocusScopeId or 0) - ImGui.Text("NavWindowingTarget: '%s'", N(g.NavWindowingTarget)) - ImGui.Unindent() - ImGui.TreePop() + ImGui_Text("WINDOWING") + ImGui_Indent() + ImGui_Text("HoveredWindow: '%s'", N(g.HoveredWindow)) + ImGui_Text("HoveredWindow->Root: '%s'", g.HoveredWindow and N(g.HoveredWindow.RootWindowDockTree) or "NULL") + ImGui_Text("HoveredWindowUnderMovingWindow: '%s'", N(g.HoveredWindowUnderMovingWindow)) + ImGui_Text("HoveredDockNode: 0x%08X", g.DebugHoveredDockNode and g.DebugHoveredDockNode.ID or 0) + ImGui_Text("MovingWindow: '%s'", N(g.MovingWindow)) + ImGui_Unindent() + ImGui_Text("ITEMS") + ImGui_Indent() + ImGui_Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, B(g.ActiveIdAllowOverlap), GetInputSourceName(g.ActiveIdSource)) + ImGui_DebugLocateItemOnHover(g.ActiveId) + ImGui_Text("ActiveIdWindow: '%s'", N(g.ActiveIdWindow)) + ImGui_Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, B(g.HoveredIdAllowOverlap)) -- Not displaying g.HoveredId as it is update mid-frame + ImGui_Text("HoverItemDelayId: 0x%08X, Timer: %.2f, ClearTimer: %.2f", g.HoverItemDelayId or 0, g.HoverItemDelayTimer or 0, g.HoverItemDelayClearTimer or 0) + ImGui_Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\"", B(g.DragDropActive), g.DragDropPayload.SourceId or 0, tostring(g.DragDropPayload.DataType or "")) + ImGui_DebugLocateItemOnHover(g.DragDropPayload.SourceId or 0) + ImGui_Unindent() + ImGui_Text("NAV,FOCUS") + ImGui_Indent() + ImGui_Text("NavWindow: '%s'", N(g.NavWindow)) + ImGui_Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer) + ImGui_DebugLocateItemOnHover(g.NavId) + ImGui_Text("NavInputSource: %s", GetInputSourceName(g.NavInputSource or 0 --[[ImGuiInputSource.None]])) + ImGui_Text("NavLastValidSelectionUserData = %s", tostring(g.NavLastValidSelectionUserData)) -- [Port] any Lua value: tostring() instead of %lld (0x%llX) + ImGui_Text("NavActive: %d, NavVisible: %d", B(io.NavActive), B(io.NavVisible)) + ImGui_Text("NavActivateId/DownId/PressedId: %08X/%08X/%08X", g.NavActivateId, g.NavActivateDownId or 0, g.NavActivatePressedId or 0) + ImGui_Text("NavActivateFlags: %04X", g.NavActivateFlags or 0) + ImGui_Text("NavCursorVisible: %d, NavHighlightItemUnderNav: %d", B(g.NavCursorVisible), B(g.NavHighlightItemUnderNav)) + ImGui_Text("NavFocusScopeId = 0x%08X", g.NavFocusScopeId or 0) + ImGui_Text("NavWindowingTarget: '%s'", N(g.NavWindowingTarget)) + ImGui_Unindent() + ImGui_TreePop() end -- Overlay: Display windows Rectangles and Begin Order @@ -22616,7 +22667,7 @@ function ImGui.ShowMetricsWindow(p_open) draw_list:AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255)) end if cfg.ShowWindowsBeginOrder and bit32.band(window.Flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) == 0 then - local font_size = ImGui.GetFontSize() + local font_size = ImGui_GetFontSize() draw_list:AddRectFilled(window.Pos, window.Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255)) draw_list:AddText(window.Pos, IM_COL32(255, 255, 255, 255), tostring(window.BeginOrderWithinContext)) end @@ -22660,12 +22711,12 @@ function ImGui.DebugBreakButtonTooltip(keyboard_only, description_of_location) if not ImGui.BeginItemTooltip() then return end - ImGui.Text("To call IM_DEBUG_BREAK() %s:", description_of_location) - ImGui.Separator() - ImGui.TextUnformatted(keyboard_only and "- Press 'Pause/Break' on keyboard." or "- Press 'Pause/Break' on keyboard.\n- or Click (may alter focus/active id).\n- or navigate using keyboard and press space.") - ImGui.Separator() - ImGui.TextUnformatted("Choose one way that doesn't interfere with what you are trying to debug!\nYou need a debugger attached or this will crash!") -- [Luau] IM_DEBUG_BREAK() calls g.DebugBreakCallback (if set) instead - ImGui.EndTooltip() + ImGui_Text("To call IM_DEBUG_BREAK() %s:", description_of_location) + ImGui_Separator() + ImGui_TextUnformatted(keyboard_only and "- Press 'Pause/Break' on keyboard." or "- Press 'Pause/Break' on keyboard.\n- or Click (may alter focus/active id).\n- or navigate using keyboard and press space.") + ImGui_Separator() + ImGui_TextUnformatted("Choose one way that doesn't interfere with what you are trying to debug!\nYou need a debugger attached or this will crash!") -- [Luau] IM_DEBUG_BREAK() calls g.DebugBreakCallback (if set) instead + ImGui_EndTooltip() end -- Special button that doesn't take focus, doesn't take input owner, and can be activated without a click etc. @@ -22674,14 +22725,14 @@ end --- @param description_of_location string --- @return bool function ImGui.DebugBreakButton(label, description_of_location) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local id = window:GetID(label) - local label_size = ImGui.CalcTextSize(label, nil, true) + local label_size = ImGui_CalcTextSize(label, nil, true) local pos = window.DC.CursorPos + ImVec2(0.0, window.DC.CurrLineTextBaseOffset) local size = ImVec2(label_size.x + g.Style.FramePadding.x * 2.0, label_size.y) @@ -22693,7 +22744,7 @@ function ImGui.DebugBreakButton(label, description_of_location) -- WE DO NOT USE ButtonEx() or ButtonBehavior() in order to reduce our side-effects. local hovered = ImGui.ItemHoverable(bb, id, g.CurrentItemFlags) - local pressed = hovered and (ImGui.IsKeyChordPressed(g.DebugBreakKeyChord) or ImGui.IsMouseClicked(0) or g.NavActivateId == id) + local pressed = hovered and (ImGui.IsKeyChordPressed(g.DebugBreakKeyChord) or ImGui_IsMouseClicked(0) or g.NavActivateId == id) ImGui.DebugBreakButtonTooltip(false, description_of_location) local src = ImGui.GetStyleColorVec4(hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]]) @@ -22702,7 +22753,7 @@ function ImGui.DebugBreakButton(label, description_of_location) col4f.x, col4f.y, col4f.z = ImGui.ColorConvertHSVtoRGB(h + 0.20, s, v) ImGui.RenderNavCursor(bb, id) - ImGui.RenderFrame(bb.Min, bb.Max, ImGui.GetColorU32(col4f), true, g.Style.FrameRounding) + ImGui.RenderFrame(bb.Min, bb.Max, ImGui_GetColorU32(col4f), true, g.Style.FrameRounding) ImGui.RenderTextClipped(bb.Min, bb.Max, label, nil, label_size, g.Style.ButtonTextAlign, bb) return pressed @@ -22710,9 +22761,14 @@ end end --[[ [SECTION] METRICS/DEBUGGER WINDOW, DEBUG LOG, ID STACK TOOL, FONT DEBUG ]] return true -- [Port] [Roblox] ModuleScripts must return exactly one value -end +end end)() -__FILES['imgui_demo.lua'] = function() +__FILES['imgui_demo.lua'] = (function() +local ImGui_AcceptDragDropPayload, ImGui_AlignTextToFramePadding, ImGui_BeginChild, ImGui_BeginCombo, ImGui_BeginDisabled, ImGui_BeginDragDropSource, ImGui_BeginDragDropTarget, ImGui_BeginGroup, ImGui_BeginMenu, ImGui_BeginMenuBar, ImGui_BeginMultiSelect, ImGui_BeginPopup, ImGui_BeginPopupContextItem, ImGui_BeginPopupModal, ImGui_BeginTabBar, ImGui_BeginTable, ImGui_Bullet, ImGui_BulletText, ImGui_Button, ImGui_CalcTextSize, ImGui_Checkbox, ImGui_CheckboxFlags, ImGui_CloseCurrentPopup, ImGui_ColorButton, ImGui_ColorEdit3, ImGui_ColorEdit4, ImGui_Columns, ImGui_Combo, ImGui_DragFloat, ImGui_DragInt, ImGui_DragScalar, ImGui_Dummy, ImGui_EndChild, ImGui_EndCombo, ImGui_EndDisabled, ImGui_EndDragDropSource, ImGui_EndGroup, ImGui_EndMenu, ImGui_EndMenuBar, ImGui_EndMultiSelect, ImGui_EndPopup, ImGui_EndTabBar, ImGui_EndTabItem, ImGui_EndTable, ImGui_EndTooltip, ImGui_GetColorU32, ImGui_GetContentRegionAvail, ImGui_GetCursorScreenPos, ImGui_GetDragDropPayload, ImGui_GetFontSize, ImGui_GetFrameHeight, ImGui_GetFrameHeightWithSpacing, ImGui_GetID, ImGui_GetIO, ImGui_GetItemRectMax, ImGui_GetItemRectMin, ImGui_GetMainViewport, ImGui_GetMouseDragDelta, ImGui_GetScrollMaxX, ImGui_GetScrollMaxY, ImGui_GetScrollX, ImGui_GetScrollY, ImGui_GetStyle, ImGui_GetTextLineHeight, ImGui_GetTextLineHeightWithSpacing, ImGui_GetTime, ImGui_GetWindowDrawList, ImGui_Indent, ImGui_InputFloat, ImGui_InputScalar, ImGui_InputText, ImGui_InvisibleButton, ImGui_IsItemActive, ImGui_IsItemHovered, ImGui_IsMouseDragging, ImGui_IsWindowFocused, ImGui_IsWindowHovered, ImGui_LogFinish, ImGui_LogText, ImGui_LogToClipboard, ImGui_MenuItem, ImGui_NewTextBuffer, ImGui_NextColumn, ImGui_OpenPopup, ImGui_PlotLines, ImGui_PopID, ImGui_PopItemFlag, ImGui_PopItemWidth, ImGui_PopStyleColor, ImGui_PopStyleVar, ImGui_ProgressBar, ImGui_PushID, ImGui_PushItemFlag, ImGui_PushItemWidth, ImGui_PushStyleColor, ImGui_PushStyleVar, ImGui_PushStyleVarY, ImGui_RadioButton, ImGui_RadioButtonEx, ImGui_SameLine, ImGui_Selectable, ImGui_Separator, ImGui_SeparatorText, ImGui_SetCursorScreenPos, ImGui_SetDragDropPayload, ImGui_SetItemDefaultFocus, ImGui_SetItemTooltip, ImGui_SetKeyboardFocusHere, ImGui_SetNextItemAllowOverlap, ImGui_SetNextItemOpen, ImGui_SetNextItemSelectionUserData, ImGui_SetNextItemShortcut, ImGui_SetNextItemWidth, ImGui_SetNextWindowContentSize, ImGui_SetNextWindowPos, ImGui_SetNextWindowSize, ImGui_SetNextWindowSizeConstraints, ImGui_SetTooltip, ImGui_Shortcut, ImGui_SliderFloat, ImGui_SliderFloat2, ImGui_SliderInt, ImGui_SliderScalar, ImGui_SmallButton, ImGui_Spacing, ImGui_TableHeadersRow, ImGui_TableNextColumn, ImGui_TableNextRow, ImGui_TableSetColumnIndex, ImGui_TableSetupColumn, ImGui_TableSetupScrollFreeze, ImGui_Text, ImGui_TextBufferToString, ImGui_TextColored, ImGui_TextDisabled, ImGui_TextLinkOpenURL, ImGui_TextUnformatted, ImGui_TextWrapped, ImGui_TreePop, ImGui_Unindent +__BIND[#__BIND + 1] = function() if ImGui then ImGui_AcceptDragDropPayload = ImGui.AcceptDragDropPayload ImGui_AlignTextToFramePadding = ImGui.AlignTextToFramePadding ImGui_BeginChild = ImGui.BeginChild ImGui_BeginCombo = ImGui.BeginCombo ImGui_BeginDisabled = ImGui.BeginDisabled ImGui_BeginDragDropSource = ImGui.BeginDragDropSource ImGui_BeginDragDropTarget = ImGui.BeginDragDropTarget ImGui_BeginGroup = ImGui.BeginGroup ImGui_BeginMenu = ImGui.BeginMenu ImGui_BeginMenuBar = ImGui.BeginMenuBar ImGui_BeginMultiSelect = ImGui.BeginMultiSelect ImGui_BeginPopup = ImGui.BeginPopup ImGui_BeginPopupContextItem = ImGui.BeginPopupContextItem ImGui_BeginPopupModal = ImGui.BeginPopupModal ImGui_BeginTabBar = ImGui.BeginTabBar ImGui_BeginTable = ImGui.BeginTable ImGui_Bullet = ImGui.Bullet ImGui_BulletText = ImGui.BulletText ImGui_Button = ImGui.Button ImGui_CalcTextSize = ImGui.CalcTextSize ImGui_Checkbox = ImGui.Checkbox ImGui_CheckboxFlags = ImGui.CheckboxFlags ImGui_CloseCurrentPopup = ImGui.CloseCurrentPopup ImGui_ColorButton = ImGui.ColorButton ImGui_ColorEdit3 = ImGui.ColorEdit3 ImGui_ColorEdit4 = ImGui.ColorEdit4 ImGui_Columns = ImGui.Columns ImGui_Combo = ImGui.Combo ImGui_DragFloat = ImGui.DragFloat ImGui_DragInt = ImGui.DragInt ImGui_DragScalar = ImGui.DragScalar ImGui_Dummy = ImGui.Dummy ImGui_EndChild = ImGui.EndChild ImGui_EndCombo = ImGui.EndCombo ImGui_EndDisabled = ImGui.EndDisabled ImGui_EndDragDropSource = ImGui.EndDragDropSource ImGui_EndGroup = ImGui.EndGroup ImGui_EndMenu = ImGui.EndMenu ImGui_EndMenuBar = ImGui.EndMenuBar ImGui_EndMultiSelect = ImGui.EndMultiSelect ImGui_EndPopup = ImGui.EndPopup ImGui_EndTabBar = ImGui.EndTabBar ImGui_EndTabItem = ImGui.EndTabItem ImGui_EndTable = ImGui.EndTable ImGui_EndTooltip = ImGui.EndTooltip ImGui_GetColorU32 = ImGui.GetColorU32 ImGui_GetContentRegionAvail = ImGui.GetContentRegionAvail ImGui_GetCursorScreenPos = ImGui.GetCursorScreenPos ImGui_GetDragDropPayload = ImGui.GetDragDropPayload ImGui_GetFontSize = ImGui.GetFontSize ImGui_GetFrameHeight = ImGui.GetFrameHeight ImGui_GetFrameHeightWithSpacing = ImGui.GetFrameHeightWithSpacing ImGui_GetID = ImGui.GetID ImGui_GetIO = ImGui.GetIO ImGui_GetItemRectMax = ImGui.GetItemRectMax ImGui_GetItemRectMin = ImGui.GetItemRectMin ImGui_GetMainViewport = ImGui.GetMainViewport ImGui_GetMouseDragDelta = ImGui.GetMouseDragDelta ImGui_GetScrollMaxX = ImGui.GetScrollMaxX ImGui_GetScrollMaxY = ImGui.GetScrollMaxY ImGui_GetScrollX = ImGui.GetScrollX ImGui_GetScrollY = ImGui.GetScrollY ImGui_GetStyle = ImGui.GetStyle ImGui_GetTextLineHeight = ImGui.GetTextLineHeight ImGui_GetTextLineHeightWithSpacing = ImGui.GetTextLineHeightWithSpacing ImGui_GetTime = ImGui.GetTime ImGui_GetWindowDrawList = ImGui.GetWindowDrawList ImGui_Indent = ImGui.Indent ImGui_InputFloat = ImGui.InputFloat ImGui_InputScalar = ImGui.InputScalar ImGui_InputText = ImGui.InputText ImGui_InvisibleButton = ImGui.InvisibleButton ImGui_IsItemActive = ImGui.IsItemActive ImGui_IsItemHovered = ImGui.IsItemHovered ImGui_IsMouseDragging = ImGui.IsMouseDragging ImGui_IsWindowFocused = ImGui.IsWindowFocused ImGui_IsWindowHovered = ImGui.IsWindowHovered ImGui_LogFinish = ImGui.LogFinish ImGui_LogText = ImGui.LogText ImGui_LogToClipboard = ImGui.LogToClipboard ImGui_MenuItem = ImGui.MenuItem ImGui_NewTextBuffer = ImGui.NewTextBuffer ImGui_NextColumn = ImGui.NextColumn ImGui_OpenPopup = ImGui.OpenPopup ImGui_PlotLines = ImGui.PlotLines ImGui_PopID = ImGui.PopID ImGui_PopItemFlag = ImGui.PopItemFlag ImGui_PopItemWidth = ImGui.PopItemWidth ImGui_PopStyleColor = ImGui.PopStyleColor ImGui_PopStyleVar = ImGui.PopStyleVar ImGui_ProgressBar = ImGui.ProgressBar ImGui_PushID = ImGui.PushID ImGui_PushItemFlag = ImGui.PushItemFlag ImGui_PushItemWidth = ImGui.PushItemWidth ImGui_PushStyleColor = ImGui.PushStyleColor ImGui_PushStyleVar = ImGui.PushStyleVar ImGui_PushStyleVarY = ImGui.PushStyleVarY ImGui_RadioButton = ImGui.RadioButton ImGui_RadioButtonEx = ImGui.RadioButtonEx ImGui_SameLine = ImGui.SameLine ImGui_Selectable = ImGui.Selectable ImGui_Separator = ImGui.Separator ImGui_SeparatorText = ImGui.SeparatorText ImGui_SetCursorScreenPos = ImGui.SetCursorScreenPos ImGui_SetDragDropPayload = ImGui.SetDragDropPayload ImGui_SetItemDefaultFocus = ImGui.SetItemDefaultFocus ImGui_SetItemTooltip = ImGui.SetItemTooltip ImGui_SetKeyboardFocusHere = ImGui.SetKeyboardFocusHere ImGui_SetNextItemAllowOverlap = ImGui.SetNextItemAllowOverlap ImGui_SetNextItemOpen = ImGui.SetNextItemOpen ImGui_SetNextItemSelectionUserData = ImGui.SetNextItemSelectionUserData ImGui_SetNextItemShortcut = ImGui.SetNextItemShortcut ImGui_SetNextItemWidth = ImGui.SetNextItemWidth ImGui_SetNextWindowContentSize = ImGui.SetNextWindowContentSize ImGui_SetNextWindowPos = ImGui.SetNextWindowPos ImGui_SetNextWindowSize = ImGui.SetNextWindowSize ImGui_SetNextWindowSizeConstraints = ImGui.SetNextWindowSizeConstraints ImGui_SetTooltip = ImGui.SetTooltip ImGui_Shortcut = ImGui.Shortcut ImGui_SliderFloat = ImGui.SliderFloat ImGui_SliderFloat2 = ImGui.SliderFloat2 ImGui_SliderInt = ImGui.SliderInt ImGui_SliderScalar = ImGui.SliderScalar ImGui_SmallButton = ImGui.SmallButton ImGui_Spacing = ImGui.Spacing ImGui_TableHeadersRow = ImGui.TableHeadersRow ImGui_TableNextColumn = ImGui.TableNextColumn ImGui_TableNextRow = ImGui.TableNextRow ImGui_TableSetColumnIndex = ImGui.TableSetColumnIndex ImGui_TableSetupColumn = ImGui.TableSetupColumn ImGui_TableSetupScrollFreeze = ImGui.TableSetupScrollFreeze ImGui_Text = ImGui.Text ImGui_TextBufferToString = ImGui.TextBufferToString ImGui_TextColored = ImGui.TextColored ImGui_TextDisabled = ImGui.TextDisabled ImGui_TextLinkOpenURL = ImGui.TextLinkOpenURL ImGui_TextUnformatted = ImGui.TextUnformatted ImGui_TextWrapped = ImGui.TextWrapped ImGui_TreePop = ImGui.TreePop ImGui_Unindent = ImGui.Unindent end end; __BIND[#__BIND]() +return function() +local ImGui_ArrowButton, ImGui_BeginItemTooltip, ImGui_BeginListBox, ImGui_BeginMainMenuBar, ImGui_BeginPopupContextWindow, ImGui_BeginTooltip, ImGui_CalcItemWidth, ImGui_ColorConvertHSVtoRGB, ImGui_ColorPicker3, ImGui_ColorPicker4, ImGui_DebugFlashStyleColor, ImGui_DebugStartItemPicker, ImGui_DemoMarker, ImGui_DockSpace, ImGui_DockSpaceOverViewport, ImGui_DragFloat2, ImGui_DragFloat3, ImGui_DragFloat4, ImGui_DragFloatRange2, ImGui_DragInt2, ImGui_DragInt3, ImGui_DragInt4, ImGui_DragIntRange2, ImGui_DragScalarN, ImGui_EndDragDropTarget, ImGui_EndListBox, ImGui_EndMainMenuBar, ImGui_GetBackgroundDrawList, ImGui_GetColumnIndex, ImGui_GetColumnOffset, ImGui_GetColumnWidth, ImGui_GetCurrentContext, ImGui_GetCursorPos, ImGui_GetCursorPosX, ImGui_GetCursorStartPos, ImGui_GetFont, ImGui_GetForegroundDrawList, ImGui_GetFrameCount, ImGui_GetItemFlags, ImGui_GetItemRectSize, ImGui_GetKeyName, ImGui_GetMouseCursor, ImGui_GetPlatformIO, ImGui_GetStyleColorName, ImGui_GetStyleColorVec4, ImGui_GetTreeNodeToLabelSpacing, ImGui_GetWindowPos, ImGui_GetWindowSize, ImGui_GetWindowWidth, ImGui_ImageButton, ImGui_ImageWithBg, ImGui_InputDouble, ImGui_InputFloat2, ImGui_InputFloat3, ImGui_InputFloat4, ImGui_InputInt, ImGui_InputInt2, ImGui_InputInt3, ImGui_InputInt4, ImGui_InputTextMultiline, ImGui_InputTextWithHint, ImGui_IsAnyItemActive, ImGui_IsAnyItemHovered, ImGui_IsItemActivated, ImGui_IsItemClicked, ImGui_IsItemDeactivated, ImGui_IsItemDeactivatedAfterEdit, ImGui_IsItemEdited, ImGui_IsItemFocused, ImGui_IsItemToggledOpen, ImGui_IsItemToggledSelection, ImGui_IsItemVisible, ImGui_IsKeyDown, ImGui_IsKeyPressed, ImGui_IsMouseClicked, ImGui_IsMouseDoubleClicked, ImGui_IsMouseDown, ImGui_IsMousePosValid, ImGui_IsMouseReleased, ImGui_IsPopupOpen, ImGui_IsRectVisible, ImGui_IsWindowAppearing, ImGui_IsWindowDocked, ImGui_LabelText, ImGui_ListBox, ImGui_LogButtons, ImGui_LogToTTY, ImGui_NewLine, ImGui_OpenPopupOnItemClick, ImGui_PlotHistogram, ImGui_PopClipRect, ImGui_PopFont, ImGui_PopTextWrapPos, ImGui_PushClipRect, ImGui_PushFont, ImGui_PushTextWrapPos, ImGui_ResetMouseDragDelta, ImGui_SetCursorPosX, ImGui_SetItemKeyOwner, ImGui_SetMouseCursor, ImGui_SetNextFrameWantCaptureKeyboard, ImGui_SetNextFrameWantCaptureMouse, ImGui_SetNextItemStorageID, ImGui_SetNextWindowBgAlpha, ImGui_SetNextWindowDockID, ImGui_SetNextWindowFocus, ImGui_SetNextWindowViewport, ImGui_SetScrollFromPosX, ImGui_SetScrollFromPosY, ImGui_SetScrollHereX, ImGui_SetScrollHereY, ImGui_SetScrollX, ImGui_SetScrollY, ImGui_SetTabItemClosed, ImGui_SetWindowSize, ImGui_ShowAboutWindow, ImGui_ShowDebugLogWindow, ImGui_ShowFontAtlas, ImGui_ShowFontSelector, ImGui_ShowIDStackToolWindow, ImGui_ShowMetricsWindow, ImGui_ShowStyleEditor, ImGui_ShowStyleSelector, ImGui_ShowUserGuide, ImGui_SliderAngle, ImGui_SliderFloat3, ImGui_SliderFloat4, ImGui_SliderInt2, ImGui_SliderInt3, ImGui_SliderInt4, ImGui_SliderScalarN, ImGui_StyleColorsClassic, ImGui_StyleColorsDark, ImGui_StyleColorsLight, ImGui_TabItemButton, ImGui_TableAngledHeadersRow, ImGui_TableGetColumnFlags, ImGui_TableGetColumnIndex, ImGui_TableGetColumnName, ImGui_TableGetRowIndex, ImGui_TableGetSortSpecs, ImGui_TableHeader, ImGui_TableSetBgColor, ImGui_TreePush, ImGui_VSliderFloat, ImGui_VSliderInt +__BIND[#__BIND + 1] = function() if ImGui then ImGui_ArrowButton = ImGui.ArrowButton ImGui_BeginItemTooltip = ImGui.BeginItemTooltip ImGui_BeginListBox = ImGui.BeginListBox ImGui_BeginMainMenuBar = ImGui.BeginMainMenuBar ImGui_BeginPopupContextWindow = ImGui.BeginPopupContextWindow ImGui_BeginTooltip = ImGui.BeginTooltip ImGui_CalcItemWidth = ImGui.CalcItemWidth ImGui_ColorConvertHSVtoRGB = ImGui.ColorConvertHSVtoRGB ImGui_ColorPicker3 = ImGui.ColorPicker3 ImGui_ColorPicker4 = ImGui.ColorPicker4 ImGui_DebugFlashStyleColor = ImGui.DebugFlashStyleColor ImGui_DebugStartItemPicker = ImGui.DebugStartItemPicker ImGui_DemoMarker = ImGui.DemoMarker ImGui_DockSpace = ImGui.DockSpace ImGui_DockSpaceOverViewport = ImGui.DockSpaceOverViewport ImGui_DragFloat2 = ImGui.DragFloat2 ImGui_DragFloat3 = ImGui.DragFloat3 ImGui_DragFloat4 = ImGui.DragFloat4 ImGui_DragFloatRange2 = ImGui.DragFloatRange2 ImGui_DragInt2 = ImGui.DragInt2 ImGui_DragInt3 = ImGui.DragInt3 ImGui_DragInt4 = ImGui.DragInt4 ImGui_DragIntRange2 = ImGui.DragIntRange2 ImGui_DragScalarN = ImGui.DragScalarN ImGui_EndDragDropTarget = ImGui.EndDragDropTarget ImGui_EndListBox = ImGui.EndListBox ImGui_EndMainMenuBar = ImGui.EndMainMenuBar ImGui_GetBackgroundDrawList = ImGui.GetBackgroundDrawList ImGui_GetColumnIndex = ImGui.GetColumnIndex ImGui_GetColumnOffset = ImGui.GetColumnOffset ImGui_GetColumnWidth = ImGui.GetColumnWidth ImGui_GetCurrentContext = ImGui.GetCurrentContext ImGui_GetCursorPos = ImGui.GetCursorPos ImGui_GetCursorPosX = ImGui.GetCursorPosX ImGui_GetCursorStartPos = ImGui.GetCursorStartPos ImGui_GetFont = ImGui.GetFont ImGui_GetForegroundDrawList = ImGui.GetForegroundDrawList ImGui_GetFrameCount = ImGui.GetFrameCount ImGui_GetItemFlags = ImGui.GetItemFlags ImGui_GetItemRectSize = ImGui.GetItemRectSize ImGui_GetKeyName = ImGui.GetKeyName ImGui_GetMouseCursor = ImGui.GetMouseCursor ImGui_GetPlatformIO = ImGui.GetPlatformIO ImGui_GetStyleColorName = ImGui.GetStyleColorName ImGui_GetStyleColorVec4 = ImGui.GetStyleColorVec4 ImGui_GetTreeNodeToLabelSpacing = ImGui.GetTreeNodeToLabelSpacing ImGui_GetWindowPos = ImGui.GetWindowPos ImGui_GetWindowSize = ImGui.GetWindowSize ImGui_GetWindowWidth = ImGui.GetWindowWidth ImGui_ImageButton = ImGui.ImageButton ImGui_ImageWithBg = ImGui.ImageWithBg ImGui_InputDouble = ImGui.InputDouble ImGui_InputFloat2 = ImGui.InputFloat2 ImGui_InputFloat3 = ImGui.InputFloat3 ImGui_InputFloat4 = ImGui.InputFloat4 ImGui_InputInt = ImGui.InputInt ImGui_InputInt2 = ImGui.InputInt2 ImGui_InputInt3 = ImGui.InputInt3 ImGui_InputInt4 = ImGui.InputInt4 ImGui_InputTextMultiline = ImGui.InputTextMultiline ImGui_InputTextWithHint = ImGui.InputTextWithHint ImGui_IsAnyItemActive = ImGui.IsAnyItemActive ImGui_IsAnyItemHovered = ImGui.IsAnyItemHovered ImGui_IsItemActivated = ImGui.IsItemActivated ImGui_IsItemClicked = ImGui.IsItemClicked ImGui_IsItemDeactivated = ImGui.IsItemDeactivated ImGui_IsItemDeactivatedAfterEdit = ImGui.IsItemDeactivatedAfterEdit ImGui_IsItemEdited = ImGui.IsItemEdited ImGui_IsItemFocused = ImGui.IsItemFocused ImGui_IsItemToggledOpen = ImGui.IsItemToggledOpen ImGui_IsItemToggledSelection = ImGui.IsItemToggledSelection ImGui_IsItemVisible = ImGui.IsItemVisible ImGui_IsKeyDown = ImGui.IsKeyDown ImGui_IsKeyPressed = ImGui.IsKeyPressed ImGui_IsMouseClicked = ImGui.IsMouseClicked ImGui_IsMouseDoubleClicked = ImGui.IsMouseDoubleClicked ImGui_IsMouseDown = ImGui.IsMouseDown ImGui_IsMousePosValid = ImGui.IsMousePosValid ImGui_IsMouseReleased = ImGui.IsMouseReleased ImGui_IsPopupOpen = ImGui.IsPopupOpen ImGui_IsRectVisible = ImGui.IsRectVisible ImGui_IsWindowAppearing = ImGui.IsWindowAppearing ImGui_IsWindowDocked = ImGui.IsWindowDocked ImGui_LabelText = ImGui.LabelText ImGui_ListBox = ImGui.ListBox ImGui_LogButtons = ImGui.LogButtons ImGui_LogToTTY = ImGui.LogToTTY ImGui_NewLine = ImGui.NewLine ImGui_OpenPopupOnItemClick = ImGui.OpenPopupOnItemClick ImGui_PlotHistogram = ImGui.PlotHistogram ImGui_PopClipRect = ImGui.PopClipRect ImGui_PopFont = ImGui.PopFont ImGui_PopTextWrapPos = ImGui.PopTextWrapPos ImGui_PushClipRect = ImGui.PushClipRect ImGui_PushFont = ImGui.PushFont ImGui_PushTextWrapPos = ImGui.PushTextWrapPos ImGui_ResetMouseDragDelta = ImGui.ResetMouseDragDelta ImGui_SetCursorPosX = ImGui.SetCursorPosX ImGui_SetItemKeyOwner = ImGui.SetItemKeyOwner ImGui_SetMouseCursor = ImGui.SetMouseCursor ImGui_SetNextFrameWantCaptureKeyboard = ImGui.SetNextFrameWantCaptureKeyboard ImGui_SetNextFrameWantCaptureMouse = ImGui.SetNextFrameWantCaptureMouse ImGui_SetNextItemStorageID = ImGui.SetNextItemStorageID ImGui_SetNextWindowBgAlpha = ImGui.SetNextWindowBgAlpha ImGui_SetNextWindowDockID = ImGui.SetNextWindowDockID ImGui_SetNextWindowFocus = ImGui.SetNextWindowFocus ImGui_SetNextWindowViewport = ImGui.SetNextWindowViewport ImGui_SetScrollFromPosX = ImGui.SetScrollFromPosX ImGui_SetScrollFromPosY = ImGui.SetScrollFromPosY ImGui_SetScrollHereX = ImGui.SetScrollHereX ImGui_SetScrollHereY = ImGui.SetScrollHereY ImGui_SetScrollX = ImGui.SetScrollX ImGui_SetScrollY = ImGui.SetScrollY ImGui_SetTabItemClosed = ImGui.SetTabItemClosed ImGui_SetWindowSize = ImGui.SetWindowSize ImGui_ShowAboutWindow = ImGui.ShowAboutWindow ImGui_ShowDebugLogWindow = ImGui.ShowDebugLogWindow ImGui_ShowFontAtlas = ImGui.ShowFontAtlas ImGui_ShowFontSelector = ImGui.ShowFontSelector ImGui_ShowIDStackToolWindow = ImGui.ShowIDStackToolWindow ImGui_ShowMetricsWindow = ImGui.ShowMetricsWindow ImGui_ShowStyleEditor = ImGui.ShowStyleEditor ImGui_ShowStyleSelector = ImGui.ShowStyleSelector ImGui_ShowUserGuide = ImGui.ShowUserGuide ImGui_SliderAngle = ImGui.SliderAngle ImGui_SliderFloat3 = ImGui.SliderFloat3 ImGui_SliderFloat4 = ImGui.SliderFloat4 ImGui_SliderInt2 = ImGui.SliderInt2 ImGui_SliderInt3 = ImGui.SliderInt3 ImGui_SliderInt4 = ImGui.SliderInt4 ImGui_SliderScalarN = ImGui.SliderScalarN ImGui_StyleColorsClassic = ImGui.StyleColorsClassic ImGui_StyleColorsDark = ImGui.StyleColorsDark ImGui_StyleColorsLight = ImGui.StyleColorsLight ImGui_TabItemButton = ImGui.TabItemButton ImGui_TableAngledHeadersRow = ImGui.TableAngledHeadersRow ImGui_TableGetColumnFlags = ImGui.TableGetColumnFlags ImGui_TableGetColumnIndex = ImGui.TableGetColumnIndex ImGui_TableGetColumnName = ImGui.TableGetColumnName ImGui_TableGetRowIndex = ImGui.TableGetRowIndex ImGui_TableGetSortSpecs = ImGui.TableGetSortSpecs ImGui_TableHeader = ImGui.TableHeader ImGui_TableSetBgColor = ImGui.TableSetBgColor ImGui_TreePush = ImGui.TreePush ImGui_VSliderFloat = ImGui.VSliderFloat ImGui_VSliderInt = ImGui.VSliderInt end end; __BIND[#__BIND]() -- dear imgui demo (Luau port of imgui_demo.cpp). Optional: the library never calls into this file. -- dear imgui, v1.93.0 WIP -- (demo code) @@ -22909,27 +22965,27 @@ local _ -- [Port] discard target for unused return values (`_, v = ImGui.Checkbo -- Helper to display a little (?) mark which shows a tooltip when hovered. -- In your own code you may want to display an actual icon if you are using a merged icon fonts (see docs/FONTS.md) function HelpMarker(desc) - ImGui.TextDisabled("(?)") - if ImGui.BeginItemTooltip() then - ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35.0) - ImGui.TextUnformatted(desc) - ImGui.PopTextWrapPos() - ImGui.EndTooltip() + ImGui_TextDisabled("(?)") + if ImGui_BeginItemTooltip() then + ImGui_PushTextWrapPos(ImGui_GetFontSize() * 35.0) + ImGui_TextUnformatted(desc) + ImGui_PopTextWrapPos() + ImGui_EndTooltip() end end function ShowDockingDisabledMessage() - local io = ImGui.GetIO() - ImGui.Text("ERROR: Docking is not enabled! See Demo > Configuration.") - ImGui.Text("Set io.ConfigFlags |= ImGuiConfigFlags_DockingEnable in your code, or ") - ImGui.SameLine(0.0, 0.0) - if ImGui.SmallButton("click here") then + local io = ImGui_GetIO() + ImGui_Text("ERROR: Docking is not enabled! See Demo > Configuration.") + ImGui_Text("Set io.ConfigFlags |= ImGuiConfigFlags_DockingEnable in your code, or ") + ImGui_SameLine(0.0, 0.0) + if ImGui_SmallButton("click here") then io.ConfigFlags = bit32.bor(io.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) end end -- Helper to wire demo markers located in code to an interactive browser (e.g. https://pthom.github.io/imgui_explorer) -function IMGUI_DEMO_MARKER(section) ImGui.DemoMarker("imgui_demo.lua", 0, section) end -- [Port] no __LINE__ in Lua: line is 0 +function IMGUI_DEMO_MARKER(section) ImGui_DemoMarker("imgui_demo.lua", 0, section) end -- [Port] no __LINE__ in Lua: line is 0 -- Sneakily forward declare functions which aren't worth putting in public API yet -- [Port] ImGui.ShowFontAtlas(atlas) and ImGui.TreeNodeSetOpen(storage_id, is_open) are already public here. @@ -23004,7 +23060,7 @@ function ImGui.ShowDemoWindow(p_open) -- Exceptionally add an extra assert here for people confused about initial Dear ImGui setup -- Most functions would normally just assert/crash if the context is missing. - assert(ImGui.GetCurrentContext() ~= nil, "Missing Dear ImGui context. Refer to examples app!") + assert(ImGui_GetCurrentContext() ~= nil, "Missing Dear ImGui context. Refer to examples app!") -- Verify ABI compatibility between caller code and compiled version of Dear ImGui. This helps detects some build issues. -- [Port] IMGUI_CHECKVERSION() dropped: no ABI to verify. @@ -23031,13 +23087,13 @@ function ImGui.ShowDemoWindow(p_open) if demo_data.ShowAppWindowTitles then demo_data.ShowAppWindowTitles = ShowExampleAppWindowTitles(demo_data.ShowAppWindowTitles) end -- Dear ImGui Tools (accessible from the "Tools" menu) - if demo_data.ShowMetrics then demo_data.ShowMetrics = ImGui.ShowMetricsWindow(demo_data.ShowMetrics) end - if demo_data.ShowDebugLog then demo_data.ShowDebugLog = ImGui.ShowDebugLogWindow(demo_data.ShowDebugLog) end - if demo_data.ShowIDStackTool then demo_data.ShowIDStackTool = ImGui.ShowIDStackToolWindow(demo_data.ShowIDStackTool) end - if demo_data.ShowAbout then demo_data.ShowAbout = ImGui.ShowAboutWindow(demo_data.ShowAbout) end + if demo_data.ShowMetrics then demo_data.ShowMetrics = ImGui_ShowMetricsWindow(demo_data.ShowMetrics) end + if demo_data.ShowDebugLog then demo_data.ShowDebugLog = ImGui_ShowDebugLogWindow(demo_data.ShowDebugLog) end + if demo_data.ShowIDStackTool then demo_data.ShowIDStackTool = ImGui_ShowIDStackToolWindow(demo_data.ShowIDStackTool) end + if demo_data.ShowAbout then demo_data.ShowAbout = ImGui_ShowAboutWindow(demo_data.ShowAbout) end if demo_data.ShowStyleEditor then demo_data.ShowStyleEditor = ImGui.Begin("Dear ImGui Style Editor", demo_data.ShowStyleEditor) - ImGui.ShowStyleEditor() + ImGui_ShowStyleEditor() ImGui.End() end @@ -23059,9 +23115,9 @@ function ImGui.ShowDemoWindow(p_open) -- We specify a default position/size in case there's no data in the .ini file. -- We only do it to make the demo applications a little more welcoming, but typically this isn't required. - local main_viewport = ImGui.GetMainViewport() - ImGui.SetNextWindowPos(ImVec2(main_viewport.WorkPos.x + 650, main_viewport.WorkPos.y + 20), 4 --[[ImGuiCond.FirstUseEver]]) - ImGui.SetNextWindowSize(ImVec2(550, 680), 4 --[[ImGuiCond.FirstUseEver]]) + local main_viewport = ImGui_GetMainViewport() + ImGui_SetNextWindowPos(ImVec2(main_viewport.WorkPos.x + 650, main_viewport.WorkPos.y + 20), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(550, 680), 4 --[[ImGuiCond.FirstUseEver]]) -- Main body of the Demo window starts here. local open, visible = ImGui.Begin("Dear ImGui Demo", begin_p_open, window_flags) @@ -23078,10 +23134,10 @@ function ImGui.ShowDemoWindow(p_open) -- - The default value is about GetWindowWidth() * 0.65f. -- - See 'Demo->Layout->Widgets Width' for details. -- Here we change the frame width based on how much width we want to give to the label. - local label_width_base = ImGui.GetFontSize() * 12 -- Some amount of width for label, based on font size. - local label_width_max = ImGui.GetContentRegionAvail().x * 0.40 -- ...but always leave some room for framed widgets. + local label_width_base = ImGui_GetFontSize() * 12 -- Some amount of width for label, based on font size. + local label_width_max = ImGui_GetContentRegionAvail().x * 0.40 -- ...but always leave some room for framed widgets. local label_width = ImMin(label_width_base, label_width_max) - ImGui.PushItemWidth(-label_width) -- Right-align: framed items will leave 'label_width' available for the label. + ImGui_PushItemWidth(-label_width) -- Right-align: framed items will leave 'label_width' available for the label. --ImGui.PushItemWidth(ImGui.GetContentRegionAvail().x * 0.40) -- e.g. Use 40% width for framed widgets, leaving 60% width for labels. --ImGui.PushItemWidth(-ImGui.GetContentRegionAvail().x * 0.40) -- e.g. Use 40% width for labels, leaving 60% width for framed widgets. --ImGui.PushItemWidth(ImGui.GetFontSize() * -12) -- e.g. Use XXX width for labels, leaving the rest for framed widgets. @@ -23089,122 +23145,122 @@ function ImGui.ShowDemoWindow(p_open) -- Menu Bar DemoWindowMenuBar(demo_data) - ImGui.Text("dear imgui says hello! (%s) (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) - ImGui.Spacing() + ImGui_Text("dear imgui says hello! (%s) (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) + ImGui_Spacing() if ImGui.CollapsingHeader("Help") then IMGUI_DEMO_MARKER("Help") - 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" .. + 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.BulletText("Web demo (w/ source code browser): ") - ImGui.SameLine(0, 0) - ImGui.TextLinkOpenURL("https://pthom.github.io/imgui_explorer") + ImGui_BulletText("Web demo (w/ source code browser): ") + ImGui_SameLine(0, 0) + ImGui_TextLinkOpenURL("https://pthom.github.io/imgui_explorer") - 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 ") - ImGui.SameLine(0, 0) - ImGui.TextLinkOpenURL("https://www.dearimgui.com/faq/") - ImGui.BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.") - ImGui.BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.") + 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 ") + ImGui_SameLine(0, 0) + ImGui_TextLinkOpenURL("https://www.dearimgui.com/faq/") + ImGui_BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.") + ImGui_BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.") - ImGui.SeparatorText("USER GUIDE:") - ImGui.ShowUserGuide() + ImGui_SeparatorText("USER GUIDE:") + ImGui_ShowUserGuide() end if ImGui.CollapsingHeader("Configuration") then - local io = ImGui.GetIO() + local io = ImGui_GetIO() if ImGui.TreeNode("Configuration##2") then IMGUI_DEMO_MARKER("Configuration") - ImGui.SeparatorText("General") - _, io.ConfigFlags = ImGui.CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", io.ConfigFlags, 1 --[[ImGuiConfigFlags.NavEnableKeyboard]]) - ImGui.SameLine(); HelpMarker("Enable keyboard controls.") - _, io.ConfigFlags = ImGui.CheckboxFlags("io.ConfigFlags: NavEnableGamepad", io.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) - ImGui.SameLine(); HelpMarker("Enable gamepad controls. Require backend to set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details.") - _, io.ConfigFlags = ImGui.CheckboxFlags("io.ConfigFlags: NoMouse", io.ConfigFlags, 16 --[[ImGuiConfigFlags.NoMouse]]) - ImGui.SameLine(); HelpMarker("Instruct dear imgui to disable mouse inputs and interactions.") + ImGui_SeparatorText("General") + _, io.ConfigFlags = ImGui_CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", io.ConfigFlags, 1 --[[ImGuiConfigFlags.NavEnableKeyboard]]) + ImGui_SameLine(); HelpMarker("Enable keyboard controls.") + _, io.ConfigFlags = ImGui_CheckboxFlags("io.ConfigFlags: NavEnableGamepad", io.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) + ImGui_SameLine(); HelpMarker("Enable gamepad controls. Require backend to set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details.") + _, io.ConfigFlags = ImGui_CheckboxFlags("io.ConfigFlags: NoMouse", io.ConfigFlags, 16 --[[ImGuiConfigFlags.NoMouse]]) + ImGui_SameLine(); HelpMarker("Instruct dear imgui to disable mouse inputs and interactions.") -- The "NoMouse" option can get us stuck with a disabled mouse! Let's provide an alternative way to fix it: if bit32.band(io.ConfigFlags, 16 --[[ImGuiConfigFlags.NoMouse]]) ~= 0 then - if math.fmod(ImGui.GetTime(), 0.40) < 0.20 then - ImGui.SameLine() - ImGui.Text("<>") + if math.fmod(ImGui_GetTime(), 0.40) < 0.20 then + ImGui_SameLine() + ImGui_Text("<>") end -- Prevent both being checked - if ImGui.IsKeyPressed(524 --[[ImGuiKey.Space]]) or bit32.band(io.ConfigFlags, 64 --[[ImGuiConfigFlags.NoKeyboard]]) ~= 0 then + if ImGui_IsKeyPressed(524 --[[ImGuiKey.Space]]) or bit32.band(io.ConfigFlags, 64 --[[ImGuiConfigFlags.NoKeyboard]]) ~= 0 then io.ConfigFlags = bit32.band(io.ConfigFlags, bit32.bnot(16 --[[ImGuiConfigFlags.NoMouse]])) end end - _, io.ConfigFlags = ImGui.CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", io.ConfigFlags, 32 --[[ImGuiConfigFlags.NoMouseCursorChange]]) - ImGui.SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility.") - _, io.ConfigFlags = ImGui.CheckboxFlags("io.ConfigFlags: NoKeyboard", io.ConfigFlags, 64 --[[ImGuiConfigFlags.NoKeyboard]]) - ImGui.SameLine(); HelpMarker("Instruct dear imgui to disable keyboard inputs and interactions.") + _, io.ConfigFlags = ImGui_CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", io.ConfigFlags, 32 --[[ImGuiConfigFlags.NoMouseCursorChange]]) + ImGui_SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility.") + _, io.ConfigFlags = ImGui_CheckboxFlags("io.ConfigFlags: NoKeyboard", io.ConfigFlags, 64 --[[ImGuiConfigFlags.NoKeyboard]]) + ImGui_SameLine(); HelpMarker("Instruct dear imgui to disable keyboard inputs and interactions.") - _, io.ConfigInputTrickleEventQueue = ImGui.Checkbox("io.ConfigInputTrickleEventQueue", io.ConfigInputTrickleEventQueue) - ImGui.SameLine(); HelpMarker("Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.") - _, io.MouseDrawCursor = ImGui.Checkbox("io.MouseDrawCursor", io.MouseDrawCursor) - ImGui.SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).") + _, io.ConfigInputTrickleEventQueue = ImGui_Checkbox("io.ConfigInputTrickleEventQueue", io.ConfigInputTrickleEventQueue) + ImGui_SameLine(); HelpMarker("Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.") + _, io.MouseDrawCursor = ImGui_Checkbox("io.MouseDrawCursor", io.MouseDrawCursor) + ImGui_SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).") - ImGui.SeparatorText("Keyboard/Gamepad Navigation") - _, io.ConfigNavSwapGamepadButtons = ImGui.Checkbox("io.ConfigNavSwapGamepadButtons", io.ConfigNavSwapGamepadButtons) - _, io.ConfigNavMoveSetMousePos = ImGui.Checkbox("io.ConfigNavMoveSetMousePos", io.ConfigNavMoveSetMousePos) - ImGui.SameLine(); HelpMarker("Directional/tabbing navigation teleports the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is difficult") - _, io.ConfigNavCaptureKeyboard = ImGui.Checkbox("io.ConfigNavCaptureKeyboard", io.ConfigNavCaptureKeyboard) - _, io.ConfigNavEscapeClearFocusItem = ImGui.Checkbox("io.ConfigNavEscapeClearFocusItem", io.ConfigNavEscapeClearFocusItem) - ImGui.SameLine(); HelpMarker("Pressing Escape clears focused item.") - _, io.ConfigNavEscapeClearFocusWindow = ImGui.Checkbox("io.ConfigNavEscapeClearFocusWindow", io.ConfigNavEscapeClearFocusWindow) - ImGui.SameLine(); HelpMarker("Pressing Escape clears focused window.") - _, io.ConfigNavCursorVisibleAuto = ImGui.Checkbox("io.ConfigNavCursorVisibleAuto", io.ConfigNavCursorVisibleAuto) - ImGui.SameLine(); HelpMarker("Using directional navigation key makes the cursor visible. Mouse click hides the cursor.") - _, io.ConfigNavCursorVisibleAlways = ImGui.Checkbox("io.ConfigNavCursorVisibleAlways", io.ConfigNavCursorVisibleAlways) - ImGui.SameLine(); HelpMarker("Navigation cursor is always visible.") + ImGui_SeparatorText("Keyboard/Gamepad Navigation") + _, io.ConfigNavSwapGamepadButtons = ImGui_Checkbox("io.ConfigNavSwapGamepadButtons", io.ConfigNavSwapGamepadButtons) + _, io.ConfigNavMoveSetMousePos = ImGui_Checkbox("io.ConfigNavMoveSetMousePos", io.ConfigNavMoveSetMousePos) + ImGui_SameLine(); HelpMarker("Directional/tabbing navigation teleports the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is difficult") + _, io.ConfigNavCaptureKeyboard = ImGui_Checkbox("io.ConfigNavCaptureKeyboard", io.ConfigNavCaptureKeyboard) + _, io.ConfigNavEscapeClearFocusItem = ImGui_Checkbox("io.ConfigNavEscapeClearFocusItem", io.ConfigNavEscapeClearFocusItem) + ImGui_SameLine(); HelpMarker("Pressing Escape clears focused item.") + _, io.ConfigNavEscapeClearFocusWindow = ImGui_Checkbox("io.ConfigNavEscapeClearFocusWindow", io.ConfigNavEscapeClearFocusWindow) + ImGui_SameLine(); HelpMarker("Pressing Escape clears focused window.") + _, io.ConfigNavCursorVisibleAuto = ImGui_Checkbox("io.ConfigNavCursorVisibleAuto", io.ConfigNavCursorVisibleAuto) + ImGui_SameLine(); HelpMarker("Using directional navigation key makes the cursor visible. Mouse click hides the cursor.") + _, io.ConfigNavCursorVisibleAlways = ImGui_Checkbox("io.ConfigNavCursorVisibleAlways", io.ConfigNavCursorVisibleAlways) + ImGui_SameLine(); HelpMarker("Navigation cursor is always visible.") - ImGui.SeparatorText("Docking") - _, io.ConfigFlags = ImGui.CheckboxFlags("io.ConfigFlags: DockingEnable", io.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) - ImGui.SameLine() + ImGui_SeparatorText("Docking") + _, io.ConfigFlags = ImGui_CheckboxFlags("io.ConfigFlags: DockingEnable", io.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) + ImGui_SameLine() if io.ConfigDockingWithShift then HelpMarker("Drag from window title bar or their tab to dock/undock. Hold SHIFT to enable docking.\n\nDrag from window menu button (upper-left button) to undock an entire node (all windows).") else HelpMarker("Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.\n\nDrag from window menu button (upper-left button) to undock an entire node (all windows).") end if bit32.band(io.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) ~= 0 then - ImGui.Indent() - _, io.ConfigDockingNoSplit = ImGui.Checkbox("io.ConfigDockingNoSplit", io.ConfigDockingNoSplit) - ImGui.SameLine(); HelpMarker("Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.") - _, io.ConfigDockingNoDockingOver = ImGui.Checkbox("io.ConfigDockingNoDockingOver", io.ConfigDockingNoDockingOver) - ImGui.SameLine(); HelpMarker("Simplified docking mode: disable window merging into a same tab-bar, so docking is limited to splitting windows.") - _, io.ConfigDockingWithShift = ImGui.Checkbox("io.ConfigDockingWithShift", io.ConfigDockingWithShift) - ImGui.SameLine(); HelpMarker("Enable docking when holding Shift only (allow to drop in wider space, reduce visual noise)") - _, io.ConfigDockingAlwaysTabBar = ImGui.Checkbox("io.ConfigDockingAlwaysTabBar", io.ConfigDockingAlwaysTabBar) - ImGui.SameLine(); HelpMarker("Create a docking node and tab-bar on single floating windows.") - _, io.ConfigDockingTransparentPayload = ImGui.Checkbox("io.ConfigDockingTransparentPayload", io.ConfigDockingTransparentPayload) - ImGui.SameLine(); HelpMarker("Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.") - ImGui.Unindent() + ImGui_Indent() + _, io.ConfigDockingNoSplit = ImGui_Checkbox("io.ConfigDockingNoSplit", io.ConfigDockingNoSplit) + ImGui_SameLine(); HelpMarker("Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.") + _, io.ConfigDockingNoDockingOver = ImGui_Checkbox("io.ConfigDockingNoDockingOver", io.ConfigDockingNoDockingOver) + ImGui_SameLine(); HelpMarker("Simplified docking mode: disable window merging into a same tab-bar, so docking is limited to splitting windows.") + _, io.ConfigDockingWithShift = ImGui_Checkbox("io.ConfigDockingWithShift", io.ConfigDockingWithShift) + ImGui_SameLine(); HelpMarker("Enable docking when holding Shift only (allow to drop in wider space, reduce visual noise)") + _, io.ConfigDockingAlwaysTabBar = ImGui_Checkbox("io.ConfigDockingAlwaysTabBar", io.ConfigDockingAlwaysTabBar) + ImGui_SameLine(); HelpMarker("Create a docking node and tab-bar on single floating windows.") + _, io.ConfigDockingTransparentPayload = ImGui_Checkbox("io.ConfigDockingTransparentPayload", io.ConfigDockingTransparentPayload) + ImGui_SameLine(); HelpMarker("Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.") + ImGui_Unindent() end - ImGui.SeparatorText("Multi-viewports") - _, io.ConfigFlags = ImGui.CheckboxFlags("io.ConfigFlags: ViewportsEnable", io.ConfigFlags, 1024 --[[ImGuiConfigFlags.ViewportsEnable]]) - ImGui.SameLine(); HelpMarker("[beta] Enable beta multi-viewports support. See ImGuiPlatformIO for details.") + ImGui_SeparatorText("Multi-viewports") + _, io.ConfigFlags = ImGui_CheckboxFlags("io.ConfigFlags: ViewportsEnable", io.ConfigFlags, 1024 --[[ImGuiConfigFlags.ViewportsEnable]]) + ImGui_SameLine(); HelpMarker("[beta] Enable beta multi-viewports support. See ImGuiPlatformIO for details.") if bit32.band(io.ConfigFlags, 1024 --[[ImGuiConfigFlags.ViewportsEnable]]) ~= 0 then - ImGui.Indent() - _, io.ConfigViewportsNoAutoMerge = ImGui.Checkbox("io.ConfigViewportsNoAutoMerge", io.ConfigViewportsNoAutoMerge) - ImGui.SameLine(); HelpMarker("Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it.") - _, io.ConfigViewportsNoTaskBarIcon = ImGui.Checkbox("io.ConfigViewportsNoTaskBarIcon", io.ConfigViewportsNoTaskBarIcon) - ImGui.SameLine(); HelpMarker("(note: some platform backends may not reflect a change of this value for existing viewports, and may need the viewport to be recreated)") - _, io.ConfigViewportsNoDecoration = ImGui.Checkbox("io.ConfigViewportsNoDecoration", io.ConfigViewportsNoDecoration) - ImGui.SameLine(); HelpMarker("(note: some platform backends may not reflect a change of this value for existing viewports, and may need the viewport to be recreated)") - _, io.ConfigViewportsNoDefaultParent = ImGui.Checkbox("io.ConfigViewportsNoDefaultParent", io.ConfigViewportsNoDefaultParent) - ImGui.SameLine(); HelpMarker("(note: some platform backends may not reflect a change of this value for existing viewports, and may need the viewport to be recreated)") - _, io.ConfigViewportsPlatformFocusSetsImGuiFocus = ImGui.Checkbox("io.ConfigViewportsPlatformFocusSetsImGuiFocus", io.ConfigViewportsPlatformFocusSetsImGuiFocus) - ImGui.SameLine(); HelpMarker("When a platform window is focused (e.g. using Alt+Tab, clicking Platform Title Bar), apply corresponding focus on imgui windows (may clear focus/active id from imgui windows location in other platform windows). In principle this is better enabled but we provide an opt-out, because some Linux window managers tend to eagerly focus windows (e.g. on mouse hover, or even a simple window pos/size change).") - ImGui.Unindent() + ImGui_Indent() + _, io.ConfigViewportsNoAutoMerge = ImGui_Checkbox("io.ConfigViewportsNoAutoMerge", io.ConfigViewportsNoAutoMerge) + ImGui_SameLine(); HelpMarker("Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it.") + _, io.ConfigViewportsNoTaskBarIcon = ImGui_Checkbox("io.ConfigViewportsNoTaskBarIcon", io.ConfigViewportsNoTaskBarIcon) + ImGui_SameLine(); HelpMarker("(note: some platform backends may not reflect a change of this value for existing viewports, and may need the viewport to be recreated)") + _, io.ConfigViewportsNoDecoration = ImGui_Checkbox("io.ConfigViewportsNoDecoration", io.ConfigViewportsNoDecoration) + ImGui_SameLine(); HelpMarker("(note: some platform backends may not reflect a change of this value for existing viewports, and may need the viewport to be recreated)") + _, io.ConfigViewportsNoDefaultParent = ImGui_Checkbox("io.ConfigViewportsNoDefaultParent", io.ConfigViewportsNoDefaultParent) + ImGui_SameLine(); HelpMarker("(note: some platform backends may not reflect a change of this value for existing viewports, and may need the viewport to be recreated)") + _, io.ConfigViewportsPlatformFocusSetsImGuiFocus = ImGui_Checkbox("io.ConfigViewportsPlatformFocusSetsImGuiFocus", io.ConfigViewportsPlatformFocusSetsImGuiFocus) + ImGui_SameLine(); HelpMarker("When a platform window is focused (e.g. using Alt+Tab, clicking Platform Title Bar), apply corresponding focus on imgui windows (may clear focus/active id from imgui windows location in other platform windows). In principle this is better enabled but we provide an opt-out, because some Linux window managers tend to eagerly focus windows (e.g. on mouse hover, or even a simple window pos/size change).") + ImGui_Unindent() end --ImGui.SeparatorText("DPI/Scaling") @@ -23213,68 +23269,68 @@ function ImGui.ShowDemoWindow(p_open) --_, io.ConfigDpiScaleViewports = ImGui.Checkbox("io.ConfigDpiScaleViewports", io.ConfigDpiScaleViewports) --ImGui.SameLine(); HelpMarker("Experimental: Scale Dear ImGui and Platform Windows when Monitor DPI changes.") - ImGui.SeparatorText("Windows") - _, io.ConfigWindowsResizeFromEdges = ImGui.Checkbox("io.ConfigWindowsResizeFromEdges", io.ConfigWindowsResizeFromEdges) - ImGui.SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires ImGuiBackendFlags_HasMouseCursors for better mouse cursor feedback.") - _, io.ConfigWindowsMoveFromTitleBarOnly = ImGui.Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", io.ConfigWindowsMoveFromTitleBarOnly) - _, io.ConfigWindowsCopyContentsWithCtrlC = ImGui.Checkbox("io.ConfigWindowsCopyContentsWithCtrlC", io.ConfigWindowsCopyContentsWithCtrlC) -- [EXPERIMENTAL] - ImGui.SameLine(); HelpMarker("*EXPERIMENTAL* Ctrl+C copy the contents of focused window into the clipboard.\n\nExperimental because:\n- (1) has known issues with nested Begin/End pairs.\n- (2) text output quality varies.\n- (3) text output is in submission order rather than spatial order.") - _, io.ConfigScrollbarScrollByPage = ImGui.Checkbox("io.ConfigScrollbarScrollByPage", io.ConfigScrollbarScrollByPage) - ImGui.SameLine(); HelpMarker("Enable scrolling page by page when clicking outside the scrollbar grab.\nWhen disabled, always scroll to clicked location.\nWhen enabled, Shift+Click scrolls to clicked location.") + ImGui_SeparatorText("Windows") + _, io.ConfigWindowsResizeFromEdges = ImGui_Checkbox("io.ConfigWindowsResizeFromEdges", io.ConfigWindowsResizeFromEdges) + ImGui_SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires ImGuiBackendFlags_HasMouseCursors for better mouse cursor feedback.") + _, io.ConfigWindowsMoveFromTitleBarOnly = ImGui_Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", io.ConfigWindowsMoveFromTitleBarOnly) + _, io.ConfigWindowsCopyContentsWithCtrlC = ImGui_Checkbox("io.ConfigWindowsCopyContentsWithCtrlC", io.ConfigWindowsCopyContentsWithCtrlC) -- [EXPERIMENTAL] + ImGui_SameLine(); HelpMarker("*EXPERIMENTAL* Ctrl+C copy the contents of focused window into the clipboard.\n\nExperimental because:\n- (1) has known issues with nested Begin/End pairs.\n- (2) text output quality varies.\n- (3) text output is in submission order rather than spatial order.") + _, io.ConfigScrollbarScrollByPage = ImGui_Checkbox("io.ConfigScrollbarScrollByPage", io.ConfigScrollbarScrollByPage) + ImGui_SameLine(); HelpMarker("Enable scrolling page by page when clicking outside the scrollbar grab.\nWhen disabled, always scroll to clicked location.\nWhen enabled, Shift+Click scrolls to clicked location.") - ImGui.SeparatorText("Widgets") - _, io.ConfigInputTextCursorBlink = ImGui.Checkbox("io.ConfigInputTextCursorBlink", io.ConfigInputTextCursorBlink) - ImGui.SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting).") - _, io.ConfigInputTextEnterKeepActive = ImGui.Checkbox("io.ConfigInputTextEnterKeepActive", io.ConfigInputTextEnterKeepActive) - ImGui.SameLine(); HelpMarker("Pressing Enter will reactivate item and select all text (single-line only).") - _, io.ConfigDragClickToInputText = ImGui.Checkbox("io.ConfigDragClickToInputText", io.ConfigDragClickToInputText) - ImGui.SameLine(); HelpMarker("Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving).") - _, io.ConfigMacOSXBehaviors = ImGui.Checkbox("io.ConfigMacOSXBehaviors", io.ConfigMacOSXBehaviors) - ImGui.SameLine(); HelpMarker("Swap Cmd<>Ctrl keys, enable various MacOS style behaviors.") - ImGui.Text("Also see Style->Rendering for rendering options.") + ImGui_SeparatorText("Widgets") + _, io.ConfigInputTextCursorBlink = ImGui_Checkbox("io.ConfigInputTextCursorBlink", io.ConfigInputTextCursorBlink) + ImGui_SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting).") + _, io.ConfigInputTextEnterKeepActive = ImGui_Checkbox("io.ConfigInputTextEnterKeepActive", io.ConfigInputTextEnterKeepActive) + ImGui_SameLine(); HelpMarker("Pressing Enter will reactivate item and select all text (single-line only).") + _, io.ConfigDragClickToInputText = ImGui_Checkbox("io.ConfigDragClickToInputText", io.ConfigDragClickToInputText) + ImGui_SameLine(); HelpMarker("Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving).") + _, io.ConfigMacOSXBehaviors = ImGui_Checkbox("io.ConfigMacOSXBehaviors", io.ConfigMacOSXBehaviors) + ImGui_SameLine(); HelpMarker("Swap Cmd<>Ctrl keys, enable various MacOS style behaviors.") + ImGui_Text("Also see Style->Rendering for rendering options.") - ImGui.SeparatorText("Settings") - _, io.ConfigIniSettingsSaveLastUsedDate = ImGui.Checkbox("io.ConfigIniSettingsSaveLastUsedDate", io.ConfigIniSettingsSaveLastUsedDate) + ImGui_SeparatorText("Settings") + _, io.ConfigIniSettingsSaveLastUsedDate = ImGui_Checkbox("io.ConfigIniSettingsSaveLastUsedDate", io.ConfigIniSettingsSaveLastUsedDate) -- Also read: https://github.com/ocornut/imgui/wiki/Error-Handling - ImGui.SeparatorText("Error Handling") + ImGui_SeparatorText("Error Handling") - _, io.ConfigErrorRecovery = ImGui.Checkbox("io.ConfigErrorRecovery", io.ConfigErrorRecovery) - ImGui.SameLine(); HelpMarker( + _, io.ConfigErrorRecovery = ImGui_Checkbox("io.ConfigErrorRecovery", io.ConfigErrorRecovery) + ImGui_SameLine(); HelpMarker( "Options to configure how we handle recoverable errors.\n" .. "- Error recovery is not perfect nor guaranteed! It is a feature to ease development.\n" .. "- You not are not supposed to rely on it in the course of a normal application run.\n" .. "- Possible usage: facilitate recovery from errors triggered from a scripting language or after specific exceptions handlers.\n" .. "- Always ensure that on programmers seat you have at minimum Asserts or Tooltips enabled when making direct imgui API call! " .. "Otherwise it would severely hinder your ability to catch and correct mistakes!") - _, io.ConfigErrorRecoveryEnableAssert = ImGui.Checkbox("io.ConfigErrorRecoveryEnableAssert", io.ConfigErrorRecoveryEnableAssert) - _, io.ConfigErrorRecoveryEnableDebugLog = ImGui.Checkbox("io.ConfigErrorRecoveryEnableDebugLog", io.ConfigErrorRecoveryEnableDebugLog) - _, io.ConfigErrorRecoveryEnableTooltip = ImGui.Checkbox("io.ConfigErrorRecoveryEnableTooltip", io.ConfigErrorRecoveryEnableTooltip) + _, io.ConfigErrorRecoveryEnableAssert = ImGui_Checkbox("io.ConfigErrorRecoveryEnableAssert", io.ConfigErrorRecoveryEnableAssert) + _, io.ConfigErrorRecoveryEnableDebugLog = ImGui_Checkbox("io.ConfigErrorRecoveryEnableDebugLog", io.ConfigErrorRecoveryEnableDebugLog) + _, io.ConfigErrorRecoveryEnableTooltip = ImGui_Checkbox("io.ConfigErrorRecoveryEnableTooltip", io.ConfigErrorRecoveryEnableTooltip) if not io.ConfigErrorRecoveryEnableAssert and not io.ConfigErrorRecoveryEnableDebugLog and not io.ConfigErrorRecoveryEnableTooltip then io.ConfigErrorRecoveryEnableAssert = true; io.ConfigErrorRecoveryEnableDebugLog = true; io.ConfigErrorRecoveryEnableTooltip = true end -- Also read: https://github.com/ocornut/imgui/wiki/Debug-Tools - ImGui.SeparatorText("Debug") - _, io.ConfigDebugIsDebuggerPresent = ImGui.Checkbox("io.ConfigDebugIsDebuggerPresent", io.ConfigDebugIsDebuggerPresent) - ImGui.SameLine(); HelpMarker("Enable various tools calling IM_DEBUG_BREAK().\n\nRequires a debugger being attached, otherwise IM_DEBUG_BREAK() options will appear to crash your application.") - _, io.ConfigDebugHighlightIdConflicts = ImGui.Checkbox("io.ConfigDebugHighlightIdConflicts", io.ConfigDebugHighlightIdConflicts) - ImGui.SameLine(); HelpMarker("Highlight and show an error message when multiple items have conflicting identifiers.") - ImGui.BeginDisabled() - _, io.ConfigDebugBeginReturnValueOnce = ImGui.Checkbox("io.ConfigDebugBeginReturnValueOnce", io.ConfigDebugBeginReturnValueOnce) - ImGui.EndDisabled() - 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.") - _, io.ConfigDebugBeginReturnValueLoop = 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.") - _, io.ConfigDebugIgnoreFocusLoss = 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.") - _, io.ConfigDebugDrawListDefaultsToStrokeLegacy = ImGui.Checkbox("io.ConfigDebugDrawListDefaultsToStrokeLegacy", io.ConfigDebugDrawListDefaultsToStrokeLegacy) - ImGui.SameLine(); HelpMarker("Option to default all ImDrawList to ImDrawFlags_StrokeLegacy mode, mimicking pre-1.93.0 rendering.") - _, io.ConfigDebugIniSettings = ImGui.Checkbox("io.ConfigDebugIniSettings", io.ConfigDebugIniSettings) - ImGui.SameLine(); HelpMarker("Option to save .ini data with extra comments (particularly helpful for Docking, but makes saving slower).") + ImGui_SeparatorText("Debug") + _, io.ConfigDebugIsDebuggerPresent = ImGui_Checkbox("io.ConfigDebugIsDebuggerPresent", io.ConfigDebugIsDebuggerPresent) + ImGui_SameLine(); HelpMarker("Enable various tools calling IM_DEBUG_BREAK().\n\nRequires a debugger being attached, otherwise IM_DEBUG_BREAK() options will appear to crash your application.") + _, io.ConfigDebugHighlightIdConflicts = ImGui_Checkbox("io.ConfigDebugHighlightIdConflicts", io.ConfigDebugHighlightIdConflicts) + ImGui_SameLine(); HelpMarker("Highlight and show an error message when multiple items have conflicting identifiers.") + ImGui_BeginDisabled() + _, io.ConfigDebugBeginReturnValueOnce = ImGui_Checkbox("io.ConfigDebugBeginReturnValueOnce", io.ConfigDebugBeginReturnValueOnce) + ImGui_EndDisabled() + 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.") + _, io.ConfigDebugBeginReturnValueLoop = 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.") + _, io.ConfigDebugIgnoreFocusLoss = 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.") + _, io.ConfigDebugDrawListDefaultsToStrokeLegacy = ImGui_Checkbox("io.ConfigDebugDrawListDefaultsToStrokeLegacy", io.ConfigDebugDrawListDefaultsToStrokeLegacy) + ImGui_SameLine(); HelpMarker("Option to default all ImDrawList to ImDrawFlags_StrokeLegacy mode, mimicking pre-1.93.0 rendering.") + _, io.ConfigDebugIniSettings = ImGui_Checkbox("io.ConfigDebugIniSettings", io.ConfigDebugIniSettings) + ImGui_SameLine(); HelpMarker("Option to save .ini data with extra comments (particularly helpful for Docking, but makes saving slower).") - ImGui.TreePop() - ImGui.Spacing() + ImGui_TreePop() + ImGui_Spacing() end if ImGui.TreeNode("Backend Flags") then @@ -23285,29 +23341,29 @@ function ImGui.ShowDemoWindow(p_open) -- Make a local copy to avoid modifying actual backend flags. -- FIXME: Maybe we need a BeginReadonly() equivalent to keep label bright? - ImGui.BeginDisabled() - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: HasGamepad", io.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: HasMouseCursors", io.BackendFlags, 2 --[[ImGuiBackendFlags.HasMouseCursors]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: HasSetMousePos", io.BackendFlags, 4 --[[ImGuiBackendFlags.HasSetMousePos]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: PlatformHasViewports", io.BackendFlags, 2048 --[[ImGuiBackendFlags.PlatformHasViewports]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: HasMouseHoveredViewport",io.BackendFlags, 4096 --[[ImGuiBackendFlags.HasMouseHoveredViewport]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: HasParentViewport", io.BackendFlags, 8192 --[[ImGuiBackendFlags.HasParentViewport]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", io.BackendFlags, 8 --[[ImGuiBackendFlags.RendererHasVtxOffset]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: RendererHasTextures", io.BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: RendererHasViewports", io.BackendFlags, 1024 --[[ImGuiBackendFlags.RendererHasViewports]]) - ImGui.EndDisabled() + ImGui_BeginDisabled() + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: HasGamepad", io.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: HasMouseCursors", io.BackendFlags, 2 --[[ImGuiBackendFlags.HasMouseCursors]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: HasSetMousePos", io.BackendFlags, 4 --[[ImGuiBackendFlags.HasSetMousePos]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: PlatformHasViewports", io.BackendFlags, 2048 --[[ImGuiBackendFlags.PlatformHasViewports]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: HasMouseHoveredViewport",io.BackendFlags, 4096 --[[ImGuiBackendFlags.HasMouseHoveredViewport]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: HasParentViewport", io.BackendFlags, 8192 --[[ImGuiBackendFlags.HasParentViewport]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", io.BackendFlags, 8 --[[ImGuiBackendFlags.RendererHasVtxOffset]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: RendererHasTextures", io.BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: RendererHasViewports", io.BackendFlags, 1024 --[[ImGuiBackendFlags.RendererHasViewports]]) + ImGui_EndDisabled() - ImGui.TreePop() - ImGui.Spacing() + ImGui_TreePop() + ImGui_Spacing() end if ImGui.TreeNode("Style, Fonts") then IMGUI_DEMO_MARKER("Configuration/Style, Fonts") - _, demo_data.ShowStyleEditor = ImGui.Checkbox("Style Editor", demo_data.ShowStyleEditor) - ImGui.SameLine() + _, demo_data.ShowStyleEditor = ImGui_Checkbox("Style Editor", demo_data.ShowStyleEditor) + ImGui_SameLine() HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function.") - ImGui.TreePop() - ImGui.Spacing() + ImGui_TreePop() + ImGui_Spacing() end if ImGui.TreeNode("Capture/Logging") then @@ -23316,34 +23372,34 @@ function ImGui.ShowDemoWindow(p_open) "The logging API redirects all text output so you can easily capture the content of " .. "a window or a block. Tree nodes can be automatically expanded.\n" .. "Try opening any of the contents below in this window and then click one of the \"Log To\" button.") - ImGui.LogButtons() + ImGui_LogButtons() HelpMarker("You can also call ImGui::LogText() to output directly to the log without a visual output.") - if ImGui.Button("Copy \"Hello, world!\" to clipboard") then - ImGui.LogToClipboard() - ImGui.LogText("Hello, world!") - ImGui.LogFinish() + if ImGui_Button("Copy \"Hello, world!\" to clipboard") then + ImGui_LogToClipboard() + ImGui_LogText("Hello, world!") + ImGui_LogFinish() end - ImGui.TreePop() + ImGui_TreePop() end end if ImGui.CollapsingHeader("Window options") then IMGUI_DEMO_MARKER("Window options") - if ImGui.BeginTable("split", 3) then - ImGui.TableNextColumn(); _, s.no_titlebar = ImGui.Checkbox("No titlebar", s.no_titlebar) - ImGui.TableNextColumn(); _, s.no_scrollbar = ImGui.Checkbox("No scrollbar", s.no_scrollbar) - ImGui.TableNextColumn(); _, s.no_menu = ImGui.Checkbox("No menu", s.no_menu) - ImGui.TableNextColumn(); _, s.no_move = ImGui.Checkbox("No move", s.no_move) - ImGui.TableNextColumn(); _, s.no_resize = ImGui.Checkbox("No resize", s.no_resize) - ImGui.TableNextColumn(); _, s.no_collapse = ImGui.Checkbox("No collapse", s.no_collapse) - ImGui.TableNextColumn(); _, s.no_close = ImGui.Checkbox("No close", s.no_close) - ImGui.TableNextColumn(); _, s.no_nav = ImGui.Checkbox("No nav", s.no_nav) - ImGui.TableNextColumn(); _, s.no_background = ImGui.Checkbox("No background", s.no_background) - ImGui.TableNextColumn(); _, s.no_bring_to_front = ImGui.Checkbox("No bring to front", s.no_bring_to_front) - ImGui.TableNextColumn(); _, s.no_docking = ImGui.Checkbox("No docking", s.no_docking) - ImGui.TableNextColumn(); _, s.unsaved_document = ImGui.Checkbox("Unsaved document", s.unsaved_document) - ImGui.EndTable() + if ImGui_BeginTable("split", 3) then + ImGui_TableNextColumn(); _, s.no_titlebar = ImGui_Checkbox("No titlebar", s.no_titlebar) + ImGui_TableNextColumn(); _, s.no_scrollbar = ImGui_Checkbox("No scrollbar", s.no_scrollbar) + ImGui_TableNextColumn(); _, s.no_menu = ImGui_Checkbox("No menu", s.no_menu) + ImGui_TableNextColumn(); _, s.no_move = ImGui_Checkbox("No move", s.no_move) + ImGui_TableNextColumn(); _, s.no_resize = ImGui_Checkbox("No resize", s.no_resize) + ImGui_TableNextColumn(); _, s.no_collapse = ImGui_Checkbox("No collapse", s.no_collapse) + ImGui_TableNextColumn(); _, s.no_close = ImGui_Checkbox("No close", s.no_close) + ImGui_TableNextColumn(); _, s.no_nav = ImGui_Checkbox("No nav", s.no_nav) + ImGui_TableNextColumn(); _, s.no_background = ImGui_Checkbox("No background", s.no_background) + ImGui_TableNextColumn(); _, s.no_bring_to_front = ImGui_Checkbox("No bring to front", s.no_bring_to_front) + ImGui_TableNextColumn(); _, s.no_docking = ImGui_Checkbox("No docking", s.no_docking) + ImGui_TableNextColumn(); _, s.unsaved_document = ImGui_Checkbox("Unsaved document", s.unsaved_document) + ImGui_EndTable() end end @@ -23355,7 +23411,7 @@ function ImGui.ShowDemoWindow(p_open) DemoWindowInputs() -- End of ShowDemoWindow() - ImGui.PopItemWidth() + ImGui_PopItemWidth() ImGui.End() return p_open end @@ -23365,66 +23421,66 @@ end ------------------------------------------------------------------------------- function DemoWindowMenuBar(demo_data) - if ImGui.BeginMenuBar() then - if ImGui.BeginMenu("Menu") then + if ImGui_BeginMenuBar() then + if ImGui_BeginMenu("Menu") then IMGUI_DEMO_MARKER("Menu/File") ShowExampleMenuFile() - ImGui.EndMenu() + ImGui_EndMenu() end - if ImGui.BeginMenu("Examples") then + if ImGui_BeginMenu("Examples") then IMGUI_DEMO_MARKER("Menu/Examples") - _, demo_data.ShowMainMenuBar = ImGui.MenuItem("Main menu bar", nil, demo_data.ShowMainMenuBar) + _, demo_data.ShowMainMenuBar = ImGui_MenuItem("Main menu bar", nil, demo_data.ShowMainMenuBar) - ImGui.SeparatorText("Mini apps") - _, demo_data.ShowAppAssetsBrowser = ImGui.MenuItem("Assets Browser", nil, demo_data.ShowAppAssetsBrowser) - _, demo_data.ShowAppConsole = ImGui.MenuItem("Console", nil, demo_data.ShowAppConsole) - _, demo_data.ShowAppCustomRendering = ImGui.MenuItem("Custom rendering", nil, demo_data.ShowAppCustomRendering) - _, demo_data.ShowAppDocuments = ImGui.MenuItem("Documents", nil, demo_data.ShowAppDocuments) - _, demo_data.ShowAppDockSpace = ImGui.MenuItem("Dockspace", nil, demo_data.ShowAppDockSpace) - _, demo_data.ShowAppImageViewer = ImGui.MenuItem("Image Viewer", nil, demo_data.ShowAppImageViewer) - _, demo_data.ShowAppLog = ImGui.MenuItem("Log", nil, demo_data.ShowAppLog) - _, demo_data.ShowAppPropertyEditor = ImGui.MenuItem("Property editor", nil, demo_data.ShowAppPropertyEditor) - _, demo_data.ShowAppLayout = ImGui.MenuItem("Simple layout", nil, demo_data.ShowAppLayout) - _, demo_data.ShowAppSimpleOverlay = ImGui.MenuItem("Simple overlay", nil, demo_data.ShowAppSimpleOverlay) + ImGui_SeparatorText("Mini apps") + _, demo_data.ShowAppAssetsBrowser = ImGui_MenuItem("Assets Browser", nil, demo_data.ShowAppAssetsBrowser) + _, demo_data.ShowAppConsole = ImGui_MenuItem("Console", nil, demo_data.ShowAppConsole) + _, demo_data.ShowAppCustomRendering = ImGui_MenuItem("Custom rendering", nil, demo_data.ShowAppCustomRendering) + _, demo_data.ShowAppDocuments = ImGui_MenuItem("Documents", nil, demo_data.ShowAppDocuments) + _, demo_data.ShowAppDockSpace = ImGui_MenuItem("Dockspace", nil, demo_data.ShowAppDockSpace) + _, demo_data.ShowAppImageViewer = ImGui_MenuItem("Image Viewer", nil, demo_data.ShowAppImageViewer) + _, demo_data.ShowAppLog = ImGui_MenuItem("Log", nil, demo_data.ShowAppLog) + _, demo_data.ShowAppPropertyEditor = ImGui_MenuItem("Property editor", nil, demo_data.ShowAppPropertyEditor) + _, demo_data.ShowAppLayout = ImGui_MenuItem("Simple layout", nil, demo_data.ShowAppLayout) + _, demo_data.ShowAppSimpleOverlay = ImGui_MenuItem("Simple overlay", nil, demo_data.ShowAppSimpleOverlay) - ImGui.SeparatorText("Concepts") - _, demo_data.ShowAppAutoResize = ImGui.MenuItem("Auto-resizing window", nil, demo_data.ShowAppAutoResize) - _, demo_data.ShowAppConstrainedResize = ImGui.MenuItem("Constrained-resizing window", nil, demo_data.ShowAppConstrainedResize) - _, demo_data.ShowAppFullscreen = ImGui.MenuItem("Fullscreen window", nil, demo_data.ShowAppFullscreen) - _, demo_data.ShowAppLongText = ImGui.MenuItem("Long text display", nil, demo_data.ShowAppLongText) - _, demo_data.ShowAppWindowTitles = ImGui.MenuItem("Manipulating window titles", nil, demo_data.ShowAppWindowTitles) + ImGui_SeparatorText("Concepts") + _, demo_data.ShowAppAutoResize = ImGui_MenuItem("Auto-resizing window", nil, demo_data.ShowAppAutoResize) + _, demo_data.ShowAppConstrainedResize = ImGui_MenuItem("Constrained-resizing window", nil, demo_data.ShowAppConstrainedResize) + _, demo_data.ShowAppFullscreen = ImGui_MenuItem("Fullscreen window", nil, demo_data.ShowAppFullscreen) + _, demo_data.ShowAppLongText = ImGui_MenuItem("Long text display", nil, demo_data.ShowAppLongText) + _, demo_data.ShowAppWindowTitles = ImGui_MenuItem("Manipulating window titles", nil, demo_data.ShowAppWindowTitles) - ImGui.EndMenu() + ImGui_EndMenu() end --if ImGui.MenuItem("MenuItem") then end -- You can also use MenuItem() inside a menu bar! - if ImGui.BeginMenu("Tools") then + if ImGui_BeginMenu("Tools") then IMGUI_DEMO_MARKER("Menu/Tools") - local io = ImGui.GetIO() + local io = ImGui_GetIO() local has_debug_tools = true -- [Port] IMGUI_DISABLE_DEBUG_TOOLS is never defined here - _, demo_data.ShowMetrics = ImGui.MenuItem("Metrics/Debugger", nil, demo_data.ShowMetrics, has_debug_tools) - if ImGui.BeginMenu("Debug Options") then - ImGui.BeginDisabled(not has_debug_tools) - _, io.ConfigDebugHighlightIdConflicts = ImGui.Checkbox("Highlight ID Conflicts", io.ConfigDebugHighlightIdConflicts) - ImGui.EndDisabled() - _, io.ConfigErrorRecoveryEnableAssert = ImGui.Checkbox("Assert on error recovery", io.ConfigErrorRecoveryEnableAssert) - ImGui.TextDisabled("(see Demo->Configuration for more)") - ImGui.EndMenu() + _, demo_data.ShowMetrics = ImGui_MenuItem("Metrics/Debugger", nil, demo_data.ShowMetrics, has_debug_tools) + if ImGui_BeginMenu("Debug Options") then + ImGui_BeginDisabled(not has_debug_tools) + _, io.ConfigDebugHighlightIdConflicts = ImGui_Checkbox("Highlight ID Conflicts", io.ConfigDebugHighlightIdConflicts) + ImGui_EndDisabled() + _, io.ConfigErrorRecoveryEnableAssert = ImGui_Checkbox("Assert on error recovery", io.ConfigErrorRecoveryEnableAssert) + ImGui_TextDisabled("(see Demo->Configuration for more)") + ImGui_EndMenu() end - _, demo_data.ShowDebugLog = ImGui.MenuItem("Debug Log", nil, demo_data.ShowDebugLog, has_debug_tools) - _, demo_data.ShowIDStackTool = ImGui.MenuItem("ID Stack Tool", nil, demo_data.ShowIDStackTool, has_debug_tools) + _, demo_data.ShowDebugLog = ImGui_MenuItem("Debug Log", nil, demo_data.ShowDebugLog, has_debug_tools) + _, demo_data.ShowIDStackTool = ImGui_MenuItem("ID Stack Tool", nil, demo_data.ShowIDStackTool, has_debug_tools) local is_debugger_present = io.ConfigDebugIsDebuggerPresent - if ImGui.MenuItem("Item Picker", nil, false, has_debug_tools) then -- and is_debugger_present - ImGui.DebugStartItemPicker() + if ImGui_MenuItem("Item Picker", nil, false, has_debug_tools) then -- and is_debugger_present + ImGui_DebugStartItemPicker() end if not is_debugger_present then - ImGui.SetItemTooltip("Requires io.ConfigDebugIsDebuggerPresent=true to be set.\n\nWe otherwise disable some extra features to avoid casual users crashing the application.") + ImGui_SetItemTooltip("Requires io.ConfigDebugIsDebuggerPresent=true to be set.\n\nWe otherwise disable some extra features to avoid casual users crashing the application.") end - _, demo_data.ShowStyleEditor = ImGui.MenuItem("Style Editor", nil, demo_data.ShowStyleEditor) - _, demo_data.ShowAbout = ImGui.MenuItem("About Dear ImGui", nil, demo_data.ShowAbout) + _, demo_data.ShowStyleEditor = ImGui_MenuItem("Style Editor", nil, demo_data.ShowStyleEditor) + _, demo_data.ShowAbout = ImGui_MenuItem("About Dear ImGui", nil, demo_data.ShowAbout) - ImGui.EndMenu() + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end end @@ -23551,28 +23607,28 @@ function ExampleImageViewerData() end function ExampleImageViewer_DrawOptions(data) - ImGui.SetNextItemShortcut(552 --[[ImGuiKey.G]], 262144 --[[ImGuiInputFlags.Tooltip]]) -- | ImGuiInputFlags.RouteGlobal - _, data.GridEnabled = ImGui.Checkbox("Grid", data.GridEnabled) - ImGui.SameLine() - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 10.0) + ImGui_SetNextItemShortcut(552 --[[ImGuiKey.G]], 262144 --[[ImGuiInputFlags.Tooltip]]) -- | ImGuiInputFlags.RouteGlobal + _, data.GridEnabled = ImGui_Checkbox("Grid", data.GridEnabled) + ImGui_SameLine() + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 10.0) local zoom_100 = data.Zoom * 100.0 local changed - zoom_100, changed = ImGui.DragFloat("##Zoom", zoom_100, 5.0, data.ZoomMin * 100.0, data.ZoomMax * 100.0, "%.0f%%", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + zoom_100, changed = ImGui_DragFloat("##Zoom", zoom_100, 5.0, data.ZoomMin * 100.0, data.ZoomMax * 100.0, "%.0f%%", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) if changed then data.Zoom = zoom_100 / 100.0 end end function ExampleImageViewer_DrawCanvas(data, canvas_size, image_tex_ref, image_w, image_h) - local io = ImGui.GetIO() - local platform_io = ImGui.GetPlatformIO() - local draw_list = ImGui.GetWindowDrawList() + local io = ImGui_GetIO() + local platform_io = ImGui_GetPlatformIO() + local draw_list = ImGui_GetWindowDrawList() assert(canvas_size.x >= 0.0 and canvas_size.y >= 0.0) -- Layout canvas - ImGui.InvisibleButton("##Canvas", canvas_size) - local canvas_min = ImGui.GetItemRectMin() - local canvas_max = ImGui.GetItemRectMax() + ImGui_InvisibleButton("##Canvas", canvas_size) + local canvas_min = ImGui_GetItemRectMin() + local canvas_max = ImGui_GetItemRectMax() if data.ViewReset then data.ViewOffset = ImVec2((canvas_size.x * 0.5 / data.Zoom) - 0.5, (canvas_size.y * 0.5 / data.Zoom) - 0.5) -- Add half a pixel padding @@ -23580,13 +23636,13 @@ function ExampleImageViewer_DrawCanvas(data, canvas_size, image_tex_ref, image_w data.ViewReset = false -- Handle inputs - if ImGui.SetItemKeyOwner(662 --[[ImGuiKey.MouseWheelY]]) then + if ImGui_SetItemKeyOwner(662 --[[ImGuiKey.MouseWheelY]]) then if io.MouseWheel ~= 0.0 then data.Zoom = ImClamp(data.Zoom * (1.0 + io.MouseWheel * 0.10), data.ZoomMin, data.ZoomMax) end end local zoom = data.Zoom -- (float)(int)ViewZoom; - if ImGui.IsItemActive() and ImGui.IsMouseDragging(0) then + if ImGui_IsItemActive() and ImGui_IsMouseDragging(0) then data.ViewOffset.x = data.ViewOffset.x - io.MouseDelta.x / zoom data.ViewOffset.y = data.ViewOffset.y - io.MouseDelta.y / zoom end @@ -23605,7 +23661,7 @@ function ExampleImageViewer_DrawCanvas(data, canvas_size, image_tex_ref, image_w end draw_list:AddImage(image_tex_ref, image_min, image_max) if platform_io.DrawCallback_SetSamplerLinear ~= nil then - draw_list:AddCallback(ImGui.GetPlatformIO().DrawCallback_SetSamplerLinear) + draw_list:AddCallback(ImGui_GetPlatformIO().DrawCallback_SetSamplerLinear) end -- Display grid lines for visible pixels @@ -23651,67 +23707,67 @@ function DemoWindowWidgetsBasic() if ImGui.TreeNode("Basic") then local s = S.DemoWindowWidgetsBasic IMGUI_DEMO_MARKER("Widgets/Basic") - ImGui.SeparatorText("General") + ImGui_SeparatorText("General") IMGUI_DEMO_MARKER("Widgets/Basic/Button") - if ImGui.Button("Button") then + if ImGui_Button("Button") then s.clicked = s.clicked + 1 end if bit32.band(s.clicked, 1) ~= 0 then - ImGui.SameLine() - ImGui.Text("Thanks for clicking me!") + ImGui_SameLine() + ImGui_Text("Thanks for clicking me!") end IMGUI_DEMO_MARKER("Widgets/Basic/Checkbox") - _, s.check = ImGui.Checkbox("checkbox", s.check) + _, s.check = ImGui_Checkbox("checkbox", s.check) IMGUI_DEMO_MARKER("Widgets/Basic/RadioButton") - _, s.e = ImGui.RadioButton("radio a", s.e, 0); ImGui.SameLine() - _, s.e = ImGui.RadioButton("radio b", s.e, 1); ImGui.SameLine() - _, s.e = ImGui.RadioButton("radio c", s.e, 2) + _, s.e = ImGui_RadioButton("radio a", s.e, 0); ImGui_SameLine() + _, s.e = ImGui_RadioButton("radio b", s.e, 1); ImGui_SameLine() + _, s.e = ImGui_RadioButton("radio c", s.e, 2) - ImGui.AlignTextToFramePadding() - ImGui.TextLinkOpenURL("Hyperlink", "https://github.com/ocornut/imgui/wiki/Error-Handling") + ImGui_AlignTextToFramePadding() + ImGui_TextLinkOpenURL("Hyperlink", "https://github.com/ocornut/imgui/wiki/Error-Handling") -- Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style. IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Colored)") for i = 0, 6 do if i > 0 then - ImGui.SameLine() + ImGui_SameLine() end - ImGui.PushID(i) - ImGui.PushStyleColor(22 --[[ImGuiCol.Button]], ImColor.HSV(i / 7.0, 0.6, 0.6).Value) - ImGui.PushStyleColor(23 --[[ImGuiCol.ButtonHovered]], ImColor.HSV(i / 7.0, 0.7, 0.7).Value) - ImGui.PushStyleColor(24 --[[ImGuiCol.ButtonActive]], ImColor.HSV(i / 7.0, 0.8, 0.8).Value) - ImGui.Button("Click") - ImGui.PopStyleColor(3) - ImGui.PopID() + ImGui_PushID(i) + ImGui_PushStyleColor(22 --[[ImGuiCol.Button]], ImColor.HSV(i / 7.0, 0.6, 0.6).Value) + ImGui_PushStyleColor(23 --[[ImGuiCol.ButtonHovered]], ImColor.HSV(i / 7.0, 0.7, 0.7).Value) + ImGui_PushStyleColor(24 --[[ImGuiCol.ButtonActive]], ImColor.HSV(i / 7.0, 0.8, 0.8).Value) + ImGui_Button("Click") + ImGui_PopStyleColor(3) + ImGui_PopID() end -- Use AlignTextToFramePadding() to align text baseline to the baseline of framed widgets elements -- (otherwise a Text+SameLine+Button sequence will have the text a little too high by default!) -- See 'Demo->Layout->Text Baseline Alignment' for details. - ImGui.AlignTextToFramePadding() - ImGui.Text("Hold to repeat:") - ImGui.SameLine() + ImGui_AlignTextToFramePadding() + ImGui_Text("Hold to repeat:") + ImGui_SameLine() -- Arrow buttons with Repeater IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Repeating)") - local spacing = ImGui.GetStyle().ItemInnerSpacing.x - ImGui.PushItemFlag(8 --[[ImGuiItemFlags.ButtonRepeat]], true) - if ImGui.ArrowButton("##left", 0 --[[ImGuiDir.Left]]) then s.counter = s.counter - 1 end - ImGui.SameLine(0.0, spacing) - if ImGui.ArrowButton("##right", 1 --[[ImGuiDir.Right]]) then s.counter = s.counter + 1 end - ImGui.PopItemFlag() - ImGui.SameLine() - ImGui.Text("%d", s.counter) + local spacing = ImGui_GetStyle().ItemInnerSpacing.x + ImGui_PushItemFlag(8 --[[ImGuiItemFlags.ButtonRepeat]], true) + if ImGui_ArrowButton("##left", 0 --[[ImGuiDir.Left]]) then s.counter = s.counter - 1 end + ImGui_SameLine(0.0, spacing) + if ImGui_ArrowButton("##right", 1 --[[ImGuiDir.Right]]) then s.counter = s.counter + 1 end + ImGui_PopItemFlag() + ImGui_SameLine() + ImGui_Text("%d", s.counter) - ImGui.Button("Tooltip") - ImGui.SetItemTooltip("I am a tooltip") + ImGui_Button("Tooltip") + ImGui_SetItemTooltip("I am a tooltip") - ImGui.LabelText("label", "Value") + ImGui_LabelText("label", "Value") - ImGui.SeparatorText("Inputs") + ImGui_SeparatorText("Inputs") do local s = S.DemoWindowWidgetsBasic.inputs @@ -23719,8 +23775,8 @@ function DemoWindowWidgetsBasic() -- - For std::string: use the wrapper in misc/cpp/imgui_stdlib.h/.cpp -- - Otherwise, see the 'Dear ImGui Demo->Widgets->Text Input->Resize Callback' for using ImGuiInputTextFlags_CallbackResize. IMGUI_DEMO_MARKER("Widgets/Basic/InputText") - ImGui.InputText("input text", s.str0, 128) - ImGui.SameLine(); HelpMarker( + ImGui_InputText("input text", s.str0, 128) + ImGui_SameLine(); HelpMarker( "USER:\n" .. "Hold Shift or use mouse to select text.\n" .. "Ctrl+Left/Right to word jump.\n" .. @@ -23733,54 +23789,54 @@ function DemoWindowWidgetsBasic() "to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated " .. "in imgui_demo.cpp).") - ImGui.InputTextWithHint("input text (w/ hint)", "enter text here", s.str1, 128) + ImGui_InputTextWithHint("input text (w/ hint)", "enter text here", s.str1, 128) IMGUI_DEMO_MARKER("Widgets/Basic/InputInt, InputFloat") - s.i0 = ImGui.InputInt("input int", s.i0) + s.i0 = ImGui_InputInt("input int", s.i0) - s.f0 = ImGui.InputFloat("input float", s.f0, 0.01, 1.0, "%.3f") + s.f0 = ImGui_InputFloat("input float", s.f0, 0.01, 1.0, "%.3f") - s.d0 = ImGui.InputDouble("input double", s.d0, 0.01, 1.0, "%.8f") + s.d0 = ImGui_InputDouble("input double", s.d0, 0.01, 1.0, "%.8f") - s.f1 = ImGui.InputFloat("input scientific", s.f1, 0.0, 0.0, "%e") - ImGui.SameLine(); HelpMarker( + s.f1 = ImGui_InputFloat("input scientific", s.f1, 0.0, 0.0, "%e") + ImGui_SameLine(); HelpMarker( "You can input value using the scientific notation,\n" .. " e.g. \"1e+8\" becomes \"100000000\".") - ImGui.InputFloat3("input float3", s.vec4a) + ImGui_InputFloat3("input float3", s.vec4a) end - ImGui.SeparatorText("Drags") + ImGui_SeparatorText("Drags") do local s = S.DemoWindowWidgetsBasic.drags IMGUI_DEMO_MARKER("Widgets/Basic/DragInt, DragFloat") - s.i1 = ImGui.DragInt("drag int", s.i1, 1) - ImGui.SameLine(); HelpMarker( + s.i1 = ImGui_DragInt("drag int", s.i1, 1) + ImGui_SameLine(); HelpMarker( "Click and drag to edit value.\n" .. "Hold Shift/Alt for faster/slower edit.\n" .. "Double-Click or Ctrl+Click to input value.") - s.i2 = ImGui.DragInt("drag int 0..100", s.i2, 1, 0, 100, "%d%%", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) - s.i3 = ImGui.DragInt("drag int wrap 100..200", s.i3, 1, 100, 200, "%d", 256 --[[ImGuiSliderFlags.WrapAround]]) + s.i2 = ImGui_DragInt("drag int 0..100", s.i2, 1, 0, 100, "%d%%", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + s.i3 = ImGui_DragInt("drag int wrap 100..200", s.i3, 1, 100, 200, "%d", 256 --[[ImGuiSliderFlags.WrapAround]]) - s.f1 = ImGui.DragFloat("drag float", s.f1, 0.005) - s.f2 = ImGui.DragFloat("drag small float", s.f2, 0.0001, 0.0, 0.0, "%.06f ns") + s.f1 = ImGui_DragFloat("drag float", s.f1, 0.005) + s.f2 = ImGui_DragFloat("drag small float", s.f2, 0.0001, 0.0, 0.0, "%.06f ns") --ImGui.DragFloat("drag wrap -1..1", f3, 0.005, -1.0, 1.0, nil, ImGuiSliderFlags.WrapAround) end - ImGui.SeparatorText("Sliders") + ImGui_SeparatorText("Sliders") do local s = S.DemoWindowWidgetsBasic.sliders IMGUI_DEMO_MARKER("Widgets/Basic/SliderInt, SliderFloat") - s.i1 = ImGui.SliderInt("slider int", s.i1, -1, 3) - ImGui.SameLine(); HelpMarker("Ctrl+Click to input value.") + s.i1 = ImGui_SliderInt("slider int", s.i1, -1, 3) + ImGui_SameLine(); HelpMarker("Ctrl+Click to input value.") - s.f1 = ImGui.SliderFloat("slider float", s.f1, 0.0, 1.0, "ratio = %.3f") - s.f2 = ImGui.SliderFloat("slider float (log)", s.f2, -10.0, 10.0, "%.4f", 32 --[[ImGuiSliderFlags.Logarithmic]]) + s.f1 = ImGui_SliderFloat("slider float", s.f1, 0.0, 1.0, "ratio = %.3f") + s.f2 = ImGui_SliderFloat("slider float (log)", s.f2, -10.0, 10.0, "%.4f", 32 --[[ImGuiSliderFlags.Logarithmic]]) IMGUI_DEMO_MARKER("Widgets/Basic/SliderAngle") - s.angle = ImGui.SliderAngle("slider angle", s.angle) + s.angle = ImGui_SliderAngle("slider angle", s.angle) -- Using the format string to display a name instead of an integer. -- Here we completely omit '%d' from the format string, so it'll only display a name. @@ -23789,23 +23845,23 @@ function DemoWindowWidgetsBasic() local Element_Fire, Element_Earth, Element_Air, Element_Water, Element_COUNT = 0, 1, 2, 3, 4 local elems_names = { "Fire", "Earth", "Air", "Water" } local elem_name = (s.elem >= 0 and s.elem < Element_COUNT) and elems_names[s.elem + 1] or "Unknown" - s.elem = ImGui.SliderInt("slider enum", s.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.") + s.elem = ImGui_SliderInt("slider enum", s.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.") end - ImGui.SeparatorText("Selectors/Pickers") + ImGui_SeparatorText("Selectors/Pickers") do local s = S.DemoWindowWidgetsBasic.pickers IMGUI_DEMO_MARKER("Widgets/Basic/ColorEdit3, ColorEdit4") - ImGui.ColorEdit3("color 1", s.col1) - ImGui.SameLine(); HelpMarker( + ImGui_ColorEdit3("color 1", s.col1) + ImGui_SameLine(); HelpMarker( "Click on the color square to open a color picker.\n" .. "Click and hold to use drag and drop.\n" .. "Right-Click on the color square to show options.\n" .. "Ctrl+Click on individual component to input value.\n") - ImGui.ColorEdit4("color 2", s.col2) + ImGui_ColorEdit4("color 2", s.col2) end do @@ -23814,8 +23870,8 @@ function DemoWindowWidgetsBasic() -- See "Combo" section for examples of how to use the more flexible BeginCombo()/EndCombo() api. IMGUI_DEMO_MARKER("Widgets/Basic/Combo") local items = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIIIIII", "JJJJ", "KKKKKKK" } - s.item_current = ImGui.Combo("combo", s.item_current, items, #items) - ImGui.SameLine(); HelpMarker( + s.item_current = ImGui_Combo("combo", s.item_current, items, #items) + ImGui_SameLine(); HelpMarker( "Using the simplified one-liner Combo API here.\n" .. "Refer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API.") end @@ -23826,8 +23882,8 @@ function DemoWindowWidgetsBasic() -- See "List boxes" section for examples of how to use the more flexible BeginListBox()/EndListBox() api. IMGUI_DEMO_MARKER("Widgets/Basic/ListBox") local items = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" } - s.item_current = ImGui.ListBox("listbox", s.item_current, items, #items, 4) - ImGui.SameLine(); HelpMarker( + s.item_current = ImGui_ListBox("listbox", s.item_current, items, #items, 4) + ImGui_SameLine(); HelpMarker( "Using the simplified one-liner ListBox API here.\n" .. "Refer to the \"List boxes\" section below for an explanation of how to use the more flexible and general BeginListBox/EndListBox API.") end @@ -23838,7 +23894,7 @@ function DemoWindowWidgetsBasic() -- if (once) -- ImGui.Text("This will be displayed only once."); - ImGui.TreePop() + ImGui_TreePop() end end @@ -23849,15 +23905,15 @@ end function DemoWindowWidgetsBullets() if ImGui.TreeNode("Bullets") then IMGUI_DEMO_MARKER("Widgets/Bullets") - ImGui.BulletText("Bullet point 1") - ImGui.BulletText("Bullet point 2\nOn multiple lines") + ImGui_BulletText("Bullet point 1") + ImGui_BulletText("Bullet point 2\nOn multiple lines") if ImGui.TreeNode("Tree node") then - ImGui.BulletText("Another bullet point") - ImGui.TreePop() + ImGui_BulletText("Another bullet point") + ImGui_TreePop() end - ImGui.Bullet(); ImGui.Text("Bullet point 3 (two calls)") - ImGui.Bullet(); ImGui.SmallButton("Button") - ImGui.TreePop() + ImGui_Bullet(); ImGui_Text("Bullet point 3 (two calls)") + ImGui_Bullet(); ImGui_SmallButton("Button") + ImGui_TreePop() end end @@ -23874,19 +23930,19 @@ function DemoWindowWidgetsCollapsingHeaders() if ImGui.TreeNode("Collapsing Headers") then local s = S.DemoWindowWidgetsCollapsingHeaders IMGUI_DEMO_MARKER("Widgets/Collapsing Headers") - _, s.closable_group = ImGui.Checkbox("Show 2nd header", s.closable_group) + _, s.closable_group = ImGui_Checkbox("Show 2nd header", s.closable_group) if ImGui.CollapsingHeader("Header", 0 --[[ImGuiTreeNodeFlags.None]]) then - ImGui.Text("IsItemHovered: %d", ImGui.IsItemHovered() and 1 or 0) + ImGui_Text("IsItemHovered: %d", ImGui_IsItemHovered() and 1 or 0) for i = 0, 4 do - ImGui.Text("Some content %d", i) + ImGui_Text("Some content %d", i) end end local open open, s.closable_group = ImGui.CollapsingHeader("Header with a close button", s.closable_group) if open then - ImGui.Text("IsItemHovered: %d", ImGui.IsItemHovered() and 1 or 0) + ImGui_Text("IsItemHovered: %d", ImGui_IsItemHovered() and 1 or 0) for i = 0, 4 do - ImGui.Text("More content %d", i) + ImGui_Text("More content %d", i) end end --[[ @@ -23894,7 +23950,7 @@ function DemoWindowWidgetsCollapsingHeaders() ImGui.Text("IsItemHovered: %d", ImGui.IsItemHovered()) end ]] - ImGui.TreePop() + ImGui_TreePop() end end @@ -23924,137 +23980,137 @@ function DemoWindowWidgetsColorAndPickers() IMGUI_DEMO_MARKER("Widgets/Color") local color = s.color - ImGui.SeparatorText("Options") - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_NoAlpha", s.base_flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_AlphaOpaque", s.base_flags, 4096 --[[ImGuiColorEditFlags.AlphaOpaque]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_AlphaNoBg", s.base_flags, 8192 --[[ImGuiColorEditFlags.AlphaNoBg]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_AlphaPreviewHalf", s.base_flags, 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_NoOptions", s.base_flags, 8 --[[ImGuiColorEditFlags.NoOptions]]); ImGui.SameLine(); HelpMarker("Right-click on the individual color widget to show options.") - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_NoDragDrop", s.base_flags, 512 --[[ImGuiColorEditFlags.NoDragDrop]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_NoColorMarkers", s.base_flags, 2048 --[[ImGuiColorEditFlags.NoColorMarkers]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_HDR", s.base_flags, 524288 --[[ImGuiColorEditFlags.HDR]]); ImGui.SameLine(); HelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.") + ImGui_SeparatorText("Options") + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_NoAlpha", s.base_flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_AlphaOpaque", s.base_flags, 4096 --[[ImGuiColorEditFlags.AlphaOpaque]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_AlphaNoBg", s.base_flags, 8192 --[[ImGuiColorEditFlags.AlphaNoBg]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_AlphaPreviewHalf", s.base_flags, 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_NoOptions", s.base_flags, 8 --[[ImGuiColorEditFlags.NoOptions]]); ImGui_SameLine(); HelpMarker("Right-click on the individual color widget to show options.") + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_NoDragDrop", s.base_flags, 512 --[[ImGuiColorEditFlags.NoDragDrop]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_NoColorMarkers", s.base_flags, 2048 --[[ImGuiColorEditFlags.NoColorMarkers]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_HDR", s.base_flags, 524288 --[[ImGuiColorEditFlags.HDR]]); ImGui_SameLine(); HelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.") local base_flags = s.base_flags IMGUI_DEMO_MARKER("Widgets/Color/ColorEdit") - ImGui.SeparatorText("Inline color editor") - ImGui.Text("Color widget:") - ImGui.SameLine(); HelpMarker( + ImGui_SeparatorText("Inline color editor") + ImGui_Text("Color widget:") + ImGui_SameLine(); HelpMarker( "Click on the color square to open a color picker.\n" .. "Ctrl+Click on individual component to input value.\n") - ImGui.ColorEdit3("MyColor##1", color, base_flags) + ImGui_ColorEdit3("MyColor##1", color, base_flags) IMGUI_DEMO_MARKER("Widgets/Color/ColorEdit (HSV, with Alpha)") - ImGui.Text("Color widget HSV with Alpha:") - ImGui.ColorEdit4("MyColor##2", color, bit32.bor(2097152 --[[ImGuiColorEditFlags.DisplayHSV]], base_flags)) + ImGui_Text("Color widget HSV with Alpha:") + ImGui_ColorEdit4("MyColor##2", color, bit32.bor(2097152 --[[ImGuiColorEditFlags.DisplayHSV]], base_flags)) IMGUI_DEMO_MARKER("Widgets/Color/ColorEdit (float display)") - ImGui.Text("Color widget with Float Display:") - ImGui.ColorEdit4("MyColor##2f", color, bit32.bor(16777216 --[[ImGuiColorEditFlags.Float]], base_flags)) + ImGui_Text("Color widget with Float Display:") + ImGui_ColorEdit4("MyColor##2f", color, bit32.bor(16777216 --[[ImGuiColorEditFlags.Float]], base_flags)) IMGUI_DEMO_MARKER("Widgets/Color/ColorButton (with Picker)") - ImGui.Text("Color button with Picker:") - ImGui.SameLine(); HelpMarker( + ImGui_Text("Color button with Picker:") + ImGui_SameLine(); HelpMarker( "With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\n" .. "With the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only " .. "be used for the tooltip and picker popup.") - ImGui.ColorEdit4("MyColor##3", color, bit32.bor(32 --[[ImGuiColorEditFlags.NoInputs]], 128 --[[ImGuiColorEditFlags.NoLabel]], base_flags)) + ImGui_ColorEdit4("MyColor##3", color, bit32.bor(32 --[[ImGuiColorEditFlags.NoInputs]], 128 --[[ImGuiColorEditFlags.NoLabel]], base_flags)) IMGUI_DEMO_MARKER("Widgets/Color/ColorButton (with custom Picker popup)") - ImGui.Text("Color button with Custom Picker Popup:") + ImGui_Text("Color button with Custom Picker Popup:") -- Generate a default palette. The palette will persist and can be edited. local saved_palette = s.saved_palette if s.saved_palette_init then for n = 0, 32 - 1 do saved_palette[n + 1] = ImVec4() - saved_palette[n + 1].x, saved_palette[n + 1].y, saved_palette[n + 1].z = ImGui.ColorConvertHSVtoRGB(n / 31.0, 0.8, 0.8) + saved_palette[n + 1].x, saved_palette[n + 1].y, saved_palette[n + 1].z = ImGui_ColorConvertHSVtoRGB(n / 31.0, 0.8, 0.8) saved_palette[n + 1].w = 1.0 -- Alpha end s.saved_palette_init = false end - local open_popup = ImGui.ColorButton("MyColor##3b", color, base_flags) - ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.x) - open_popup = ImGui.Button("Palette") or open_popup + local open_popup = ImGui_ColorButton("MyColor##3b", color, base_flags) + ImGui_SameLine(0, ImGui_GetStyle().ItemInnerSpacing.x) + open_popup = ImGui_Button("Palette") or open_popup if open_popup then - ImGui.OpenPopup("mypicker") + ImGui_OpenPopup("mypicker") ImVec4_Copy(s.backup_color, color) end - if ImGui.BeginPopup("mypicker") then - ImGui.Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!") - ImGui.Separator() - ImGui.ColorPicker4("##picker", color, bit32.bor(base_flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]], 16 --[[ImGuiColorEditFlags.NoSmallPreview]])) - ImGui.SameLine() + if ImGui_BeginPopup("mypicker") then + ImGui_Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!") + ImGui_Separator() + ImGui_ColorPicker4("##picker", color, bit32.bor(base_flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]], 16 --[[ImGuiColorEditFlags.NoSmallPreview]])) + ImGui_SameLine() - ImGui.BeginGroup() -- Lock X position - ImGui.Text("Current") - ImGui.ColorButton("##current", color, bit32.bor(4 --[[ImGuiColorEditFlags.NoPicker]], 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]), ImVec2(60, 40)) - ImGui.Text("Previous") - if ImGui.ColorButton("##previous", s.backup_color, bit32.bor(4 --[[ImGuiColorEditFlags.NoPicker]], 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]), ImVec2(60, 40)) then + ImGui_BeginGroup() -- Lock X position + ImGui_Text("Current") + ImGui_ColorButton("##current", color, bit32.bor(4 --[[ImGuiColorEditFlags.NoPicker]], 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]), ImVec2(60, 40)) + ImGui_Text("Previous") + if ImGui_ColorButton("##previous", s.backup_color, bit32.bor(4 --[[ImGuiColorEditFlags.NoPicker]], 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]), ImVec2(60, 40)) then ImVec4_Copy(color, s.backup_color) end - ImGui.Separator() - ImGui.Text("Palette") + ImGui_Separator() + ImGui_Text("Palette") for n = 0, #saved_palette - 1 do - ImGui.PushID(n) + ImGui_PushID(n) if (n % 8) ~= 0 then - ImGui.SameLine(0.0, ImGui.GetStyle().ItemSpacing.y) + ImGui_SameLine(0.0, ImGui_GetStyle().ItemSpacing.y) end local palette_button_flags = bit32.bor(2 --[[ImGuiColorEditFlags.NoAlpha]], 4 --[[ImGuiColorEditFlags.NoPicker]], 64 --[[ImGuiColorEditFlags.NoTooltip]]) - if ImGui.ColorButton("##palette", saved_palette[n + 1], palette_button_flags, ImVec2(20, 20)) then + if ImGui_ColorButton("##palette", saved_palette[n + 1], palette_button_flags, ImVec2(20, 20)) then color.x, color.y, color.z = saved_palette[n + 1].x, saved_palette[n + 1].y, saved_palette[n + 1].z -- Preserve alpha! end -- Allow user to drop colors into each palette entry. Note that ColorButton() is already a -- drag source by default, unless specifying the ImGuiColorEditFlags_NoDragDrop flag. - if ImGui.BeginDragDropTarget() then - local payload = ImGui.AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F) + if ImGui_BeginDragDropTarget() then + local payload = ImGui_AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F) if payload then local d = payload.Data -- [Port] memcpy -> copy components (Data is a 1-based float array) saved_palette[n + 1].x, saved_palette[n + 1].y, saved_palette[n + 1].z = d[1], d[2], d[3] end - payload = ImGui.AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F) + payload = ImGui_AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F) if payload then local d = payload.Data -- [Port] memcpy -> copy components saved_palette[n + 1].x, saved_palette[n + 1].y, saved_palette[n + 1].z, saved_palette[n + 1].w = d[1], d[2], d[3], d[4] end - ImGui.EndDragDropTarget() + ImGui_EndDragDropTarget() end - ImGui.PopID() + ImGui_PopID() end - ImGui.EndGroup() - ImGui.EndPopup() + ImGui_EndGroup() + ImGui_EndPopup() end IMGUI_DEMO_MARKER("Widgets/Color/ColorButton (simple)") - ImGui.Text("Color button only:") - _, s.no_border = ImGui.Checkbox("ImGuiColorEditFlags_NoBorder", s.no_border) - ImGui.ColorButton("MyColor##3c", color, bit32.bor(base_flags, s.no_border and 1024 --[[ImGuiColorEditFlags.NoBorder]] or 0), ImVec2(80, 80)) + ImGui_Text("Color button only:") + _, s.no_border = ImGui_Checkbox("ImGuiColorEditFlags_NoBorder", s.no_border) + ImGui_ColorButton("MyColor##3c", color, bit32.bor(base_flags, s.no_border and 1024 --[[ImGuiColorEditFlags.NoBorder]] or 0), ImVec2(80, 80)) IMGUI_DEMO_MARKER("Widgets/Color/ColorPicker") - ImGui.SeparatorText("Color picker") + ImGui_SeparatorText("Color picker") - ImGui.PushID("Color picker") - _, s.color_picker_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_NoAlpha", s.color_picker_flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) - _, s.color_picker_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_AlphaBar", s.color_picker_flags, 262144 --[[ImGuiColorEditFlags.AlphaBar]]) - _, s.color_picker_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_NoSidePreview", s.color_picker_flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]]) + ImGui_PushID("Color picker") + _, s.color_picker_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_NoAlpha", s.color_picker_flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) + _, s.color_picker_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_AlphaBar", s.color_picker_flags, 262144 --[[ImGuiColorEditFlags.AlphaBar]]) + _, s.color_picker_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_NoSidePreview", s.color_picker_flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]]) if bit32.band(s.color_picker_flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]]) ~= 0 then - ImGui.SameLine() - _, s.ref_color = ImGui.Checkbox("With Ref Color", s.ref_color) + ImGui_SameLine() + _, s.ref_color = ImGui_Checkbox("With Ref Color", s.ref_color) if s.ref_color then - ImGui.SameLine() - ImGui.ColorEdit4("##RefColor", s.ref_color_v, bit32.bor(32 --[[ImGuiColorEditFlags.NoInputs]], base_flags)) + ImGui_SameLine() + ImGui_ColorEdit4("##RefColor", s.ref_color_v, bit32.bor(32 --[[ImGuiColorEditFlags.NoInputs]], base_flags)) end end - _, s.color_picker_flags = ImGui.CheckboxFlags("ImGuiColorEditFlags_PickerNoRotate", s.color_picker_flags, 134217728 --[[ImGuiColorEditFlags.PickerNoRotate]]) + _, s.color_picker_flags = ImGui_CheckboxFlags("ImGuiColorEditFlags_PickerNoRotate", s.color_picker_flags, 134217728 --[[ImGuiColorEditFlags.PickerNoRotate]]) - s.picker_mode = ImGui.Combo("Picker Mode", s.picker_mode, "Auto/Current\0ImGuiColorEditFlags_PickerHueBar\0ImGuiColorEditFlags_PickerHueWheel\0") - ImGui.SameLine(); HelpMarker("When not specified explicitly, user can right-click the picker to change mode.") + s.picker_mode = ImGui_Combo("Picker Mode", s.picker_mode, "Auto/Current\0ImGuiColorEditFlags_PickerHueBar\0ImGuiColorEditFlags_PickerHueWheel\0") + ImGui_SameLine(); HelpMarker("When not specified explicitly, user can right-click the picker to change mode.") - s.display_mode = ImGui.Combo("Display Mode", s.display_mode, "Auto/Current\0ImGuiColorEditFlags_NoInputs\0ImGuiColorEditFlags_DisplayRGB\0ImGuiColorEditFlags_DisplayHSV\0ImGuiColorEditFlags_DisplayHex\0") - ImGui.SameLine(); HelpMarker( + s.display_mode = ImGui_Combo("Display Mode", s.display_mode, "Auto/Current\0ImGuiColorEditFlags_NoInputs\0ImGuiColorEditFlags_DisplayRGB\0ImGuiColorEditFlags_DisplayHSV\0ImGuiColorEditFlags_DisplayHex\0") + ImGui_SameLine(); HelpMarker( "ColorEdit defaults to displaying RGB inputs if you don't specify a display mode, " .. "but the user can change it with a right-click on those inputs.\n\nColorPicker defaults to displaying RGB+HSV+Hex " .. "if you don't specify a display mode.\n\nYou can change the defaults using io.ConfigColorEditFlags.") @@ -24066,46 +24122,46 @@ function DemoWindowWidgetsColorAndPickers() if s.display_mode == 2 then flags = bit32.bor(flags, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]]) end -- Override display mode if s.display_mode == 3 then flags = bit32.bor(flags, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]]) end if s.display_mode == 4 then flags = bit32.bor(flags, 4194304 --[[ImGuiColorEditFlags.DisplayHex]]) end - ImGui.ColorPicker4("MyColor##4", color, flags, s.ref_color and s.ref_color_v or nil) + ImGui_ColorPicker4("MyColor##4", color, flags, s.ref_color and s.ref_color_v or nil) - ImGui.Text("Set defaults in code:") - ImGui.SameLine(); HelpMarker( + ImGui_Text("Set defaults in code:") + ImGui_SameLine(); HelpMarker( "io.ConfigColorEditFlags is designed to allow you to set boot-time default.\n" .. "We don't have Push/Pop functions because you can force options on a per-widget basis if needed, " .. "and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid " .. "encouraging you to persistently save values that aren't forward-compatible.") - if ImGui.Button("Overwrite default: Uint8 + HSV + Hue Bar") then - ImGui.GetIO().ConfigColorEditFlags = bit32.bor(8388608 --[[ImGuiColorEditFlags.Uint8]], 2097152 --[[ImGuiColorEditFlags.DisplayHSV]], 33554432 --[[ImGuiColorEditFlags.PickerHueBar]], 268435456 --[[ImGuiColorEditFlags.InputRGB]]) -- [Port] + InputRGB: without it ColorEdit4's InputMask_ power-of-two assert trips + if ImGui_Button("Overwrite default: Uint8 + HSV + Hue Bar") then + ImGui_GetIO().ConfigColorEditFlags = bit32.bor(8388608 --[[ImGuiColorEditFlags.Uint8]], 2097152 --[[ImGuiColorEditFlags.DisplayHSV]], 33554432 --[[ImGuiColorEditFlags.PickerHueBar]], 268435456 --[[ImGuiColorEditFlags.InputRGB]]) -- [Port] + InputRGB: without it ColorEdit4's InputMask_ power-of-two assert trips end - if ImGui.Button("Overwrite default: Float + HDR + Hue Wheel") then - ImGui.GetIO().ConfigColorEditFlags = bit32.bor(16777216 --[[ImGuiColorEditFlags.Float]], 524288 --[[ImGuiColorEditFlags.HDR]], 67108864 --[[ImGuiColorEditFlags.PickerHueWheel]], 1048576 --[[ImGuiColorEditFlags.DisplayRGB]], 268435456 --[[ImGuiColorEditFlags.InputRGB]]) -- [Port] + DisplayRGB + InputRGB: same asserts (DisplayMask_/InputMask_) + if ImGui_Button("Overwrite default: Float + HDR + Hue Wheel") then + ImGui_GetIO().ConfigColorEditFlags = bit32.bor(16777216 --[[ImGuiColorEditFlags.Float]], 524288 --[[ImGuiColorEditFlags.HDR]], 67108864 --[[ImGuiColorEditFlags.PickerHueWheel]], 1048576 --[[ImGuiColorEditFlags.DisplayRGB]], 268435456 --[[ImGuiColorEditFlags.InputRGB]]) -- [Port] + DisplayRGB + InputRGB: same asserts (DisplayMask_/InputMask_) end -- Always display a small version of both types of pickers -- (that's in order to make it more visible in the demo to people who are skimming quickly through it) - ImGui.Text("Both types:") - local w = (ImGui.GetContentRegionAvail().x - ImGui.GetStyle().ItemSpacing.y) * 0.40 - ImGui.SetNextItemWidth(w) - ImGui.ColorPicker3("##MyColor##5", color, bit32.bor(33554432 --[[ImGuiColorEditFlags.PickerHueBar]], 256 --[[ImGuiColorEditFlags.NoSidePreview]], 32 --[[ImGuiColorEditFlags.NoInputs]], 2 --[[ImGuiColorEditFlags.NoAlpha]])) - ImGui.SameLine() - ImGui.SetNextItemWidth(w) - ImGui.ColorPicker3("##MyColor##6", color, bit32.bor(67108864 --[[ImGuiColorEditFlags.PickerHueWheel]], 256 --[[ImGuiColorEditFlags.NoSidePreview]], 32 --[[ImGuiColorEditFlags.NoInputs]], 2 --[[ImGuiColorEditFlags.NoAlpha]])) - ImGui.PopID() + ImGui_Text("Both types:") + local w = (ImGui_GetContentRegionAvail().x - ImGui_GetStyle().ItemSpacing.y) * 0.40 + ImGui_SetNextItemWidth(w) + ImGui_ColorPicker3("##MyColor##5", color, bit32.bor(33554432 --[[ImGuiColorEditFlags.PickerHueBar]], 256 --[[ImGuiColorEditFlags.NoSidePreview]], 32 --[[ImGuiColorEditFlags.NoInputs]], 2 --[[ImGuiColorEditFlags.NoAlpha]])) + ImGui_SameLine() + ImGui_SetNextItemWidth(w) + ImGui_ColorPicker3("##MyColor##6", color, bit32.bor(67108864 --[[ImGuiColorEditFlags.PickerHueWheel]], 256 --[[ImGuiColorEditFlags.NoSidePreview]], 32 --[[ImGuiColorEditFlags.NoInputs]], 2 --[[ImGuiColorEditFlags.NoAlpha]])) + ImGui_PopID() -- HSV encoded support (to avoid RGB<>HSV round trips and singularities when S==0 or V==0) local color_hsv = s.color_hsv -- Stored as HSV! - ImGui.Spacing() - ImGui.Text("HSV encoded colors") - ImGui.SameLine(); HelpMarker( + ImGui_Spacing() + ImGui_Text("HSV encoded colors") + ImGui_SameLine(); HelpMarker( "By default, colors are given to ColorEdit and ColorPicker in RGB, but ImGuiColorEditFlags_InputHSV " .. "allows you to store colors as HSV and pass them to ColorEdit and ColorPicker as HSV. This comes with the " .. "added benefit that you can manipulate hue values with the picker even when saturation or value are zero.") - ImGui.Text("Color widget with InputHSV:") - ImGui.ColorEdit4("HSV shown as RGB##1", color_hsv, bit32.bor(1048576 --[[ImGuiColorEditFlags.DisplayRGB]], 536870912 --[[ImGuiColorEditFlags.InputHSV]], 16777216 --[[ImGuiColorEditFlags.Float]])) - ImGui.ColorEdit4("HSV shown as HSV##1", color_hsv, bit32.bor(2097152 --[[ImGuiColorEditFlags.DisplayHSV]], 536870912 --[[ImGuiColorEditFlags.InputHSV]], 16777216 --[[ImGuiColorEditFlags.Float]])) - ImGui.DragFloat4("Raw HSV values", color_hsv, 0.01, 0.0, 1.0) + ImGui_Text("Color widget with InputHSV:") + ImGui_ColorEdit4("HSV shown as RGB##1", color_hsv, bit32.bor(1048576 --[[ImGuiColorEditFlags.DisplayRGB]], 536870912 --[[ImGuiColorEditFlags.InputHSV]], 16777216 --[[ImGuiColorEditFlags.Float]])) + ImGui_ColorEdit4("HSV shown as HSV##1", color_hsv, bit32.bor(2097152 --[[ImGuiColorEditFlags.DisplayHSV]], 536870912 --[[ImGuiColorEditFlags.InputHSV]], 16777216 --[[ImGuiColorEditFlags.Float]])) + ImGui_DragFloat4("Raw HSV values", color_hsv, 0.01, 0.0, 1.0) - ImGui.TreePop() + ImGui_TreePop() end end @@ -24129,31 +24185,31 @@ function DemoWindowWidgetsComboBoxes() IMGUI_DEMO_MARKER("Widgets/Combo") -- Combo Boxes are also called "Dropdown" in other systems -- Expose flags as checkbox for the demo - _, s.flags = ImGui.CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", s.flags, 1 --[[ImGuiComboFlags.PopupAlignLeft]]) - ImGui.SameLine(); HelpMarker("Only makes a difference if the popup is larger than the combo") - pressed, s.flags = ImGui.CheckboxFlags("ImGuiComboFlags_NoArrowButton", s.flags, 32 --[[ImGuiComboFlags.NoArrowButton]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", s.flags, 1 --[[ImGuiComboFlags.PopupAlignLeft]]) + ImGui_SameLine(); HelpMarker("Only makes a difference if the popup is larger than the combo") + pressed, s.flags = ImGui_CheckboxFlags("ImGuiComboFlags_NoArrowButton", s.flags, 32 --[[ImGuiComboFlags.NoArrowButton]]) if pressed then s.flags = bit32.band(s.flags, bit32.bnot(64 --[[ImGuiComboFlags.NoPreview]])) -- Clear incompatible flags end - pressed, s.flags = ImGui.CheckboxFlags("ImGuiComboFlags_NoPreview", s.flags, 64 --[[ImGuiComboFlags.NoPreview]]) + pressed, s.flags = ImGui_CheckboxFlags("ImGuiComboFlags_NoPreview", s.flags, 64 --[[ImGuiComboFlags.NoPreview]]) if pressed then s.flags = bit32.band(s.flags, bit32.bnot(bit32.bor(32 --[[ImGuiComboFlags.NoArrowButton]], 128 --[[ImGuiComboFlags.WidthFitPreview]]))) -- Clear incompatible flags end - pressed, s.flags = ImGui.CheckboxFlags("ImGuiComboFlags_WidthFitPreview", s.flags, 128 --[[ImGuiComboFlags.WidthFitPreview]]) + pressed, s.flags = ImGui_CheckboxFlags("ImGuiComboFlags_WidthFitPreview", s.flags, 128 --[[ImGuiComboFlags.WidthFitPreview]]) if pressed then s.flags = bit32.band(s.flags, bit32.bnot(64 --[[ImGuiComboFlags.NoPreview]])) end -- Override default popup height - pressed, s.flags = ImGui.CheckboxFlags("ImGuiComboFlags_HeightSmall", s.flags, 2 --[[ImGuiComboFlags.HeightSmall]]) + pressed, s.flags = ImGui_CheckboxFlags("ImGuiComboFlags_HeightSmall", s.flags, 2 --[[ImGuiComboFlags.HeightSmall]]) if pressed then s.flags = bit32.band(s.flags, bit32.bnot(bit32.band(30 --[[ImGuiComboFlags.HeightMask_]], bit32.bnot(2 --[[ImGuiComboFlags.HeightSmall]])))) end - pressed, s.flags = ImGui.CheckboxFlags("ImGuiComboFlags_HeightRegular", s.flags, 4 --[[ImGuiComboFlags.HeightRegular]]) + pressed, s.flags = ImGui_CheckboxFlags("ImGuiComboFlags_HeightRegular", s.flags, 4 --[[ImGuiComboFlags.HeightRegular]]) if pressed then s.flags = bit32.band(s.flags, bit32.bnot(bit32.band(30 --[[ImGuiComboFlags.HeightMask_]], bit32.bnot(4 --[[ImGuiComboFlags.HeightRegular]])))) end - pressed, s.flags = ImGui.CheckboxFlags("ImGuiComboFlags_HeightLargest", s.flags, 16 --[[ImGuiComboFlags.HeightLargest]]) + pressed, s.flags = ImGui_CheckboxFlags("ImGuiComboFlags_HeightLargest", s.flags, 16 --[[ImGuiComboFlags.HeightLargest]]) if pressed then s.flags = bit32.band(s.flags, bit32.bnot(bit32.band(30 --[[ImGuiComboFlags.HeightMask_]], bit32.bnot(16 --[[ImGuiComboFlags.HeightLargest]])))) end @@ -24165,61 +24221,61 @@ function DemoWindowWidgetsComboBoxes() -- Pass in the preview value visible before opening the combo (it could technically be different contents or not pulled from items[]) local combo_preview_value = items[s.item_selected_idx + 1] - if ImGui.BeginCombo("combo 1", combo_preview_value, s.flags) then + if ImGui_BeginCombo("combo 1", combo_preview_value, s.flags) then for n = 0, #items - 1 do local is_selected = (s.item_selected_idx == n) - if ImGui.Selectable(items[n + 1], is_selected) then + if ImGui_Selectable(items[n + 1], is_selected) then s.item_selected_idx = n end -- Set the initial focus when opening the combo (scrolling + keyboard navigation focus) if is_selected then - ImGui.SetItemDefaultFocus() + ImGui_SetItemDefaultFocus() end end - ImGui.EndCombo() + ImGui_EndCombo() end -- Show case embedding a filter using a simple trick: displaying the filter inside combo contents. -- See https://github.com/ocornut/imgui/issues/718 for advanced/esoteric alternatives. - if ImGui.BeginCombo("combo 2 (w/ filter)", combo_preview_value, s.flags) then + if ImGui_BeginCombo("combo 2 (w/ filter)", combo_preview_value, s.flags) then if s.filter == nil then s.filter = ImGuiTextFilter() end local filter = s.filter - if ImGui.IsWindowAppearing() then - ImGui.SetKeyboardFocusHere() + if ImGui_IsWindowAppearing() then + ImGui_SetKeyboardFocusHere() filter:Clear() end - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 551 --[[ImGuiKey.F]])) - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 551 --[[ImGuiKey.F]])) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) filter:DrawWithHint("##Filter", "Filter (incl -excl)") for n = 0, #items - 1 do local is_selected = (s.item_selected_idx == n) if filter:PassFilter(items[n + 1]) then - if ImGui.Selectable(items[n + 1], is_selected) then + if ImGui_Selectable(items[n + 1], is_selected) then s.item_selected_idx = n end end end - ImGui.EndCombo() + ImGui_EndCombo() end - ImGui.Spacing() - ImGui.SeparatorText("One-liner variants") + ImGui_Spacing() + ImGui_SeparatorText("One-liner variants") HelpMarker("The Combo() function is not greatly useful apart from cases were you want to embed all options in a single strings.\nFlags above don't apply to this section.") -- Simplified one-liner Combo() API, using values packed in a single constant string -- This is a convenience for when the selection set is small and known at compile-time. - s.item_current_2 = ImGui.Combo("combo 3 (one-liner)", s.item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0") + s.item_current_2 = ImGui_Combo("combo 3 (one-liner)", s.item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0") -- Simplified one-liner Combo() using an array of const char* -- This is not very useful (may obsolete): prefer using BeginCombo()/EndCombo() for full control. - s.item_current_3 = ImGui.Combo("combo 4 (array)", s.item_current_3, items, #items) + s.item_current_3 = ImGui_Combo("combo 4 (array)", s.item_current_3, items, #items) -- Simplified one-liner Combo() using an accessor function - s.item_current_4 = ImGui.Combo("combo 5 (function)", s.item_current_4, function(data, n) return data[n + 1] end, items, #items) + s.item_current_4 = ImGui_Combo("combo 5 (function)", s.item_current_4, function(data, n) return data[n + 1] end, items, #items) - ImGui.TreePop() + ImGui_TreePop() end end @@ -24284,81 +24340,81 @@ function DemoWindowWidgetsDataTypes() local drag_speed = 0.2 IMGUI_DEMO_MARKER("Widgets/Data Types/Drags") - ImGui.SeparatorText("Drags") - _, s.drag_clamp = ImGui.Checkbox("Clamp integers to 0..50", s.drag_clamp) - ImGui.SameLine(); HelpMarker( + ImGui_SeparatorText("Drags") + _, s.drag_clamp = ImGui_Checkbox("Clamp integers to 0..50", s.drag_clamp) + ImGui_SameLine(); HelpMarker( "As with every widget in dear imgui, we never modify values unless there is a user interaction.\n" .. "You can override the clamping limits by using Ctrl+Click to input a value.") local drag_clamp = s.drag_clamp - s.s8_v = ImGui.DragScalar("drag s8", 0 --[[ImGuiDataType.S8]], s.s8_v, drag_speed, drag_clamp and s8_zero or nil, drag_clamp and s8_fifty or nil) - s.u8_v = ImGui.DragScalar("drag u8", 1 --[[ImGuiDataType.U8]], s.u8_v, drag_speed, drag_clamp and u8_zero or nil, drag_clamp and u8_fifty or nil, "%u ms") - s.s16_v = ImGui.DragScalar("drag s16", 2 --[[ImGuiDataType.S16]], s.s16_v, drag_speed, drag_clamp and s16_zero or nil, drag_clamp and s16_fifty or nil) - s.u16_v = ImGui.DragScalar("drag u16", 3 --[[ImGuiDataType.U16]], s.u16_v, drag_speed, drag_clamp and u16_zero or nil, drag_clamp and u16_fifty or nil, "%u ms") - s.s32_v = ImGui.DragScalar("drag s32", 4 --[[ImGuiDataType.S32]], s.s32_v, drag_speed, drag_clamp and s32_zero or nil, drag_clamp and s32_fifty or nil) - s.s32_v = ImGui.DragScalar("drag s32 hex", 4 --[[ImGuiDataType.S32]], s.s32_v, drag_speed, drag_clamp and s32_zero or nil, drag_clamp and s32_fifty or nil, "0x%08X") - s.u32_v = ImGui.DragScalar("drag u32", 5 --[[ImGuiDataType.U32]], s.u32_v, drag_speed, drag_clamp and u32_zero or nil, drag_clamp and u32_fifty or nil, "%u ms") - s.s64_v = ImGui.DragScalar("drag s64", 6 --[[ImGuiDataType.S64]], s.s64_v, drag_speed, drag_clamp and s64_zero or nil, drag_clamp and s64_fifty or nil) - s.u64_v = ImGui.DragScalar("drag u64", 7 --[[ImGuiDataType.U64]], s.u64_v, drag_speed, drag_clamp and u64_zero or nil, drag_clamp and u64_fifty or nil) - s.f32_v = ImGui.DragScalar("drag float", 8 --[[ImGuiDataType.Float]], s.f32_v, 0.005, f32_zero, f32_one, "%f") - s.f32_v = ImGui.DragScalar("drag float log", 8 --[[ImGuiDataType.Float]], s.f32_v, 0.005, f32_zero, f32_one, "%f", 32 --[[ImGuiSliderFlags.Logarithmic]]) - s.f64_v = ImGui.DragScalar("drag double", 9 --[[ImGuiDataType.Double]], s.f64_v, 0.0005, f64_zero, nil, "%.10f grams") - s.f64_v = ImGui.DragScalar("drag double log",9 --[[ImGuiDataType.Double]], s.f64_v, 0.0005, f64_zero, f64_one, "0 < %.10f < 1", 32 --[[ImGuiSliderFlags.Logarithmic]]) + s.s8_v = ImGui_DragScalar("drag s8", 0 --[[ImGuiDataType.S8]], s.s8_v, drag_speed, drag_clamp and s8_zero or nil, drag_clamp and s8_fifty or nil) + s.u8_v = ImGui_DragScalar("drag u8", 1 --[[ImGuiDataType.U8]], s.u8_v, drag_speed, drag_clamp and u8_zero or nil, drag_clamp and u8_fifty or nil, "%u ms") + s.s16_v = ImGui_DragScalar("drag s16", 2 --[[ImGuiDataType.S16]], s.s16_v, drag_speed, drag_clamp and s16_zero or nil, drag_clamp and s16_fifty or nil) + s.u16_v = ImGui_DragScalar("drag u16", 3 --[[ImGuiDataType.U16]], s.u16_v, drag_speed, drag_clamp and u16_zero or nil, drag_clamp and u16_fifty or nil, "%u ms") + s.s32_v = ImGui_DragScalar("drag s32", 4 --[[ImGuiDataType.S32]], s.s32_v, drag_speed, drag_clamp and s32_zero or nil, drag_clamp and s32_fifty or nil) + s.s32_v = ImGui_DragScalar("drag s32 hex", 4 --[[ImGuiDataType.S32]], s.s32_v, drag_speed, drag_clamp and s32_zero or nil, drag_clamp and s32_fifty or nil, "0x%08X") + s.u32_v = ImGui_DragScalar("drag u32", 5 --[[ImGuiDataType.U32]], s.u32_v, drag_speed, drag_clamp and u32_zero or nil, drag_clamp and u32_fifty or nil, "%u ms") + s.s64_v = ImGui_DragScalar("drag s64", 6 --[[ImGuiDataType.S64]], s.s64_v, drag_speed, drag_clamp and s64_zero or nil, drag_clamp and s64_fifty or nil) + s.u64_v = ImGui_DragScalar("drag u64", 7 --[[ImGuiDataType.U64]], s.u64_v, drag_speed, drag_clamp and u64_zero or nil, drag_clamp and u64_fifty or nil) + s.f32_v = ImGui_DragScalar("drag float", 8 --[[ImGuiDataType.Float]], s.f32_v, 0.005, f32_zero, f32_one, "%f") + s.f32_v = ImGui_DragScalar("drag float log", 8 --[[ImGuiDataType.Float]], s.f32_v, 0.005, f32_zero, f32_one, "%f", 32 --[[ImGuiSliderFlags.Logarithmic]]) + s.f64_v = ImGui_DragScalar("drag double", 9 --[[ImGuiDataType.Double]], s.f64_v, 0.0005, f64_zero, nil, "%.10f grams") + s.f64_v = ImGui_DragScalar("drag double log",9 --[[ImGuiDataType.Double]], s.f64_v, 0.0005, f64_zero, f64_one, "0 < %.10f < 1", 32 --[[ImGuiSliderFlags.Logarithmic]]) IMGUI_DEMO_MARKER("Widgets/Data Types/Sliders") - ImGui.SeparatorText("Sliders") - s.s8_v = ImGui.SliderScalar("slider s8 full", 0 --[[ImGuiDataType.S8]], s.s8_v, s8_min, s8_max, "%d") - s.u8_v = ImGui.SliderScalar("slider u8 full", 1 --[[ImGuiDataType.U8]], s.u8_v, u8_min, u8_max, "%u") - s.s16_v = ImGui.SliderScalar("slider s16 full", 2 --[[ImGuiDataType.S16]], s.s16_v, s16_min, s16_max, "%d") - s.u16_v = ImGui.SliderScalar("slider u16 full", 3 --[[ImGuiDataType.U16]], s.u16_v, u16_min, u16_max, "%u") - s.s32_v = ImGui.SliderScalar("slider s32 low", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_zero, s32_fifty,"%d") - s.s32_v = ImGui.SliderScalar("slider s32 high", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_hi_a, s32_hi_b, "%d") - s.s32_v = ImGui.SliderScalar("slider s32 full", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_min, s32_max, "%d") - s.s32_v = ImGui.SliderScalar("slider s32 hex", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_zero, s32_fifty, "0x%04X") - s.u32_v = ImGui.SliderScalar("slider u32 low", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_zero, u32_fifty,"%u") - s.u32_v = ImGui.SliderScalar("slider u32 high", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_hi_a, u32_hi_b, "%u") - s.u32_v = ImGui.SliderScalar("slider u32 full", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_min, u32_max, "%u") - s.s64_v = ImGui.SliderScalar("slider s64 low", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_zero, s64_fifty,"%lld") -- "%" PRId64 - s.s64_v = ImGui.SliderScalar("slider s64 high", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_hi_a, s64_hi_b, "%lld") - s.s64_v = ImGui.SliderScalar("slider s64 full", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_min, s64_max, "%lld") - s.u64_v = ImGui.SliderScalar("slider u64 low", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_zero, u64_fifty,"%llu ms") -- "%" PRIu64 " ms" - s.u64_v = ImGui.SliderScalar("slider u64 high", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_hi_a, u64_hi_b, "%llu ms") - s.u64_v = ImGui.SliderScalar("slider u64 full", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_min, u64_max, "%llu ms") - s.f32_v = ImGui.SliderScalar("slider float low", 8 --[[ImGuiDataType.Float]], s.f32_v, f32_zero, f32_one) - s.f32_v = ImGui.SliderScalar("slider float low log", 8 --[[ImGuiDataType.Float]], s.f32_v, f32_zero, f32_one, "%.10f", 32 --[[ImGuiSliderFlags.Logarithmic]]) - s.f32_v = ImGui.SliderScalar("slider float high", 8 --[[ImGuiDataType.Float]], s.f32_v, f32_lo_a, f32_hi_a, "%e") - s.f64_v = ImGui.SliderScalar("slider double low", 9 --[[ImGuiDataType.Double]], s.f64_v, f64_zero, f64_one, "%.10f grams") - s.f64_v = ImGui.SliderScalar("slider double low log",9 --[[ImGuiDataType.Double]], s.f64_v, f64_zero, f64_one, "%.10f", 32 --[[ImGuiSliderFlags.Logarithmic]]) - s.f64_v = ImGui.SliderScalar("slider double high", 9 --[[ImGuiDataType.Double]], s.f64_v, f64_lo_a, f64_hi_a, "%e grams") + ImGui_SeparatorText("Sliders") + s.s8_v = ImGui_SliderScalar("slider s8 full", 0 --[[ImGuiDataType.S8]], s.s8_v, s8_min, s8_max, "%d") + s.u8_v = ImGui_SliderScalar("slider u8 full", 1 --[[ImGuiDataType.U8]], s.u8_v, u8_min, u8_max, "%u") + s.s16_v = ImGui_SliderScalar("slider s16 full", 2 --[[ImGuiDataType.S16]], s.s16_v, s16_min, s16_max, "%d") + s.u16_v = ImGui_SliderScalar("slider u16 full", 3 --[[ImGuiDataType.U16]], s.u16_v, u16_min, u16_max, "%u") + s.s32_v = ImGui_SliderScalar("slider s32 low", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_zero, s32_fifty,"%d") + s.s32_v = ImGui_SliderScalar("slider s32 high", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_hi_a, s32_hi_b, "%d") + s.s32_v = ImGui_SliderScalar("slider s32 full", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_min, s32_max, "%d") + s.s32_v = ImGui_SliderScalar("slider s32 hex", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_zero, s32_fifty, "0x%04X") + s.u32_v = ImGui_SliderScalar("slider u32 low", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_zero, u32_fifty,"%u") + s.u32_v = ImGui_SliderScalar("slider u32 high", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_hi_a, u32_hi_b, "%u") + s.u32_v = ImGui_SliderScalar("slider u32 full", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_min, u32_max, "%u") + s.s64_v = ImGui_SliderScalar("slider s64 low", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_zero, s64_fifty,"%lld") -- "%" PRId64 + s.s64_v = ImGui_SliderScalar("slider s64 high", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_hi_a, s64_hi_b, "%lld") + s.s64_v = ImGui_SliderScalar("slider s64 full", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_min, s64_max, "%lld") + s.u64_v = ImGui_SliderScalar("slider u64 low", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_zero, u64_fifty,"%llu ms") -- "%" PRIu64 " ms" + s.u64_v = ImGui_SliderScalar("slider u64 high", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_hi_a, u64_hi_b, "%llu ms") + s.u64_v = ImGui_SliderScalar("slider u64 full", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_min, u64_max, "%llu ms") + s.f32_v = ImGui_SliderScalar("slider float low", 8 --[[ImGuiDataType.Float]], s.f32_v, f32_zero, f32_one) + s.f32_v = ImGui_SliderScalar("slider float low log", 8 --[[ImGuiDataType.Float]], s.f32_v, f32_zero, f32_one, "%.10f", 32 --[[ImGuiSliderFlags.Logarithmic]]) + s.f32_v = ImGui_SliderScalar("slider float high", 8 --[[ImGuiDataType.Float]], s.f32_v, f32_lo_a, f32_hi_a, "%e") + s.f64_v = ImGui_SliderScalar("slider double low", 9 --[[ImGuiDataType.Double]], s.f64_v, f64_zero, f64_one, "%.10f grams") + s.f64_v = ImGui_SliderScalar("slider double low log",9 --[[ImGuiDataType.Double]], s.f64_v, f64_zero, f64_one, "%.10f", 32 --[[ImGuiSliderFlags.Logarithmic]]) + s.f64_v = ImGui_SliderScalar("slider double high", 9 --[[ImGuiDataType.Double]], s.f64_v, f64_lo_a, f64_hi_a, "%e grams") - ImGui.SeparatorText("Sliders (reverse)") - s.s8_v = ImGui.SliderScalar("slider s8 reverse", 0 --[[ImGuiDataType.S8]], s.s8_v, s8_max, s8_min, "%d") - s.u8_v = ImGui.SliderScalar("slider u8 reverse", 1 --[[ImGuiDataType.U8]], s.u8_v, u8_max, u8_min, "%u") - s.s32_v = ImGui.SliderScalar("slider s32 reverse", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_fifty, s32_zero, "%d") - s.u32_v = ImGui.SliderScalar("slider u32 reverse", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_fifty, u32_zero, "%u") - s.s64_v = ImGui.SliderScalar("slider s64 reverse", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_fifty, s64_zero, "%lld") - s.u64_v = ImGui.SliderScalar("slider u64 reverse", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_fifty, u64_zero, "%llu ms") + ImGui_SeparatorText("Sliders (reverse)") + s.s8_v = ImGui_SliderScalar("slider s8 reverse", 0 --[[ImGuiDataType.S8]], s.s8_v, s8_max, s8_min, "%d") + s.u8_v = ImGui_SliderScalar("slider u8 reverse", 1 --[[ImGuiDataType.U8]], s.u8_v, u8_max, u8_min, "%u") + s.s32_v = ImGui_SliderScalar("slider s32 reverse", 4 --[[ImGuiDataType.S32]], s.s32_v, s32_fifty, s32_zero, "%d") + s.u32_v = ImGui_SliderScalar("slider u32 reverse", 5 --[[ImGuiDataType.U32]], s.u32_v, u32_fifty, u32_zero, "%u") + s.s64_v = ImGui_SliderScalar("slider s64 reverse", 6 --[[ImGuiDataType.S64]], s.s64_v, s64_fifty, s64_zero, "%lld") + s.u64_v = ImGui_SliderScalar("slider u64 reverse", 7 --[[ImGuiDataType.U64]], s.u64_v, u64_fifty, u64_zero, "%llu ms") IMGUI_DEMO_MARKER("Widgets/Data Types/Inputs") - ImGui.SeparatorText("Inputs") - _, s.inputs_step = ImGui.Checkbox("Show step buttons", s.inputs_step) - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_ReadOnly", s.flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_ParseEmptyRefVal", s.flags, 8192 --[[ImGuiInputTextFlags.ParseEmptyRefVal]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_DisplayEmptyRefVal", s.flags, 16384 --[[ImGuiInputTextFlags.DisplayEmptyRefVal]]) + ImGui_SeparatorText("Inputs") + _, s.inputs_step = ImGui_Checkbox("Show step buttons", s.inputs_step) + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_ReadOnly", s.flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_ParseEmptyRefVal", s.flags, 8192 --[[ImGuiInputTextFlags.ParseEmptyRefVal]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_DisplayEmptyRefVal", s.flags, 16384 --[[ImGuiInputTextFlags.DisplayEmptyRefVal]]) local inputs_step, flags = s.inputs_step, s.flags - s.s8_v = ImGui.InputScalar("input s8", 0 --[[ImGuiDataType.S8]], s.s8_v, inputs_step and s8_one or nil, nil, "%d", flags) - s.u8_v = ImGui.InputScalar("input u8", 1 --[[ImGuiDataType.U8]], s.u8_v, inputs_step and u8_one or nil, nil, "%u", flags) - s.s16_v = ImGui.InputScalar("input s16", 2 --[[ImGuiDataType.S16]], s.s16_v, inputs_step and s16_one or nil, nil, "%d", flags) - s.u16_v = ImGui.InputScalar("input u16", 3 --[[ImGuiDataType.U16]], s.u16_v, inputs_step and u16_one or nil, nil, "%u", flags) - s.s32_v = ImGui.InputScalar("input s32", 4 --[[ImGuiDataType.S32]], s.s32_v, inputs_step and s32_one or nil, nil, "%d", flags) - s.s32_v = ImGui.InputScalar("input s32 hex", 4 --[[ImGuiDataType.S32]], s.s32_v, inputs_step and s32_one or nil, nil, "%04X", flags) - s.u32_v = ImGui.InputScalar("input u32", 5 --[[ImGuiDataType.U32]], s.u32_v, inputs_step and u32_one or nil, nil, "%u", flags) - s.u32_v = ImGui.InputScalar("input u32 hex", 5 --[[ImGuiDataType.U32]], s.u32_v, inputs_step and u32_one or nil, nil, "%08X", flags) - s.s64_v = ImGui.InputScalar("input s64", 6 --[[ImGuiDataType.S64]], s.s64_v, inputs_step and s64_one or nil, nil, nil, flags) - s.u64_v = ImGui.InputScalar("input u64", 7 --[[ImGuiDataType.U64]], s.u64_v, inputs_step and u64_one or nil, nil, nil, flags) - s.f32_v = ImGui.InputScalar("input float", 8 --[[ImGuiDataType.Float]], s.f32_v, inputs_step and f32_one or nil, nil, nil, flags) - s.f64_v = ImGui.InputScalar("input double", 9 --[[ImGuiDataType.Double]], s.f64_v, inputs_step and f64_one or nil, nil, nil, flags) + s.s8_v = ImGui_InputScalar("input s8", 0 --[[ImGuiDataType.S8]], s.s8_v, inputs_step and s8_one or nil, nil, "%d", flags) + s.u8_v = ImGui_InputScalar("input u8", 1 --[[ImGuiDataType.U8]], s.u8_v, inputs_step and u8_one or nil, nil, "%u", flags) + s.s16_v = ImGui_InputScalar("input s16", 2 --[[ImGuiDataType.S16]], s.s16_v, inputs_step and s16_one or nil, nil, "%d", flags) + s.u16_v = ImGui_InputScalar("input u16", 3 --[[ImGuiDataType.U16]], s.u16_v, inputs_step and u16_one or nil, nil, "%u", flags) + s.s32_v = ImGui_InputScalar("input s32", 4 --[[ImGuiDataType.S32]], s.s32_v, inputs_step and s32_one or nil, nil, "%d", flags) + s.s32_v = ImGui_InputScalar("input s32 hex", 4 --[[ImGuiDataType.S32]], s.s32_v, inputs_step and s32_one or nil, nil, "%04X", flags) + s.u32_v = ImGui_InputScalar("input u32", 5 --[[ImGuiDataType.U32]], s.u32_v, inputs_step and u32_one or nil, nil, "%u", flags) + s.u32_v = ImGui_InputScalar("input u32 hex", 5 --[[ImGuiDataType.U32]], s.u32_v, inputs_step and u32_one or nil, nil, "%08X", flags) + s.s64_v = ImGui_InputScalar("input s64", 6 --[[ImGuiDataType.S64]], s.s64_v, inputs_step and s64_one or nil, nil, nil, flags) + s.u64_v = ImGui_InputScalar("input u64", 7 --[[ImGuiDataType.U64]], s.u64_v, inputs_step and u64_one or nil, nil, nil, flags) + s.f32_v = ImGui_InputScalar("input float", 8 --[[ImGuiDataType.Float]], s.f32_v, inputs_step and f32_one or nil, nil, nil, flags) + s.f64_v = ImGui_InputScalar("input double", 9 --[[ImGuiDataType.Double]], s.f64_v, inputs_step and f64_one or nil, nil, nil, flags) - ImGui.TreePop() + ImGui_TreePop() end end @@ -24370,9 +24426,9 @@ function DemoWindowWidgetsDisableBlocks(demo_data) local _ if ImGui.TreeNode("Disable Blocks") then IMGUI_DEMO_MARKER("Widgets/Disable Blocks") - _, demo_data.DisableSections = ImGui.Checkbox("Disable entire section above", demo_data.DisableSections) - ImGui.SameLine(); HelpMarker("Demonstrate using BeginDisabled()/EndDisabled() across other sections.") - ImGui.TreePop() + _, demo_data.DisableSections = ImGui_Checkbox("Disable entire section above", demo_data.DisableSections) + ImGui_SameLine(); HelpMarker("Demonstrate using BeginDisabled()/EndDisabled() across other sections.") + ImGui_TreePop() end end @@ -24404,39 +24460,39 @@ function DemoWindowWidgetsDragAndDrop() -- to allow your own widgets to use colors in their drag and drop interaction. -- Also see 'Demo->Widgets->Color/Picker Widgets->Palette' demo. HelpMarker("You can drag from the color squares.") - ImGui.ColorEdit3("color 1", s.col1) - ImGui.ColorEdit4("color 2", s.col2) - ImGui.TreePop() + ImGui_ColorEdit3("color 1", s.col1) + ImGui_ColorEdit4("color 2", s.col2) + ImGui_TreePop() end if ImGui.TreeNode("Drag and drop to copy/swap items") then IMGUI_DEMO_MARKER("Widgets/Drag and drop/Copy-swap items") local Mode_Copy, Mode_Move, Mode_Swap = 0, 1, 2 - if ImGui.RadioButtonEx("Copy", s.mode == Mode_Copy) then s.mode = Mode_Copy end ImGui.SameLine() - if ImGui.RadioButtonEx("Move", s.mode == Mode_Move) then s.mode = Mode_Move end ImGui.SameLine() - if ImGui.RadioButtonEx("Swap", s.mode == Mode_Swap) then s.mode = Mode_Swap end + if ImGui_RadioButtonEx("Copy", s.mode == Mode_Copy) then s.mode = Mode_Copy end ImGui_SameLine() + if ImGui_RadioButtonEx("Move", s.mode == Mode_Move) then s.mode = Mode_Move end ImGui_SameLine() + if ImGui_RadioButtonEx("Swap", s.mode == Mode_Swap) then s.mode = Mode_Swap end local names = s.names for n = 0, #names - 1 do - ImGui.PushID(n) + ImGui_PushID(n) if (n % 3) ~= 0 then - ImGui.SameLine() + ImGui_SameLine() end - ImGui.Button(names[n + 1], ImVec2(60, 60)) + ImGui_Button(names[n + 1], ImVec2(60, 60)) -- Our buttons are both drag sources and drag targets here! - if ImGui.BeginDragDropSource(0 --[[ImGuiDragDropFlags.None]]) then + if ImGui_BeginDragDropSource(0 --[[ImGuiDragDropFlags.None]]) then -- Set payload to carry the index of our item (could be anything) - ImGui.SetDragDropPayload("DND_DEMO_CELL", n, 4) -- [Port] sizeof(int) -> 4, payload carries the Lua value + ImGui_SetDragDropPayload("DND_DEMO_CELL", n, 4) -- [Port] sizeof(int) -> 4, payload carries the Lua value -- Display preview (could be anything, e.g. when dragging an image we could decide to display -- the filename and a small preview of the image, etc.) - if s.mode == Mode_Copy then ImGui.Text("Copy %s", names[n + 1]) end - if s.mode == Mode_Move then ImGui.Text("Move %s", names[n + 1]) end - if s.mode == Mode_Swap then ImGui.Text("Swap %s", names[n + 1]) end - ImGui.EndDragDropSource() + if s.mode == Mode_Copy then ImGui_Text("Copy %s", names[n + 1]) end + if s.mode == Mode_Move then ImGui_Text("Move %s", names[n + 1]) end + if s.mode == Mode_Swap then ImGui_Text("Swap %s", names[n + 1]) end + ImGui_EndDragDropSource() end - if ImGui.BeginDragDropTarget() then - local payload = ImGui.AcceptDragDropPayload("DND_DEMO_CELL") + if ImGui_BeginDragDropTarget() then + local payload = ImGui_AcceptDragDropPayload("DND_DEMO_CELL") if payload then assert(payload.DataSize == 4) local payload_n = payload.Data @@ -24453,11 +24509,11 @@ function DemoWindowWidgetsDragAndDrop() names[payload_n + 1] = tmp end end - ImGui.EndDragDropTarget() + ImGui_EndDragDropTarget() end - ImGui.PopID() + ImGui_PopID() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Drag to reorder items (simple)") then @@ -24465,7 +24521,7 @@ function DemoWindowWidgetsDragAndDrop() -- FIXME: there is temporary (usually single-frame) ID Conflict during reordering as a same item may be submitting twice. -- This code was always slightly faulty but in a way which was not easily noticeable. -- Until we fix this, enable ImGuiItemFlags_AllowDuplicateId to disable detecting the issue. - ImGui.PushItemFlag(32 --[[ImGuiItemFlags.AllowDuplicateId]], true) + ImGui_PushItemFlag(32 --[[ImGuiItemFlags.AllowDuplicateId]], true) -- Simple reordering HelpMarker( @@ -24474,47 +24530,47 @@ function DemoWindowWidgetsDragAndDrop() local item_names = s.item_names for n = 0, #item_names - 1 do local item = item_names[n + 1] - ImGui.Selectable(item) + ImGui_Selectable(item) - if ImGui.IsItemActive() and not ImGui.IsItemHovered() then - local n_next = n + ((ImGui.GetMouseDragDelta(0).y < 0.0) and -1 or 1) + if ImGui_IsItemActive() and not ImGui_IsItemHovered() then + local n_next = n + ((ImGui_GetMouseDragDelta(0).y < 0.0) and -1 or 1) if n_next >= 0 and n_next < #item_names then item_names[n + 1] = item_names[n_next + 1] item_names[n_next + 1] = item - ImGui.ResetMouseDragDelta() + ImGui_ResetMouseDragDelta() end end end - ImGui.PopItemFlag() - ImGui.TreePop() + ImGui_PopItemFlag() + ImGui_TreePop() end if ImGui.TreeNode("Tooltip at target location") then IMGUI_DEMO_MARKER("Widgets/Drag and Drop/Tooltip at target location") for n = 0, 1 do -- Drop targets - ImGui.Button((n ~= 0) and "drop here##1" or "drop here##0") - if ImGui.BeginDragDropTarget() then + ImGui_Button((n ~= 0) and "drop here##1" or "drop here##0") + if ImGui_BeginDragDropTarget() then local drop_target_flags = bit32.bor(1024 --[[ImGuiDragDropFlags.AcceptBeforeDelivery]], 4096 --[[ImGuiDragDropFlags.AcceptNoPreviewTooltip]]) - local payload = ImGui.AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, drop_target_flags) + local payload = ImGui_AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, drop_target_flags) if payload then - ImGui.SetMouseCursor(10 --[[ImGuiMouseCursor.NotAllowed]]) - ImGui.SetTooltip("Cannot drop here!") + ImGui_SetMouseCursor(10 --[[ImGuiMouseCursor.NotAllowed]]) + ImGui_SetTooltip("Cannot drop here!") end - ImGui.EndDragDropTarget() + ImGui_EndDragDropTarget() end -- Drop source if n == 0 then - ImGui.ColorButton("drag me", s.col4) + ImGui_ColorButton("drag me", s.col4) end end - ImGui.TreePop() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -24540,43 +24596,43 @@ function DemoWindowWidgetsDragsAndSliders() local s = S.DemoWindowWidgetsDragsAndSliders IMGUI_DEMO_MARKER("Widgets/Drag and Slider Flags") -- Demonstrate using advanced flags for DragXXX and SliderXXX functions. Note that the flags are the same! - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_AlwaysClamp", s.flags, 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_ClampOnInput", s.flags, 512 --[[ImGuiSliderFlags.ClampOnInput]]) - ImGui.SameLine(); HelpMarker("Clamp value to min/max bounds when input manually with Ctrl+Click. By default Ctrl+Click allows going out of bounds.") - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_ClampZeroRange", s.flags, 1024 --[[ImGuiSliderFlags.ClampZeroRange]]) - ImGui.SameLine(); HelpMarker("Clamp even if min==max==0.0f. Otherwise DragXXX functions don't clamp.") - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_Logarithmic", s.flags, 32 --[[ImGuiSliderFlags.Logarithmic]]) - ImGui.SameLine(); HelpMarker("Enable logarithmic editing (more precision for small values).") - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_NoRoundToFormat", s.flags, 64 --[[ImGuiSliderFlags.NoRoundToFormat]]) - ImGui.SameLine(); HelpMarker("Disable rounding underlying value to match precision of the format string (e.g. %.3f values are rounded to those 3 digits).") - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_NoInput", s.flags, 128 --[[ImGuiSliderFlags.NoInput]]) - ImGui.SameLine(); HelpMarker("Disable Ctrl+Click or Enter key allowing to input text directly into the widget.") - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_NoSpeedTweaks", s.flags, 2048 --[[ImGuiSliderFlags.NoSpeedTweaks]]) - ImGui.SameLine(); HelpMarker("Disable keyboard modifiers altering tweak speed. Useful if you want to alter tweak speed yourself based on your own logic.") - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_WrapAround", s.flags, 256 --[[ImGuiSliderFlags.WrapAround]]) - ImGui.SameLine(); HelpMarker("Enable wrapping around from max to min and from min to max (only supported by DragXXX() functions)") - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_ColorMarkers", s.flags, 4096 --[[ImGuiSliderFlags.ColorMarkers]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_AlwaysClamp", s.flags, 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_ClampOnInput", s.flags, 512 --[[ImGuiSliderFlags.ClampOnInput]]) + ImGui_SameLine(); HelpMarker("Clamp value to min/max bounds when input manually with Ctrl+Click. By default Ctrl+Click allows going out of bounds.") + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_ClampZeroRange", s.flags, 1024 --[[ImGuiSliderFlags.ClampZeroRange]]) + ImGui_SameLine(); HelpMarker("Clamp even if min==max==0.0f. Otherwise DragXXX functions don't clamp.") + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_Logarithmic", s.flags, 32 --[[ImGuiSliderFlags.Logarithmic]]) + ImGui_SameLine(); HelpMarker("Enable logarithmic editing (more precision for small values).") + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_NoRoundToFormat", s.flags, 64 --[[ImGuiSliderFlags.NoRoundToFormat]]) + ImGui_SameLine(); HelpMarker("Disable rounding underlying value to match precision of the format string (e.g. %.3f values are rounded to those 3 digits).") + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_NoInput", s.flags, 128 --[[ImGuiSliderFlags.NoInput]]) + ImGui_SameLine(); HelpMarker("Disable Ctrl+Click or Enter key allowing to input text directly into the widget.") + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_NoSpeedTweaks", s.flags, 2048 --[[ImGuiSliderFlags.NoSpeedTweaks]]) + ImGui_SameLine(); HelpMarker("Disable keyboard modifiers altering tweak speed. Useful if you want to alter tweak speed yourself based on your own logic.") + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_WrapAround", s.flags, 256 --[[ImGuiSliderFlags.WrapAround]]) + ImGui_SameLine(); HelpMarker("Enable wrapping around from max to min and from min to max (only supported by DragXXX() functions)") + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_ColorMarkers", s.flags, 4096 --[[ImGuiSliderFlags.ColorMarkers]]) local flags = s.flags -- Drags - ImGui.Text("Underlying float value: %f", s.drag_f) - s.drag_f = ImGui.DragFloat("DragFloat (0 -> 1)", s.drag_f, 0.005, 0.0, 1.0, "%.3f", flags) - s.drag_f = ImGui.DragFloat("DragFloat (0 -> +inf)", s.drag_f, 0.005, 0.0, 3.4028234663853e+38 --[[FLT_MAX]], "%.3f", flags) - s.drag_f = ImGui.DragFloat("DragFloat (-inf -> 1)", s.drag_f, 0.005, -3.4028234663853e+38 --[[FLT_MAX]], 1.0, "%.3f", flags) - s.drag_f = ImGui.DragFloat("DragFloat (-inf -> +inf)", s.drag_f, 0.005, -3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]], "%.3f", flags) + ImGui_Text("Underlying float value: %f", s.drag_f) + s.drag_f = ImGui_DragFloat("DragFloat (0 -> 1)", s.drag_f, 0.005, 0.0, 1.0, "%.3f", flags) + s.drag_f = ImGui_DragFloat("DragFloat (0 -> +inf)", s.drag_f, 0.005, 0.0, 3.4028234663853e+38 --[[FLT_MAX]], "%.3f", flags) + s.drag_f = ImGui_DragFloat("DragFloat (-inf -> 1)", s.drag_f, 0.005, -3.4028234663853e+38 --[[FLT_MAX]], 1.0, "%.3f", flags) + s.drag_f = ImGui_DragFloat("DragFloat (-inf -> +inf)", s.drag_f, 0.005, -3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]], "%.3f", flags) --ImGui.DragFloat("DragFloat (0 -> 0)", drag_f, 0.005, 0.0, 0.0, "%.3f", flags) -- To test ClampZeroRange --ImGui.DragFloat("DragFloat (100 -> 100)", drag_f, 0.005, 100.0, 100.0, "%.3f", flags) - s.drag_i = ImGui.DragInt("DragInt (0 -> 100)", s.drag_i, 0.5, 0, 100, "%d", flags) - ImGui.DragFloat4("DragFloat4 (0 -> 1)", s.drag_f4, 0.005, 0.0, 1.0, "%.3f", flags) -- Multi-component item, mostly here to document the effect of ImGuiSliderFlags_ColorMarkers. + s.drag_i = ImGui_DragInt("DragInt (0 -> 100)", s.drag_i, 0.5, 0, 100, "%d", flags) + ImGui_DragFloat4("DragFloat4 (0 -> 1)", s.drag_f4, 0.005, 0.0, 1.0, "%.3f", flags) -- Multi-component item, mostly here to document the effect of ImGuiSliderFlags_ColorMarkers. -- Sliders local flags_for_sliders = bit32.band(flags, bit32.bnot(256 --[[ImGuiSliderFlags.WrapAround]])) - ImGui.Text("Underlying float value: %f", s.slider_f) - s.slider_f = ImGui.SliderFloat("SliderFloat (0 -> 1)", s.slider_f, 0.0, 1.0, "%.3f", flags_for_sliders) - s.slider_i = ImGui.SliderInt("SliderInt (0 -> 100)", s.slider_i, 0, 100, "%d", flags_for_sliders) - ImGui.SliderFloat4("SliderFloat4 (0 -> 1)", s.slider_f4, 0.0, 1.0, "%.3f", flags_for_sliders) -- Multi-component item, mostly here to document the effect of ImGuiSliderFlags_ColorMarkers. -- [Port] flags_for_sliders: upstream passes `flags`, which trips SliderScalar's WrapAround assert + ImGui_Text("Underlying float value: %f", s.slider_f) + s.slider_f = ImGui_SliderFloat("SliderFloat (0 -> 1)", s.slider_f, 0.0, 1.0, "%.3f", flags_for_sliders) + s.slider_i = ImGui_SliderInt("SliderInt (0 -> 100)", s.slider_i, 0, 100, "%d", flags_for_sliders) + ImGui_SliderFloat4("SliderFloat4 (0 -> 1)", s.slider_f4, 0.0, 1.0, "%.3f", flags_for_sliders) -- Multi-component item, mostly here to document the effect of ImGuiSliderFlags_ColorMarkers. -- [Port] flags_for_sliders: upstream passes `flags`, which trips SliderScalar's WrapAround assert - ImGui.TreePop() + ImGui_TreePop() end end @@ -24587,10 +24643,10 @@ end function DemoWindowWidgetsFonts() if ImGui.TreeNode("Fonts") then IMGUI_DEMO_MARKER("Widgets/Fonts") - local atlas = ImGui.GetIO().Fonts - ImGui.ShowFontAtlas(atlas) + local atlas = ImGui_GetIO().Fonts + ImGui_ShowFontAtlas(atlas) -- FIXME-NEWATLAS: Provide a demo to add/create a procedural font? - ImGui.TreePop() + ImGui_TreePop() end end @@ -24606,8 +24662,8 @@ function DemoWindowWidgetsImages() local s = S.DemoWindowWidgetsImages if ImGui.TreeNode("Images") then IMGUI_DEMO_MARKER("Widgets/Images") - local io = ImGui.GetIO() - ImGui.TextWrapped( + local io = ImGui_GetIO() + ImGui_TextWrapped( "Below we are displaying the font texture (which is the only texture we have access to in this demo). " .. "Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. " .. "Hover the texture for a zoomed view!") @@ -24632,50 +24688,50 @@ function DemoWindowWidgetsImages() local my_tex_id = atlas.TexRef local my_tex_w = atlas.TexData.Width -- Regular user code should never have to care about TexData-> fields, but since we want to display the entire texture here, we pull Width/Height from it. local my_tex_h = atlas.TexData.Height - ImGui.Text("%.0fx%.0f", my_tex_w, my_tex_h) + ImGui_Text("%.0fx%.0f", my_tex_w, my_tex_h) -- Basic drawing - ImGui.SeparatorText("Image()/ImageWithBg() function") + ImGui_SeparatorText("Image()/ImageWithBg() function") local uv_min = ImVec2(0.0, 0.0) -- Top-left local uv_max = ImVec2(1.0, 1.0) -- Lower-right - ImGui.PushStyleVar(24 --[[ImGuiStyleVar.ImageBorderSize]], ImMax(1.0, ImGui.GetStyle().ImageBorderSize)) - ImGui.ImageWithBg(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, ImVec4(0.0, 0.0, 0.0, 1.0)) - ImGui.PopStyleVar() + ImGui_PushStyleVar(24 --[[ImGuiStyleVar.ImageBorderSize]], ImMax(1.0, ImGui_GetStyle().ImageBorderSize)) + ImGui_ImageWithBg(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, ImVec4(0.0, 0.0, 0.0, 1.0)) + ImGui_PopStyleVar() -- Fancy widget - ImGui.SeparatorText("Interactive Image Viewer") - local canvas_size = ImVec2(ImGui.GetContentRegionAvail().x, my_tex_h * 2.0) + ImGui_SeparatorText("Interactive Image Viewer") + local canvas_size = ImVec2(ImGui_GetContentRegionAvail().x, my_tex_h * 2.0) ExampleImageViewer_DrawOptions(s.image_viewer) ExampleImageViewer_DrawCanvas(s.image_viewer, canvas_size, my_tex_id, math.floor(my_tex_w), math.floor(my_tex_h)) IMGUI_DEMO_MARKER("Widgets/Images/Textured buttons") - ImGui.SeparatorText("Textured Buttons") - ImGui.TextWrapped("And now some textured buttons..") + ImGui_SeparatorText("Textured Buttons") + ImGui_TextWrapped("And now some textured buttons..") for i = 0, 7 do -- UV coordinates are often (0.0, 0.0) and (1.0, 1.0) to display an entire textures. -- Here are trying to display only a 32x32 pixels area of the texture, hence the UV computation. -- Read about UV coordinates here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples - ImGui.PushID(i) + ImGui_PushID(i) if i > 0 then - ImGui.PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(i - 1.0, i - 1.0)) + ImGui_PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(i - 1.0, i - 1.0)) end local size = ImVec2(32.0, 32.0) -- Size of the image we want to make visible local uv0 = ImVec2(0.0, 0.0) -- UV coordinates for lower-left local uv1 = ImVec2(32.0 / my_tex_w, 32.0 / my_tex_h) -- UV coordinates for (32,32) in our texture local bg_col = ImVec4(0.0, 0.0, 0.0, 1.0) -- Black background local tint_col = ImVec4(1.0, 1.0, 1.0, 1.0) -- No tint - if ImGui.ImageButton("", my_tex_id, size, uv0, uv1, bg_col, tint_col) then + if ImGui_ImageButton("", my_tex_id, size, uv0, uv1, bg_col, tint_col) then s.pressed_count = s.pressed_count + 1 end if i > 0 then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end - ImGui.PopID() - ImGui.SameLine() + ImGui_PopID() + ImGui_SameLine() end - ImGui.NewLine() - ImGui.Text("Pressed %d times.", s.pressed_count) - ImGui.TreePop() + ImGui_NewLine() + ImGui_Text("Pressed %d times.", s.pressed_count) + ImGui_TreePop() end end @@ -24703,48 +24759,48 @@ function DemoWindowWidgetsListBoxes() -- static int item_selected_idx = 0; // Here we store our selected data as an index. local item_highlighted_idx = -1 -- Here we store our highlighted data as an index. - _, s.item_highlight = ImGui.Checkbox("Highlight hovered item in second listbox", s.item_highlight) + _, s.item_highlight = ImGui_Checkbox("Highlight hovered item in second listbox", s.item_highlight) - if ImGui.BeginListBox("listbox 1") then + if ImGui_BeginListBox("listbox 1") then for n = 0, #items - 1 do local is_selected = (s.item_selected_idx == n) - if ImGui.Selectable(items[n + 1], is_selected) then + if ImGui_Selectable(items[n + 1], is_selected) then s.item_selected_idx = n end - if s.item_highlight and ImGui.IsItemHovered() then + if s.item_highlight and ImGui_IsItemHovered() then item_highlighted_idx = n end -- Set the initial focus when opening the combo (scrolling + keyboard navigation focus) if is_selected then - ImGui.SetItemDefaultFocus() + ImGui_SetItemDefaultFocus() end end - ImGui.EndListBox() + ImGui_EndListBox() end - ImGui.SameLine(); HelpMarker("Here we are sharing selection state between both boxes.") + ImGui_SameLine(); HelpMarker("Here we are sharing selection state between both boxes.") -- Custom size: use all width, 5 items tall - ImGui.Text("Full-width:") - if ImGui.BeginListBox("##listbox 2", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 5 * ImGui.GetTextLineHeightWithSpacing())) then + ImGui_Text("Full-width:") + if ImGui_BeginListBox("##listbox 2", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 5 * ImGui_GetTextLineHeightWithSpacing())) then for n = 0, #items - 1 do local is_selected = (s.item_selected_idx == n) local flags = 0 if item_highlighted_idx == n then flags = 32 --[[ImGuiSelectableFlags.Highlight]] end - if ImGui.Selectable(items[n + 1], is_selected, flags) then + if ImGui_Selectable(items[n + 1], is_selected, flags) then s.item_selected_idx = n end -- Set the initial focus when opening the combo (scrolling + keyboard navigation focus) if is_selected then - ImGui.SetItemDefaultFocus() + ImGui_SetItemDefaultFocus() end end - ImGui.EndListBox() + ImGui_EndListBox() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -24762,29 +24818,29 @@ function DemoWindowWidgetsLiveEdit(demo_data) if ImGui.TreeNode("Live Edit Flags") then IMGUI_DEMO_MARKER("Widgets/Live Edit Flags") - ImGui.TextWrapped("Select whether to apply keyboard edits to backing variables _while_ typing.") + ImGui_TextWrapped("Select whether to apply keyboard edits to backing variables _while_ typing.") - _, demo_data.LiveEditOverride = ImGui.Checkbox("Override Live Edit Flags in Demo Window", demo_data.LiveEditOverride) + _, demo_data.LiveEditOverride = ImGui_Checkbox("Override Live Edit Flags in Demo Window", demo_data.LiveEditOverride) if not demo_data.LiveEditOverride then - demo_data.LiveEditFlags = ImGui.GetItemFlags() + demo_data.LiveEditFlags = ImGui_GetItemFlags() end - ImGui.BeginDisabled(demo_data.LiveEditOverride == false) - ImGui.Indent() - _, demo_data.LiveEditFlags = ImGui.CheckboxFlags("ImGuiItemFlags_LiveEditOnInputText", demo_data.LiveEditFlags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) - _, demo_data.LiveEditFlags = ImGui.CheckboxFlags("ImGuiItemFlags_LiveEditOnInputScalar", demo_data.LiveEditFlags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) - ImGui.Unindent() - ImGui.EndDisabled() + ImGui_BeginDisabled(demo_data.LiveEditOverride == false) + ImGui_Indent() + _, demo_data.LiveEditFlags = ImGui_CheckboxFlags("ImGuiItemFlags_LiveEditOnInputText", demo_data.LiveEditFlags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) + _, demo_data.LiveEditFlags = ImGui_CheckboxFlags("ImGuiItemFlags_LiveEditOnInputScalar", demo_data.LiveEditFlags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) + ImGui_Unindent() + ImGui_EndDisabled() - ImGui.Text("Try typing '123' and seeing effect on backing value:") - ImGui.InputText("str", s.str, 32) - ImGui.Text("Backing value: \"%s\"", ImGui.TextBufferToString(s.str)) - s.i = ImGui.InputInt("int", s.i, 0, 0) - ImGui.Text("Backing value: %d", s.i) - s.f = ImGui.SliderFloat("float", s.f, 0.0, 100.0) - ImGui.Text("Backing value: %f", s.f) + ImGui_Text("Try typing '123' and seeing effect on backing value:") + ImGui_InputText("str", s.str, 32) + ImGui_Text("Backing value: \"%s\"", ImGui_TextBufferToString(s.str)) + s.i = ImGui_InputInt("int", s.i, 0, 0) + ImGui_Text("Backing value: %d", s.i) + s.f = ImGui_SliderFloat("float", s.f, 0.0, 100.0) + ImGui_Text("Backing value: %f", s.f) - ImGui.TreePop() + ImGui_TreePop() end end @@ -24804,19 +24860,19 @@ function DemoWindowWidgetsMixedValues() local items = s.items local item_ref = 1 -- [Port] index of the reference item (C++: float* item_ref = &items[0]) - _, s.use_liveedit = ImGui.Checkbox("ImGuiItemFlags_LiveEditOnInput", s.use_liveedit) + _, s.use_liveedit = ImGui_Checkbox("ImGuiItemFlags_LiveEditOnInput", s.use_liveedit) - ImGui.SeparatorText("Scalar/Text Widgets") + ImGui_SeparatorText("Scalar/Text Widgets") local is_mixed = items[1] ~= items[2] or items[1] ~= items[3] -- Demonstrate Drags, Sliders, Inputs - ImGui.PushItemFlag(384 --[[ImGuiItemFlags.LiveEditOnInput]], s.use_liveedit) - ImGui.PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], is_mixed) + ImGui_PushItemFlag(384 --[[ImGuiItemFlags.LiveEditOnInput]], s.use_liveedit) + ImGui_PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], is_mixed) local edited = false local changed - items[item_ref], changed = ImGui.DragFloat("DragFloat", items[item_ref]); edited = edited or changed - items[item_ref], changed = ImGui.SliderFloat("SliderFloat", items[item_ref], 0.0, 100.0); edited = edited or changed - items[item_ref], changed = ImGui.InputFloat("InputFloat", items[item_ref], 1.0); edited = edited or changed + items[item_ref], changed = ImGui_DragFloat("DragFloat", items[item_ref]); edited = edited or changed + items[item_ref], changed = ImGui_SliderFloat("SliderFloat", items[item_ref], 0.0, 100.0); edited = edited or changed + items[item_ref], changed = ImGui_InputFloat("InputFloat", items[item_ref], 1.0); edited = edited or changed if edited then for n = 1, #items do if n ~= item_ref then @@ -24824,32 +24880,32 @@ function DemoWindowWidgetsMixedValues() end end end - ImGui.PopItemFlag() + ImGui_PopItemFlag() - ImGui.Text("Underlying data:") - items[1] = ImGui.InputFloat("item 0 (ref)", items[1]) - items[2] = ImGui.InputFloat("item 1", items[2]) - items[3] = ImGui.InputFloat("item 2", items[3]) - ImGui.PopItemFlag() + ImGui_Text("Underlying data:") + items[1] = ImGui_InputFloat("item 0 (ref)", items[1]) + items[2] = ImGui_InputFloat("item 1", items[2]) + items[3] = ImGui_InputFloat("item 2", items[3]) + ImGui_PopItemFlag() -- Demonstrate Checkbox(), RadioButton(), Combo(), ColorEdit4() - ImGui.SeparatorText("Others Widgets") - ImGui.Text("(note: edits are not applied in this demo)") -- <-- Would need more state tracking. + ImGui_SeparatorText("Others Widgets") + ImGui_Text("(note: edits are not applied in this demo)") -- <-- Would need more state tracking. local b_on, b_off = true, false - _, b_on = ImGui.Checkbox("Checkbox On", b_on) - _, b_off = ImGui.Checkbox("Checkbox Off", b_off) - ImGui.PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], true) - _, b_off = ImGui.Checkbox("Checkbox Mixed", b_off) - ImGui.RadioButtonEx("RadioButton Mixed", true) -- [Port] RadioButton(label, bool active) overload is RadioButtonEx - ImGui.SameLine() - ImGui.RadioButtonEx("RadioButton Mixed##2", true) -- Showing 2 radio buttons makes the example more clear + _, b_on = ImGui_Checkbox("Checkbox On", b_on) + _, b_off = ImGui_Checkbox("Checkbox Off", b_off) + ImGui_PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], true) + _, b_off = ImGui_Checkbox("Checkbox Mixed", b_off) + ImGui_RadioButtonEx("RadioButton Mixed", true) -- [Port] RadioButton(label, bool active) overload is RadioButtonEx + ImGui_SameLine() + ImGui_RadioButtonEx("RadioButton Mixed##2", true) -- Showing 2 radio buttons makes the example more clear local combo_idx = 0 - combo_idx = ImGui.Combo("Combo", combo_idx, "One\0Two\0Three\0") + combo_idx = ImGui_Combo("Combo", combo_idx, "One\0Two\0Three\0") local color = ImVec4(0.5, 0.5, 0.5, 0.5) - ImGui.ColorEdit4("ColorEdit4", color) - ImGui.PopItemFlag() + ImGui_ColorEdit4("ColorEdit4", color) + ImGui_PopItemFlag() - ImGui.TreePop() + ImGui_TreePop() end end @@ -24871,39 +24927,39 @@ function DemoWindowWidgetsMultiComponents() local vec4f = s.vec4f local vec4i = s.vec4i - _, s.flags = ImGui.CheckboxFlags("ImGuiSliderFlags_ColorMarkers", s.flags, 4096 --[[ImGuiSliderFlags.ColorMarkers]]) -- Only passing this to Drag/Sliders + _, s.flags = ImGui_CheckboxFlags("ImGuiSliderFlags_ColorMarkers", s.flags, 4096 --[[ImGuiSliderFlags.ColorMarkers]]) -- Only passing this to Drag/Sliders local flags = s.flags - ImGui.SeparatorText("2-wide") - ImGui.InputFloat2("input float2", vec4f) - ImGui.InputInt2("input int2", vec4i) - ImGui.DragFloat2("drag float2", vec4f, 0.01, 0.0, 1.0, nil, flags) - ImGui.DragInt2("drag int2", vec4i, 1, 0, 255, nil, flags) - ImGui.SliderFloat2("slider float2", vec4f, 0.0, 1.0, nil, flags) - ImGui.SliderInt2("slider int2", vec4i, 0, 255, nil, flags) + ImGui_SeparatorText("2-wide") + ImGui_InputFloat2("input float2", vec4f) + ImGui_InputInt2("input int2", vec4i) + ImGui_DragFloat2("drag float2", vec4f, 0.01, 0.0, 1.0, nil, flags) + ImGui_DragInt2("drag int2", vec4i, 1, 0, 255, nil, flags) + ImGui_SliderFloat2("slider float2", vec4f, 0.0, 1.0, nil, flags) + ImGui_SliderInt2("slider int2", vec4i, 0, 255, nil, flags) - ImGui.SeparatorText("3-wide") - ImGui.InputFloat3("input float3", vec4f) - ImGui.InputInt3("input int3", vec4i) - ImGui.DragFloat3("drag float3", vec4f, 0.01, 0.0, 1.0, nil, flags) - ImGui.DragInt3("drag int3", vec4i, 1, 0, 255, nil, flags) - ImGui.SliderFloat3("slider float3", vec4f, 0.0, 1.0, nil, flags) - ImGui.SliderInt3("slider int3", vec4i, 0, 255, nil, flags) + ImGui_SeparatorText("3-wide") + ImGui_InputFloat3("input float3", vec4f) + ImGui_InputInt3("input int3", vec4i) + ImGui_DragFloat3("drag float3", vec4f, 0.01, 0.0, 1.0, nil, flags) + ImGui_DragInt3("drag int3", vec4i, 1, 0, 255, nil, flags) + ImGui_SliderFloat3("slider float3", vec4f, 0.0, 1.0, nil, flags) + ImGui_SliderInt3("slider int3", vec4i, 0, 255, nil, flags) - ImGui.SeparatorText("4-wide") - ImGui.InputFloat4("input float4", vec4f) - ImGui.InputInt4("input int4", vec4i) - ImGui.DragFloat4("drag float4", vec4f, 0.01, 0.0, 1.0, nil, flags) - ImGui.DragInt4("drag int4", vec4i, 1, 0, 255, nil, flags) - ImGui.SliderFloat4("slider float4", vec4f, 0.0, 1.0, nil, flags) - ImGui.SliderInt4("slider int4", vec4i, 0, 255, nil, flags) + ImGui_SeparatorText("4-wide") + ImGui_InputFloat4("input float4", vec4f) + ImGui_InputInt4("input int4", vec4i) + ImGui_DragFloat4("drag float4", vec4f, 0.01, 0.0, 1.0, nil, flags) + ImGui_DragInt4("drag int4", vec4i, 1, 0, 255, nil, flags) + ImGui_SliderFloat4("slider float4", vec4f, 0.0, 1.0, nil, flags) + ImGui_SliderInt4("slider int4", vec4i, 0, 255, nil, flags) - ImGui.SeparatorText("Ranges") - s.begin, s["end"] = ImGui.DragFloatRange2("range float", s.begin, s["end"], 0.25, 0.0, 100.0, "Min: %.1f %%", "Max: %.1f %%", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) - s.begin_i, s.end_i = ImGui.DragIntRange2("range int", s.begin_i, s.end_i, 5, 0, 1000, "Min: %d units", "Max: %d units") - s.begin_i, s.end_i = ImGui.DragIntRange2("range int (no bounds)", s.begin_i, s.end_i, 5, 0, 0, "Min: %d units", "Max: %d units") + ImGui_SeparatorText("Ranges") + s.begin, s["end"] = ImGui_DragFloatRange2("range float", s.begin, s["end"], 0.25, 0.0, 100.0, "Min: %.1f %%", "Max: %.1f %%", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + s.begin_i, s.end_i = ImGui_DragIntRange2("range int", s.begin_i, s.end_i, 5, 0, 1000, "Min: %d units", "Max: %d units") + s.begin_i, s.end_i = ImGui_DragIntRange2("range int (no bounds)", s.begin_i, s.end_i, 5, 0, 0, "Min: %d units", "Max: %d units") - ImGui.TreePop() + ImGui_TreePop() end end @@ -24937,16 +24993,16 @@ function DemoWindowWidgetsPlotting() -- (see others https://github.com/ocornut/imgui/wiki/Useful-Extensions) if ImGui.TreeNode("Plotting") then IMGUI_DEMO_MARKER("Widgets/Plotting") - ImGui.Text("Need better plotting and graphing? Consider using ImPlot:") - ImGui.TextLinkOpenURL("https://github.com/epezent/implot") - ImGui.Separator() + ImGui_Text("Need better plotting and graphing? Consider using ImPlot:") + ImGui_TextLinkOpenURL("https://github.com/epezent/implot") + ImGui_Separator() - _, s.animate = ImGui.Checkbox("Animate", s.animate) + _, s.animate = ImGui_Checkbox("Animate", s.animate) -- Plot as lines and plot as histogram local arr = s.arr - ImGui.PlotLines("Frame Times", arr, nil, #arr) - ImGui.PlotHistogram("Histogram", arr, nil, #arr, 0, nil, 0.0, 1.0, ImVec2(0, 80.0)) + ImGui_PlotLines("Frame Times", arr, nil, #arr) + ImGui_PlotHistogram("Histogram", arr, nil, #arr, 0, nil, 0.0, 1.0, ImVec2(0, 80.0)) -- ImGui.SameLine(); HelpMarker("Consider using ImPlot instead!") -- Fill an array of contiguous float values to plot @@ -24954,9 +25010,9 @@ function DemoWindowWidgetsPlotting() -- and the sizeof() of your structure in the "stride" parameter. local values = s.values if not s.animate or s.refresh_time == 0.0 then - s.refresh_time = ImGui.GetTime() + s.refresh_time = ImGui_GetTime() end - while s.refresh_time < ImGui.GetTime() do -- Create data at fixed 60 Hz rate for the demo + while s.refresh_time < ImGui_GetTime() do -- Create data at fixed 60 Hz rate for the demo values[s.values_offset + 1] = math.cos(s.phase) s.values_offset = (s.values_offset + 1) % #values s.phase = s.phase + 0.10 * s.values_offset @@ -24972,24 +25028,24 @@ function DemoWindowWidgetsPlotting() end average = average / #values local overlay = string.format("avg %f", average) - ImGui.PlotLines("Lines", values, nil, #values, s.values_offset, overlay, -1.0, 1.0, ImVec2(0, 80.0)) + ImGui_PlotLines("Lines", values, nil, #values, s.values_offset, overlay, -1.0, 1.0, ImVec2(0, 80.0)) end -- Use functions to generate output -- FIXME: This is actually VERY awkward because current plot API only pass in indices. -- We probably want an API passing floats and user provide sample rate/count. local Funcs = DemoPlottingFuncs - ImGui.SeparatorText("Functions") - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - s.func_type = ImGui.Combo("func", s.func_type, "Sin\0Saw\0") - ImGui.SameLine() - s.display_count = ImGui.SliderInt("Sample count", s.display_count, 1, 400) + ImGui_SeparatorText("Functions") + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + s.func_type = ImGui_Combo("func", s.func_type, "Sin\0Saw\0") + ImGui_SameLine() + s.display_count = ImGui_SliderInt("Sample count", s.display_count, 1, 400) local func = Funcs.Saw if s.func_type == 0 then func = Funcs.Sin end - ImGui.PlotLines("Lines##2", func, nil, s.display_count, 0, nil, -1.0, 1.0, ImVec2(0, 80)) - ImGui.PlotHistogram("Histogram##2", func, nil, s.display_count, 0, nil, -1.0, 1.0, ImVec2(0, 80)) + ImGui_PlotLines("Lines##2", func, nil, s.display_count, 0, nil, -1.0, 1.0, ImVec2(0, 80)) + ImGui_PlotHistogram("Histogram##2", func, nil, s.display_count, 0, nil, -1.0, 1.0, ImVec2(0, 80)) - ImGui.TreePop() + ImGui_TreePop() end end @@ -25005,7 +25061,7 @@ function DemoWindowWidgetsProgressBars() if ImGui.TreeNode("Progress Bars") then IMGUI_DEMO_MARKER("Widgets/Progress Bars") -- Animate a simple progress bar - s.progress_accum = s.progress_accum + s.progress_dir * 0.4 * ImGui.GetIO().DeltaTime + s.progress_accum = s.progress_accum + s.progress_dir * 0.4 * ImGui_GetIO().DeltaTime if s.progress_accum >= 1.1 then s.progress_accum = 1.1; s.progress_dir = s.progress_dir * -1.0 end if s.progress_accum <= -0.1 then s.progress_accum = -0.1; s.progress_dir = s.progress_dir * -1.0 end @@ -25013,20 +25069,20 @@ function DemoWindowWidgetsProgressBars() -- Typically we would use ImVec2(-1.0,0.0) or ImVec2(-FLT_MIN,0.0) to use all available width, -- or ImVec2(width,0.0) for a specified width. ImVec2(0.0,0.0) uses ItemWidth. - ImGui.ProgressBar(progress, ImVec2(0.0, 0.0)) - ImGui.SameLine(0.0, ImGui.GetStyle().ItemInnerSpacing.x) - ImGui.Text("Progress Bar") + ImGui_ProgressBar(progress, ImVec2(0.0, 0.0)) + ImGui_SameLine(0.0, ImGui_GetStyle().ItemInnerSpacing.x) + ImGui_Text("Progress Bar") local buf = string.format("%d/%d", math.floor(progress * 1753), 1753) - ImGui.ProgressBar(progress, ImVec2(0.0, 0.0), buf) + ImGui_ProgressBar(progress, ImVec2(0.0, 0.0), buf) -- Pass an animated negative value, e.g. -1.0 * ImGui.GetTime() is the recommended value. -- Adjust the factor if you want to adjust the animation speed. - ImGui.ProgressBar(-1.0 * ImGui.GetTime(), ImVec2(0.0, 0.0), "Searching..") - ImGui.SameLine(0.0, ImGui.GetStyle().ItemInnerSpacing.x) - ImGui.Text("Indeterminate") + ImGui_ProgressBar(-1.0 * ImGui_GetTime(), ImVec2(0.0, 0.0), "Searching..") + ImGui_SameLine(0.0, ImGui_GetStyle().ItemInnerSpacing.x) + ImGui_Text("Indeterminate") - ImGui.TreePop() + ImGui_TreePop() end end @@ -25062,26 +25118,26 @@ function DemoWindowWidgetsQueryingStatuses() "Text", "Button", "Button (w/ repeat)", "Checkbox", "SliderFloat", "InputText", "InputTextMultiline", "InputFloat", "InputFloat3", "ColorEdit4", "Selectable", "MenuItem", "TreeNode", "TreeNode (w/ double-click)", "Combo", "ListBox" } - s.item_type = ImGui.Combo("Item Type", s.item_type, item_names, #item_names, #item_names) - ImGui.SameLine() + s.item_type = ImGui_Combo("Item Type", s.item_type, item_names, #item_names, #item_names) + ImGui_SameLine() HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions. Note that the bool return value of most ImGui function is generally equivalent to calling ImGui::IsItemHovered().") - _, s.item_disabled = ImGui.Checkbox("Item Disabled", s.item_disabled) - _, s.item_mixedvalue = ImGui.Checkbox("Item MixedValue", s.item_mixedvalue) - _, s.liveedit_flags_override = ImGui.Checkbox("Override LiveEdit:", s.liveedit_flags_override) - ImGui.SameLine() + _, s.item_disabled = ImGui_Checkbox("Item Disabled", s.item_disabled) + _, s.item_mixedvalue = ImGui_Checkbox("Item MixedValue", s.item_mixedvalue) + _, s.liveedit_flags_override = ImGui_Checkbox("Override LiveEdit:", s.liveedit_flags_override) + ImGui_SameLine() if not s.liveedit_flags_override then - s.liveedit_flags = ImGui.GetItemFlags() + s.liveedit_flags = ImGui_GetItemFlags() end - ImGui.BeginDisabled(s.liveedit_flags_override == false) - _, s.liveedit_flags = ImGui.CheckboxFlags("_LiveEditOnInput", s.liveedit_flags, 384 --[[ImGuiItemFlags.LiveEditOnInput]]) - ImGui.SameLine() - _, s.liveedit_flags = ImGui.CheckboxFlags("_LiveEditOnInputText", s.liveedit_flags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) - ImGui.SameLine() - _, s.liveedit_flags = ImGui.CheckboxFlags("_LiveEditOnInputScalar", s.liveedit_flags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) - ImGui.EndDisabled() + ImGui_BeginDisabled(s.liveedit_flags_override == false) + _, s.liveedit_flags = ImGui_CheckboxFlags("_LiveEditOnInput", s.liveedit_flags, 384 --[[ImGuiItemFlags.LiveEditOnInput]]) + ImGui_SameLine() + _, s.liveedit_flags = ImGui_CheckboxFlags("_LiveEditOnInputText", s.liveedit_flags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) + ImGui_SameLine() + _, s.liveedit_flags = ImGui_CheckboxFlags("_LiveEditOnInputScalar", s.liveedit_flags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) + ImGui_EndDisabled() if s.liveedit_flags_override then - ImGui.PushItemFlag(128 --[[ImGuiItemFlags.LiveEditOnInputText]], bit32.band(s.liveedit_flags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) ~= 0) - ImGui.PushItemFlag(256 --[[ImGuiItemFlags.LiveEditOnInputScalar]], bit32.band(s.liveedit_flags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) ~= 0) + ImGui_PushItemFlag(128 --[[ImGuiItemFlags.LiveEditOnInputText]], bit32.band(s.liveedit_flags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) ~= 0) + ImGui_PushItemFlag(256 --[[ImGuiItemFlags.LiveEditOnInputScalar]], bit32.band(s.liveedit_flags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) ~= 0) end -- Submit selected items so we can query their status in the code following it. @@ -25089,39 +25145,39 @@ function DemoWindowWidgetsQueryingStatuses() local item_type = s.item_type local col4f = s.col4f if s.item_disabled then - ImGui.BeginDisabled(true) + ImGui_BeginDisabled(true) end if s.item_mixedvalue then - ImGui.PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], true) + ImGui_PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], true) end - if item_type == 0 then ImGui.Text("ITEM: Text") end -- Testing text items with no identifier/interaction - if item_type == 1 then ret = ImGui.Button("ITEM: Button") end -- Testing button - if item_type == 2 then ImGui.PushItemFlag(8 --[[ImGuiItemFlags.ButtonRepeat]], true); ret = ImGui.Button("ITEM: Button"); ImGui.PopItemFlag() end -- Testing button (with repeater) - if item_type == 3 then ret, s.b = ImGui.Checkbox("ITEM: Checkbox", s.b) end -- Testing checkbox - if item_type == 4 then col4f[1], ret = ImGui.SliderFloat("ITEM: SliderFloat", col4f[1], 0.0, 1.0) end -- Testing basic item - if item_type == 5 then ret = ImGui.InputText("ITEM: InputText", s.str, 16) end -- Testing input text (which handles tabbing) - if item_type == 6 then ret = ImGui.InputTextMultiline("ITEM: InputTextMultiline", s.str, 16) end -- Testing input text (which uses a child window) - if item_type == 7 then col4f[1], ret = ImGui.InputFloat("ITEM: InputFloat", col4f[1], 1.0) end -- Testing +/- buttons on scalar input - if item_type == 8 then ret = ImGui.InputFloat3("ITEM: InputFloat3", col4f) end -- Testing multi-component items (IsItemXXX flags are reported merged) - if item_type == 9 then ret = ImGui.ColorEdit4("ITEM: ColorEdit4", col4f) end -- Testing multi-component items (IsItemXXX flags are reported merged) - if item_type == 10 then ret = ImGui.Selectable("ITEM: Selectable") end -- Testing selectable item - if item_type == 11 then ret = ImGui.MenuItem("ITEM: MenuItem") end -- Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy) - if item_type == 12 then ret = ImGui.TreeNode("ITEM: TreeNode"); if ret then ImGui.TreePop() end end -- Testing tree node + if item_type == 0 then ImGui_Text("ITEM: Text") end -- Testing text items with no identifier/interaction + if item_type == 1 then ret = ImGui_Button("ITEM: Button") end -- Testing button + if item_type == 2 then ImGui_PushItemFlag(8 --[[ImGuiItemFlags.ButtonRepeat]], true); ret = ImGui_Button("ITEM: Button"); ImGui_PopItemFlag() end -- Testing button (with repeater) + if item_type == 3 then ret, s.b = ImGui_Checkbox("ITEM: Checkbox", s.b) end -- Testing checkbox + if item_type == 4 then col4f[1], ret = ImGui_SliderFloat("ITEM: SliderFloat", col4f[1], 0.0, 1.0) end -- Testing basic item + if item_type == 5 then ret = ImGui_InputText("ITEM: InputText", s.str, 16) end -- Testing input text (which handles tabbing) + if item_type == 6 then ret = ImGui_InputTextMultiline("ITEM: InputTextMultiline", s.str, 16) end -- Testing input text (which uses a child window) + if item_type == 7 then col4f[1], ret = ImGui_InputFloat("ITEM: InputFloat", col4f[1], 1.0) end -- Testing +/- buttons on scalar input + if item_type == 8 then ret = ImGui_InputFloat3("ITEM: InputFloat3", col4f) end -- Testing multi-component items (IsItemXXX flags are reported merged) + if item_type == 9 then ret = ImGui_ColorEdit4("ITEM: ColorEdit4", col4f) end -- Testing multi-component items (IsItemXXX flags are reported merged) + if item_type == 10 then ret = ImGui_Selectable("ITEM: Selectable") end -- Testing selectable item + if item_type == 11 then ret = ImGui_MenuItem("ITEM: MenuItem") end -- Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy) + if item_type == 12 then ret = ImGui.TreeNode("ITEM: TreeNode"); if ret then ImGui_TreePop() end end -- Testing tree node if item_type == 13 then ret = ImGui.TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", bit32.bor(64 --[[ImGuiTreeNodeFlags.OpenOnDoubleClick]], 8 --[[ImGuiTreeNodeFlags.NoTreePushOnOpen]])) end -- Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy. - if item_type == 14 then local items = { "Apple", "Banana", "Cherry", "Kiwi" }; s.current, ret = ImGui.Combo("ITEM: Combo", s.current, items, #items) end - if item_type == 15 then local items = { "Apple", "Banana", "Cherry", "Kiwi" }; s.current_2, ret = ImGui.ListBox("ITEM: ListBox", s.current_2, items, #items, #items) end + if item_type == 14 then local items = { "Apple", "Banana", "Cherry", "Kiwi" }; s.current, ret = ImGui_Combo("ITEM: Combo", s.current, items, #items) end + if item_type == 15 then local items = { "Apple", "Banana", "Cherry", "Kiwi" }; s.current_2, ret = ImGui_ListBox("ITEM: ListBox", s.current_2, items, #items, #items) end - local hovered_delay_none = ImGui.IsItemHovered() - local hovered_delay_stationary = ImGui.IsItemHovered(8192 --[[ImGuiHoveredFlags.Stationary]]) - local hovered_delay_short = ImGui.IsItemHovered(32768 --[[ImGuiHoveredFlags.DelayShort]]) - local hovered_delay_normal = ImGui.IsItemHovered(65536 --[[ImGuiHoveredFlags.DelayNormal]]) - local hovered_delay_tooltip = ImGui.IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) -- = Normal + Stationary + local hovered_delay_none = ImGui_IsItemHovered() + local hovered_delay_stationary = ImGui_IsItemHovered(8192 --[[ImGuiHoveredFlags.Stationary]]) + local hovered_delay_short = ImGui_IsItemHovered(32768 --[[ImGuiHoveredFlags.DelayShort]]) + local hovered_delay_normal = ImGui_IsItemHovered(65536 --[[ImGuiHoveredFlags.DelayNormal]]) + local hovered_delay_tooltip = ImGui_IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) -- = Normal + Stationary -- Display the values of IsItemHovered() and other common item state functions. -- Note that the ImGuiHoveredFlags_XXX flags can be combined. -- Because BulletText is an item itself and that would affect the output of IsItemXXX functions, -- we query every state in a single call to avoid storing them and to simplify the code. - ImGui.BulletText( + ImGui_BulletText( "Return value = %d\n" .. "IsItemFocused() = %d\n" .. "IsItemHovered() = %d\n" .. @@ -25143,27 +25199,27 @@ function DemoWindowWidgetsQueryingStatuses() "GetItemRectMax() = (%.1f, %.1f)\n" .. "GetItemRectSize() = (%.1f, %.1f)", B(ret), - B(ImGui.IsItemFocused()), - B(ImGui.IsItemHovered()), - B(ImGui.IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]])), - B(ImGui.IsItemHovered(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]])), - B(ImGui.IsItemHovered(256 --[[ImGuiHoveredFlags.AllowWhenOverlappedByItem]])), - B(ImGui.IsItemHovered(512 --[[ImGuiHoveredFlags.AllowWhenOverlappedByWindow]])), - B(ImGui.IsItemHovered(1024 --[[ImGuiHoveredFlags.AllowWhenDisabled]])), - B(ImGui.IsItemHovered(928 --[[ImGuiHoveredFlags.RectOnly]])), - B(ImGui.IsItemActive()), - B(ImGui.IsItemEdited()), - B(ImGui.IsItemActivated()), - B(ImGui.IsItemDeactivated()), - B(ImGui.IsItemDeactivatedAfterEdit()), - B(ImGui.IsItemVisible()), - B(ImGui.IsItemClicked()), - B(ImGui.IsItemToggledOpen()), - ImGui.GetItemRectMin().x, ImGui.GetItemRectMin().y, - ImGui.GetItemRectMax().x, ImGui.GetItemRectMax().y, - ImGui.GetItemRectSize().x, ImGui.GetItemRectSize().y + B(ImGui_IsItemFocused()), + B(ImGui_IsItemHovered()), + B(ImGui_IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]])), + B(ImGui_IsItemHovered(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]])), + B(ImGui_IsItemHovered(256 --[[ImGuiHoveredFlags.AllowWhenOverlappedByItem]])), + B(ImGui_IsItemHovered(512 --[[ImGuiHoveredFlags.AllowWhenOverlappedByWindow]])), + B(ImGui_IsItemHovered(1024 --[[ImGuiHoveredFlags.AllowWhenDisabled]])), + B(ImGui_IsItemHovered(928 --[[ImGuiHoveredFlags.RectOnly]])), + B(ImGui_IsItemActive()), + B(ImGui_IsItemEdited()), + B(ImGui_IsItemActivated()), + B(ImGui_IsItemDeactivated()), + B(ImGui_IsItemDeactivatedAfterEdit()), + B(ImGui_IsItemVisible()), + B(ImGui_IsItemClicked()), + B(ImGui_IsItemToggledOpen()), + ImGui_GetItemRectMin().x, ImGui_GetItemRectMin().y, + ImGui_GetItemRectMax().x, ImGui_GetItemRectMax().y, + ImGui_GetItemRectSize().x, ImGui_GetItemRectSize().y ) - ImGui.BulletText( + ImGui_BulletText( "with Hovering Delay or Stationary test:\n" .. "IsItemHovered() = %d\n" .. "IsItemHovered(_Stationary) = %d\n" .. @@ -25173,33 +25229,33 @@ function DemoWindowWidgetsQueryingStatuses() B(hovered_delay_none), B(hovered_delay_stationary), B(hovered_delay_short), B(hovered_delay_normal), B(hovered_delay_tooltip)) if s.liveedit_flags_override then - ImGui.PopItemFlag() - ImGui.PopItemFlag() + ImGui_PopItemFlag() + ImGui_PopItemFlag() end if s.item_mixedvalue then - ImGui.PopItemFlag() + ImGui_PopItemFlag() end if s.item_disabled then - ImGui.EndDisabled() + ImGui_EndDisabled() end - local buf = ImGui.NewTextBuffer("", 1) - ImGui.InputText("unused", buf, 1, 512 --[[ImGuiInputTextFlags.ReadOnly]]) - ImGui.SameLine() + local buf = ImGui_NewTextBuffer("", 1) + ImGui_InputText("unused", buf, 1, 512 --[[ImGuiInputTextFlags.ReadOnly]]) + ImGui_SameLine() HelpMarker("This widget is only here to be able to tab-out of the widgets above and see e.g. Deactivated() status.") - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Querying Window Status (Focused/Hovered etc.)") then IMGUI_DEMO_MARKER("Widgets/Querying Window Status (Focused,Hovered etc.)") - _, s.embed_all_inside_a_child_window = ImGui.Checkbox("Embed everything inside a child window for testing _RootWindow flag.", s.embed_all_inside_a_child_window) + _, s.embed_all_inside_a_child_window = ImGui_Checkbox("Embed everything inside a child window for testing _RootWindow flag.", s.embed_all_inside_a_child_window) if s.embed_all_inside_a_child_window then - ImGui.BeginChild("outer_child", ImVec2(0, ImGui.GetFontSize() * 20.0), 1 --[[ImGuiChildFlags.Borders]]) + ImGui_BeginChild("outer_child", ImVec2(0, ImGui_GetFontSize() * 20.0), 1 --[[ImGuiChildFlags.Borders]]) end -- Testing IsWindowFocused() function with its various flags. - ImGui.BulletText( + ImGui_BulletText( "IsWindowFocused() = %d\n" .. "IsWindowFocused(_ChildWindows) = %d\n" .. "IsWindowFocused(_ChildWindows|_NoPopupHierarchy) = %d\n" .. @@ -25211,20 +25267,20 @@ function DemoWindowWidgetsQueryingStatuses() "IsWindowFocused(_RootWindow|_NoPopupHierarchy) = %d\n" .. "IsWindowFocused(_RootWindow|_DockHierarchy) = %d\n" .. "IsWindowFocused(_AnyWindow) = %d\n", - B(ImGui.IsWindowFocused()), - B(ImGui.IsWindowFocused(1 --[[ImGuiFocusedFlags.ChildWindows]])), - B(ImGui.IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 8 --[[ImGuiFocusedFlags.NoPopupHierarchy]]))), - B(ImGui.IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 16 --[[ImGuiFocusedFlags.DockHierarchy]]))), - B(ImGui.IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 2 --[[ImGuiFocusedFlags.RootWindow]]))), - B(ImGui.IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 2 --[[ImGuiFocusedFlags.RootWindow]], 8 --[[ImGuiFocusedFlags.NoPopupHierarchy]]))), - B(ImGui.IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 2 --[[ImGuiFocusedFlags.RootWindow]], 16 --[[ImGuiFocusedFlags.DockHierarchy]]))), - B(ImGui.IsWindowFocused(2 --[[ImGuiFocusedFlags.RootWindow]])), - B(ImGui.IsWindowFocused(bit32.bor(2 --[[ImGuiFocusedFlags.RootWindow]], 8 --[[ImGuiFocusedFlags.NoPopupHierarchy]]))), - B(ImGui.IsWindowFocused(bit32.bor(2 --[[ImGuiFocusedFlags.RootWindow]], 16 --[[ImGuiFocusedFlags.DockHierarchy]]))), - B(ImGui.IsWindowFocused(4 --[[ImGuiFocusedFlags.AnyWindow]]))) + B(ImGui_IsWindowFocused()), + B(ImGui_IsWindowFocused(1 --[[ImGuiFocusedFlags.ChildWindows]])), + B(ImGui_IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 8 --[[ImGuiFocusedFlags.NoPopupHierarchy]]))), + B(ImGui_IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 16 --[[ImGuiFocusedFlags.DockHierarchy]]))), + B(ImGui_IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 2 --[[ImGuiFocusedFlags.RootWindow]]))), + B(ImGui_IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 2 --[[ImGuiFocusedFlags.RootWindow]], 8 --[[ImGuiFocusedFlags.NoPopupHierarchy]]))), + B(ImGui_IsWindowFocused(bit32.bor(1 --[[ImGuiFocusedFlags.ChildWindows]], 2 --[[ImGuiFocusedFlags.RootWindow]], 16 --[[ImGuiFocusedFlags.DockHierarchy]]))), + B(ImGui_IsWindowFocused(2 --[[ImGuiFocusedFlags.RootWindow]])), + B(ImGui_IsWindowFocused(bit32.bor(2 --[[ImGuiFocusedFlags.RootWindow]], 8 --[[ImGuiFocusedFlags.NoPopupHierarchy]]))), + B(ImGui_IsWindowFocused(bit32.bor(2 --[[ImGuiFocusedFlags.RootWindow]], 16 --[[ImGuiFocusedFlags.DockHierarchy]]))), + B(ImGui_IsWindowFocused(4 --[[ImGuiFocusedFlags.AnyWindow]]))) -- Testing IsWindowHovered() function with its various flags. - ImGui.BulletText( + ImGui_BulletText( "IsWindowHovered() = %d\n" .. "IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n" .. "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n" .. @@ -25240,49 +25296,49 @@ function DemoWindowWidgetsQueryingStatuses() "IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n" .. "IsWindowHovered(_AnyWindow) = %d\n" .. "IsWindowHovered(_Stationary) = %d\n", - B(ImGui.IsWindowHovered()), - B(ImGui.IsWindowHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]])), - B(ImGui.IsWindowHovered(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]])), - B(ImGui.IsWindowHovered(1 --[[ImGuiHoveredFlags.ChildWindows]])), - B(ImGui.IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 8 --[[ImGuiHoveredFlags.NoPopupHierarchy]]))), - B(ImGui.IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 16 --[[ImGuiHoveredFlags.DockHierarchy]]))), - B(ImGui.IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 2 --[[ImGuiHoveredFlags.RootWindow]]))), - B(ImGui.IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 2 --[[ImGuiHoveredFlags.RootWindow]], 8 --[[ImGuiHoveredFlags.NoPopupHierarchy]]))), - B(ImGui.IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 2 --[[ImGuiHoveredFlags.RootWindow]], 16 --[[ImGuiHoveredFlags.DockHierarchy]]))), - B(ImGui.IsWindowHovered(2 --[[ImGuiHoveredFlags.RootWindow]])), - B(ImGui.IsWindowHovered(bit32.bor(2 --[[ImGuiHoveredFlags.RootWindow]], 8 --[[ImGuiHoveredFlags.NoPopupHierarchy]]))), - B(ImGui.IsWindowHovered(bit32.bor(2 --[[ImGuiHoveredFlags.RootWindow]], 16 --[[ImGuiHoveredFlags.DockHierarchy]]))), - B(ImGui.IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]))), - B(ImGui.IsWindowHovered(4 --[[ImGuiHoveredFlags.AnyWindow]])), - B(ImGui.IsWindowHovered(8192 --[[ImGuiHoveredFlags.Stationary]]))) + B(ImGui_IsWindowHovered()), + B(ImGui_IsWindowHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]])), + B(ImGui_IsWindowHovered(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]])), + B(ImGui_IsWindowHovered(1 --[[ImGuiHoveredFlags.ChildWindows]])), + B(ImGui_IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 8 --[[ImGuiHoveredFlags.NoPopupHierarchy]]))), + B(ImGui_IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 16 --[[ImGuiHoveredFlags.DockHierarchy]]))), + B(ImGui_IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 2 --[[ImGuiHoveredFlags.RootWindow]]))), + B(ImGui_IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 2 --[[ImGuiHoveredFlags.RootWindow]], 8 --[[ImGuiHoveredFlags.NoPopupHierarchy]]))), + B(ImGui_IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 2 --[[ImGuiHoveredFlags.RootWindow]], 16 --[[ImGuiHoveredFlags.DockHierarchy]]))), + B(ImGui_IsWindowHovered(2 --[[ImGuiHoveredFlags.RootWindow]])), + B(ImGui_IsWindowHovered(bit32.bor(2 --[[ImGuiHoveredFlags.RootWindow]], 8 --[[ImGuiHoveredFlags.NoPopupHierarchy]]))), + B(ImGui_IsWindowHovered(bit32.bor(2 --[[ImGuiHoveredFlags.RootWindow]], 16 --[[ImGuiHoveredFlags.DockHierarchy]]))), + B(ImGui_IsWindowHovered(bit32.bor(1 --[[ImGuiHoveredFlags.ChildWindows]], 32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]))), + B(ImGui_IsWindowHovered(4 --[[ImGuiHoveredFlags.AnyWindow]])), + B(ImGui_IsWindowHovered(8192 --[[ImGuiHoveredFlags.Stationary]]))) - ImGui.BeginChild("child", ImVec2(0, 50), 1 --[[ImGuiChildFlags.Borders]]) - ImGui.Text("This is another child window for testing the _ChildWindows flag.") - ImGui.EndChild() + ImGui_BeginChild("child", ImVec2(0, 50), 1 --[[ImGuiChildFlags.Borders]]) + ImGui_Text("This is another child window for testing the _ChildWindows flag.") + ImGui_EndChild() if s.embed_all_inside_a_child_window then - ImGui.EndChild() + ImGui_EndChild() end -- Calling IsItemHovered() after begin returns the hovered status of the title bar. -- This is useful in particular if you want to create a context menu associated to the title bar of a window. -- This will also work when docked into a Tab (the Tab replace the Title Bar and guarantee the same properties). - _, s.test_window = ImGui.Checkbox("Hovered/Active tests after Begin() for title bar testing", s.test_window) + _, s.test_window = ImGui_Checkbox("Hovered/Active tests after Begin() for title bar testing", s.test_window) if s.test_window then -- FIXME-DOCK: This window cannot be docked within the ImGui Demo window, this will cause a feedback loop and get them stuck. -- Could we fix this through an ImGuiWindowClass feature? Or an API call to tag our parent as "don't skip items"? s.test_window = ImGui.Begin("Title bar Hovered/Active tests", s.test_window) - if ImGui.BeginPopupContextItem() then -- <-- This is using IsItemHovered() - if ImGui.MenuItem("Close") then s.test_window = false end - ImGui.EndPopup() + if ImGui_BeginPopupContextItem() then -- <-- This is using IsItemHovered() + if ImGui_MenuItem("Close") then s.test_window = false end + ImGui_EndPopup() end - ImGui.Text( + ImGui_Text( "IsItemHovered() after begin = %d (== is title bar hovered)\n" .. "IsItemActive() after begin = %d (== is window being clicked/moved)\n", - B(ImGui.IsItemHovered()), B(ImGui.IsItemActive())) + B(ImGui_IsItemHovered()), B(ImGui_IsItemActive())) ImGui.End() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -25315,15 +25371,15 @@ function DemoWindowWidgetsSelectables() IMGUI_DEMO_MARKER("Widgets/Selectables/Basic") if ImGui.TreeNode("Basic") then local selection = s.selection - if ImGui.Selectable("1. I am selectable", selection[1]) then selection[1] = not selection[1] end - if ImGui.Selectable("2. I am selectable", selection[2]) then selection[2] = not selection[2] end - if ImGui.Selectable("3. I am selectable", selection[3]) then selection[3] = not selection[3] end - if ImGui.Selectable("4. I am double clickable", selection[4], 4 --[[ImGuiSelectableFlags.AllowDoubleClick]]) then - if ImGui.IsMouseDoubleClicked(0) then + if ImGui_Selectable("1. I am selectable", selection[1]) then selection[1] = not selection[1] end + if ImGui_Selectable("2. I am selectable", selection[2]) then selection[2] = not selection[2] end + if ImGui_Selectable("3. I am selectable", selection[3]) then selection[3] = not selection[3] end + if ImGui_Selectable("4. I am double clickable", selection[4], 4 --[[ImGuiSelectableFlags.AllowDoubleClick]]) then + if ImGui_IsMouseDoubleClicked(0) then selection[4] = not selection[4] end end - ImGui.TreePop() + ImGui_TreePop() end IMGUI_DEMO_MARKER("Widgets/Selectables/Rendering more items on the same line") @@ -25333,66 +25389,66 @@ function DemoWindowWidgetsSelectables() -- - Using the Selectable() override that takes "bool* p_selected" parameter, the bool value is toggled automatically. do local selected = s.selected_multi - ImGui.SetNextItemAllowOverlap(); if ImGui.Selectable("main.c", selected[1]) then selected[1] = not selected[1] end; ImGui.SameLine(); ImGui.SmallButton("Link 1") - ImGui.SetNextItemAllowOverlap(); if ImGui.Selectable("hello.cpp", selected[2]) then selected[2] = not selected[2] end; ImGui.SameLine(); ImGui.SmallButton("Link 2") - ImGui.SetNextItemAllowOverlap(); if ImGui.Selectable("hello.h", selected[3]) then selected[3] = not selected[3] end; ImGui.SameLine(); ImGui.SmallButton("Link 3") + ImGui_SetNextItemAllowOverlap(); if ImGui_Selectable("main.c", selected[1]) then selected[1] = not selected[1] end; ImGui_SameLine(); ImGui_SmallButton("Link 1") + ImGui_SetNextItemAllowOverlap(); if ImGui_Selectable("hello.cpp", selected[2]) then selected[2] = not selected[2] end; ImGui_SameLine(); ImGui_SmallButton("Link 2") + ImGui_SetNextItemAllowOverlap(); if ImGui_Selectable("hello.h", selected[3]) then selected[3] = not selected[3] end; ImGui_SameLine(); ImGui_SmallButton("Link 3") end -- (2) -- - Using ImGuiSelectableFlags_AllowOverlap is a shortcut for calling SetNextItemAllowOverlap() -- - No visible label, display contents inside the selectable bounds. -- - We don't maintain actual selection in this example to keep things simple. - ImGui.Spacing() + ImGui_Spacing() do local checked = s.checked - local color_marker_w = ImGui.CalcTextSize("x").x + local color_marker_w = ImGui_CalcTextSize("x").x for n = 0, 4 do - ImGui.PushID(n) - ImGui.AlignTextToFramePadding() - if ImGui.Selectable("##selectable", s.selected_n == n, 16 --[[ImGuiSelectableFlags.AllowOverlap]]) then + ImGui_PushID(n) + ImGui_AlignTextToFramePadding() + if ImGui_Selectable("##selectable", s.selected_n == n, 16 --[[ImGuiSelectableFlags.AllowOverlap]]) then s.selected_n = n end - ImGui.SameLine(0, 0) - _, checked[n + 1] = ImGui.Checkbox("##check", checked[n + 1]) - ImGui.SameLine() + ImGui_SameLine(0, 0) + _, checked[n + 1] = ImGui_Checkbox("##check", checked[n + 1]) + ImGui_SameLine() local color = ImVec4(bit32.band(n, 1) ~= 0 and 1.0 or 0.2, bit32.band(n, 2) ~= 0 and 1.0 or 0.2, 0.2, 1.0) - ImGui.ColorButton("##color", color, 64 --[[ImGuiColorEditFlags.NoTooltip]], ImVec2(color_marker_w, 0)) - ImGui.SameLine() - ImGui.Text("Some label") - ImGui.PopID() + ImGui_ColorButton("##color", color, 64 --[[ImGuiColorEditFlags.NoTooltip]], ImVec2(color_marker_w, 0)) + ImGui_SameLine() + ImGui_Text("Some label") + ImGui_PopID() end end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("In Tables") then IMGUI_DEMO_MARKER("Widgets/Selectables/In Tables") local selected = s.selected_tables - if ImGui.BeginTable("split1", 3, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]], 1920 --[[ImGuiTableFlags.Borders]])) then + if ImGui_BeginTable("split1", 3, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]], 1920 --[[ImGuiTableFlags.Borders]])) then for i = 0, 9 do local label = string.format("Item %d", i) - ImGui.TableNextColumn() - if ImGui.Selectable(label, selected[i + 1]) then selected[i + 1] = not selected[i + 1] end -- FIXME-TABLE: Selection overlap + ImGui_TableNextColumn() + if ImGui_Selectable(label, selected[i + 1]) then selected[i + 1] = not selected[i + 1] end -- FIXME-TABLE: Selection overlap end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.Spacing() - if ImGui.BeginTable("split2", 3, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]], 1920 --[[ImGuiTableFlags.Borders]])) then + ImGui_Spacing() + if ImGui_BeginTable("split2", 3, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]], 1920 --[[ImGuiTableFlags.Borders]])) then for i = 0, 9 do local label = string.format("Item %d", i) - ImGui.TableNextRow() - ImGui.TableNextColumn() - if ImGui.Selectable(label, selected[i + 1], 2 --[[ImGuiSelectableFlags.SpanAllColumns]]) then selected[i + 1] = not selected[i + 1] end - ImGui.TableNextColumn() - ImGui.Text("Some other contents") - ImGui.TableNextColumn() - ImGui.Text("123456") + ImGui_TableNextRow() + ImGui_TableNextColumn() + if ImGui_Selectable(label, selected[i + 1], 2 --[[ImGuiSelectableFlags.SpanAllColumns]]) then selected[i + 1] = not selected[i + 1] end + ImGui_TableNextColumn() + ImGui_Text("Some other contents") + ImGui_TableNextColumn() + ImGui_Text("123456") end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Grid") then @@ -25400,21 +25456,21 @@ function DemoWindowWidgetsSelectables() local selected = s.selected_grid -- Add in a bit of silly fun... - local time = ImGui.GetTime() + local time = ImGui_GetTime() local winning_state = true -- If all cells are selected... for y = 1, 4 do for x = 1, 4 do if selected[y][x] == 0 then winning_state = false end end end -- [Port] memchr(selected, 0, sizeof(selected)) == NULL if winning_state then - ImGui.PushStyleVar(39 --[[ImGuiStyleVar.SelectableTextAlign]], ImVec2(0.5 + 0.5 * math.cos(time * 2.0), 0.5 + 0.5 * math.sin(time * 3.0))) + ImGui_PushStyleVar(39 --[[ImGuiStyleVar.SelectableTextAlign]], ImVec2(0.5 + 0.5 * math.cos(time * 2.0), 0.5 + 0.5 * math.sin(time * 3.0))) end - local size = ImGui.CalcTextSize("Sailor").x + local size = ImGui_CalcTextSize("Sailor").x for y = 0, 3 do for x = 0, 3 do if x > 0 then - ImGui.SameLine() + ImGui_SameLine() end - ImGui.PushID(y * 4 + x) - if ImGui.Selectable("Sailor", selected[y + 1][x + 1] ~= 0, 0, ImVec2(size, size)) then + ImGui_PushID(y * 4 + x) + if ImGui_Selectable("Sailor", selected[y + 1][x + 1] ~= 0, 0, ImVec2(size, size)) then -- Toggle clicked cell + toggle neighbors selected[y + 1][x + 1] = bit32.bxor(selected[y + 1][x + 1], 1) if x > 0 then selected[y + 1][x] = bit32.bxor(selected[y + 1][x], 1) end @@ -25422,14 +25478,14 @@ function DemoWindowWidgetsSelectables() if y > 0 then selected[y][x + 1] = bit32.bxor(selected[y][x + 1], 1) end if y < 3 then selected[y + 2][x + 1] = bit32.bxor(selected[y + 2][x + 1], 1) end end - ImGui.PopID() + ImGui_PopID() end end if winning_state then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Alignment") then IMGUI_DEMO_MARKER("Widgets/Selectables/Alignment") @@ -25439,21 +25495,21 @@ function DemoWindowWidgetsSelectables() "left-align otherwise it becomes difficult to layout multiple items on a same line") local selected = s.selected_align - local size = ImGui.CalcTextSize("(1.0,1.0)").x + local size = ImGui_CalcTextSize("(1.0,1.0)").x for y = 0, 2 do for x = 0, 2 do local alignment = ImVec2(x / 2.0, y / 2.0) local name = string.format("(%.1f,%.1f)", alignment.x, alignment.y) - if x > 0 then ImGui.SameLine() end - ImGui.PushStyleVar(39 --[[ImGuiStyleVar.SelectableTextAlign]], alignment) + if x > 0 then ImGui_SameLine() end + ImGui_PushStyleVar(39 --[[ImGuiStyleVar.SelectableTextAlign]], alignment) local idx = 3 * y + x + 1 - if ImGui.Selectable(name, selected[idx], 0 --[[ImGuiSelectableFlags.None]], ImVec2(size, size)) then selected[idx] = not selected[idx] end - ImGui.PopStyleVar() + if ImGui_Selectable(name, selected[idx], 0 --[[ImGuiSelectableFlags.None]], ImVec2(size, size)) then selected[idx] = not selected[idx] end + ImGui_PopStyleVar() end end - ImGui.TreePop() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -25605,11 +25661,11 @@ function ExampleDualListBoxMT:SortItems(n) end function ExampleDualListBoxMT:Show() --if (ImGui::Checkbox("Sorted", &OptKeepSorted) && OptKeepSorted) { SortItems(0); SortItems(1); } - if ImGui.BeginTable("split", 3, 0 --[[ImGuiTableFlags.None]]) then - ImGui.TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) -- Left side - ImGui.TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) -- Buttons - ImGui.TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) -- Right side - ImGui.TableNextRow() + if ImGui_BeginTable("split", 3, 0 --[[ImGuiTableFlags.None]]) then + ImGui_TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) -- Left side + ImGui_TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) -- Buttons + ImGui_TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) -- Right side + ImGui_TableNextRow() local request_move_selected = -1 local request_move_all = -1 @@ -25620,67 +25676,67 @@ function ExampleDualListBoxMT:Show() local items = self.Items[side + 1] local selection = self.Selections[side + 1] - ImGui.TableSetColumnIndex((side == 0) and 0 or 2) - ImGui.Text("%s (%d)", (side == 0) and "Available" or "Basket", items.Size) + ImGui_TableSetColumnIndex((side == 0) and 0 or 2) + ImGui_Text("%s (%d)", (side == 0) and "Available" or "Basket", items.Size) -- Submit scrolling range to avoid glitches on moving/deletion - local items_height = ImGui.GetTextLineHeightWithSpacing() - ImGui.SetNextWindowContentSize(ImVec2(0.0, items.Size * items_height)) + local items_height = ImGui_GetTextLineHeightWithSpacing() + ImGui_SetNextWindowContentSize(ImVec2(0.0, items.Size * items_height)) local child_visible if side == 0 then -- Left child is resizable - ImGui.SetNextWindowSizeConstraints(ImVec2(0.0, ImGui.GetFrameHeightWithSpacing() * 4), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]])) - child_visible = ImGui.BeginChild("0", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) - child_height_0 = ImGui.GetWindowSize().y + ImGui_SetNextWindowSizeConstraints(ImVec2(0.0, ImGui_GetFrameHeightWithSpacing() * 4), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]])) + child_visible = ImGui_BeginChild("0", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) + child_height_0 = ImGui_GetWindowSize().y else -- Right child use same height as left one - child_visible = ImGui.BeginChild("1", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], child_height_0), 128 --[[ImGuiChildFlags.FrameStyle]]) + child_visible = ImGui_BeginChild("1", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], child_height_0), 128 --[[ImGuiChildFlags.FrameStyle]]) end if child_visible then local flags = 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]] - local ms_io = ImGui.BeginMultiSelect(flags, selection.Size, items.Size) + local ms_io = ImGui_BeginMultiSelect(flags, selection.Size, items.Size) self:ApplySelectionRequests(ms_io, side) for item_n = 0, items.Size - 1 do local item_id = items.Data[item_n + 1] local item_is_selected = selection:Contains(item_id) - ImGui.SetNextItemSelectionUserData(item_n) - ImGui.Selectable(ExampleNames[item_id + 1], item_is_selected, 4 --[[ImGuiSelectableFlags.AllowDoubleClick]]) - if ImGui.IsItemFocused() then + ImGui_SetNextItemSelectionUserData(item_n) + ImGui_Selectable(ExampleNames[item_id + 1], item_is_selected, 4 --[[ImGuiSelectableFlags.AllowDoubleClick]]) + if ImGui_IsItemFocused() then -- FIXME-MULTISELECT: Dual List Box: Transfer focus - if ImGui.IsKeyPressed(525 --[[ImGuiKey.Enter]]) or ImGui.IsKeyPressed(627 --[[ImGuiKey.KeypadEnter]]) then + if ImGui_IsKeyPressed(525 --[[ImGuiKey.Enter]]) or ImGui_IsKeyPressed(627 --[[ImGuiKey.KeypadEnter]]) then request_move_selected = side end - if ImGui.IsMouseDoubleClicked(0) then -- FIXME-MULTISELECT: Double-click on multi-selection? + if ImGui_IsMouseDoubleClicked(0) then -- FIXME-MULTISELECT: Double-click on multi-selection? request_move_selected = side end end end - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() self:ApplySelectionRequests(ms_io, side) end - ImGui.EndChild() + ImGui_EndChild() end -- Buttons columns - ImGui.TableSetColumnIndex(1) - ImGui.NewLine() + ImGui_TableSetColumnIndex(1) + ImGui_NewLine() --ImVec2 button_sz = { ImGui::CalcTextSize(">>").x + ImGui::GetStyle().FramePadding.x * 2.0f, ImGui::GetFrameHeight() + padding.y * 2.0f }; - local button_sz = ImVec2(ImGui.GetFrameHeight(), ImGui.GetFrameHeight()) + local button_sz = ImVec2(ImGui_GetFrameHeight(), ImGui_GetFrameHeight()) -- (Using BeginDisabled()/EndDisabled() works but feels distracting given how it is currently visualized) - if ImGui.Button(">>", button_sz) then + if ImGui_Button(">>", button_sz) then request_move_all = 0 end - if ImGui.Button(">", button_sz) then + if ImGui_Button(">", button_sz) then request_move_selected = 0 end - if ImGui.Button("<", button_sz) then + if ImGui_Button("<", button_sz) then request_move_selected = 1 end - if ImGui.Button("<<", button_sz) then + if ImGui_Button("<<", button_sz) then request_move_all = 1 end @@ -25702,7 +25758,7 @@ function ExampleDualListBoxMT:Show() } ]] - ImGui.EndTable() + ImGui_EndTable() end end @@ -25722,14 +25778,14 @@ function ExampleTreeFuncs.DrawNode(node, selection) -- Using SetNextItemStorageID() to specify storage id, so we can easily peek into -- the storage holding open/close stage, using our TreeNodeGetOpen/TreeNodeSetOpen() functions. - ImGui.SetNextItemSelectionUserData(node) -- [Port] the node table itself is the selection user data (C++ casts the pointer) - ImGui.SetNextItemStorageID(node.UID) + ImGui_SetNextItemSelectionUserData(node) -- [Port] the node table itself is the selection user data (C++ casts the pointer) + ImGui_SetNextItemStorageID(node.UID) if ImGui.TreeNodeEx(node.Name, tree_node_flags) then for _, child in ipairs(node.Childs) do ExampleTreeFuncs.DrawNode(child, selection) end - ImGui.TreePop() - elseif ImGui.IsItemToggledOpen() then + ImGui_TreePop() + elseif ImGui_IsItemToggledOpen() then ExampleTreeFuncs.TreeCloseAndUnselectChildNodes(node, selection) end end @@ -25853,9 +25909,9 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) IMGUI_DEMO_MARKER("Widgets/Selection State & Multi-Select") HelpMarker("Selections can be built using Selectable(), TreeNode() or other widgets. Selection state is owned by application code/data.") - ImGui.BulletText("Wiki page:") - ImGui.SameLine() - ImGui.TextLinkOpenURL("imgui/wiki/Multi-Select", "https://github.com/ocornut/imgui/wiki/Multi-Select") + ImGui_BulletText("Wiki page:") + ImGui_SameLine() + ImGui_TextLinkOpenURL("imgui/wiki/Multi-Select", "https://github.com/ocornut/imgui/wiki/Multi-Select") -- Without any fancy API: manage single-selection yourself. if ImGui.TreeNode("Single-Select") then @@ -25863,11 +25919,11 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) local st = s.single_select for n = 0, 4 do local buf = string.format("Object %d", n) - if ImGui.Selectable(buf, st.selected == n) then + if ImGui_Selectable(buf, st.selected == n) then st.selected = n end end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate implementation a most-basic form of multi-selection manually @@ -25878,14 +25934,14 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) local selection = s.manual.selection for n = 0, 4 do local buf = string.format("Object %d", n) - if ImGui.Selectable(buf, selection[n + 1]) then - if not ImGui.GetIO().KeyCtrl then -- Clear selection when Ctrl is not held + if ImGui_Selectable(buf, selection[n + 1]) then + if not ImGui_GetIO().KeyCtrl then -- Clear selection when Ctrl is not held for i = 1, 5 do selection[i] = false end end selection[n + 1] = not selection[n + 1] -- Toggle current item end end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate handling proper multi-selection using the BeginMultiSelect/EndMultiSelect API. @@ -25893,38 +25949,38 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) -- We use the ImGuiSelectionBasicStorage helper which you may freely reimplement. if ImGui.TreeNode("Multi-Select") then IMGUI_DEMO_MARKER("Widgets/Selection State/Multi-Select") - ImGui.Text("Supported features:") - ImGui.BulletText("Keyboard navigation (arrows, page up/down, home/end, space).") - ImGui.BulletText("Ctrl modifier to preserve and toggle selection.") - ImGui.BulletText("Shift modifier for range selection.") - ImGui.BulletText("Ctrl+A to select all.") - ImGui.BulletText("Escape to clear selection.") - ImGui.BulletText("Click and drag to box-select.") - ImGui.Text("Tip: Use 'Demo->Tools->Debug Log->Selection' to see selection requests as they happen.") + ImGui_Text("Supported features:") + ImGui_BulletText("Keyboard navigation (arrows, page up/down, home/end, space).") + ImGui_BulletText("Ctrl modifier to preserve and toggle selection.") + ImGui_BulletText("Shift modifier for range selection.") + ImGui_BulletText("Ctrl+A to select all.") + ImGui_BulletText("Escape to clear selection.") + ImGui_BulletText("Click and drag to box-select.") + ImGui_Text("Tip: Use 'Demo->Tools->Debug Log->Selection' to see selection requests as they happen.") -- Use default selection.Adapter: Pass index to SetNextItemSelectionUserData(), store index in Selection local ITEMS_COUNT = 50 local selection = s.multi_select.selection - ImGui.Text("Selection: %d/%d", selection.Size, ITEMS_COUNT) + ImGui_Text("Selection: %d/%d", selection.Size, ITEMS_COUNT) -- The BeginChild() has no purpose for selection logic, other that offering a scrolling region. - if ImGui.BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then + if ImGui_BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then local flags = bit32.bor(512 --[[ImGuiMultiSelectFlags.ClearOnEscape]], 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) - local ms_io = ImGui.BeginMultiSelect(flags, selection.Size, ITEMS_COUNT) + local ms_io = ImGui_BeginMultiSelect(flags, selection.Size, ITEMS_COUNT) selection:ApplyRequests(ms_io) for n = 0, ITEMS_COUNT - 1 do local label = string.format("Object %05d: %s", n, ExampleNames[n % #ExampleNames + 1]) local item_is_selected = selection:Contains(n) - ImGui.SetNextItemSelectionUserData(n) - ImGui.Selectable(label, item_is_selected) + ImGui_SetNextItemSelectionUserData(n) + ImGui_Selectable(label, item_is_selected) end - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() selection:ApplyRequests(ms_io) end - ImGui.EndChild() - ImGui.TreePop() + ImGui_EndChild() + ImGui_TreePop() end -- Demonstrate using the clipper with BeginMultiSelect()/EndMultiSelect() @@ -25933,14 +25989,14 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) -- Use default selection.Adapter: Pass index to SetNextItemSelectionUserData(), store index in Selection local selection = s.with_clipper.selection - ImGui.Text("Added features:") - ImGui.BulletText("Using ImGuiListClipper.") + ImGui_Text("Added features:") + ImGui_BulletText("Using ImGuiListClipper.") local ITEMS_COUNT = 10000 - ImGui.Text("Selection: %d/%d", selection.Size, ITEMS_COUNT) - if ImGui.BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then + ImGui_Text("Selection: %d/%d", selection.Size, ITEMS_COUNT) + if ImGui_BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then local flags = bit32.bor(512 --[[ImGuiMultiSelectFlags.ClearOnEscape]], 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) - local ms_io = ImGui.BeginMultiSelect(flags, selection.Size, ITEMS_COUNT) + local ms_io = ImGui_BeginMultiSelect(flags, selection.Size, ITEMS_COUNT) selection:ApplyRequests(ms_io) local clipper = ImGuiListClipper() @@ -25952,16 +26008,16 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) for n = clipper.DisplayStart, clipper.DisplayEnd - 1 do local label = string.format("Object %05d: %s", n, ExampleNames[n % #ExampleNames + 1]) local item_is_selected = selection:Contains(n) - ImGui.SetNextItemSelectionUserData(n) - ImGui.Selectable(label, item_is_selected) + ImGui_SetNextItemSelectionUserData(n) + ImGui_Selectable(label, item_is_selected) end end - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() selection:ApplyRequests(ms_io) end - ImGui.EndChild() - ImGui.TreePop() + ImGui_EndChild() + ImGui_TreePop() end -- Demonstrate dynamic item list + deletion support using the BeginMultiSelect/EndMultiSelect API. @@ -25982,9 +26038,9 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) selection.UserData = items selection.AdapterIndexToStorageId = function(self, idx) local p_items = self.UserData; return p_items.Data[idx + 1] end -- Index -> ID - ImGui.Text("Added features:") - ImGui.BulletText("Dynamic list with Delete key support.") - ImGui.Text("Selection size: %d/%d", selection.Size, items.Size) + ImGui_Text("Added features:") + ImGui_BulletText("Dynamic list with Delete key support.") + ImGui_Text("Selection size: %d/%d", selection.Size, items.Size) -- Initialize default list with 50 items + button to add/remove items. if st.items_next_id == 0 then @@ -25992,20 +26048,20 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) items:push_back(st.items_next_id); st.items_next_id = st.items_next_id + 1 end end - if ImGui.SmallButton("Add 20 items") then for _ = 0, 19 do items:push_back(st.items_next_id); st.items_next_id = st.items_next_id + 1 end end - ImGui.SameLine() - if ImGui.SmallButton("Remove 20 items") then for _ = ImMin(20, items.Size), 1, -1 do selection:SetItemSelected(items:back(), false); items:pop_back() end end + if ImGui_SmallButton("Add 20 items") then for _ = 0, 19 do items:push_back(st.items_next_id); st.items_next_id = st.items_next_id + 1 end end + ImGui_SameLine() + if ImGui_SmallButton("Remove 20 items") then for _ = ImMin(20, items.Size), 1, -1 do selection:SetItemSelected(items:back(), false); items:pop_back() end end -- (1) Extra to support deletion: Submit scrolling range to avoid glitches on deletion - local items_height = ImGui.GetTextLineHeightWithSpacing() - ImGui.SetNextWindowContentSize(ImVec2(0.0, items.Size * items_height)) + local items_height = ImGui_GetTextLineHeightWithSpacing() + ImGui_SetNextWindowContentSize(ImVec2(0.0, items.Size * items_height)) - if ImGui.BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then + if ImGui_BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then local flags = bit32.bor(512 --[[ImGuiMultiSelectFlags.ClearOnEscape]], 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) - local ms_io = ImGui.BeginMultiSelect(flags, selection.Size, items.Size) + local ms_io = ImGui_BeginMultiSelect(flags, selection.Size, items.Size) selection:ApplyRequests(ms_io) - local want_delete = ImGui.Shortcut(522 --[[ImGuiKey.Delete]], 1 --[[ImGuiInputFlags.Repeat]]) and (selection.Size > 0) + local want_delete = ImGui_Shortcut(522 --[[ImGuiKey.Delete]], 1 --[[ImGuiInputFlags.Repeat]]) and (selection.Size > 0) local item_curr_idx_to_focus = -1 if want_delete then item_curr_idx_to_focus = selection:ApplyDeletionPreLoop(ms_io, items.Size) end @@ -26014,22 +26070,22 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) local label = string.format("Object %05d: %s", item_id, ExampleNames[item_id % #ExampleNames + 1]) -- [Port] %05u -> %05d local item_is_selected = selection:Contains(item_id) - ImGui.SetNextItemSelectionUserData(n) - ImGui.Selectable(label, item_is_selected) + ImGui_SetNextItemSelectionUserData(n) + ImGui_Selectable(label, item_is_selected) if item_curr_idx_to_focus == n then - ImGui.SetKeyboardFocusHere(-1) + ImGui_SetKeyboardFocusHere(-1) end end -- Apply multi-select requests - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() selection:ApplyRequests(ms_io) if want_delete then selection:ApplyDeletionPostLoop(ms_io, items, item_curr_idx_to_focus) end end - ImGui.EndChild() - ImGui.TreePop() + ImGui_EndChild() + ImGui_TreePop() end -- Implement a Dual List Box (#6648) @@ -26046,7 +26102,7 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) -- Show dlb:Show() - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate using the clipper with BeginMultiSelect()/EndMultiSelect() @@ -26055,15 +26111,15 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) local selection = s.in_a_table.selection local ITEMS_COUNT = 10000 - ImGui.Text("Selection: %d/%d", selection.Size, ITEMS_COUNT) - if ImGui.BeginTable("##Basket", 2, bit32.bor(33554432 --[[ImGuiTableFlags.ScrollY]], 64 --[[ImGuiTableFlags.RowBg]], 1280 --[[ImGuiTableFlags.BordersOuter]]), ImVec2(0.0, ImGui.GetFontSize() * 20)) then - ImGui.TableSetupColumn("Object") - ImGui.TableSetupColumn("Action") - ImGui.TableSetupScrollFreeze(0, 1) - ImGui.TableHeadersRow() + ImGui_Text("Selection: %d/%d", selection.Size, ITEMS_COUNT) + if ImGui_BeginTable("##Basket", 2, bit32.bor(33554432 --[[ImGuiTableFlags.ScrollY]], 64 --[[ImGuiTableFlags.RowBg]], 1280 --[[ImGuiTableFlags.BordersOuter]]), ImVec2(0.0, ImGui_GetFontSize() * 20)) then + ImGui_TableSetupColumn("Object") + ImGui_TableSetupColumn("Action") + ImGui_TableSetupScrollFreeze(0, 1) + ImGui_TableHeadersRow() local flags = bit32.bor(512 --[[ImGuiMultiSelectFlags.ClearOnEscape]], 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) - local ms_io = ImGui.BeginMultiSelect(flags, selection.Size, ITEMS_COUNT) + local ms_io = ImGui_BeginMultiSelect(flags, selection.Size, ITEMS_COUNT) selection:ApplyRequests(ms_io) local clipper = ImGuiListClipper() @@ -26073,57 +26129,57 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) end while clipper:Step() do for n = clipper.DisplayStart, clipper.DisplayEnd - 1 do - ImGui.TableNextRow() - ImGui.TableNextColumn() - ImGui.PushID(n) + ImGui_TableNextRow() + ImGui_TableNextColumn() + ImGui_PushID(n) local label = string.format("Object %05d: %s", n, ExampleNames[n % #ExampleNames + 1]) local item_is_selected = selection:Contains(n) - ImGui.SetNextItemSelectionUserData(n) - ImGui.Selectable(label, item_is_selected, bit32.bor(2 --[[ImGuiSelectableFlags.SpanAllColumns]], 16 --[[ImGuiSelectableFlags.AllowOverlap]])) - ImGui.TableNextColumn() - ImGui.SmallButton("hello") - ImGui.PopID() + ImGui_SetNextItemSelectionUserData(n) + ImGui_Selectable(label, item_is_selected, bit32.bor(2 --[[ImGuiSelectableFlags.SpanAllColumns]], 16 --[[ImGuiSelectableFlags.AllowOverlap]])) + ImGui_TableNextColumn() + ImGui_SmallButton("hello") + ImGui_PopID() end end - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() selection:ApplyRequests(ms_io) - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Multi-Select (checkboxes)") then IMGUI_DEMO_MARKER("Widgets/Selection State/Multi-Select (checkboxes)") - ImGui.Text("In a list of checkboxes (not selectable):") - ImGui.BulletText("Using _NoAutoSelect + _NoAutoClear flags.") - ImGui.BulletText("Shift+Click to check multiple boxes.") - ImGui.BulletText("Shift+Keyboard to copy current value to other boxes.") + ImGui_Text("In a list of checkboxes (not selectable):") + ImGui_BulletText("Using _NoAutoSelect + _NoAutoClear flags.") + ImGui_BulletText("Shift+Click to check multiple boxes.") + ImGui_BulletText("Shift+Keyboard to copy current value to other boxes.") -- If you have an array of checkboxes, you may want to use NoAutoSelect + NoAutoClear and the ImGuiSelectionExternalStorage helper. local st = s.checkboxes local items = st.items - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", st.flags, 8 --[[ImGuiMultiSelectFlags.NoAutoSelect]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", st.flags, 16 --[[ImGuiMultiSelectFlags.NoAutoClear]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect2d", st.flags, 128 --[[ImGuiMultiSelectFlags.BoxSelect2d]]) -- Cannot use ImGuiMultiSelectFlags_BoxSelect1d as checkboxes are varying width. + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", st.flags, 8 --[[ImGuiMultiSelectFlags.NoAutoSelect]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", st.flags, 16 --[[ImGuiMultiSelectFlags.NoAutoClear]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect2d", st.flags, 128 --[[ImGuiMultiSelectFlags.BoxSelect2d]]) -- Cannot use ImGuiMultiSelectFlags_BoxSelect1d as checkboxes are varying width. - if ImGui.BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetFontSize() * 20), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 8 --[[ImGuiChildFlags.ResizeY]])) then - local ms_io = ImGui.BeginMultiSelect(st.flags, -1, #items) + if ImGui_BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetFontSize() * 20), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 8 --[[ImGuiChildFlags.ResizeY]])) then + local ms_io = ImGui_BeginMultiSelect(st.flags, -1, #items) local storage_wrapper = ImGuiSelectionExternalStorage() storage_wrapper.UserData = items storage_wrapper.AdapterSetItemSelected = function(self, n, selected) local array = self.UserData; array[n + 1] = selected end storage_wrapper:ApplyRequests(ms_io) for n = 0, 19 do local label = string.format("Item %d", n) - ImGui.SetNextItemSelectionUserData(n) - _, items[n + 1] = ImGui.Checkbox(label, items[n + 1]) + ImGui_SetNextItemSelectionUserData(n) + _, items[n + 1] = ImGui_Checkbox(label, items[n + 1]) end - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() storage_wrapper:ApplyRequests(ms_io) end - ImGui.EndChild() + ImGui_EndChild() - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate individual selection scopes in same window @@ -26137,46 +26193,46 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) -- Use ImGuiMultiSelectFlags_ScopeRect to not affect other selections in same window. local pressed - pressed, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_ScopeWindow", st.flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) + pressed, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_ScopeWindow", st.flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) if pressed and bit32.band(st.flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) ~= 0 then st.flags = bit32.band(st.flags, bit32.bnot(4096 --[[ImGuiMultiSelectFlags.ScopeRect]])) end - pressed, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_ScopeRect", st.flags, 4096 --[[ImGuiMultiSelectFlags.ScopeRect]]) + pressed, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_ScopeRect", st.flags, 4096 --[[ImGuiMultiSelectFlags.ScopeRect]]) if pressed and bit32.band(st.flags, 4096 --[[ImGuiMultiSelectFlags.ScopeRect]]) ~= 0 then st.flags = bit32.band(st.flags, bit32.bnot(2048 --[[ImGuiMultiSelectFlags.ScopeWindow]])) end - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", st.flags, 1024 --[[ImGuiMultiSelectFlags.ClearOnClickVoid]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect1d", st.flags, 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", st.flags, 1024 --[[ImGuiMultiSelectFlags.ClearOnClickVoid]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect1d", st.flags, 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) for selection_scope_n = 0, SCOPES_COUNT - 1 do - ImGui.PushID(selection_scope_n) + ImGui_PushID(selection_scope_n) local selection = selections_data[selection_scope_n + 1] - local ms_io = ImGui.BeginMultiSelect(st.flags, selection.Size, ITEMS_COUNT) + local ms_io = ImGui_BeginMultiSelect(st.flags, selection.Size, ITEMS_COUNT) selection:ApplyRequests(ms_io) - ImGui.SeparatorText("Selection scope") - ImGui.Text("Selection size: %d/%d", selection.Size, ITEMS_COUNT) + ImGui_SeparatorText("Selection scope") + ImGui_Text("Selection size: %d/%d", selection.Size, ITEMS_COUNT) for n = 0, ITEMS_COUNT - 1 do local label = string.format("Object %05d: %s", n, ExampleNames[n % #ExampleNames + 1]) local item_is_selected = selection:Contains(n) - ImGui.SetNextItemSelectionUserData(n) - ImGui.Selectable(label, item_is_selected) + ImGui_SetNextItemSelectionUserData(n) + ImGui_Selectable(label, item_is_selected) end -- Apply multi-select requests - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() selection:ApplyRequests(ms_io) - ImGui.PopID() + ImGui_PopID() end - ImGui.TreePop() + ImGui_TreePop() end -- See ShowExampleAppAssetsBrowser() if ImGui.TreeNode("Multi-Select (tiled assets browser)") then - _, demo_data.ShowAppAssetsBrowser = ImGui.Checkbox("Assets Browser", demo_data.ShowAppAssetsBrowser) - ImGui.Text("(also access from 'Examples->Assets Browser' in menu)") - ImGui.TreePop() + _, demo_data.ShowAppAssetsBrowser = ImGui_Checkbox("Assets Browser", demo_data.ShowAppAssetsBrowser) + ImGui_Text("(also access from 'Examples->Assets Browser' in menu)") + ImGui_TreePop() end -- Demonstrate supporting multiple-selection in a tree. @@ -26202,22 +26258,22 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) if demo_data.DemoTree == nil then demo_data.DemoTree = ExampleTree_CreateDemoTree() -- Create tree once end - ImGui.Text("Selection size: %d", selection.Size) + ImGui_Text("Selection size: %d", selection.Size) - if ImGui.BeginChild("##Tree", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then + if ImGui_BeginChild("##Tree", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then local tree = demo_data.DemoTree local ms_flags = bit32.bor(512 --[[ImGuiMultiSelectFlags.ClearOnEscape]], 128 --[[ImGuiMultiSelectFlags.BoxSelect2d]]) - local ms_io = ImGui.BeginMultiSelect(ms_flags, selection.Size, -1) + local ms_io = ImGui_BeginMultiSelect(ms_flags, selection.Size, -1) ExampleTreeFuncs.ApplySelectionRequests(ms_io, tree, selection) for _, node in ipairs(tree.Childs) do ExampleTreeFuncs.DrawNode(node, selection) end - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() ExampleTreeFuncs.ApplySelectionRequests(ms_io, tree, selection) end - ImGui.EndChild() + ImGui_EndChild() - ImGui.TreePop() + ImGui_TreePop() end -- Advanced demonstration of BeginMultiSelect() @@ -26234,53 +26290,53 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) local st = s.advanced if ImGui.TreeNode("Options") then - if ImGui.RadioButtonEx("Selectables", st.widget_type == WidgetType_Selectable) then st.widget_type = WidgetType_Selectable end -- [Port] RadioButton(label, bool) -> RadioButtonEx - ImGui.SameLine() - if ImGui.RadioButtonEx("Tree nodes", st.widget_type == WidgetType_TreeNode) then st.widget_type = WidgetType_TreeNode end - ImGui.SameLine() + if ImGui_RadioButtonEx("Selectables", st.widget_type == WidgetType_Selectable) then st.widget_type = WidgetType_Selectable end -- [Port] RadioButton(label, bool) -> RadioButtonEx + ImGui_SameLine() + if ImGui_RadioButtonEx("Tree nodes", st.widget_type == WidgetType_TreeNode) then st.widget_type = WidgetType_TreeNode end + ImGui_SameLine() HelpMarker("TreeNode() is technically supported but... using this correctly is more complicated (you need some sort of linear/random access to your tree, which is suited to advanced trees setups already implementing filters and clipper. We will work toward simplifying and demoing this.\n\nFor now the tree demo is actually a little bit meaningless because it is an empty tree with only root nodes.") - _, st.use_clipper = ImGui.Checkbox("Enable clipper", st.use_clipper) - _, st.use_deletion = ImGui.Checkbox("Enable deletion", st.use_deletion) - _, st.use_drag_drop = ImGui.Checkbox("Enable drag & drop", st.use_drag_drop) - _, st.show_in_table = ImGui.Checkbox("Show in a table", st.show_in_table) - _, st.show_color_button = ImGui.Checkbox("Show color button", st.show_color_button) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_SingleSelect", st.flags, 1 --[[ImGuiMultiSelectFlags.SingleSelect]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoSelectAll", st.flags, 2 --[[ImGuiMultiSelectFlags.NoSelectAll]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoRangeSelect", st.flags, 4 --[[ImGuiMultiSelectFlags.NoRangeSelect]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", st.flags, 8 --[[ImGuiMultiSelectFlags.NoAutoSelect]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", st.flags, 16 --[[ImGuiMultiSelectFlags.NoAutoClear]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClearOnReselect", st.flags, 32 --[[ImGuiMultiSelectFlags.NoAutoClearOnReselect]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_NoSelectOnRightClick", st.flags, 131072 --[[ImGuiMultiSelectFlags.NoSelectOnRightClick]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect1d", st.flags, 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect2d", st.flags, 128 --[[ImGuiMultiSelectFlags.BoxSelect2d]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_BoxSelectNoScroll", st.flags, 256 --[[ImGuiMultiSelectFlags.BoxSelectNoScroll]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_ClearOnEscape", st.flags, 512 --[[ImGuiMultiSelectFlags.ClearOnEscape]]) - _, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", st.flags, 1024 --[[ImGuiMultiSelectFlags.ClearOnClickVoid]]) + _, st.use_clipper = ImGui_Checkbox("Enable clipper", st.use_clipper) + _, st.use_deletion = ImGui_Checkbox("Enable deletion", st.use_deletion) + _, st.use_drag_drop = ImGui_Checkbox("Enable drag & drop", st.use_drag_drop) + _, st.show_in_table = ImGui_Checkbox("Show in a table", st.show_in_table) + _, st.show_color_button = ImGui_Checkbox("Show color button", st.show_color_button) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_SingleSelect", st.flags, 1 --[[ImGuiMultiSelectFlags.SingleSelect]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoSelectAll", st.flags, 2 --[[ImGuiMultiSelectFlags.NoSelectAll]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoRangeSelect", st.flags, 4 --[[ImGuiMultiSelectFlags.NoRangeSelect]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", st.flags, 8 --[[ImGuiMultiSelectFlags.NoAutoSelect]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", st.flags, 16 --[[ImGuiMultiSelectFlags.NoAutoClear]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClearOnReselect", st.flags, 32 --[[ImGuiMultiSelectFlags.NoAutoClearOnReselect]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_NoSelectOnRightClick", st.flags, 131072 --[[ImGuiMultiSelectFlags.NoSelectOnRightClick]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect1d", st.flags, 64 --[[ImGuiMultiSelectFlags.BoxSelect1d]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect2d", st.flags, 128 --[[ImGuiMultiSelectFlags.BoxSelect2d]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_BoxSelectNoScroll", st.flags, 256 --[[ImGuiMultiSelectFlags.BoxSelectNoScroll]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_ClearOnEscape", st.flags, 512 --[[ImGuiMultiSelectFlags.ClearOnEscape]]) + _, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_ClearOnClickVoid", st.flags, 1024 --[[ImGuiMultiSelectFlags.ClearOnClickVoid]]) local pressed - pressed, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_ScopeWindow", st.flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) + pressed, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_ScopeWindow", st.flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) if pressed and bit32.band(st.flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) ~= 0 then st.flags = bit32.band(st.flags, bit32.bnot(4096 --[[ImGuiMultiSelectFlags.ScopeRect]])) end - pressed, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_ScopeRect", st.flags, 4096 --[[ImGuiMultiSelectFlags.ScopeRect]]) + pressed, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_ScopeRect", st.flags, 4096 --[[ImGuiMultiSelectFlags.ScopeRect]]) if pressed and bit32.band(st.flags, 4096 --[[ImGuiMultiSelectFlags.ScopeRect]]) ~= 0 then st.flags = bit32.band(st.flags, bit32.bnot(2048 --[[ImGuiMultiSelectFlags.ScopeWindow]])) end - pressed, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_SelectOnAuto", st.flags, 8192 --[[ImGuiMultiSelectFlags.SelectOnAuto]]) + pressed, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_SelectOnAuto", st.flags, 8192 --[[ImGuiMultiSelectFlags.SelectOnAuto]]) if pressed then st.flags = bit32.band(st.flags, bit32.bnot(bit32.bxor(57344 --[[ImGuiMultiSelectFlags.SelectOnMask_]], 8192 --[[ImGuiMultiSelectFlags.SelectOnAuto]]))) end - ImGui.SameLine(); HelpMarker("Apply selection on mouse down when clicking on unselected item, on mouse up when clicking on selected item. (Default)") - pressed, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_SelectOnClickAlways", st.flags, 16384 --[[ImGuiMultiSelectFlags.SelectOnClickAlways]]) + ImGui_SameLine(); HelpMarker("Apply selection on mouse down when clicking on unselected item, on mouse up when clicking on selected item. (Default)") + pressed, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_SelectOnClickAlways", st.flags, 16384 --[[ImGuiMultiSelectFlags.SelectOnClickAlways]]) if pressed then st.flags = bit32.band(st.flags, bit32.bnot(bit32.bxor(57344 --[[ImGuiMultiSelectFlags.SelectOnMask_]], 16384 --[[ImGuiMultiSelectFlags.SelectOnClickAlways]]))) end - ImGui.SameLine(); HelpMarker("Prevents Drag and Drop from being used on multi-selection, but allows e.g. BoxSelect to always reselect even when clicking inside an existing selection. (Excel style behavior)") - pressed, st.flags = ImGui.CheckboxFlags("ImGuiMultiSelectFlags_SelectOnClickRelease", st.flags, 32768 --[[ImGuiMultiSelectFlags.SelectOnClickRelease]]) + ImGui_SameLine(); HelpMarker("Prevents Drag and Drop from being used on multi-selection, but allows e.g. BoxSelect to always reselect even when clicking inside an existing selection. (Excel style behavior)") + pressed, st.flags = ImGui_CheckboxFlags("ImGuiMultiSelectFlags_SelectOnClickRelease", st.flags, 32768 --[[ImGuiMultiSelectFlags.SelectOnClickRelease]]) if pressed then st.flags = bit32.band(st.flags, bit32.bnot(bit32.bxor(57344 --[[ImGuiMultiSelectFlags.SelectOnMask_]], 32768 --[[ImGuiMultiSelectFlags.SelectOnClickRelease]]))) end - ImGui.SameLine(); HelpMarker("Allow dragging an unselected item without altering selection.") - ImGui.TreePop() + ImGui_SameLine(); HelpMarker("Allow dragging an unselected item without altering selection.") + ImGui_TreePop() end -- Initialize default list with 1000 items. @@ -26289,31 +26345,31 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) if st.items_next_id == 0 then for _ = 0, 999 do items:push_back(st.items_next_id); st.items_next_id = st.items_next_id + 1 end end local selection = st.selection - ImGui.Text("Selection size: %d/%d", selection.Size, items.Size) + ImGui_Text("Selection size: %d/%d", selection.Size, items.Size) - local items_height = (st.widget_type == WidgetType_TreeNode) and ImGui.GetTextLineHeight() or ImGui.GetTextLineHeightWithSpacing() - ImGui.SetNextWindowContentSize(ImVec2(0.0, items.Size * items_height)) - if ImGui.BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then - local color_button_sz = ImVec2(ImGui.GetFontSize(), ImGui.GetFontSize()) + local items_height = (st.widget_type == WidgetType_TreeNode) and ImGui_GetTextLineHeight() or ImGui_GetTextLineHeightWithSpacing() + ImGui_SetNextWindowContentSize(ImVec2(0.0, items.Size * items_height)) + if ImGui_BeginChild("##Basket", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetFontSize() * 20), bit32.bor(128 --[[ImGuiChildFlags.FrameStyle]], 8 --[[ImGuiChildFlags.ResizeY]])) then + local color_button_sz = ImVec2(ImGui_GetFontSize(), ImGui_GetFontSize()) if st.widget_type == WidgetType_TreeNode then - ImGui.PushStyleVarY(14 --[[ImGuiStyleVar.ItemSpacing]], 0.0) + ImGui_PushStyleVarY(14 --[[ImGuiStyleVar.ItemSpacing]], 0.0) end - local ms_io = ImGui.BeginMultiSelect(st.flags, selection.Size, items.Size) + local ms_io = ImGui_BeginMultiSelect(st.flags, selection.Size, items.Size) selection:ApplyRequests(ms_io) - local want_delete = (ImGui.Shortcut(522 --[[ImGuiKey.Delete]], 1 --[[ImGuiInputFlags.Repeat]]) and (selection.Size > 0)) or st.request_deletion_from_menu + local want_delete = (ImGui_Shortcut(522 --[[ImGuiKey.Delete]], 1 --[[ImGuiInputFlags.Repeat]]) and (selection.Size > 0)) or st.request_deletion_from_menu local item_curr_idx_to_focus = -1 if want_delete then item_curr_idx_to_focus = selection:ApplyDeletionPreLoop(ms_io, items.Size) end st.request_deletion_from_menu = false if st.show_in_table then if st.widget_type == WidgetType_TreeNode then - ImGui.PushStyleVar(17 --[[ImGuiStyleVar.CellPadding]], ImVec2(0.0, 0.0)) + ImGui_PushStyleVar(17 --[[ImGuiStyleVar.CellPadding]], ImVec2(0.0, 0.0)) end - ImGui.BeginTable("##Split", 2, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]], 4194304 --[[ImGuiTableFlags.NoPadOuterX]])) - ImGui.TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]], 0.70) - ImGui.TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]], 0.30) + ImGui_BeginTable("##Split", 2, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]], 4194304 --[[ImGuiTableFlags.NoPadOuterX]])) + ImGui_TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]], 0.70) + ImGui_TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]], 0.30) --ImGui::PushStyleVarY(ImGuiStyleVar_ItemSpacing, 0.0f); end @@ -26333,7 +26389,7 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) local item_end = st.use_clipper and clipper.DisplayEnd or items.Size for n = item_begin, item_end - 1 do if st.show_in_table then - ImGui.TableNextColumn() + ImGui_TableNextColumn() end local item_id = items.Data[n + 1] @@ -26344,22 +26400,22 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) -- aka not depend on their index in the list. Here we use our persistent item_id -- instead of index to build a unique ID that will persist. -- (If we used PushID(index) instead, focus wouldn't be restored correctly after deletion). - ImGui.PushID(item_id) + ImGui_PushID(item_id) -- Emit a color button, to test that Shift+LeftArrow landing on an item that is not part -- of the selection scope doesn't erroneously alter our selection. if st.show_color_button then local dummy_col = bit32.bor((n * 0xC250B74B) % 4294967296, 4278190080 --[[IM_COL32_A_MASK]]) -- [Port] unsigned 32-bit wrap-around - ImGui.ColorButton("##", ImColor(dummy_col).Value, 64 --[[ImGuiColorEditFlags.NoTooltip]], color_button_sz) - ImGui.SameLine() + ImGui_ColorButton("##", ImColor(dummy_col).Value, 64 --[[ImGuiColorEditFlags.NoTooltip]], color_button_sz) + ImGui_SameLine() end -- Submit item local item_is_selected = selection:Contains(n) local item_is_open = false - ImGui.SetNextItemSelectionUserData(n) + ImGui_SetNextItemSelectionUserData(n) if st.widget_type == WidgetType_Selectable then - ImGui.Selectable(label, item_is_selected, 0 --[[ImGuiSelectableFlags.None]]) + ImGui_Selectable(label, item_is_selected, 0 --[[ImGuiSelectableFlags.None]]) elseif st.widget_type == WidgetType_TreeNode then local tree_node_flags = bit32.bor(2048 --[[ImGuiTreeNodeFlags.SpanAvailWidth]], 128 --[[ImGuiTreeNodeFlags.OpenOnArrow]], 64 --[[ImGuiTreeNodeFlags.OpenOnDoubleClick]]) if item_is_selected then @@ -26370,14 +26426,14 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) -- Focus (for after deletion) if item_curr_idx_to_focus == n then - ImGui.SetKeyboardFocusHere(-1) + ImGui_SetKeyboardFocusHere(-1) end -- Drag and Drop - if st.use_drag_drop and ImGui.BeginDragDropSource() then + if st.use_drag_drop and ImGui_BeginDragDropSource() then -- Create payload with full selection OR single unselected item. -- (the later is only possible when using ImGuiMultiSelectFlags_SelectOnClickRelease) - if ImGui.GetDragDropPayload() == nil then + if ImGui_GetDragDropPayload() == nil then local payload_items = ImVector() local it = nil local id = 0 @@ -26391,51 +26447,51 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) payload_items:push_back(id) end end - ImGui.SetDragDropPayload("MULTISELECT_DEMO_ITEMS", payload_items.Data, payload_items.Size * 4) -- [Port] size_in_bytes() = Size * sizeof(int), payload carries the Lua array + ImGui_SetDragDropPayload("MULTISELECT_DEMO_ITEMS", payload_items.Data, payload_items.Size * 4) -- [Port] size_in_bytes() = Size * sizeof(int), payload carries the Lua array end -- Display payload content in tooltip - local payload = ImGui.GetDragDropPayload() + local payload = ImGui_GetDragDropPayload() local payload_items = payload.Data local payload_count = math.floor(payload.DataSize / 4) -- [Port] sizeof(int) = 4 if payload_count == 1 then - ImGui.Text("Object %05d: %s", payload_items[1], ExampleNames[payload_items[1] % #ExampleNames + 1]) + ImGui_Text("Object %05d: %s", payload_items[1], ExampleNames[payload_items[1] % #ExampleNames + 1]) else - ImGui.Text("Dragging %d objects", payload_count) + ImGui_Text("Dragging %d objects", payload_count) end - ImGui.EndDragDropSource() + ImGui_EndDragDropSource() end if st.widget_type == WidgetType_TreeNode and item_is_open then - ImGui.TreePop() + ImGui_TreePop() end -- Right-click: context menu - if ImGui.BeginPopupContextItem() then - ImGui.BeginDisabled(not st.use_deletion or selection.Size == 0) + if ImGui_BeginPopupContextItem() then + ImGui_BeginDisabled(not st.use_deletion or selection.Size == 0) label = string.format("Delete %d item(s)###DeleteSelected", selection.Size) - if ImGui.Selectable(label) then + if ImGui_Selectable(label) then st.request_deletion_from_menu = true end - ImGui.EndDisabled() - ImGui.Selectable("Close") - ImGui.EndPopup() + ImGui_EndDisabled() + ImGui_Selectable("Close") + ImGui_EndPopup() end -- Demo content within a table if st.show_in_table then - ImGui.TableNextColumn() - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) - ImGui.PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0, 0)) + ImGui_TableNextColumn() + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0, 0)) -- [Port] InputText() needs a byte buffer: one cached read-only buffer per category (buf_size includes the terminator) local category_buf = st.item_category_bufs[item_category] - if category_buf == nil then category_buf = ImGui.NewTextBuffer(item_category, #item_category + 1); st.item_category_bufs[item_category] = category_buf end - ImGui.InputText("##NoLabel", category_buf, #item_category + 1, 512 --[[ImGuiInputTextFlags.ReadOnly]]) - ImGui.PopStyleVar() + if category_buf == nil then category_buf = ImGui_NewTextBuffer(item_category, #item_category + 1); st.item_category_bufs[item_category] = category_buf end + ImGui_InputText("##NoLabel", category_buf, #item_category + 1, 512 --[[ImGuiInputTextFlags.ReadOnly]]) + ImGui_PopStyleVar() end - ImGui.PopID() + ImGui_PopID() end if not st.use_clipper then break @@ -26443,27 +26499,27 @@ function DemoWindowWidgetsSelectionAndMultiSelect(demo_data) end if st.show_in_table then - ImGui.EndTable() + ImGui_EndTable() if st.widget_type == WidgetType_TreeNode then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end end -- Apply multi-select requests - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() selection:ApplyRequests(ms_io) if want_delete then selection:ApplyDeletionPostLoop(ms_io, items, item_curr_idx_to_focus) end if st.widget_type == WidgetType_TreeNode then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end end - ImGui.EndChild() - ImGui.TreePop() + ImGui_EndChild() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -26477,15 +26533,15 @@ function EditTabBarFittingPolicyFlags(p_flags) p_flags = bit32.bor(p_flags, 128 --[[ImGuiTabBarFlags.FittingPolicyDefault_]]) end local pressed - pressed, p_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_FittingPolicyMixed", p_flags, 128 --[[ImGuiTabBarFlags.FittingPolicyMixed]]) + pressed, p_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_FittingPolicyMixed", p_flags, 128 --[[ImGuiTabBarFlags.FittingPolicyMixed]]) if pressed then p_flags = bit32.band(p_flags, bit32.bnot(bit32.bxor(896 --[[ImGuiTabBarFlags.FittingPolicyMask_]], 128 --[[ImGuiTabBarFlags.FittingPolicyMixed]]))) end - pressed, p_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_FittingPolicyShrink", p_flags, 256 --[[ImGuiTabBarFlags.FittingPolicyShrink]]) + pressed, p_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_FittingPolicyShrink", p_flags, 256 --[[ImGuiTabBarFlags.FittingPolicyShrink]]) if pressed then p_flags = bit32.band(p_flags, bit32.bnot(bit32.bxor(896 --[[ImGuiTabBarFlags.FittingPolicyMask_]], 256 --[[ImGuiTabBarFlags.FittingPolicyShrink]]))) end - pressed, p_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", p_flags, 512 --[[ImGuiTabBarFlags.FittingPolicyScroll]]) + pressed, p_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", p_flags, 512 --[[ImGuiTabBarFlags.FittingPolicyScroll]]) if pressed then p_flags = bit32.band(p_flags, bit32.bnot(bit32.bxor(896 --[[ImGuiTabBarFlags.FittingPolicyMask_]], 512 --[[ImGuiTabBarFlags.FittingPolicyScroll]]))) end @@ -26509,65 +26565,65 @@ function DemoWindowWidgetsTabs() if ImGui.TreeNode("Basic") then IMGUI_DEMO_MARKER("Widgets/Tabs/Basic") local tab_bar_flags = 0 --[[ImGuiTabBarFlags.None]] - if ImGui.BeginTabBar("MyTabBar", tab_bar_flags) then + if ImGui_BeginTabBar("MyTabBar", tab_bar_flags) then if ImGui.BeginTabItem("Avocado") then - ImGui.Text("This is the Avocado tab!\nblah blah blah blah blah") - ImGui.EndTabItem() + ImGui_Text("This is the Avocado tab!\nblah blah blah blah blah") + ImGui_EndTabItem() end if ImGui.BeginTabItem("Broccoli") then - ImGui.Text("This is the Broccoli tab!\nblah blah blah blah blah") - ImGui.EndTabItem() + ImGui_Text("This is the Broccoli tab!\nblah blah blah blah blah") + ImGui_EndTabItem() end if ImGui.BeginTabItem("Cucumber") then - ImGui.Text("This is the Cucumber tab!\nblah blah blah blah blah") - ImGui.EndTabItem() + ImGui_Text("This is the Cucumber tab!\nblah blah blah blah blah") + ImGui_EndTabItem() end - ImGui.EndTabBar() + ImGui_EndTabBar() end - ImGui.Separator() - ImGui.TreePop() + ImGui_Separator() + ImGui_TreePop() end if ImGui.TreeNode("Advanced & Close Button") then IMGUI_DEMO_MARKER("Widgets/Tabs/Advanced & Close Button") -- Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0). - _, s.tab_bar_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_Reorderable", s.tab_bar_flags, 1 --[[ImGuiTabBarFlags.Reorderable]]) - _, s.tab_bar_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", s.tab_bar_flags, 2 --[[ImGuiTabBarFlags.AutoSelectNewTabs]]) - _, s.tab_bar_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", s.tab_bar_flags, 4 --[[ImGuiTabBarFlags.TabListPopupButton]]) - _, s.tab_bar_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", s.tab_bar_flags, 8 --[[ImGuiTabBarFlags.NoCloseWithMiddleMouseButton]]) - _, s.tab_bar_flags = ImGui.CheckboxFlags("ImGuiTabBarFlags_DrawSelectedOverline", s.tab_bar_flags, 64 --[[ImGuiTabBarFlags.DrawSelectedOverline]]) + _, s.tab_bar_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_Reorderable", s.tab_bar_flags, 1 --[[ImGuiTabBarFlags.Reorderable]]) + _, s.tab_bar_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", s.tab_bar_flags, 2 --[[ImGuiTabBarFlags.AutoSelectNewTabs]]) + _, s.tab_bar_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", s.tab_bar_flags, 4 --[[ImGuiTabBarFlags.TabListPopupButton]]) + _, s.tab_bar_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", s.tab_bar_flags, 8 --[[ImGuiTabBarFlags.NoCloseWithMiddleMouseButton]]) + _, s.tab_bar_flags = ImGui_CheckboxFlags("ImGuiTabBarFlags_DrawSelectedOverline", s.tab_bar_flags, 64 --[[ImGuiTabBarFlags.DrawSelectedOverline]]) s.tab_bar_flags = EditTabBarFittingPolicyFlags(s.tab_bar_flags) -- Tab Bar - ImGui.AlignTextToFramePadding() - ImGui.Text("Opened:") + ImGui_AlignTextToFramePadding() + ImGui_Text("Opened:") local names = { "Artichoke", "Beetroot", "Celery", "Daikon" } local opened = s.opened -- Persistent user state for n = 0, #opened - 1 do - ImGui.SameLine() - _, opened[n + 1] = ImGui.Checkbox(names[n + 1], opened[n + 1]) + ImGui_SameLine() + _, opened[n + 1] = ImGui_Checkbox(names[n + 1], opened[n + 1]) end -- Passing a bool* to BeginTabItem() is similar to passing one to Begin(): -- the underlying bool will be set to false when the tab is closed. - if ImGui.BeginTabBar("MyTabBar", s.tab_bar_flags) then + if ImGui_BeginTabBar("MyTabBar", s.tab_bar_flags) then for n = 0, #opened - 1 do if opened[n + 1] then local visible visible, opened[n + 1] = ImGui.BeginTabItem(names[n + 1], opened[n + 1], 0 --[[ImGuiTabItemFlags.None]]) if visible then - ImGui.Text("This is the %s tab!", names[n + 1]) + ImGui_Text("This is the %s tab!", names[n + 1]) if bit32.band(n, 1) ~= 0 then - ImGui.Text("I am an odd tab.") + ImGui_Text("I am an odd tab.") end - ImGui.EndTabItem() + ImGui_EndTabItem() end end end - ImGui.EndTabBar() + ImGui_EndTabBar() end - ImGui.Separator() - ImGui.TreePop() + ImGui_Separator() + ImGui_TreePop() end if ImGui.TreeNode("TabItemButton & Leading/Trailing flags") then @@ -26582,32 +26638,32 @@ function DemoWindowWidgetsTabs() -- TabItemButton() and Leading/Trailing flags are distinct features which we will demo together. -- (It is possible to submit regular tabs with Leading/Trailing flags, or TabItemButton tabs without Leading/Trailing flags... -- but they tend to make more sense together) - _, s.show_leading_button = ImGui.Checkbox("Show Leading TabItemButton()", s.show_leading_button) - _, s.show_trailing_button = ImGui.Checkbox("Show Trailing TabItemButton()", s.show_trailing_button) - _, s.show_leading_trailing_tabs = ImGui.Checkbox("Show Leading+Trailing TabItem()", s.show_leading_trailing_tabs) + _, s.show_leading_button = ImGui_Checkbox("Show Leading TabItemButton()", s.show_leading_button) + _, s.show_trailing_button = ImGui_Checkbox("Show Trailing TabItemButton()", s.show_trailing_button) + _, s.show_leading_trailing_tabs = ImGui_Checkbox("Show Leading+Trailing TabItem()", s.show_leading_trailing_tabs) -- Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs s.tab_bar_flags_2 = EditTabBarFittingPolicyFlags(s.tab_bar_flags_2) - if ImGui.BeginTabBar("MyTabBar", s.tab_bar_flags_2) then + if ImGui_BeginTabBar("MyTabBar", s.tab_bar_flags_2) then -- Demo a Leading TabItemButton(): click the "?" button to open a menu if s.show_leading_button then - if ImGui.TabItemButton("?", bit32.bor(64 --[[ImGuiTabItemFlags.Leading]], 16 --[[ImGuiTabItemFlags.NoTooltip]])) then - ImGui.OpenPopup("MyHelpMenu") + if ImGui_TabItemButton("?", bit32.bor(64 --[[ImGuiTabItemFlags.Leading]], 16 --[[ImGuiTabItemFlags.NoTooltip]])) then + ImGui_OpenPopup("MyHelpMenu") end end - if ImGui.BeginPopup("MyHelpMenu") then - ImGui.Selectable("Hello!") - ImGui.EndPopup() + if ImGui_BeginPopup("MyHelpMenu") then + ImGui_Selectable("Hello!") + ImGui_EndPopup() end -- Demo Leading/Trailing Tabs if s.show_leading_trailing_tabs then if ImGui.BeginTabItem("Leading", nil, 64 --[[ImGuiTabItemFlags.Leading]]) then - ImGui.EndTabItem() + ImGui_EndTabItem() end if ImGui.BeginTabItem("Trailing", nil, 128 --[[ImGuiTabItemFlags.Trailing]]) then - ImGui.EndTabItem() + ImGui_EndTabItem() end end @@ -26615,7 +26671,7 @@ function DemoWindowWidgetsTabs() -- (In your app you may want to use a font icon instead of the "+") -- We submit it before the regular tabs, but thanks to the ImGuiTabItemFlags_Trailing flag it will always appear at the end. if s.show_trailing_button then - if ImGui.TabItemButton("+", bit32.bor(128 --[[ImGuiTabItemFlags.Trailing]], 16 --[[ImGuiTabItemFlags.NoTooltip]])) then + if ImGui_TabItemButton("+", bit32.bor(128 --[[ImGuiTabItemFlags.Trailing]], 16 --[[ImGuiTabItemFlags.NoTooltip]])) then active_tabs:push_back(s.next_tab_id); s.next_tab_id = s.next_tab_id + 1 -- Add new tab end end @@ -26628,8 +26684,8 @@ function DemoWindowWidgetsTabs() local visible visible, open = ImGui.BeginTabItem(name, open, 0 --[[ImGuiTabItemFlags.None]]) if visible then - ImGui.Text("This is the %s tab!", name) - ImGui.EndTabItem() + ImGui_Text("This is the %s tab!", name) + ImGui_EndTabItem() end if not open then @@ -26639,12 +26695,12 @@ function DemoWindowWidgetsTabs() end end - ImGui.EndTabBar() + ImGui_EndTabBar() end - ImGui.Separator() - ImGui.TreePop() + ImGui_Separator() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -26665,78 +26721,78 @@ function DemoWindowWidgetsText() if ImGui.TreeNode("Colorful Text") then IMGUI_DEMO_MARKER("Widgets/Text/Colored Text") -- Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility. - ImGui.TextColored(ImVec4(1.0, 0.0, 1.0, 1.0), "Pink") - ImGui.TextColored(ImVec4(1.0, 1.0, 0.0, 1.0), "Yellow") - ImGui.TextDisabled("Disabled") - ImGui.SameLine(); HelpMarker("The TextDisabled color is stored in ImGuiStyle.") - ImGui.TreePop() + ImGui_TextColored(ImVec4(1.0, 0.0, 1.0, 1.0), "Pink") + ImGui_TextColored(ImVec4(1.0, 1.0, 0.0, 1.0), "Yellow") + ImGui_TextDisabled("Disabled") + ImGui_SameLine(); HelpMarker("The TextDisabled color is stored in ImGuiStyle.") + ImGui_TreePop() end if ImGui.TreeNode("Font Size") then IMGUI_DEMO_MARKER("Widgets/Text/Font Size") - local style = ImGui.GetStyle() + local style = ImGui_GetStyle() local global_scale = style.FontScaleMain * style.FontScaleDpi - ImGui.Text("style.FontScaleMain = %0.2f", style.FontScaleMain) - ImGui.Text("style.FontScaleDpi = %0.2f", style.FontScaleDpi) - ImGui.Text("global_scale = ~%0.2f", global_scale) -- This is not technically accurate as internal scales may apply, but conceptually let's pretend it is. - ImGui.Text("FontSize = %0.2f", ImGui.GetFontSize()) + ImGui_Text("style.FontScaleMain = %0.2f", style.FontScaleMain) + ImGui_Text("style.FontScaleDpi = %0.2f", style.FontScaleDpi) + ImGui_Text("global_scale = ~%0.2f", global_scale) -- This is not technically accurate as internal scales may apply, but conceptually let's pretend it is. + ImGui_Text("FontSize = %0.2f", ImGui_GetFontSize()) - ImGui.SeparatorText("") - s.custom_size = ImGui.SliderFloat("custom_size", s.custom_size, 10.0, 100.0, "%.0f") - ImGui.Text("ImGui::PushFont(nullptr, custom_size);") - ImGui.PushFont(nil, s.custom_size) - ImGui.Text("FontSize = %.2f (== %.2f * global_scale)", ImGui.GetFontSize(), s.custom_size) - ImGui.PopFont() + ImGui_SeparatorText("") + s.custom_size = ImGui_SliderFloat("custom_size", s.custom_size, 10.0, 100.0, "%.0f") + ImGui_Text("ImGui::PushFont(nullptr, custom_size);") + ImGui_PushFont(nil, s.custom_size) + ImGui_Text("FontSize = %.2f (== %.2f * global_scale)", ImGui_GetFontSize(), s.custom_size) + ImGui_PopFont() - ImGui.SeparatorText("") - s.custom_scale = ImGui.SliderFloat("custom_scale", s.custom_scale, 0.5, 4.0, "%.2f") - ImGui.Text("ImGui::PushFont(nullptr, style.FontSizeBase * custom_scale);") - ImGui.PushFont(nil, style.FontSizeBase * s.custom_scale) - ImGui.Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui.GetFontSize(), s.custom_scale) - ImGui.PopFont() + ImGui_SeparatorText("") + s.custom_scale = ImGui_SliderFloat("custom_scale", s.custom_scale, 0.5, 4.0, "%.2f") + ImGui_Text("ImGui::PushFont(nullptr, style.FontSizeBase * custom_scale);") + ImGui_PushFont(nil, style.FontSizeBase * s.custom_scale) + ImGui_Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui_GetFontSize(), s.custom_scale) + ImGui_PopFont() - ImGui.SeparatorText("") + ImGui_SeparatorText("") local scaling = 0.5 while scaling <= 4.0 do - ImGui.PushFont(nil, style.FontSizeBase * scaling) - ImGui.Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui.GetFontSize(), scaling) - ImGui.PopFont() + ImGui_PushFont(nil, style.FontSizeBase * scaling) + ImGui_Text("FontSize = %.2f (== style.FontSizeBase * %.2f * global_scale)", ImGui_GetFontSize(), scaling) + ImGui_PopFont() scaling = scaling + 0.5 end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Word Wrapping") then IMGUI_DEMO_MARKER("Widgets/Text/Word Wrapping") -- Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility. - ImGui.TextWrapped( + ImGui_TextWrapped( "This text should automatically wrap on the edge of the window. The current implementation " .. "for text wrapping follows simple rules suitable for English and possibly other languages.") - ImGui.Spacing() + ImGui_Spacing() - s.wrap_width = ImGui.SliderFloat("Wrap width", s.wrap_width, -20, 600, "%.0f") + s.wrap_width = ImGui_SliderFloat("Wrap width", s.wrap_width, -20, 600, "%.0f") - local draw_list = ImGui.GetWindowDrawList() + local draw_list = ImGui_GetWindowDrawList() for n = 0, 1 do - ImGui.Text("Test paragraph %d:", n) - local pos = ImGui.GetCursorScreenPos() + ImGui_Text("Test paragraph %d:", n) + local pos = ImGui_GetCursorScreenPos() local marker_min = ImVec2(pos.x + s.wrap_width, pos.y) - local marker_max = ImVec2(pos.x + s.wrap_width + 10, pos.y + ImGui.GetTextLineHeight()) - ImGui.PushTextWrapPos(ImGui.GetCursorPos().x + s.wrap_width) + local marker_max = ImVec2(pos.x + s.wrap_width + 10, pos.y + ImGui_GetTextLineHeight()) + ImGui_PushTextWrapPos(ImGui_GetCursorPos().x + s.wrap_width) if n == 0 then - ImGui.Text("The lazy dog is a good dog. This paragraph should fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", s.wrap_width) + ImGui_Text("The lazy dog is a good dog. This paragraph should fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", s.wrap_width) else - ImGui.Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh") + ImGui_Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh") end -- Draw actual text bounding box, following by marker of our expected limit (should not overlap!) - draw_list:AddRect(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), IM_COL32(255, 255, 0, 255)) + draw_list:AddRect(ImGui_GetItemRectMin(), ImGui_GetItemRectMax(), IM_COL32(255, 255, 0, 255)) draw_list:AddRectFilled(marker_min, marker_max, IM_COL32(255, 0, 255, 255)) - ImGui.PopTextWrapPos() + ImGui_PopTextWrapPos() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("UTF-8 Text") then @@ -26751,17 +26807,17 @@ function DemoWindowWidgetsText() -- Don't do this in your application! Please use u8"text in any language" in your application! -- Note that characters values are preserved even by InputText() if the font cannot be displayed, -- so you can safely copy & paste garbled characters into another application. - ImGui.TextWrapped( + ImGui_TextWrapped( "CJK text will only appear if the font was loaded with the appropriate CJK character ranges. " .. "Call io.Fonts->AddFontFromFileTTF() manually to load extra character ranges. " .. "Read docs/FONTS.md for details.") - ImGui.Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)") - ImGui.Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)") + ImGui_Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)") + ImGui_Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)") --static char buf[32] = u8"NIHONGO"; -- <- this is how you would write it with C++11, using real kanjis - ImGui.InputText("UTF-8 input", s.buf, 32) - ImGui.TreePop() + ImGui_InputText("UTF-8 input", s.buf, 32) + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -26780,30 +26836,30 @@ function DemoWindowWidgetsTextFilter() -- You may want to implement a more feature-full filtering scheme in your own application. HelpMarker("Not a widget per-se, but ImGuiTextFilter is a helper to perform simple filtering on text strings.") local filter = s.filter - ImGui.Text("Filter usage:\n" .. + ImGui_Text("Filter usage:\n" .. " \"\" display all lines\n" .. " xxx display lines containing \"xxx\"\n" .. " xxx yyy display lines containing \"xxx\" and \"yyy\"\n" .. " \"xxx yyy\" display lines containing \"xxx yyy\"\n" .. " xxx,yyy display lines containing \"xxx\" or \"yyy\"\n" .. " -xxx hide lines containing \"xxx\"") - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) filter:DrawWithHint("##Filter", "Filter (incl -excl)") - if ImGui.BeginChild("##items", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetTextLineHeightWithSpacing() * 15), 128 --[[ImGuiChildFlags.FrameStyle]]) then + if ImGui_BeginChild("##items", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetTextLineHeightWithSpacing() * 15), 128 --[[ImGuiChildFlags.FrameStyle]]) then local lines = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" } for _, item in ipairs(lines) do if filter:PassFilter(item) then - ImGui.TextUnformatted(item) + ImGui_TextUnformatted(item) end end for _, item in ipairs(ExampleNames) do if filter:PassFilter(item) then - ImGui.TextUnformatted(item) + ImGui_TextUnformatted(item) end end end - ImGui.EndChild() - ImGui.TreePop() + ImGui_EndChild() + ImGui_TreePop() end end @@ -26861,14 +26917,14 @@ function DemoWindowWidgetsTextInput() -- - For std::string: use the wrapper in misc/cpp/imgui_stdlib.h/.cpp -- - Otherwise, see the 'Dear ImGui Demo->Widgets->Text Input->Resize Callback' for using ImGuiInputTextFlags_CallbackResize. HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp because we don't want to include in here)") - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_ReadOnly", s.flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_WordWrap", s.flags, 16777216 --[[ImGuiInputTextFlags.WordWrap]]) - ImGui.SameLine(); HelpMarker("Feature is currently in Beta. Please read comments in imgui.h") - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", s.flags, 32 --[[ImGuiInputTextFlags.AllowTabInput]]) - ImGui.SameLine(); HelpMarker("When _AllowTabInput is set, passing through the widget with Tabbing doesn't automatically activate it, in order to also cycling through subsequent widgets.") - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", s.flags, 256 --[[ImGuiInputTextFlags.CtrlEnterForNewLine]]) - ImGui.InputTextMultiline("##source", s.text, 1024 * 16, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetTextLineHeight() * 16), s.flags) - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_ReadOnly", s.flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_WordWrap", s.flags, 16777216 --[[ImGuiInputTextFlags.WordWrap]]) + ImGui_SameLine(); HelpMarker("Feature is currently in Beta. Please read comments in imgui.h") + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", s.flags, 32 --[[ImGuiInputTextFlags.AllowTabInput]]) + ImGui_SameLine(); HelpMarker("When _AllowTabInput is set, passing through the widget with Tabbing doesn't automatically activate it, in order to also cycling through subsequent widgets.") + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", s.flags, 256 --[[ImGuiInputTextFlags.CtrlEnterForNewLine]]) + ImGui_InputTextMultiline("##source", s.text, 1024 * 16, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetTextLineHeight() * 16), s.flags) + ImGui_TreePop() end if ImGui.TreeNode("Filtered Text Input") then @@ -26890,24 +26946,24 @@ function DemoWindowWidgetsTextInput() return 1 end - ImGui.InputText("default", s.buf1, 32) - ImGui.InputText("decimal", s.buf2, 32, 1 --[[ImGuiInputTextFlags.CharsDecimal]]) - ImGui.InputText("hexadecimal", s.buf3, 32, bit32.bor(2 --[[ImGuiInputTextFlags.CharsHexadecimal]], 8 --[[ImGuiInputTextFlags.CharsUppercase]])) - ImGui.InputText("uppercase", s.buf4, 32, 8 --[[ImGuiInputTextFlags.CharsUppercase]]) - ImGui.InputText("no blank", s.buf5, 32, 16 --[[ImGuiInputTextFlags.CharsNoBlank]]) - ImGui.InputText("casing swap", s.buf6, 32, 2097152 --[[ImGuiInputTextFlags.CallbackCharFilter]], TextFilters.FilterCasingSwap) -- Use CharFilter callback to replace characters. - ImGui.InputText("\"imgui\"", s.buf7, 32, 2097152 --[[ImGuiInputTextFlags.CallbackCharFilter]], TextFilters.FilterImGuiLetters) -- Use CharFilter callback to disable some characters. - ImGui.TreePop() + ImGui_InputText("default", s.buf1, 32) + ImGui_InputText("decimal", s.buf2, 32, 1 --[[ImGuiInputTextFlags.CharsDecimal]]) + ImGui_InputText("hexadecimal", s.buf3, 32, bit32.bor(2 --[[ImGuiInputTextFlags.CharsHexadecimal]], 8 --[[ImGuiInputTextFlags.CharsUppercase]])) + ImGui_InputText("uppercase", s.buf4, 32, 8 --[[ImGuiInputTextFlags.CharsUppercase]]) + ImGui_InputText("no blank", s.buf5, 32, 16 --[[ImGuiInputTextFlags.CharsNoBlank]]) + ImGui_InputText("casing swap", s.buf6, 32, 2097152 --[[ImGuiInputTextFlags.CallbackCharFilter]], TextFilters.FilterCasingSwap) -- Use CharFilter callback to replace characters. + ImGui_InputText("\"imgui\"", s.buf7, 32, 2097152 --[[ImGuiInputTextFlags.CallbackCharFilter]], TextFilters.FilterImGuiLetters) -- Use CharFilter callback to disable some characters. + ImGui_TreePop() end if ImGui.TreeNode("Password Input") then IMGUI_DEMO_MARKER("Widgets/Text Input/Password input") local s = S_ti.password - ImGui.InputText("password", s.password, 64, 1024 --[[ImGuiInputTextFlags.Password]]) - ImGui.SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n") - ImGui.InputTextWithHint("password (w/ hint)", "", s.password, 64, 1024 --[[ImGuiInputTextFlags.Password]]) - ImGui.InputText("password (clear)", s.password, 64) - ImGui.TreePop() + ImGui_InputText("password", s.password, 64, 1024 --[[ImGuiInputTextFlags.Password]]) + ImGui_SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n") + ImGui_InputTextWithHint("password (w/ hint)", "", s.password, 64, 1024 --[[ImGuiInputTextFlags.Password]]) + ImGui_InputText("password (clear)", s.password, 64) + ImGui_TreePop() end if ImGui.TreeNode("Completion, History, Edit Callbacks") then @@ -26939,22 +26995,22 @@ function DemoWindowWidgetsTextInput() end return 0 end - ImGui.InputText("Completion", s.buf1, 64, 262144 --[[ImGuiInputTextFlags.CallbackCompletion]], Funcs.MyCallback) - ImGui.SameLine(); HelpMarker( + ImGui_InputText("Completion", s.buf1, 64, 262144 --[[ImGuiInputTextFlags.CallbackCompletion]], Funcs.MyCallback) + ImGui_SameLine(); HelpMarker( "Here we append \"..\" each time Tab is pressed. " .. "See 'Examples>Console' for a more meaningful demonstration of using this callback.") - ImGui.InputText("History", s.buf2, 64, 524288 --[[ImGuiInputTextFlags.CallbackHistory]], Funcs.MyCallback) - ImGui.SameLine(); HelpMarker( + ImGui_InputText("History", s.buf2, 64, 524288 --[[ImGuiInputTextFlags.CallbackHistory]], Funcs.MyCallback) + ImGui_SameLine(); HelpMarker( "Here we replace and select text each time Up/Down are pressed. " .. "See 'Examples>Console' for a more meaningful demonstration of using this callback.") - ImGui.InputText("Edit", s.buf3, 64, 8388608 --[[ImGuiInputTextFlags.CallbackEdit]], Funcs.MyCallback, s) -- [Port] (void*)&edit_count -> s - ImGui.SameLine(); HelpMarker( + ImGui_InputText("Edit", s.buf3, 64, 8388608 --[[ImGuiInputTextFlags.CallbackEdit]], Funcs.MyCallback, s) -- [Port] (void*)&edit_count -> s + ImGui_SameLine(); HelpMarker( "Here we toggle the casing of the first character on every edit + count edits.") - ImGui.SameLine(); ImGui.Text("(%d)", s.edit_count) + ImGui_SameLine(); ImGui_Text("(%d)", s.edit_count) - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Resize Callback") then @@ -26983,42 +27039,42 @@ function DemoWindowWidgetsTextInput() if size == nil then size = ImVec2(0, 0) end if flags == nil then flags = 0 end assert(bit32.band(flags, 4194304 --[[ImGuiInputTextFlags.CallbackResize]]) == 0) - return ImGui.InputTextMultiline(label, my_str.Data, my_str.Size, size, bit32.bor(flags, 4194304 --[[ImGuiInputTextFlags.CallbackResize]]), Funcs.MyResizeCallback, my_str) + return ImGui_InputTextMultiline(label, my_str.Data, my_str.Size, size, bit32.bor(flags, 4194304 --[[ImGuiInputTextFlags.CallbackResize]]), Funcs.MyResizeCallback, my_str) end -- For this demo we are using ImVector as a string container. -- Note that because we need to store a terminating zero character, our size/capacity are 1 more -- than usually reported by a typical string class. - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_WordWrap", s.flags, 16777216 --[[ImGuiInputTextFlags.WordWrap]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_WordWrap", s.flags, 16777216 --[[ImGuiInputTextFlags.WordWrap]]) local my_str = s.my_str if my_str:empty() then my_str:push_back(0) end - Funcs.MyInputTextMultiline("##MyStr", my_str, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetTextLineHeight() * 16), s.flags) - ImGui.Text("Data: %s\nSize: %d\nCapacity: %d", tostring(my_str.Data), my_str.Size, my_str.Capacity) -- [Port] %p -> %s + tostring - ImGui.TreePop() + Funcs.MyInputTextMultiline("##MyStr", my_str, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetTextLineHeight() * 16), s.flags) + ImGui_Text("Data: %s\nSize: %d\nCapacity: %d", tostring(my_str.Data), my_str.Size, my_str.Capacity) -- [Port] %p -> %s + tostring + ImGui_TreePop() end if ImGui.TreeNode("Eliding, Alignment") then IMGUI_DEMO_MARKER("Widgets/Text Input/Eliding, Alignment") local s = S_ti.eliding - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_ElideLeft", s.flags, 131072 --[[ImGuiInputTextFlags.ElideLeft]]) - ImGui.InputText("Path", s.buf1, 128, s.flags) - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_ElideLeft", s.flags, 131072 --[[ImGuiInputTextFlags.ElideLeft]]) + ImGui_InputText("Path", s.buf1, 128, s.flags) + ImGui_TreePop() end if ImGui.TreeNode("Miscellaneous") then IMGUI_DEMO_MARKER("Widgets/Text Input/Miscellaneous") local s = S_ti.misc - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_EscapeClearsAll", s.flags, 128 --[[ImGuiInputTextFlags.EscapeClearsAll]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_ReadOnly", s.flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiInputTextFlags_NoUndoRedo", s.flags, 65536 --[[ImGuiInputTextFlags.NoUndoRedo]]) - ImGui.InputText("Hello", s.buf1, 16, s.flags) - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_EscapeClearsAll", s.flags, 128 --[[ImGuiInputTextFlags.EscapeClearsAll]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_ReadOnly", s.flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiInputTextFlags_NoUndoRedo", s.flags, 65536 --[[ImGuiInputTextFlags.NoUndoRedo]]) + ImGui_InputText("Hello", s.buf1, 16, s.flags) + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -27036,7 +27092,7 @@ function DemoWindowWidgetsTooltips() if ImGui.TreeNode("Tooltips") then IMGUI_DEMO_MARKER("Widgets/Tooltips") -- Tooltips are windows following the mouse. They do not take focus away. - ImGui.SeparatorText("General") + ImGui_SeparatorText("General") -- Typical use cases: -- - Short-form (text only): SetItemTooltip("Hello"); @@ -27051,34 +27107,34 @@ function DemoWindowWidgetsTooltips() local sz = ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0) - ImGui.Button("Basic", sz) - ImGui.SetItemTooltip("I am a tooltip") + ImGui_Button("Basic", sz) + ImGui_SetItemTooltip("I am a tooltip") - ImGui.Button("Fancy", sz) - if ImGui.BeginItemTooltip() then - ImGui.Text("I am a fancy tooltip") - ImGui.PlotLines("Curve", s.arr, nil, #s.arr) - ImGui.Text("Sin(time) = %f", math.sin(ImGui.GetTime())) - ImGui.EndTooltip() + ImGui_Button("Fancy", sz) + if ImGui_BeginItemTooltip() then + ImGui_Text("I am a fancy tooltip") + ImGui_PlotLines("Curve", s.arr, nil, #s.arr) + ImGui_Text("Sin(time) = %f", math.sin(ImGui_GetTime())) + ImGui_EndTooltip() end - ImGui.SeparatorText("Always On") + ImGui_SeparatorText("Always On") -- Showcase NOT relying on a IsItemHovered() to emit a tooltip. -- Here the tooltip is always emitted when 'always_on == true'. - _, s.always_on = ImGui.RadioButton("Off", s.always_on, 0) - ImGui.SameLine() - _, s.always_on = ImGui.RadioButton("Always On (Simple)", s.always_on, 1) - ImGui.SameLine() - _, s.always_on = ImGui.RadioButton("Always On (Advanced)", s.always_on, 2) + _, s.always_on = ImGui_RadioButton("Off", s.always_on, 0) + ImGui_SameLine() + _, s.always_on = ImGui_RadioButton("Always On (Simple)", s.always_on, 1) + ImGui_SameLine() + _, s.always_on = ImGui_RadioButton("Always On (Advanced)", s.always_on, 2) if s.always_on == 1 then - ImGui.SetTooltip("I am following you around.") - elseif s.always_on == 2 and ImGui.BeginTooltip() then - ImGui.ProgressBar(math.sin(ImGui.GetTime()) * 0.5 + 0.5, ImVec2(ImGui.GetFontSize() * 25, 0.0)) - ImGui.EndTooltip() + ImGui_SetTooltip("I am following you around.") + elseif s.always_on == 2 and ImGui_BeginTooltip() then + ImGui_ProgressBar(math.sin(ImGui_GetTime()) * 0.5 + 0.5, ImVec2(ImGui_GetFontSize() * 25, 0.0)) + ImGui_EndTooltip() end - ImGui.SeparatorText("Custom") + ImGui_SeparatorText("Custom") HelpMarker( "Passing ImGuiHoveredFlags_ForTooltip to IsItemHovered() is the preferred way to standardize " .. @@ -27089,41 +27145,41 @@ function DemoWindowWidgetsTooltips() -- Passing ImGuiHoveredFlags_ForTooltip to IsItemHovered() will pull ImGuiHoveredFlags flags values from -- 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' depending on whether mouse or keyboard/gamepad is being used. -- With default settings, ImGuiHoveredFlags_ForTooltip is equivalent to ImGuiHoveredFlags_DelayShort + ImGuiHoveredFlags_Stationary. - ImGui.Button("Manual", sz) - if ImGui.IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then - ImGui.SetTooltip("I am a manually emitted tooltip.") + ImGui_Button("Manual", sz) + if ImGui_IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then + ImGui_SetTooltip("I am a manually emitted tooltip.") end - ImGui.Button("DelayNone", sz) - if ImGui.IsItemHovered(16384 --[[ImGuiHoveredFlags.DelayNone]]) then - ImGui.SetTooltip("I am a tooltip with no delay.") + ImGui_Button("DelayNone", sz) + if ImGui_IsItemHovered(16384 --[[ImGuiHoveredFlags.DelayNone]]) then + ImGui_SetTooltip("I am a tooltip with no delay.") end - ImGui.Button("DelayShort", sz) - if ImGui.IsItemHovered(bit32.bor(32768 --[[ImGuiHoveredFlags.DelayShort]], 131072 --[[ImGuiHoveredFlags.NoSharedDelay]])) then - ImGui.SetTooltip("I am a tooltip with a short delay (%0.2f sec).", ImGui.GetStyle().HoverDelayShort) + ImGui_Button("DelayShort", sz) + if ImGui_IsItemHovered(bit32.bor(32768 --[[ImGuiHoveredFlags.DelayShort]], 131072 --[[ImGuiHoveredFlags.NoSharedDelay]])) then + ImGui_SetTooltip("I am a tooltip with a short delay (%0.2f sec).", ImGui_GetStyle().HoverDelayShort) end - ImGui.Button("DelayLong", sz) - if ImGui.IsItemHovered(bit32.bor(65536 --[[ImGuiHoveredFlags.DelayNormal]], 131072 --[[ImGuiHoveredFlags.NoSharedDelay]])) then - ImGui.SetTooltip("I am a tooltip with a long delay (%0.2f sec).", ImGui.GetStyle().HoverDelayNormal) + ImGui_Button("DelayLong", sz) + if ImGui_IsItemHovered(bit32.bor(65536 --[[ImGuiHoveredFlags.DelayNormal]], 131072 --[[ImGuiHoveredFlags.NoSharedDelay]])) then + ImGui_SetTooltip("I am a tooltip with a long delay (%0.2f sec).", ImGui_GetStyle().HoverDelayNormal) end - ImGui.Button("Stationary", sz) - if ImGui.IsItemHovered(8192 --[[ImGuiHoveredFlags.Stationary]]) then - ImGui.SetTooltip("I am a tooltip requiring mouse to be stationary before activating.") + ImGui_Button("Stationary", sz) + if ImGui_IsItemHovered(8192 --[[ImGuiHoveredFlags.Stationary]]) then + ImGui_SetTooltip("I am a tooltip requiring mouse to be stationary before activating.") end -- Using ImGuiHoveredFlags_ForTooltip will pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav', -- which default value include the ImGuiHoveredFlags_AllowWhenDisabled flag. - ImGui.BeginDisabled() - ImGui.Button("Disabled item", sz) - if ImGui.IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then - ImGui.SetTooltip("I am a tooltip for a disabled item.") + ImGui_BeginDisabled() + ImGui_Button("Disabled item", sz) + if ImGui_IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then + ImGui_SetTooltip("I am a tooltip for a disabled item.") end - ImGui.EndDisabled() + ImGui_EndDisabled() - ImGui.TreePop() + ImGui_TreePop() end end @@ -27149,55 +27205,55 @@ function DemoWindowWidgetsTreeNodes() -- Use SetNextItemOpen() so set the default state of a node to be open. We could -- also use TreeNodeEx() with the ImGuiTreeNodeFlags_DefaultOpen flag to achieve the same thing! if i == 0 then - ImGui.SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) + ImGui_SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) end -- Here we use PushID() to generate a unique base ID, and then the "" used as TreeNode id won't conflict. -- An alternative to using 'PushID() + TreeNode("", ...)' to generate a unique ID is to use 'TreeNode((void*)(intptr_t)i, ...)', -- aka generate a dummy pointer-sized value to be hashed. The demo below uses that technique. Both are fine. - ImGui.PushID(i) + ImGui_PushID(i) if ImGui.TreeNode("", "Child %d", i) then - ImGui.Text("blah blah") - ImGui.SameLine() - if ImGui.SmallButton("button") then end - ImGui.TreePop() + ImGui_Text("blah blah") + ImGui_SameLine() + if ImGui_SmallButton("button") then end + ImGui_TreePop() end - ImGui.PopID() + ImGui_PopID() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Hierarchy Lines") then IMGUI_DEMO_MARKER("Widgets/Tree Nodes/Hierarchy Lines") HelpMarker("Default option for DrawLinesXXX is stored in style.TreeLinesFlags") - _, s.base_flags = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesNone", s.base_flags, 262144 --[[ImGuiTreeNodeFlags.DrawLinesNone]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesFull", s.base_flags, 524288 --[[ImGuiTreeNodeFlags.DrawLinesFull]]) - _, s.base_flags = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesToNodes", s.base_flags, 1048576 --[[ImGuiTreeNodeFlags.DrawLinesToNodes]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesNone", s.base_flags, 262144 --[[ImGuiTreeNodeFlags.DrawLinesNone]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesFull", s.base_flags, 524288 --[[ImGuiTreeNodeFlags.DrawLinesFull]]) + _, s.base_flags = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesToNodes", s.base_flags, 1048576 --[[ImGuiTreeNodeFlags.DrawLinesToNodes]]) if ImGui.TreeNodeEx("Parent", s.base_flags) then if ImGui.TreeNodeEx("Child 1", s.base_flags) then - ImGui.Button("Button for Child 1") - ImGui.TreePop() + ImGui_Button("Button for Child 1") + ImGui_TreePop() end if ImGui.TreeNodeEx("Child 2", s.base_flags) then - ImGui.Button("Button for Child 2") - ImGui.TreePop() + ImGui_Button("Button for Child 2") + ImGui_TreePop() end - ImGui.Text("Remaining contents") - ImGui.Text("Remaining contents") - ImGui.TreePop() + ImGui_Text("Remaining contents") + ImGui_Text("Remaining contents") + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Clipping Large Trees") then IMGUI_DEMO_MARKER("Widgets/Tree Nodes/Clipping Large Trees") - ImGui.TextWrapped( + ImGui_TextWrapped( "- Using ImGuiListClipper with trees is a less easy than on arrays or grids.\n" .. "- Refer to 'Demo->Examples->Property Editor' for an example of how to do that.\n" .. "- Discuss in #3823") - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Selectable Nodes") then @@ -27224,47 +27280,47 @@ function DemoWindowWidgetsTreeNodes() end local is_open = ImGui.TreeNodeEx(node_n, flags, "Selectable Node %d", node_n) -- [Port] (void*)(intptr_t)node_n -> node_n - if ImGui.IsItemClicked() and not ImGui.IsItemToggledOpen() then + if ImGui_IsItemClicked() and not ImGui_IsItemToggledOpen() then node_clicked_idx = node_n end if is_open then - ImGui.BulletText("") - ImGui.TreePop() + ImGui_BulletText("") + ImGui_TreePop() end end if node_clicked_idx ~= -1 then -- Update selection state (process outside of tree loop to avoid visual inconsistencies during the clicking frame) - if ImGui.GetIO().KeyCtrl then + if ImGui_GetIO().KeyCtrl then s.selection_mask = bit32.bxor(s.selection_mask, bit32.lshift(1, node_clicked_idx)) -- Ctrl+Click to toggle else --if (!(selection_mask & (1 << node_clicked_idx))) -- Depending on selection behavior you want, may want to preserve selection when clicking on item that is part of the selection s.selection_mask = bit32.lshift(1, node_clicked_idx) -- Click to single-select end end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Advanced") then IMGUI_DEMO_MARKER("Widgets/Tree Nodes/Advanced") - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_OpenOnArrow", s.base_flags_2, 128 --[[ImGuiTreeNodeFlags.OpenOnArrow]]) - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", s.base_flags_2, 64 --[[ImGuiTreeNodeFlags.OpenOnDoubleClick]]) - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", s.base_flags_2, 2048 --[[ImGuiTreeNodeFlags.SpanAvailWidth]]); ImGui.SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be laid out after the node.") - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", s.base_flags_2, 4096 --[[ImGuiTreeNodeFlags.SpanFullWidth]]) - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_SpanLabelWidth", s.base_flags_2, 8192 --[[ImGuiTreeNodeFlags.SpanLabelWidth]]); ImGui.SameLine(); HelpMarker("Reduce hit area to the text label and a bit of margin.") - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", s.base_flags_2, 16384 --[[ImGuiTreeNodeFlags.SpanAllColumns]]); ImGui.SameLine(); HelpMarker("For use in Tables only.") - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_AllowOverlap", s.base_flags_2, 4 --[[ImGuiTreeNodeFlags.AllowOverlap]]) - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_Framed", s.base_flags_2, 2 --[[ImGuiTreeNodeFlags.Framed]]); ImGui.SameLine(); HelpMarker("Draw frame with background (e.g. for CollapsingHeader)") - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_FramePadding", s.base_flags_2, 1024 --[[ImGuiTreeNodeFlags.FramePadding]]) - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_NavLeftJumpsToParent", s.base_flags_2, 131072 --[[ImGuiTreeNodeFlags.NavLeftJumpsToParent]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_OpenOnArrow", s.base_flags_2, 128 --[[ImGuiTreeNodeFlags.OpenOnArrow]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", s.base_flags_2, 64 --[[ImGuiTreeNodeFlags.OpenOnDoubleClick]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", s.base_flags_2, 2048 --[[ImGuiTreeNodeFlags.SpanAvailWidth]]); ImGui_SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be laid out after the node.") + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", s.base_flags_2, 4096 --[[ImGuiTreeNodeFlags.SpanFullWidth]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_SpanLabelWidth", s.base_flags_2, 8192 --[[ImGuiTreeNodeFlags.SpanLabelWidth]]); ImGui_SameLine(); HelpMarker("Reduce hit area to the text label and a bit of margin.") + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", s.base_flags_2, 16384 --[[ImGuiTreeNodeFlags.SpanAllColumns]]); ImGui_SameLine(); HelpMarker("For use in Tables only.") + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_AllowOverlap", s.base_flags_2, 4 --[[ImGuiTreeNodeFlags.AllowOverlap]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_Framed", s.base_flags_2, 2 --[[ImGuiTreeNodeFlags.Framed]]); ImGui_SameLine(); HelpMarker("Draw frame with background (e.g. for CollapsingHeader)") + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_FramePadding", s.base_flags_2, 1024 --[[ImGuiTreeNodeFlags.FramePadding]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_NavLeftJumpsToParent", s.base_flags_2, 131072 --[[ImGuiTreeNodeFlags.NavLeftJumpsToParent]]) HelpMarker("Default option for DrawLinesXXX is stored in style.TreeLinesFlags") - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesNone", s.base_flags_2, 262144 --[[ImGuiTreeNodeFlags.DrawLinesNone]]) - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesFull", s.base_flags_2, 524288 --[[ImGuiTreeNodeFlags.DrawLinesFull]]) - _, s.base_flags_2 = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesToNodes", s.base_flags_2, 1048576 --[[ImGuiTreeNodeFlags.DrawLinesToNodes]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesNone", s.base_flags_2, 262144 --[[ImGuiTreeNodeFlags.DrawLinesNone]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesFull", s.base_flags_2, 524288 --[[ImGuiTreeNodeFlags.DrawLinesFull]]) + _, s.base_flags_2 = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_DrawLinesToNodes", s.base_flags_2, 1048576 --[[ImGuiTreeNodeFlags.DrawLinesToNodes]]) - _, s.align_label_with_current_x_position = ImGui.Checkbox("Align label with current X position", s.align_label_with_current_x_position) - _, s.use_drag_and_drop = ImGui.Checkbox("Make Tree Nodes as drag & drop sources", s.use_drag_and_drop) + _, s.align_label_with_current_x_position = ImGui_Checkbox("Align label with current X position", s.align_label_with_current_x_position) + _, s.use_drag_and_drop = ImGui_Checkbox("Make Tree Nodes as drag & drop sources", s.use_drag_and_drop) if s.align_label_with_current_x_position then - ImGui.Unindent(ImGui.GetTreeNodeToLabelSpacing()) + ImGui_Unindent(ImGui_GetTreeNodeToLabelSpacing()) end for node_n = 0, 5 do @@ -27272,21 +27328,21 @@ function DemoWindowWidgetsTreeNodes() if node_n < 3 then -- Items 0..2 are Tree Node local is_open = ImGui.TreeNodeEx(node_n, node_flags, "Selectable Node %d", node_n) - if s.use_drag_and_drop and ImGui.BeginDragDropSource() then - ImGui.SetDragDropPayload("MY_TREENODE_PAYLOAD_TYPE", nil, 0) - ImGui.Text("This is a drag and drop source") - ImGui.EndDragDropSource() + if s.use_drag_and_drop and ImGui_BeginDragDropSource() then + ImGui_SetDragDropPayload("MY_TREENODE_PAYLOAD_TYPE", nil, 0) + ImGui_Text("This is a drag and drop source") + ImGui_EndDragDropSource() end if node_n == 2 and bit32.band(s.base_flags_2, 8192 --[[ImGuiTreeNodeFlags.SpanLabelWidth]]) ~= 0 then -- Item 2 has an additional inline button to help demonstrate SpanLabelWidth. - ImGui.SameLine() - if ImGui.SmallButton("button") then end + ImGui_SameLine() + if ImGui_SmallButton("button") then end end if is_open then - ImGui.BulletText("Blah blah\nBlah Blah") - ImGui.SameLine() - ImGui.SmallButton("Button") - ImGui.TreePop() + ImGui_BulletText("Blah blah\nBlah Blah") + ImGui_SameLine() + ImGui_SmallButton("Button") + ImGui_TreePop() end else -- Items 3..5 are Tree Leaves @@ -27294,19 +27350,19 @@ function DemoWindowWidgetsTreeNodes() -- use BulletText() or advance the cursor by GetTreeNodeToLabelSpacing() and call Text(). node_flags = bit32.bor(node_flags, 256 --[[ImGuiTreeNodeFlags.Leaf]], 8 --[[ImGuiTreeNodeFlags.NoTreePushOnOpen]]) -- ImGuiTreeNodeFlags_Bullet ImGui.TreeNodeEx(node_n, node_flags, "Selectable Leaf %d", node_n) - if s.use_drag_and_drop and ImGui.BeginDragDropSource() then - ImGui.SetDragDropPayload("MY_TREENODE_PAYLOAD_TYPE", nil, 0) - ImGui.Text("This is a drag and drop source") - ImGui.EndDragDropSource() + if s.use_drag_and_drop and ImGui_BeginDragDropSource() then + ImGui_SetDragDropPayload("MY_TREENODE_PAYLOAD_TYPE", nil, 0) + ImGui_Text("This is a drag and drop source") + ImGui_EndDragDropSource() end end end if s.align_label_with_current_x_position then - ImGui.Indent(ImGui.GetTreeNodeToLabelSpacing()) + ImGui_Indent(ImGui_GetTreeNodeToLabelSpacing()) end - ImGui.TreePop() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end end @@ -27324,62 +27380,62 @@ function DemoWindowWidgetsVerticalSliders() if ImGui.TreeNode("Vertical Sliders") then IMGUI_DEMO_MARKER("Widgets/Vertical Sliders") local spacing = 4 - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(spacing, spacing)) + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(spacing, spacing)) - s.int_value = ImGui.VSliderInt("##int", ImVec2(18, 160), s.int_value, 0, 5) - ImGui.SameLine() + s.int_value = ImGui_VSliderInt("##int", ImVec2(18, 160), s.int_value, 0, 5) + ImGui_SameLine() local values = s.values - ImGui.PushID("set1") + ImGui_PushID("set1") for i = 0, 6 do - if i > 0 then ImGui.SameLine() end - ImGui.PushID(i) - ImGui.PushStyleColor(7 --[[ImGuiCol.FrameBg]], ImColor.HSV(i / 7.0, 0.5, 0.5).Value) - ImGui.PushStyleColor(8 --[[ImGuiCol.FrameBgHovered]], ImColor.HSV(i / 7.0, 0.6, 0.5).Value) - ImGui.PushStyleColor(9 --[[ImGuiCol.FrameBgActive]], ImColor.HSV(i / 7.0, 0.7, 0.5).Value) - ImGui.PushStyleColor(20 --[[ImGuiCol.SliderGrab]], ImColor.HSV(i / 7.0, 0.9, 0.9).Value) - values[i + 1] = ImGui.VSliderFloat("##v", ImVec2(18, 160), values[i + 1], 0.0, 1.0, "") - if ImGui.IsItemActive() or ImGui.IsItemHovered() then - ImGui.SetTooltip("%.3f", values[i + 1]) + if i > 0 then ImGui_SameLine() end + ImGui_PushID(i) + ImGui_PushStyleColor(7 --[[ImGuiCol.FrameBg]], ImColor.HSV(i / 7.0, 0.5, 0.5).Value) + ImGui_PushStyleColor(8 --[[ImGuiCol.FrameBgHovered]], ImColor.HSV(i / 7.0, 0.6, 0.5).Value) + ImGui_PushStyleColor(9 --[[ImGuiCol.FrameBgActive]], ImColor.HSV(i / 7.0, 0.7, 0.5).Value) + ImGui_PushStyleColor(20 --[[ImGuiCol.SliderGrab]], ImColor.HSV(i / 7.0, 0.9, 0.9).Value) + values[i + 1] = ImGui_VSliderFloat("##v", ImVec2(18, 160), values[i + 1], 0.0, 1.0, "") + if ImGui_IsItemActive() or ImGui_IsItemHovered() then + ImGui_SetTooltip("%.3f", values[i + 1]) end - ImGui.PopStyleColor(4) - ImGui.PopID() + ImGui_PopStyleColor(4) + ImGui_PopID() end - ImGui.PopID() + ImGui_PopID() - ImGui.SameLine() - ImGui.PushID("set2") + ImGui_SameLine() + ImGui_PushID("set2") local values2 = s.values2 local rows = 3 local small_slider_size = ImVec2(18, math.floor((160.0 - (rows - 1) * spacing) / rows)) for nx = 0, 3 do - if nx > 0 then ImGui.SameLine() end - ImGui.BeginGroup() + if nx > 0 then ImGui_SameLine() end + ImGui_BeginGroup() for ny = 0, rows - 1 do - ImGui.PushID(nx * rows + ny) - values2[nx + 1] = ImGui.VSliderFloat("##v", small_slider_size, values2[nx + 1], 0.0, 1.0, "") - if ImGui.IsItemActive() or ImGui.IsItemHovered() then - ImGui.SetTooltip("%.3f", values2[nx + 1]) + ImGui_PushID(nx * rows + ny) + values2[nx + 1] = ImGui_VSliderFloat("##v", small_slider_size, values2[nx + 1], 0.0, 1.0, "") + if ImGui_IsItemActive() or ImGui_IsItemHovered() then + ImGui_SetTooltip("%.3f", values2[nx + 1]) end - ImGui.PopID() + ImGui_PopID() end - ImGui.EndGroup() + ImGui_EndGroup() end - ImGui.PopID() + ImGui_PopID() - ImGui.SameLine() - ImGui.PushID("set3") + ImGui_SameLine() + ImGui_PushID("set3") for i = 0, 3 do - if i > 0 then ImGui.SameLine() end - ImGui.PushID(i) - ImGui.PushStyleVar(21 --[[ImGuiStyleVar.GrabMinSize]], 40) - values[i + 1] = ImGui.VSliderFloat("##v", ImVec2(40, 160), values[i + 1], 0.0, 1.0, "%.2f\nsec") - ImGui.PopStyleVar() - ImGui.PopID() + if i > 0 then ImGui_SameLine() end + ImGui_PushID(i) + ImGui_PushStyleVar(21 --[[ImGuiStyleVar.GrabMinSize]], 40) + values[i + 1] = ImGui_VSliderFloat("##v", ImVec2(40, 160), values[i + 1], 0.0, 1.0, "%.2f\nsec") + ImGui_PopStyleVar() + ImGui_PopID() end - ImGui.PopID() - ImGui.PopStyleVar() - ImGui.TreePop() + ImGui_PopID() + ImGui_PopStyleVar() + ImGui_TreePop() end end @@ -27397,11 +27453,11 @@ function DemoWindowWidgets(demo_data) local disable_all = demo_data.DisableSections -- The Checkbox for that is inside the "Disabled" section at the bottom local override_liveedit = demo_data.LiveEditOverride if disable_all then - ImGui.BeginDisabled() + ImGui_BeginDisabled() end if override_liveedit then - ImGui.PushItemFlag(128 --[[ImGuiItemFlags.LiveEditOnInputText]], bit32.band(demo_data.LiveEditFlags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) ~= 0) - ImGui.PushItemFlag(256 --[[ImGuiItemFlags.LiveEditOnInputScalar]], bit32.band(demo_data.LiveEditFlags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) ~= 0) + ImGui_PushItemFlag(128 --[[ImGuiItemFlags.LiveEditOnInputText]], bit32.band(demo_data.LiveEditFlags, 128 --[[ImGuiItemFlags.LiveEditOnInputText]]) ~= 0) + ImGui_PushItemFlag(256 --[[ImGuiItemFlags.LiveEditOnInputScalar]], bit32.band(demo_data.LiveEditFlags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) ~= 0) end DemoWindowWidgetsBasic() @@ -27412,11 +27468,11 @@ function DemoWindowWidgets(demo_data) DemoWindowWidgetsDataTypes() if disable_all then - ImGui.EndDisabled() + ImGui_EndDisabled() end DemoWindowWidgetsDisableBlocks(demo_data) if disable_all then - ImGui.BeginDisabled() + ImGui_BeginDisabled() end DemoWindowWidgetsDragAndDrop() @@ -27441,11 +27497,11 @@ function DemoWindowWidgets(demo_data) DemoWindowWidgetsVerticalSliders() if override_liveedit then - ImGui.PopItemFlag() - ImGui.PopItemFlag() + ImGui_PopItemFlag() + ImGui_PopItemFlag() end if disable_all then - ImGui.EndDisabled() + ImGui_EndDisabled() end end @@ -27502,11 +27558,11 @@ function DemoWindowLayout() if ImGui.TreeNode("Child windows") then IMGUI_DEMO_MARKER("Layout/Child windows") - ImGui.SeparatorText("Child windows") + ImGui_SeparatorText("Child windows") HelpMarker("Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window.") - _, s.disable_mouse_wheel = ImGui.Checkbox("Disable Mouse Wheel", s.disable_mouse_wheel) - _, s.disable_menu = ImGui.Checkbox("Disable Menu", s.disable_menu) + _, s.disable_mouse_wheel = ImGui_Checkbox("Disable Mouse Wheel", s.disable_mouse_wheel) + _, s.disable_menu = ImGui_Checkbox("Disable Menu", s.disable_menu) -- Child 1: no border, enable horizontal scrollbar do @@ -27514,14 +27570,14 @@ function DemoWindowLayout() if s.disable_mouse_wheel then window_flags = bit32.bor(window_flags, 16 --[[ImGuiWindowFlags.NoScrollWithMouse]]) end - ImGui.BeginChild("ChildL", ImVec2(ImGui.GetContentRegionAvail().x * 0.5, 260), 0 --[[ImGuiChildFlags.None]], window_flags) + ImGui_BeginChild("ChildL", ImVec2(ImGui_GetContentRegionAvail().x * 0.5, 260), 0 --[[ImGuiChildFlags.None]], window_flags) for i = 0, 99 do - ImGui.Text("%04d: scrollable region", i) + ImGui_Text("%04d: scrollable region", i) end - ImGui.EndChild() + ImGui_EndChild() end - ImGui.SameLine() + ImGui_SameLine() -- Child 2: rounded border do @@ -27532,62 +27588,62 @@ function DemoWindowLayout() if not s.disable_menu then window_flags = bit32.bor(window_flags, 1024 --[[ImGuiWindowFlags.MenuBar]]) end - ImGui.PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], 5.0) - ImGui.BeginChild("ChildR", ImVec2(0, 260), 1 --[[ImGuiChildFlags.Borders]], window_flags) - if not s.disable_menu and ImGui.BeginMenuBar() then - if ImGui.BeginMenu("Menu") then + ImGui_PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], 5.0) + ImGui_BeginChild("ChildR", ImVec2(0, 260), 1 --[[ImGuiChildFlags.Borders]], window_flags) + if not s.disable_menu and ImGui_BeginMenuBar() then + if ImGui_BeginMenu("Menu") then ShowExampleMenuFile() - ImGui.EndMenu() + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end - if ImGui.BeginTable("split", 2, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]])) then + if ImGui_BeginTable("split", 2, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 16 --[[ImGuiTableFlags.NoSavedSettings]])) then for i = 0, 99 do local buf = string.format("%03d", i) - ImGui.TableNextColumn() - ImGui.Button(buf, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) + ImGui_TableNextColumn() + ImGui_Button(buf, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.EndChild() - ImGui.PopStyleVar() + ImGui_EndChild() + ImGui_PopStyleVar() end -- Child 3: manual-resize - ImGui.SeparatorText("Manual-resize") + ImGui_SeparatorText("Manual-resize") do HelpMarker("Drag bottom border to resize. Double-click bottom border to auto-fit to vertical contents.") --if (ImGui.Button("Set Height to 200")) -- ImGui.SetNextWindowSize(ImVec2(-FLT_MIN, 200.0f)); - ImGui.PushStyleColor(3 --[[ImGuiCol.ChildBg]], ImGui.GetStyleColorVec4(7 --[[ImGuiCol.FrameBg]])) - if ImGui.BeginChild("ResizableChild", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui.GetTextLineHeightWithSpacing() * 8), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 8 --[[ImGuiChildFlags.ResizeY]])) then + ImGui_PushStyleColor(3 --[[ImGuiCol.ChildBg]], ImGui_GetStyleColorVec4(7 --[[ImGuiCol.FrameBg]])) + if ImGui_BeginChild("ResizableChild", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], ImGui_GetTextLineHeightWithSpacing() * 8), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 8 --[[ImGuiChildFlags.ResizeY]])) then for n = 0, 9 do - ImGui.Text("Line %04d", n) + ImGui_Text("Line %04d", n) end end - ImGui.PopStyleColor() - ImGui.EndChild() + ImGui_PopStyleColor() + ImGui_EndChild() end -- Child 4: auto-resizing height with a limit - ImGui.SeparatorText("Auto-resize with constraints") + ImGui_SeparatorText("Auto-resize with constraints") do - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - s.draw_lines = ImGui.DragInt("Lines Count", s.draw_lines, 0.2) - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - s.max_height_in_lines = ImGui.DragInt("Max Height (in Lines)", s.max_height_in_lines, 0.2) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + s.draw_lines = ImGui_DragInt("Lines Count", s.draw_lines, 0.2) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + s.max_height_in_lines = ImGui_DragInt("Max Height (in Lines)", s.max_height_in_lines, 0.2) - ImGui.SetNextWindowSizeConstraints(ImVec2(0.0, ImGui.GetTextLineHeightWithSpacing() * 1), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], ImGui.GetTextLineHeightWithSpacing() * s.max_height_in_lines)) - if ImGui.BeginChild("ConstrainedChild", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 32 --[[ImGuiChildFlags.AutoResizeY]])) then + ImGui_SetNextWindowSizeConstraints(ImVec2(0.0, ImGui_GetTextLineHeightWithSpacing() * 1), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], ImGui_GetTextLineHeightWithSpacing() * s.max_height_in_lines)) + if ImGui_BeginChild("ConstrainedChild", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 32 --[[ImGuiChildFlags.AutoResizeY]])) then for n = 0, s.draw_lines - 1 do - ImGui.Text("Line %04d", n) + ImGui_Text("Line %04d", n) end end - ImGui.EndChild() + ImGui_EndChild() end - ImGui.SeparatorText("Misc/Advanced") + ImGui_SeparatorText("Misc/Advanced") -- Demonstrate a few extra things -- - Changing ImGuiCol.ChildBg (which is transparent black in default styles) @@ -27597,206 +27653,206 @@ function DemoWindowLayout() -- - Using ImGui.GetItemRectMin/Max() to query the "item" state (because the child window is an item from -- the POV of the parent window). See 'Demo->Querying Status (Edited/Active/Hovered etc.)' for details. do - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - s.offset_x = ImGui.DragInt("Offset X", s.offset_x, 1.0, -1000, 1000) - _, s.override_bg_color = ImGui.Checkbox("Override ChildBg color", s.override_bg_color) - _, s.child_flags = ImGui.CheckboxFlags("ImGuiChildFlags_Borders", s.child_flags, 1 --[[ImGuiChildFlags.Borders]]) - _, s.child_flags = ImGui.CheckboxFlags("ImGuiChildFlags_AlwaysUseWindowPadding", s.child_flags, 2 --[[ImGuiChildFlags.AlwaysUseWindowPadding]]) - _, s.child_flags = ImGui.CheckboxFlags("ImGuiChildFlags_ResizeX", s.child_flags, 4 --[[ImGuiChildFlags.ResizeX]]) - _, s.child_flags = ImGui.CheckboxFlags("ImGuiChildFlags_ResizeY", s.child_flags, 8 --[[ImGuiChildFlags.ResizeY]]) - _, s.child_flags = ImGui.CheckboxFlags("ImGuiChildFlags_FrameStyle", s.child_flags, 128 --[[ImGuiChildFlags.FrameStyle]]) - ImGui.SameLine(); HelpMarker("Style the child window like a framed item: use FrameBg, FrameRounding, FrameBorderSize, FramePadding instead of ChildBg, ChildRounding, ChildBorderSize, WindowPadding.") + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + s.offset_x = ImGui_DragInt("Offset X", s.offset_x, 1.0, -1000, 1000) + _, s.override_bg_color = ImGui_Checkbox("Override ChildBg color", s.override_bg_color) + _, s.child_flags = ImGui_CheckboxFlags("ImGuiChildFlags_Borders", s.child_flags, 1 --[[ImGuiChildFlags.Borders]]) + _, s.child_flags = ImGui_CheckboxFlags("ImGuiChildFlags_AlwaysUseWindowPadding", s.child_flags, 2 --[[ImGuiChildFlags.AlwaysUseWindowPadding]]) + _, s.child_flags = ImGui_CheckboxFlags("ImGuiChildFlags_ResizeX", s.child_flags, 4 --[[ImGuiChildFlags.ResizeX]]) + _, s.child_flags = ImGui_CheckboxFlags("ImGuiChildFlags_ResizeY", s.child_flags, 8 --[[ImGuiChildFlags.ResizeY]]) + _, s.child_flags = ImGui_CheckboxFlags("ImGuiChildFlags_FrameStyle", s.child_flags, 128 --[[ImGuiChildFlags.FrameStyle]]) + ImGui_SameLine(); HelpMarker("Style the child window like a framed item: use FrameBg, FrameRounding, FrameBorderSize, FramePadding instead of ChildBg, ChildRounding, ChildBorderSize, WindowPadding.") if bit32.band(s.child_flags, 128 --[[ImGuiChildFlags.FrameStyle]]) ~= 0 then s.override_bg_color = false end - ImGui.SetCursorPosX(ImGui.GetCursorPosX() + s.offset_x) + ImGui_SetCursorPosX(ImGui_GetCursorPosX() + s.offset_x) if s.override_bg_color then - ImGui.PushStyleColor(3 --[[ImGuiCol.ChildBg]], IM_COL32(255, 0, 0, 100)) + ImGui_PushStyleColor(3 --[[ImGuiCol.ChildBg]], IM_COL32(255, 0, 0, 100)) end - ImGui.BeginChild("Red", ImVec2(200, 100), s.child_flags, 0 --[[ImGuiWindowFlags.None]]) + ImGui_BeginChild("Red", ImVec2(200, 100), s.child_flags, 0 --[[ImGuiWindowFlags.None]]) if s.override_bg_color then - ImGui.PopStyleColor() + ImGui_PopStyleColor() end for n = 0, 49 do - ImGui.Text("Some test %d", n) + ImGui_Text("Some test %d", n) end - ImGui.EndChild() - local child_is_hovered = ImGui.IsItemHovered() - local child_rect_min = ImGui.GetItemRectMin() - local child_rect_max = ImGui.GetItemRectMax() - ImGui.Text("Hovered: %d", child_is_hovered and 1 or 0) - ImGui.Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y) + ImGui_EndChild() + local child_is_hovered = ImGui_IsItemHovered() + local child_rect_min = ImGui_GetItemRectMin() + local child_rect_max = ImGui_GetItemRectMax() + ImGui_Text("Hovered: %d", child_is_hovered and 1 or 0) + ImGui_Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y) end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Widgets Width") then IMGUI_DEMO_MARKER("Layout/Widgets Width") - _, s.show_indented_items = ImGui.Checkbox("Show indented items", s.show_indented_items) + _, s.show_indented_items = ImGui_Checkbox("Show indented items", s.show_indented_items) -- Use SetNextItemWidth() to set the width of a single upcoming item. -- Use PushItemWidth()/PopItemWidth() to set the width of a group of items. -- In real code use you'll probably want to choose width values that are proportional to your font size -- e.g. Using '20.0f * GetFontSize()' as width instead of '200.0f', etc. - ImGui.Text("SetNextItemWidth/PushItemWidth(100)") - ImGui.SameLine(); HelpMarker("Fixed width.") - ImGui.PushItemWidth(100) - s.f = ImGui.DragFloat("float##1b", s.f) + ImGui_Text("SetNextItemWidth/PushItemWidth(100)") + ImGui_SameLine(); HelpMarker("Fixed width.") + ImGui_PushItemWidth(100) + s.f = ImGui_DragFloat("float##1b", s.f) if s.show_indented_items then - ImGui.Indent() - s.f = ImGui.DragFloat("float (indented)##1b", s.f) - ImGui.Unindent() + ImGui_Indent() + s.f = ImGui_DragFloat("float (indented)##1b", s.f) + ImGui_Unindent() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() - ImGui.Text("SetNextItemWidth/PushItemWidth(-100)") - ImGui.SameLine(); HelpMarker("Align to right edge minus 100") - ImGui.PushItemWidth(-100) - s.f = ImGui.DragFloat("float##2a", s.f) + ImGui_Text("SetNextItemWidth/PushItemWidth(-100)") + ImGui_SameLine(); HelpMarker("Align to right edge minus 100") + ImGui_PushItemWidth(-100) + s.f = ImGui_DragFloat("float##2a", s.f) if s.show_indented_items then - ImGui.Indent() - s.f = ImGui.DragFloat("float (indented)##2b", s.f) - ImGui.Unindent() + ImGui_Indent() + s.f = ImGui_DragFloat("float (indented)##2b", s.f) + ImGui_Unindent() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() - ImGui.Text("SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)") - ImGui.SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)") - ImGui.PushItemWidth(ImGui.GetContentRegionAvail().x * 0.5) - s.f = ImGui.DragFloat("float##3a", s.f) + ImGui_Text("SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)") + ImGui_SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)") + ImGui_PushItemWidth(ImGui_GetContentRegionAvail().x * 0.5) + s.f = ImGui_DragFloat("float##3a", s.f) if s.show_indented_items then - ImGui.Indent() - s.f = ImGui.DragFloat("float (indented)##3b", s.f) - ImGui.Unindent() + ImGui_Indent() + s.f = ImGui_DragFloat("float (indented)##3b", s.f) + ImGui_Unindent() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() - ImGui.Text("SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)") - ImGui.SameLine(); HelpMarker("Align to right edge minus half") - ImGui.PushItemWidth(-ImGui.GetContentRegionAvail().x * 0.5) - s.f = ImGui.DragFloat("float##4a", s.f) + ImGui_Text("SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)") + ImGui_SameLine(); HelpMarker("Align to right edge minus half") + ImGui_PushItemWidth(-ImGui_GetContentRegionAvail().x * 0.5) + s.f = ImGui_DragFloat("float##4a", s.f) if s.show_indented_items then - ImGui.Indent() - s.f = ImGui.DragFloat("float (indented)##4b", s.f) - ImGui.Unindent() + ImGui_Indent() + s.f = ImGui_DragFloat("float (indented)##4b", s.f) + ImGui_Unindent() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() - ImGui.Text("SetNextItemWidth/PushItemWidth(-Min(GetContentRegionAvail().x * 0.40f, GetFontSize() * 12))") - ImGui.PushItemWidth(-ImMin(ImGui.GetFontSize() * 12, ImGui.GetContentRegionAvail().x * 0.40)) - s.f = ImGui.DragFloat("float##5a", s.f) + ImGui_Text("SetNextItemWidth/PushItemWidth(-Min(GetContentRegionAvail().x * 0.40f, GetFontSize() * 12))") + ImGui_PushItemWidth(-ImMin(ImGui_GetFontSize() * 12, ImGui_GetContentRegionAvail().x * 0.40)) + s.f = ImGui_DragFloat("float##5a", s.f) if s.show_indented_items then - ImGui.Indent() - s.f = ImGui.DragFloat("float (indented)##5b", s.f) - ImGui.Unindent() + ImGui_Indent() + s.f = ImGui_DragFloat("float (indented)##5b", s.f) + ImGui_Unindent() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() -- Demonstrate using PushItemWidth to surround three items. -- Calling SetNextItemWidth() before each of them would have the same effect. - ImGui.Text("SetNextItemWidth/PushItemWidth(-FLT_MIN)") - ImGui.SameLine(); HelpMarker("Align to right edge") - ImGui.PushItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) - s.f = ImGui.DragFloat("##float6a", s.f) + ImGui_Text("SetNextItemWidth/PushItemWidth(-FLT_MIN)") + ImGui_SameLine(); HelpMarker("Align to right edge") + ImGui_PushItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + s.f = ImGui_DragFloat("##float6a", s.f) if s.show_indented_items then - ImGui.Indent() - s.f = ImGui.DragFloat("float (indented)##6b", s.f) - ImGui.Unindent() + ImGui_Indent() + s.f = ImGui_DragFloat("float (indented)##6b", s.f) + ImGui_Unindent() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Basic Horizontal Layout") then IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout") - ImGui.TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)") + ImGui_TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)") -- Text IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/SameLine") - ImGui.Text("Two items: Hello"); ImGui.SameLine() - ImGui.TextColored(ImVec4(1, 1, 0, 1), "Sailor") + ImGui_Text("Two items: Hello"); ImGui_SameLine() + ImGui_TextColored(ImVec4(1, 1, 0, 1), "Sailor") -- Adjust spacing - ImGui.Text("More spacing: Hello"); ImGui.SameLine(0, 20) - ImGui.TextColored(ImVec4(1, 1, 0, 1), "Sailor") + ImGui_Text("More spacing: Hello"); ImGui_SameLine(0, 20) + ImGui_TextColored(ImVec4(1, 1, 0, 1), "Sailor") -- Button - ImGui.AlignTextToFramePadding() - ImGui.Text("Normal buttons"); ImGui.SameLine() - ImGui.Button("Banana"); ImGui.SameLine() - ImGui.Button("Apple"); ImGui.SameLine() - ImGui.Button("Corniflower") + ImGui_AlignTextToFramePadding() + ImGui_Text("Normal buttons"); ImGui_SameLine() + ImGui_Button("Banana"); ImGui_SameLine() + ImGui_Button("Apple"); ImGui_SameLine() + ImGui_Button("Corniflower") -- Button - ImGui.Text("Small buttons"); ImGui.SameLine() - ImGui.SmallButton("Like this one"); ImGui.SameLine() - ImGui.Text("can fit within a text block.") + ImGui_Text("Small buttons"); ImGui_SameLine() + ImGui_SmallButton("Like this one"); ImGui_SameLine() + ImGui_Text("can fit within a text block.") -- Aligned to arbitrary position. Easy/cheap column. IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/SameLine (with offset)") - ImGui.Text("Aligned") - ImGui.SameLine(150); ImGui.Text("x=150") - ImGui.SameLine(300); ImGui.Text("x=300") - ImGui.Text("Aligned") - ImGui.SameLine(150); ImGui.SmallButton("x=150") - ImGui.SameLine(300); ImGui.SmallButton("x=300") + ImGui_Text("Aligned") + ImGui_SameLine(150); ImGui_Text("x=150") + ImGui_SameLine(300); ImGui_Text("x=300") + ImGui_Text("Aligned") + ImGui_SameLine(150); ImGui_SmallButton("x=150") + ImGui_SameLine(300); ImGui_SmallButton("x=300") -- Checkbox IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/SameLine (more)") - _, s.c1 = ImGui.Checkbox("My", s.c1); ImGui.SameLine() - _, s.c2 = ImGui.Checkbox("Tailor", s.c2); ImGui.SameLine() - _, s.c3 = ImGui.Checkbox("Is", s.c3); ImGui.SameLine() - _, s.c4 = ImGui.Checkbox("Rich", s.c4) + _, s.c1 = ImGui_Checkbox("My", s.c1); ImGui_SameLine() + _, s.c2 = ImGui_Checkbox("Tailor", s.c2); ImGui_SameLine() + _, s.c3 = ImGui_Checkbox("Is", s.c3); ImGui_SameLine() + _, s.c4 = ImGui_Checkbox("Rich", s.c4) -- Various - ImGui.PushItemWidth(ImGui.CalcTextSize("AAAAAAA").x) + ImGui_PushItemWidth(ImGui_CalcTextSize("AAAAAAA").x) local items = { "AAAA", "BBBB", "CCCC", "DDDD" } - s.item = ImGui.Combo("Combo", s.item, items, #items); ImGui.SameLine() - s.f0 = ImGui.SliderFloat("X", s.f0, 0.0, 5.0); ImGui.SameLine() - s.f1 = ImGui.SliderFloat("Y", s.f1, 0.0, 5.0); ImGui.SameLine() - s.f2 = ImGui.SliderFloat("Z", s.f2, 0.0, 5.0) + s.item = ImGui_Combo("Combo", s.item, items, #items); ImGui_SameLine() + s.f0 = ImGui_SliderFloat("X", s.f0, 0.0, 5.0); ImGui_SameLine() + s.f1 = ImGui_SliderFloat("Y", s.f1, 0.0, 5.0); ImGui_SameLine() + s.f2 = ImGui_SliderFloat("Z", s.f2, 0.0, 5.0) - ImGui.Text("Lists:") + ImGui_Text("Lists:") for i = 0, 3 do - if i > 0 then ImGui.SameLine() end - ImGui.PushID(i) - s.selection[i + 1] = ImGui.ListBox("", s.selection[i + 1], items, #items) - ImGui.PopID() + if i > 0 then ImGui_SameLine() end + ImGui_PushID(i) + s.selection[i + 1] = ImGui_ListBox("", s.selection[i + 1], items, #items) + ImGui_PopID() --ImGui.SetItemTooltip("ListBox %d hovered", i); end - ImGui.PopItemWidth() + ImGui_PopItemWidth() -- Dummy IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/Dummy") local button_sz = ImVec2(40, 40) - ImGui.Button("A", button_sz); ImGui.SameLine() - ImGui.Dummy(button_sz); ImGui.SameLine() - ImGui.Button("B", button_sz) + ImGui_Button("A", button_sz); ImGui_SameLine() + ImGui_Dummy(button_sz); ImGui_SameLine() + ImGui_Button("B", button_sz) -- Manually wrapping -- (we should eventually provide this as an automatic layout feature, but for now you can do it manually) IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/Manual wrapping") - ImGui.Text("Manual wrapping:") - local style = ImGui.GetStyle() + ImGui_Text("Manual wrapping:") + local style = ImGui_GetStyle() local buttons_count = 20 - local window_visible_x2 = ImGui.GetCursorScreenPos().x + ImGui.GetContentRegionAvail().x + local window_visible_x2 = ImGui_GetCursorScreenPos().x + ImGui_GetContentRegionAvail().x for n = 0, buttons_count - 1 do - ImGui.PushID(n) - ImGui.Button("Box", button_sz) - local last_button_x2 = ImGui.GetItemRectMax().x + ImGui_PushID(n) + ImGui_Button("Box", button_sz) + local last_button_x2 = ImGui_GetItemRectMax().x local next_button_x2 = last_button_x2 + style.ItemSpacing.x + button_sz.x -- Expected position if next button was on same line if n + 1 < buttons_count and next_button_x2 < window_visible_x2 then - ImGui.SameLine() + ImGui_SameLine() end - ImGui.PopID() + ImGui_PopID() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Groups") then @@ -27805,171 +27861,171 @@ function DemoWindowLayout() "BeginGroup() basically locks the horizontal position for new line. " .. "EndGroup() bundles the whole group so that you can use \"item\" functions such as " .. "IsItemHovered()/IsItemActive() or SameLine() etc. on the whole group.") - ImGui.BeginGroup() + ImGui_BeginGroup() do - ImGui.BeginGroup() - ImGui.Button("AAA") - ImGui.SameLine() - ImGui.Button("BBB") - ImGui.SameLine() - ImGui.BeginGroup() - ImGui.Button("CCC") - ImGui.Button("DDD") - ImGui.EndGroup() - ImGui.SameLine() - ImGui.Button("EEE") - ImGui.EndGroup() - ImGui.SetItemTooltip("First group hovered") + ImGui_BeginGroup() + ImGui_Button("AAA") + ImGui_SameLine() + ImGui_Button("BBB") + ImGui_SameLine() + ImGui_BeginGroup() + ImGui_Button("CCC") + ImGui_Button("DDD") + ImGui_EndGroup() + ImGui_SameLine() + ImGui_Button("EEE") + ImGui_EndGroup() + ImGui_SetItemTooltip("First group hovered") end -- Capture the group size and create widgets using the same size - local size = ImGui.GetItemRectSize() + local size = ImGui_GetItemRectSize() local values = { 0.5, 0.20, 0.80, 0.60, 0.25 } - ImGui.PlotHistogram("##values", values, nil, #values, 0, nil, 0.0, 1.0, size) + ImGui_PlotHistogram("##values", values, nil, #values, 0, nil, 0.0, 1.0, size) - ImGui.Button("ACTION", ImVec2((size.x - ImGui.GetStyle().ItemSpacing.x) * 0.5, size.y)) - ImGui.SameLine() - ImGui.Button("REACTION", ImVec2((size.x - ImGui.GetStyle().ItemSpacing.x) * 0.5, size.y)) - ImGui.EndGroup() - ImGui.SameLine() + ImGui_Button("ACTION", ImVec2((size.x - ImGui_GetStyle().ItemSpacing.x) * 0.5, size.y)) + ImGui_SameLine() + ImGui_Button("REACTION", ImVec2((size.x - ImGui_GetStyle().ItemSpacing.x) * 0.5, size.y)) + ImGui_EndGroup() + ImGui_SameLine() - ImGui.Button("LEVERAGE\nBUZZWORD", size) - ImGui.SameLine() + ImGui_Button("LEVERAGE\nBUZZWORD", size) + ImGui_SameLine() - if ImGui.BeginListBox("List", size) then - ImGui.Selectable("Selected", true) - ImGui.Selectable("Not Selected", false) - ImGui.EndListBox() + if ImGui_BeginListBox("List", size) then + ImGui_Selectable("Selected", true) + ImGui_Selectable("Not Selected", false) + ImGui_EndListBox() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Text Baseline Alignment") then IMGUI_DEMO_MARKER("Layout/Text Baseline Alignment") do - ImGui.BulletText("Text baseline:") - ImGui.SameLine(); HelpMarker( + ImGui_BulletText("Text baseline:") + ImGui_SameLine(); HelpMarker( "This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. " .. "Lines only composed of text or \"small\" widgets use less vertical space than lines with framed widgets.") - ImGui.Indent() + ImGui_Indent() - ImGui.Text("KO Blahblah"); ImGui.SameLine() - ImGui.Button("Some framed item"); ImGui.SameLine() + ImGui_Text("KO Blahblah"); ImGui_SameLine() + ImGui_Button("Some framed item"); ImGui_SameLine() HelpMarker("Baseline of button will look misaligned with text..") -- If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets. -- (because we don't know what's coming after the Text() statement, we need to move the text baseline -- down by FramePadding.y ahead of time) - ImGui.AlignTextToFramePadding() - ImGui.Text("OK Blahblah"); ImGui.SameLine() - ImGui.Button("Some framed item##2"); ImGui.SameLine() + ImGui_AlignTextToFramePadding() + ImGui_Text("OK Blahblah"); ImGui_SameLine() + ImGui_Button("Some framed item##2"); ImGui_SameLine() HelpMarker("We call AlignTextToFramePadding() to vertically align the text baseline by +FramePadding.y") -- SmallButton() uses the same vertical padding as Text - ImGui.Button("TEST##1"); ImGui.SameLine() - ImGui.Text("TEST"); ImGui.SameLine() - ImGui.SmallButton("TEST##2") + ImGui_Button("TEST##1"); ImGui_SameLine() + ImGui_Text("TEST"); ImGui_SameLine() + ImGui_SmallButton("TEST##2") -- If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets. - ImGui.AlignTextToFramePadding() - ImGui.Text("Text aligned to framed item"); ImGui.SameLine() - ImGui.Button("Item##1"); ImGui.SameLine() - ImGui.Text("Item"); ImGui.SameLine() - ImGui.SmallButton("Item##2"); ImGui.SameLine() - ImGui.Button("Item##3") + ImGui_AlignTextToFramePadding() + ImGui_Text("Text aligned to framed item"); ImGui_SameLine() + ImGui_Button("Item##1"); ImGui_SameLine() + ImGui_Text("Item"); ImGui_SameLine() + ImGui_SmallButton("Item##2"); ImGui_SameLine() + ImGui_Button("Item##3") - ImGui.Unindent() + ImGui_Unindent() end - ImGui.Spacing() + ImGui_Spacing() do - ImGui.BulletText("Multi-line text:") - ImGui.Indent() - ImGui.Text("One\nTwo\nThree"); ImGui.SameLine() - ImGui.Text("Hello\nWorld"); ImGui.SameLine() - ImGui.Text("Banana") + ImGui_BulletText("Multi-line text:") + ImGui_Indent() + ImGui_Text("One\nTwo\nThree"); ImGui_SameLine() + ImGui_Text("Hello\nWorld"); ImGui_SameLine() + ImGui_Text("Banana") - ImGui.Text("Banana"); ImGui.SameLine() - ImGui.Text("Hello\nWorld"); ImGui.SameLine() - ImGui.Text("One\nTwo\nThree") + ImGui_Text("Banana"); ImGui_SameLine() + ImGui_Text("Hello\nWorld"); ImGui_SameLine() + ImGui_Text("One\nTwo\nThree") - ImGui.Button("HOP##1"); ImGui.SameLine() - ImGui.Text("Banana"); ImGui.SameLine() - ImGui.Text("Hello\nWorld"); ImGui.SameLine() - ImGui.Text("Banana") + ImGui_Button("HOP##1"); ImGui_SameLine() + ImGui_Text("Banana"); ImGui_SameLine() + ImGui_Text("Hello\nWorld"); ImGui_SameLine() + ImGui_Text("Banana") - ImGui.Button("HOP##2"); ImGui.SameLine() - ImGui.Text("Hello\nWorld"); ImGui.SameLine() - ImGui.Text("Banana") - ImGui.Unindent() + ImGui_Button("HOP##2"); ImGui_SameLine() + ImGui_Text("Hello\nWorld"); ImGui_SameLine() + ImGui_Text("Banana") + ImGui_Unindent() end - ImGui.Spacing() + ImGui_Spacing() do - ImGui.BulletText("Misc items:") - ImGui.Indent() + ImGui_BulletText("Misc items:") + ImGui_Indent() -- SmallButton() sets FramePadding to zero. Text baseline is aligned to match baseline of previous Button. - ImGui.Button("80x80", ImVec2(80, 80)) - ImGui.SameLine() - ImGui.Button("50x50", ImVec2(50, 50)) - ImGui.SameLine() - ImGui.Button("Button()") - ImGui.SameLine() - ImGui.SmallButton("SmallButton()") + ImGui_Button("80x80", ImVec2(80, 80)) + ImGui_SameLine() + ImGui_Button("50x50", ImVec2(50, 50)) + ImGui_SameLine() + ImGui_Button("Button()") + ImGui_SameLine() + ImGui_SmallButton("SmallButton()") -- Tree -- (here the node appears after a button and has odd intent, so we use ImGuiTreeNodeFlags.DrawLinesNone to disable hierarchy outline) - local spacing = ImGui.GetStyle().ItemInnerSpacing.x - ImGui.Button("Button##1") -- Will make line higher - ImGui.SameLine(0.0, spacing) + local spacing = ImGui_GetStyle().ItemInnerSpacing.x + ImGui_Button("Button##1") -- Will make line higher + ImGui_SameLine(0.0, spacing) if ImGui.TreeNodeEx("Node##1", 262144 --[[ImGuiTreeNodeFlags.DrawLinesNone]]) then -- Placeholder tree data for i = 0, 5 do - ImGui.BulletText("Item %d..", i) + ImGui_BulletText("Item %d..", i) end - ImGui.TreePop() + ImGui_TreePop() end - local padding = math.floor(ImGui.GetFontSize() * 1.20) -- Large padding - ImGui.PushStyleVarY(11 --[[ImGuiStyleVar.FramePadding]], padding) - ImGui.Button("Button##2") - ImGui.PopStyleVar() - ImGui.SameLine(0.0, spacing) + local padding = math.floor(ImGui_GetFontSize() * 1.20) -- Large padding + ImGui_PushStyleVarY(11 --[[ImGuiStyleVar.FramePadding]], padding) + ImGui_Button("Button##2") + ImGui_PopStyleVar() + ImGui_SameLine(0.0, spacing) if ImGui.TreeNodeEx("Node##2", 262144 --[[ImGuiTreeNodeFlags.DrawLinesNone]]) then - ImGui.TreePop() + ImGui_TreePop() end -- Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. -- Otherwise you can use SmallButton() (smaller fit). - ImGui.AlignTextToFramePadding() + ImGui_AlignTextToFramePadding() -- Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add -- other contents "inside" the node. local node_open = ImGui.TreeNode("Node##3") - ImGui.SameLine(0.0, spacing); ImGui.Button("Button##3") + ImGui_SameLine(0.0, spacing); ImGui_Button("Button##3") if node_open then -- Placeholder tree data for i = 0, 5 do - ImGui.BulletText("Item %d..", i) + ImGui_BulletText("Item %d..", i) end - ImGui.TreePop() + ImGui_TreePop() end -- Bullet - ImGui.Button("Button##4") - ImGui.SameLine(0.0, spacing) - ImGui.BulletText("Bullet text") + ImGui_Button("Button##4") + ImGui_SameLine(0.0, spacing) + ImGui_BulletText("Bullet text") - ImGui.AlignTextToFramePadding() - ImGui.BulletText("Node") - ImGui.SameLine(0.0, spacing); ImGui.Button("Button##5") - ImGui.Unindent() + ImGui_AlignTextToFramePadding() + ImGui_BulletText("Node") + ImGui_SameLine(0.0, spacing); ImGui_Button("Button##5") + ImGui_Unindent() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Scrolling") then @@ -27977,268 +28033,268 @@ function DemoWindowLayout() -- Vertical scroll functions HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position.") - _, s.enable_extra_decorations = ImGui.Checkbox("Decoration", s.enable_extra_decorations) + _, s.enable_extra_decorations = ImGui_Checkbox("Decoration", s.enable_extra_decorations) - ImGui.PushItemWidth(ImGui.GetFontSize() * 10) + ImGui_PushItemWidth(ImGui_GetFontSize() * 10) local track_changed - s.track_item, track_changed = ImGui.DragInt("##item", s.track_item, 0.25, 0, 99, "Item = %d") + s.track_item, track_changed = ImGui_DragInt("##item", s.track_item, 0.25, 0, 99, "Item = %d") s.enable_track = s.enable_track or track_changed - ImGui.SameLine() - _, s.enable_track = ImGui.Checkbox("Track", s.enable_track) + ImGui_SameLine() + _, s.enable_track = ImGui_Checkbox("Track", s.enable_track) local scroll_to_off - s.scroll_to_off_px, scroll_to_off = ImGui.DragFloat("##off", s.scroll_to_off_px, 1.00, 0, 3.4028234663853e+38 --[[FLT_MAX]], "+%.0f px") - ImGui.SameLine() - scroll_to_off = ImGui.Button("Scroll Offset") or scroll_to_off + s.scroll_to_off_px, scroll_to_off = ImGui_DragFloat("##off", s.scroll_to_off_px, 1.00, 0, 3.4028234663853e+38 --[[FLT_MAX]], "+%.0f px") + ImGui_SameLine() + scroll_to_off = ImGui_Button("Scroll Offset") or scroll_to_off local scroll_to_pos - s.scroll_to_pos_px, scroll_to_pos = ImGui.DragFloat("##pos", s.scroll_to_pos_px, 1.00, -10, 3.4028234663853e+38 --[[FLT_MAX]], "X/Y = %.0f px") - ImGui.SameLine() - scroll_to_pos = ImGui.Button("Scroll To Pos") or scroll_to_pos - ImGui.PopItemWidth() + s.scroll_to_pos_px, scroll_to_pos = ImGui_DragFloat("##pos", s.scroll_to_pos_px, 1.00, -10, 3.4028234663853e+38 --[[FLT_MAX]], "X/Y = %.0f px") + ImGui_SameLine() + scroll_to_pos = ImGui_Button("Scroll To Pos") or scroll_to_pos + ImGui_PopItemWidth() if scroll_to_off or scroll_to_pos then s.enable_track = false end - local style = ImGui.GetStyle() - local child_w = (ImGui.GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5 + local style = ImGui_GetStyle() + local child_w = (ImGui_GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5 if child_w < 1.0 then child_w = 1.0 end - ImGui.PushID("##VerticalScrolling") + ImGui_PushID("##VerticalScrolling") for i = 0, 4 do - if i > 0 then ImGui.SameLine() end - ImGui.BeginGroup() + if i > 0 then ImGui_SameLine() end + ImGui_BeginGroup() local names = { "Top", "25%", "Center", "75%", "Bottom" } - ImGui.TextUnformatted(names[i + 1]) + ImGui_TextUnformatted(names[i + 1]) local child_flags = 0 if s.enable_extra_decorations then child_flags = 1024 --[[ImGuiWindowFlags.MenuBar]] end - local child_id = ImGui.GetID(i) - local child_is_visible = ImGui.BeginChild(child_id, ImVec2(child_w, 200.0), 1 --[[ImGuiChildFlags.Borders]], child_flags) - if ImGui.BeginMenuBar() then - ImGui.TextUnformatted("abc") - ImGui.EndMenuBar() + local child_id = ImGui_GetID(i) + local child_is_visible = ImGui_BeginChild(child_id, ImVec2(child_w, 200.0), 1 --[[ImGuiChildFlags.Borders]], child_flags) + if ImGui_BeginMenuBar() then + ImGui_TextUnformatted("abc") + ImGui_EndMenuBar() end if scroll_to_off then - ImGui.SetScrollY(s.scroll_to_off_px) + ImGui_SetScrollY(s.scroll_to_off_px) end if scroll_to_pos then - ImGui.SetScrollFromPosY(ImGui.GetCursorStartPos().y + s.scroll_to_pos_px, i * 0.25) + ImGui_SetScrollFromPosY(ImGui_GetCursorStartPos().y + s.scroll_to_pos_px, i * 0.25) end if child_is_visible then -- Avoid calling SetScrollHereY when running with culled items for item = 0, 99 do if s.enable_track and item == s.track_item then - ImGui.TextColored(ImVec4(1, 1, 0, 1), "Item %d", item) - ImGui.SetScrollHereY(i * 0.25) -- 0.0f:top, 0.5f:center, 1.0f:bottom + ImGui_TextColored(ImVec4(1, 1, 0, 1), "Item %d", item) + ImGui_SetScrollHereY(i * 0.25) -- 0.0f:top, 0.5f:center, 1.0f:bottom else - ImGui.Text("Item %d", item) + ImGui_Text("Item %d", item) end end end - local scroll_y = ImGui.GetScrollY() - local scroll_max_y = ImGui.GetScrollMaxY() - ImGui.EndChild() - ImGui.Text("%.0f/%.0f", scroll_y, scroll_max_y) - ImGui.EndGroup() + local scroll_y = ImGui_GetScrollY() + local scroll_max_y = ImGui_GetScrollMaxY() + ImGui_EndChild() + ImGui_Text("%.0f/%.0f", scroll_y, scroll_max_y) + ImGui_EndGroup() end - ImGui.PopID() + ImGui_PopID() -- Horizontal scroll functions IMGUI_DEMO_MARKER("Layout/Scrolling/Horizontal") - ImGui.Spacing() + ImGui_Spacing() HelpMarker( "Use SetScrollHereX() or SetScrollFromPosX() to scroll to a given horizontal position.\n\n" .. "Because the clipping rectangle of most window hides half worth of WindowPadding on the " .. "left/right, using SetScrollFromPosX(+1) will usually result in clipped text whereas the " .. "equivalent SetScrollFromPosY(+1) wouldn't.") - ImGui.PushID("##HorizontalScrolling") + ImGui_PushID("##HorizontalScrolling") for i = 0, 4 do - local child_height = ImGui.GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0 + local child_height = ImGui_GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0 local child_flags = 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]] if s.enable_extra_decorations then child_flags = bit32.bor(child_flags, 16384 --[[ImGuiWindowFlags.AlwaysVerticalScrollbar]]) end - local child_id = ImGui.GetID(i) - local child_is_visible = ImGui.BeginChild(child_id, ImVec2(-100, child_height), 1 --[[ImGuiChildFlags.Borders]], child_flags) + local child_id = ImGui_GetID(i) + local child_is_visible = ImGui_BeginChild(child_id, ImVec2(-100, child_height), 1 --[[ImGuiChildFlags.Borders]], child_flags) if scroll_to_off then - ImGui.SetScrollX(s.scroll_to_off_px) + ImGui_SetScrollX(s.scroll_to_off_px) end if scroll_to_pos then - ImGui.SetScrollFromPosX(ImGui.GetCursorStartPos().x + s.scroll_to_pos_px, i * 0.25) + ImGui_SetScrollFromPosX(ImGui_GetCursorStartPos().x + s.scroll_to_pos_px, i * 0.25) end if child_is_visible then -- Avoid calling SetScrollHereY when running with culled items for item = 0, 99 do if item > 0 then - ImGui.SameLine() + ImGui_SameLine() end if s.enable_track and item == s.track_item then - ImGui.TextColored(ImVec4(1, 1, 0, 1), "Item %d", item) - ImGui.SetScrollHereX(i * 0.25) -- 0.0f:left, 0.5f:center, 1.0f:right + ImGui_TextColored(ImVec4(1, 1, 0, 1), "Item %d", item) + ImGui_SetScrollHereX(i * 0.25) -- 0.0f:left, 0.5f:center, 1.0f:right else - ImGui.Text("Item %d", item) + ImGui_Text("Item %d", item) end end end - local scroll_x = ImGui.GetScrollX() - local scroll_max_x = ImGui.GetScrollMaxX() - ImGui.EndChild() - ImGui.SameLine() + local scroll_x = ImGui_GetScrollX() + local scroll_max_x = ImGui_GetScrollMaxX() + ImGui_EndChild() + ImGui_SameLine() local names = { "Left", "25%", "Center", "75%", "Right" } - ImGui.Text("%s\n%.0f/%.0f", names[i + 1], scroll_x, scroll_max_x) - ImGui.Spacing() + ImGui_Text("%s\n%.0f/%.0f", names[i + 1], scroll_x, scroll_max_x) + ImGui_Spacing() end - ImGui.PopID() + ImGui_PopID() -- Miscellaneous Horizontal Scrolling Demo IMGUI_DEMO_MARKER("Layout/Scrolling/Horizontal (more)") HelpMarker( "Horizontal scrolling for a window is enabled via the ImGuiWindowFlags_HorizontalScrollbar flag.\n\n" .. "You may want to also explicitly specify content width by using SetNextWindowContentWidth() before Begin().") - s.lines = ImGui.SliderInt("Lines", s.lines, 1, 15) - ImGui.PushStyleVar(12 --[[ImGuiStyleVar.FrameRounding]], 3.0) - ImGui.PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(2.0, 1.0)) - local scrolling_child_size = ImVec2(0, ImGui.GetFrameHeightWithSpacing() * 7 + 30) - ImGui.BeginChild("scrolling", scrolling_child_size, 1 --[[ImGuiChildFlags.Borders]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) + s.lines = ImGui_SliderInt("Lines", s.lines, 1, 15) + ImGui_PushStyleVar(12 --[[ImGuiStyleVar.FrameRounding]], 3.0) + ImGui_PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(2.0, 1.0)) + local scrolling_child_size = ImVec2(0, ImGui_GetFrameHeightWithSpacing() * 7 + 30) + ImGui_BeginChild("scrolling", scrolling_child_size, 1 --[[ImGuiChildFlags.Borders]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) for line = 0, s.lines - 1 do -- Display random stuff. For the sake of this trivial demo we are using basic Button() + SameLine() -- If you want to create your own time line for a real application you may be better off manipulating -- the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets -- yourself. You may also want to use the lower-level ImDrawList API. local num_buttons = 10 + ((line % 2 == 1) and line * 9 or line * 3) - local base_w = ImGui.GetFontSize() * 3 + local base_w = ImGui_GetFontSize() * 3 for n = 0, num_buttons - 1 do - if n > 0 then ImGui.SameLine() end - ImGui.PushID(n + line * 1000) + if n > 0 then ImGui_SameLine() end + ImGui_PushID(n + line * 1000) local num_buf = string.format("%d", n) local label = num_buf if n % 15 == 0 then label = "FizzBuzz" elseif n % 3 == 0 then label = "Fizz" elseif n % 5 == 0 then label = "Buzz" end local hue = n * 0.05 - ImGui.PushStyleColor(22 --[[ImGuiCol.Button]], ImColor.HSV(hue, 0.6, 0.6).Value) - ImGui.PushStyleColor(23 --[[ImGuiCol.ButtonHovered]], ImColor.HSV(hue, 0.7, 0.7).Value) - ImGui.PushStyleColor(24 --[[ImGuiCol.ButtonActive]], ImColor.HSV(hue, 0.8, 0.8).Value) - ImGui.Button(label, ImVec2(base_w + math.sin(line + n) * base_w * 0.5, 0.0)) - ImGui.PopStyleColor(3) - ImGui.PopID() + ImGui_PushStyleColor(22 --[[ImGuiCol.Button]], ImColor.HSV(hue, 0.6, 0.6).Value) + ImGui_PushStyleColor(23 --[[ImGuiCol.ButtonHovered]], ImColor.HSV(hue, 0.7, 0.7).Value) + ImGui_PushStyleColor(24 --[[ImGuiCol.ButtonActive]], ImColor.HSV(hue, 0.8, 0.8).Value) + ImGui_Button(label, ImVec2(base_w + math.sin(line + n) * base_w * 0.5, 0.0)) + ImGui_PopStyleColor(3) + ImGui_PopID() end end - local scroll_x = ImGui.GetScrollX() - local scroll_max_x = ImGui.GetScrollMaxX() - ImGui.EndChild() - ImGui.PopStyleVar(2) + local scroll_x = ImGui_GetScrollX() + local scroll_max_x = ImGui_GetScrollMaxX() + ImGui_EndChild() + ImGui_PopStyleVar(2) local scroll_x_delta = 0.0 - ImGui.SmallButton("<<") - if ImGui.IsItemActive() then - scroll_x_delta = -ImGui.GetIO().DeltaTime * 1000.0 + ImGui_SmallButton("<<") + if ImGui_IsItemActive() then + scroll_x_delta = -ImGui_GetIO().DeltaTime * 1000.0 end - ImGui.SameLine() - ImGui.Text("Scroll from code"); ImGui.SameLine() - ImGui.SmallButton(">>") - if ImGui.IsItemActive() then - scroll_x_delta = ImGui.GetIO().DeltaTime * 1000.0 + ImGui_SameLine() + ImGui_Text("Scroll from code"); ImGui_SameLine() + ImGui_SmallButton(">>") + if ImGui_IsItemActive() then + scroll_x_delta = ImGui_GetIO().DeltaTime * 1000.0 end - ImGui.SameLine() - ImGui.Text("%.0f/%.0f", scroll_x, scroll_max_x) + ImGui_SameLine() + ImGui_Text("%.0f/%.0f", scroll_x, scroll_max_x) if scroll_x_delta ~= 0.0 then -- Demonstrate a trick: you can use Begin to set yourself in the context of another window -- (here we are already out of your child window) - ImGui.BeginChild("scrolling") - ImGui.SetScrollX(ImGui.GetScrollX() + scroll_x_delta) - ImGui.EndChild() + ImGui_BeginChild("scrolling") + ImGui_SetScrollX(ImGui_GetScrollX() + scroll_x_delta) + ImGui_EndChild() end - ImGui.Spacing() + ImGui_Spacing() - _, s.show_horizontal_contents_size_demo_window = ImGui.Checkbox("Show Horizontal contents size demo window", s.show_horizontal_contents_size_demo_window) + _, s.show_horizontal_contents_size_demo_window = ImGui_Checkbox("Show Horizontal contents size demo window", s.show_horizontal_contents_size_demo_window) if s.show_horizontal_contents_size_demo_window then if s.explicit_content_size then - ImGui.SetNextWindowContentSize(ImVec2(s.contents_size_x, 0.0)) + ImGui_SetNextWindowContentSize(ImVec2(s.contents_size_x, 0.0)) end local window_flags = 0 if s.show_h_scrollbar then window_flags = 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]] end s.show_horizontal_contents_size_demo_window = ImGui.Begin("Horizontal contents size demo window", s.show_horizontal_contents_size_demo_window, window_flags) IMGUI_DEMO_MARKER("Layout/Scrolling/Horizontal contents size demo window") - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(2, 0)) - ImGui.PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(2, 0)) + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(2, 0)) + ImGui_PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(2, 0)) HelpMarker( "Test how different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\n" .. "Use 'Metrics->Tools->Show windows rectangles' to visualize rectangles.") - _, s.show_h_scrollbar = ImGui.Checkbox("H-scrollbar", s.show_h_scrollbar) - _, s.show_button = ImGui.Checkbox("Button", s.show_button) -- Will grow contents size (unless explicitly overwritten) - _, s.show_tree_nodes = ImGui.Checkbox("Tree nodes", s.show_tree_nodes) -- Will grow contents size and display highlight over full width - _, s.show_text_wrapped = ImGui.Checkbox("Text wrapped", s.show_text_wrapped)-- Will grow and use contents size - _, s.show_columns = ImGui.Checkbox("Columns", s.show_columns) -- Will use contents size - _, s.show_tab_bar = ImGui.Checkbox("Tab bar", s.show_tab_bar) -- Will use contents size - _, s.show_child = ImGui.Checkbox("Child", s.show_child) -- Will grow and use contents size - _, s.explicit_content_size = ImGui.Checkbox("Explicit content size", s.explicit_content_size) - ImGui.Text("Scroll %.1f/%.1f %.1f/%.1f", ImGui.GetScrollX(), ImGui.GetScrollMaxX(), ImGui.GetScrollY(), ImGui.GetScrollMaxY()) + _, s.show_h_scrollbar = ImGui_Checkbox("H-scrollbar", s.show_h_scrollbar) + _, s.show_button = ImGui_Checkbox("Button", s.show_button) -- Will grow contents size (unless explicitly overwritten) + _, s.show_tree_nodes = ImGui_Checkbox("Tree nodes", s.show_tree_nodes) -- Will grow contents size and display highlight over full width + _, s.show_text_wrapped = ImGui_Checkbox("Text wrapped", s.show_text_wrapped)-- Will grow and use contents size + _, s.show_columns = ImGui_Checkbox("Columns", s.show_columns) -- Will use contents size + _, s.show_tab_bar = ImGui_Checkbox("Tab bar", s.show_tab_bar) -- Will use contents size + _, s.show_child = ImGui_Checkbox("Child", s.show_child) -- Will grow and use contents size + _, s.explicit_content_size = ImGui_Checkbox("Explicit content size", s.explicit_content_size) + ImGui_Text("Scroll %.1f/%.1f %.1f/%.1f", ImGui_GetScrollX(), ImGui_GetScrollMaxX(), ImGui_GetScrollY(), ImGui_GetScrollMaxY()) if s.explicit_content_size then - ImGui.SameLine() - ImGui.SetNextItemWidth(ImGui.CalcTextSize("123456").x) - s.contents_size_x = ImGui.DragFloat("##csx", s.contents_size_x) - local p = ImGui.GetCursorScreenPos() - ImGui.GetWindowDrawList():AddRectFilled(p, ImVec2(p.x + 10, p.y + 10), 4294967295 --[[IM_COL32_WHITE]]) - ImGui.GetWindowDrawList():AddRectFilled(ImVec2(p.x + s.contents_size_x - 10, p.y), ImVec2(p.x + s.contents_size_x, p.y + 10), 4294967295 --[[IM_COL32_WHITE]]) - ImGui.Dummy(ImVec2(0, 10)) + ImGui_SameLine() + ImGui_SetNextItemWidth(ImGui_CalcTextSize("123456").x) + s.contents_size_x = ImGui_DragFloat("##csx", s.contents_size_x) + local p = ImGui_GetCursorScreenPos() + ImGui_GetWindowDrawList():AddRectFilled(p, ImVec2(p.x + 10, p.y + 10), 4294967295 --[[IM_COL32_WHITE]]) + ImGui_GetWindowDrawList():AddRectFilled(ImVec2(p.x + s.contents_size_x - 10, p.y), ImVec2(p.x + s.contents_size_x, p.y + 10), 4294967295 --[[IM_COL32_WHITE]]) + ImGui_Dummy(ImVec2(0, 10)) end - ImGui.PopStyleVar(2) - ImGui.Separator() + ImGui_PopStyleVar(2) + ImGui_Separator() if s.show_button then - ImGui.Button("this is a 300-wide button", ImVec2(300, 0)) + ImGui_Button("this is a 300-wide button", ImVec2(300, 0)) end if s.show_tree_nodes then local open = true if ImGui.TreeNode("this is a tree node") then if ImGui.TreeNode("another one of those tree node...") then - ImGui.Text("Some tree contents") - ImGui.TreePop() + ImGui_Text("Some tree contents") + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end _, open = ImGui.CollapsingHeader("CollapsingHeader", open) end if s.show_text_wrapped then - ImGui.TextWrapped("This text should automatically wrap on the edge of the work rectangle.") + ImGui_TextWrapped("This text should automatically wrap on the edge of the work rectangle.") end if s.show_columns then - ImGui.Text("Tables:") - if ImGui.BeginTable("table", 4, 1920 --[[ImGuiTableFlags.Borders]]) then + ImGui_Text("Tables:") + if ImGui_BeginTable("table", 4, 1920 --[[ImGuiTableFlags.Borders]]) then for n = 0, 3 do - ImGui.TableNextColumn() - ImGui.Text("Width %.2f", ImGui.GetContentRegionAvail().x) + ImGui_TableNextColumn() + ImGui_Text("Width %.2f", ImGui_GetContentRegionAvail().x) end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.Text("Columns:") - ImGui.Columns(4) + ImGui_Text("Columns:") + ImGui_Columns(4) for n = 0, 3 do - ImGui.Text("Width %.2f", ImGui.GetColumnWidth()) - ImGui.NextColumn() + ImGui_Text("Width %.2f", ImGui_GetColumnWidth()) + ImGui_NextColumn() end - ImGui.Columns(1) + ImGui_Columns(1) end - if s.show_tab_bar and ImGui.BeginTabBar("Hello") then - if ImGui.BeginTabItem("OneOneOne") then ImGui.EndTabItem() end - if ImGui.BeginTabItem("TwoTwoTwo") then ImGui.EndTabItem() end - if ImGui.BeginTabItem("ThreeThreeThree") then ImGui.EndTabItem() end - if ImGui.BeginTabItem("FourFourFour") then ImGui.EndTabItem() end - ImGui.EndTabBar() + if s.show_tab_bar and ImGui_BeginTabBar("Hello") then + if ImGui.BeginTabItem("OneOneOne") then ImGui_EndTabItem() end + if ImGui.BeginTabItem("TwoTwoTwo") then ImGui_EndTabItem() end + if ImGui.BeginTabItem("ThreeThreeThree") then ImGui_EndTabItem() end + if ImGui.BeginTabItem("FourFourFour") then ImGui_EndTabItem() end + ImGui_EndTabBar() end if s.show_child then - ImGui.BeginChild("child", ImVec2(0, 0), 1 --[[ImGuiChildFlags.Borders]]) - ImGui.EndChild() + ImGui_BeginChild("child", ImVec2(0, 0), 1 --[[ImGuiChildFlags.Borders]]) + ImGui_EndChild() end ImGui.End() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Text Clipping") then IMGUI_DEMO_MARKER("Layout/Text Clipping") local size = s.size local offset = s.offset - ImGui.DragFloat2("size", size, 0.5, 1.0, 200.0, "%.0f") - ImGui.TextWrapped("(Click and drag to scroll)") + ImGui_DragFloat2("size", size, 0.5, 1.0, 200.0, "%.0f") + ImGui_TextWrapped("(Click and drag to scroll)") HelpMarker( "(Left) Using ImGui::PushClipRect():\n" .. @@ -28253,30 +28309,30 @@ function DemoWindowLayout() for n = 0, 2 do repeat if n > 0 then - ImGui.SameLine() + ImGui_SameLine() end - ImGui.PushID(n) - ImGui.InvisibleButton("##canvas", size) - if ImGui.IsItemActive() and ImGui.IsMouseDragging(0 --[[ImGuiMouseButton.Left]]) then - offset.x = offset.x + ImGui.GetIO().MouseDelta.x - offset.y = offset.y + ImGui.GetIO().MouseDelta.y + ImGui_PushID(n) + ImGui_InvisibleButton("##canvas", size) + if ImGui_IsItemActive() and ImGui_IsMouseDragging(0 --[[ImGuiMouseButton.Left]]) then + offset.x = offset.x + ImGui_GetIO().MouseDelta.x + offset.y = offset.y + ImGui_GetIO().MouseDelta.y end - ImGui.PopID() - if not ImGui.IsItemVisible() then -- Skip rendering as ImDrawList elements are not clipped. + ImGui_PopID() + if not ImGui_IsItemVisible() then -- Skip rendering as ImDrawList elements are not clipped. break -- continue end - local p0 = ImGui.GetItemRectMin() - local p1 = ImGui.GetItemRectMax() + local p0 = ImGui_GetItemRectMin() + local p1 = ImGui_GetItemRectMax() local text_str = "Line 1 hello\nLine 2 clip me!" local text_pos = ImVec2(p0.x + offset.x, p0.y + offset.y) - local draw_list = ImGui.GetWindowDrawList() + local draw_list = ImGui_GetWindowDrawList() if n == 0 then - ImGui.PushClipRect(p0, p1, true) + ImGui_PushClipRect(p0, p1, true) draw_list:AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)) draw_list:AddText(text_pos, 4294967295 --[[IM_COL32_WHITE]], text_str) - ImGui.PopClipRect() + ImGui_PopClipRect() elseif n == 1 then draw_list:PushClipRect(p0, p1, true) draw_list:AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)) @@ -28285,11 +28341,11 @@ function DemoWindowLayout() elseif n == 2 then local clip_rect = ImVec4(p0.x, p0.y, p1.x, p1.y) -- AddText() takes a ImVec4* here so let's convert. draw_list:AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)) - draw_list:AddText(ImGui.GetFont(), ImGui.GetFontSize(), text_pos, 4294967295 --[[IM_COL32_WHITE]], text_str, 1, #text_str + 1, 0.0, clip_rect) -- [Port] explicit text_begin/text_end (port's AddText needs text_end) + draw_list:AddText(ImGui_GetFont(), ImGui_GetFontSize(), text_pos, 4294967295 --[[IM_COL32_WHITE]], text_str, 1, #text_str + 1, 0.0, clip_rect) -- [Port] explicit text_begin/text_end (port's AddText needs text_end) end until true end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Overlap Mode") then @@ -28299,28 +28355,28 @@ function DemoWindowLayout() "Hit-testing is by default performed in item submission order, which generally is perceived as 'back-to-front'.\n\n" .. "By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. " .. "Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.") - _, s.enable_allow_overlap = ImGui.Checkbox("Enable AllowOverlap", s.enable_allow_overlap) + _, s.enable_allow_overlap = ImGui_Checkbox("Enable AllowOverlap", s.enable_allow_overlap) - local button1_pos = ImGui.GetCursorScreenPos() + local button1_pos = ImGui_GetCursorScreenPos() local button2_pos = ImVec2(button1_pos.x + 50.0, button1_pos.y + 50.0) if s.enable_allow_overlap then - ImGui.SetNextItemAllowOverlap() + ImGui_SetNextItemAllowOverlap() end - ImGui.Button("Button 1", ImVec2(80, 80)) - ImGui.SetCursorScreenPos(button2_pos) - ImGui.Button("Button 2", ImVec2(80, 80)) + ImGui_Button("Button 1", ImVec2(80, 80)) + ImGui_SetCursorScreenPos(button2_pos) + ImGui_Button("Button 2", ImVec2(80, 80)) -- This is typically used with width-spanning items. -- (note that Selectable() has a dedicated flag ImGuiSelectableFlags.AllowOverlap, which is a shortcut -- for using SetNextItemAllowOverlap(). For demo purpose we use SetNextItemAllowOverlap() here.) if s.enable_allow_overlap then - ImGui.SetNextItemAllowOverlap() + ImGui_SetNextItemAllowOverlap() end - ImGui.Selectable("Some Selectable", false) - ImGui.SameLine() - ImGui.SmallButton("++") + ImGui_Selectable("Some Selectable", false) + ImGui_SameLine() + ImGui_SmallButton("++") - ImGui.TreePop() + ImGui_TreePop() end end @@ -28364,7 +28420,7 @@ function DemoWindowPopups() if ImGui.TreeNode("Popups") then IMGUI_DEMO_MARKER("Popups/Popups") - ImGui.TextWrapped( + ImGui_TextWrapped( "When a popup is active, it inhibits interacting with windows that are behind the popup. " .. "Clicking outside the popup closes it.") @@ -28373,85 +28429,85 @@ function DemoWindowPopups() -- Simple selection popup (if you want to show the current selection inside the Button itself, -- you may want to build a string using the "###" operator to preserve a constant ID with a variable label) - if ImGui.Button("Select..") then - ImGui.OpenPopup("my_select_popup") + if ImGui_Button("Select..") then + ImGui_OpenPopup("my_select_popup") end - ImGui.SameLine() + ImGui_SameLine() local fish_name = "" if s.selected_fish ~= -1 then fish_name = names[s.selected_fish + 1] end - ImGui.TextUnformatted(fish_name) - if ImGui.BeginPopup("my_select_popup") then - ImGui.SeparatorText("Aquarium") + ImGui_TextUnformatted(fish_name) + if ImGui_BeginPopup("my_select_popup") then + ImGui_SeparatorText("Aquarium") for i = 0, #names - 1 do - if ImGui.Selectable(names[i + 1]) then + if ImGui_Selectable(names[i + 1]) then s.selected_fish = i end end - ImGui.EndPopup() + ImGui_EndPopup() end -- Showing a menu with toggles - if ImGui.Button("Toggle..") then - ImGui.OpenPopup("my_toggle_popup") + if ImGui_Button("Toggle..") then + ImGui_OpenPopup("my_toggle_popup") end - if ImGui.BeginPopup("my_toggle_popup") then + if ImGui_BeginPopup("my_toggle_popup") then for i = 0, #names - 1 do - _, toggles[i + 1] = ImGui.MenuItem(names[i + 1], "", toggles[i + 1]) + _, toggles[i + 1] = ImGui_MenuItem(names[i + 1], "", toggles[i + 1]) end - if ImGui.BeginMenu("Sub-menu") then - ImGui.MenuItem("Click me") - ImGui.EndMenu() + if ImGui_BeginMenu("Sub-menu") then + ImGui_MenuItem("Click me") + ImGui_EndMenu() end - ImGui.Separator() - ImGui.Text("Tooltip here") - ImGui.SetItemTooltip("I am a tooltip over a popup") + ImGui_Separator() + ImGui_Text("Tooltip here") + ImGui_SetItemTooltip("I am a tooltip over a popup") - if ImGui.Button("Stacked Popup") then - ImGui.OpenPopup("another popup") + if ImGui_Button("Stacked Popup") then + ImGui_OpenPopup("another popup") end - if ImGui.BeginPopup("another popup") then + if ImGui_BeginPopup("another popup") then for i = 0, #names - 1 do - _, toggles[i + 1] = ImGui.MenuItem(names[i + 1], "", toggles[i + 1]) + _, toggles[i + 1] = ImGui_MenuItem(names[i + 1], "", toggles[i + 1]) end - if ImGui.BeginMenu("Sub-menu") then - ImGui.MenuItem("Click me") - if ImGui.Button("Stacked Popup") then - ImGui.OpenPopup("another popup") + if ImGui_BeginMenu("Sub-menu") then + ImGui_MenuItem("Click me") + if ImGui_Button("Stacked Popup") then + ImGui_OpenPopup("another popup") end - if ImGui.BeginPopup("another popup") then - ImGui.Text("I am the last one here.") - ImGui.EndPopup() + if ImGui_BeginPopup("another popup") then + ImGui_Text("I am the last one here.") + ImGui_EndPopup() end - ImGui.EndMenu() + ImGui_EndMenu() end - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end -- Call the more complete ShowExampleMenuFile which we use in various places of this demo - if ImGui.Button("With a menu..") then - ImGui.OpenPopup("my_file_popup") + if ImGui_Button("With a menu..") then + ImGui_OpenPopup("my_file_popup") end - if ImGui.BeginPopup("my_file_popup", 1024 --[[ImGuiWindowFlags.MenuBar]]) then - if ImGui.BeginMenuBar() then - if ImGui.BeginMenu("File") then + if ImGui_BeginPopup("my_file_popup", 1024 --[[ImGuiWindowFlags.MenuBar]]) then + if ImGui_BeginMenuBar() then + if ImGui_BeginMenu("File") then ShowExampleMenuFile() - ImGui.EndMenu() + ImGui_EndMenu() end - if ImGui.BeginMenu("Edit") then - ImGui.MenuItem("Dummy") - ImGui.EndMenu() + if ImGui_BeginMenu("Edit") then + ImGui_MenuItem("Dummy") + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end - ImGui.Text("Hello from popup!") - ImGui.Button("This is a dummy button..") - ImGui.EndPopup() + ImGui_Text("Hello from popup!") + ImGui_Button("This is a dummy button..") + ImGui_EndPopup() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Context menus") then @@ -28473,18 +28529,18 @@ function DemoWindowPopups() do local names = { "Label1", "Label2", "Label3", "Label4", "Label5" } for n = 0, 4 do - if ImGui.Selectable(names[n + 1], s.selected == n) then + if ImGui_Selectable(names[n + 1], s.selected == n) then s.selected = n end - if ImGui.BeginPopupContextItem() then -- <-- use last item id as popup id + if ImGui_BeginPopupContextItem() then -- <-- use last item id as popup id s.selected = n - ImGui.Text("This is a popup for \"%s\"!", names[n + 1]) - if ImGui.Button("Close") then - ImGui.CloseCurrentPopup() + ImGui_Text("This is a popup for \"%s\"!", names[n + 1]) + if ImGui_Button("Close") then + ImGui_CloseCurrentPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.SetItemTooltip("Right-click to open popup") + ImGui_SetItemTooltip("Right-click to open popup") end end @@ -28493,24 +28549,24 @@ function DemoWindowPopups() -- Using an explicit identifier is also convenient if you want to activate the popups from different locations. do HelpMarker("Text() elements don't have stable identifiers so we need to provide one.") - ImGui.Text("Value = %.3f <-- (1) right-click this text", s.value) - if ImGui.BeginPopupContextItem("my popup") then - if ImGui.Selectable("Set to zero") then s.value = 0.0 end - if ImGui.Selectable("Set to PI") then s.value = 3.1415 end - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) - s.value = ImGui.DragFloat("##Value", s.value, 0.1, 0.0, 0.0) - ImGui.EndPopup() + ImGui_Text("Value = %.3f <-- (1) right-click this text", s.value) + if ImGui_BeginPopupContextItem("my popup") then + if ImGui_Selectable("Set to zero") then s.value = 0.0 end + if ImGui_Selectable("Set to PI") then s.value = 3.1415 end + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + s.value = ImGui_DragFloat("##Value", s.value, 0.1, 0.0, 0.0) + ImGui_EndPopup() end -- We can also use OpenPopupOnItemClick() to toggle the visibility of a given popup. -- Here we make it that right-clicking this other text element opens the same popup as above. -- The popup itself will be submitted by the code above. - ImGui.Text("(2) Or right-click this text") - ImGui.OpenPopupOnItemClick("my popup", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) + ImGui_Text("(2) Or right-click this text") + ImGui_OpenPopupOnItemClick("my popup", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) -- Back to square one: manually open the same popup. - if ImGui.Button("(3) Or click this button") then - ImGui.OpenPopup("my popup") + if ImGui_Button("(3) Or click this button") then + ImGui_OpenPopup("my popup") end end @@ -28520,71 +28576,71 @@ function DemoWindowPopups() -- In this example we showcase altering the item label while preserving its identifier, using the ### operator (see FAQ). do HelpMarker("Showcase using a popup ID linked to item ID, with the item having a changing label + stable ID using the ### operator.") - local buf = string.format("Button: %s###Button", ImGui.TextBufferToString(s.name)) -- ### operator override ID ignoring the preceding label - ImGui.Button(buf) - if ImGui.BeginPopupContextItem() then - ImGui.Text("Edit name:") - ImGui.InputText("##edit", s.name, 32) - if ImGui.Button("Close") then - ImGui.CloseCurrentPopup() + local buf = string.format("Button: %s###Button", ImGui_TextBufferToString(s.name)) -- ### operator override ID ignoring the preceding label + ImGui_Button(buf) + if ImGui_BeginPopupContextItem() then + ImGui_Text("Edit name:") + ImGui_InputText("##edit", s.name, 32) + if ImGui_Button("Close") then + ImGui_CloseCurrentPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.SameLine(); ImGui.Text("(<-- right-click here)") + ImGui_SameLine(); ImGui_Text("(<-- right-click here)") end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Modals") then IMGUI_DEMO_MARKER("Popups/Modals") - ImGui.TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside.") + ImGui_TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside.") - if ImGui.Button("Delete..") then - ImGui.OpenPopup("Delete?") + if ImGui_Button("Delete..") then + ImGui_OpenPopup("Delete?") end -- Always center this window when appearing - local center = ImGui.GetMainViewport():GetCenter() - ImGui.SetNextWindowPos(center, 8 --[[ImGuiCond.Appearing]], ImVec2(0.5, 0.5)) + local center = ImGui_GetMainViewport():GetCenter() + ImGui_SetNextWindowPos(center, 8 --[[ImGuiCond.Appearing]], ImVec2(0.5, 0.5)) - if ImGui.BeginPopupModal("Delete?", nil, 64 --[[ImGuiWindowFlags.AlwaysAutoResize]]) then - ImGui.Text("All those beautiful files will be deleted.\nThis operation cannot be undone!") - ImGui.Separator() + if ImGui_BeginPopupModal("Delete?", nil, 64 --[[ImGuiWindowFlags.AlwaysAutoResize]]) then + ImGui_Text("All those beautiful files will be deleted.\nThis operation cannot be undone!") + ImGui_Separator() --static int unused_i = 0; --ImGui.Combo("Combo", unused_i, "Delete\0Delete harder\0"); - ImGui.PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0, 0)) - _, s.dont_ask_me_next_time = ImGui.Checkbox("Don't ask me next time", s.dont_ask_me_next_time) - ImGui.PopStyleVar() + ImGui_PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0, 0)) + _, s.dont_ask_me_next_time = ImGui_Checkbox("Don't ask me next time", s.dont_ask_me_next_time) + ImGui_PopStyleVar() - if ImGui.Button("OK", ImVec2(120, 0)) then ImGui.CloseCurrentPopup() end - ImGui.SetItemDefaultFocus() - ImGui.SameLine() - if ImGui.Button("Cancel", ImVec2(120, 0)) then ImGui.CloseCurrentPopup() end - ImGui.EndPopup() + if ImGui_Button("OK", ImVec2(120, 0)) then ImGui_CloseCurrentPopup() end + ImGui_SetItemDefaultFocus() + ImGui_SameLine() + if ImGui_Button("Cancel", ImVec2(120, 0)) then ImGui_CloseCurrentPopup() end + ImGui_EndPopup() end - if ImGui.Button("Stacked modals..") then - ImGui.OpenPopup("Stacked 1") + if ImGui_Button("Stacked modals..") then + ImGui_OpenPopup("Stacked 1") end - if ImGui.BeginPopupModal("Stacked 1", nil, 1024 --[[ImGuiWindowFlags.MenuBar]]) then - if ImGui.BeginMenuBar() then - if ImGui.BeginMenu("File") then - if ImGui.MenuItem("Some menu item") then end - ImGui.EndMenu() + if ImGui_BeginPopupModal("Stacked 1", nil, 1024 --[[ImGuiWindowFlags.MenuBar]]) then + if ImGui_BeginMenuBar() then + if ImGui_BeginMenu("File") then + if ImGui_MenuItem("Some menu item") then end + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end - ImGui.Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it.") + ImGui_Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it.") -- Testing behavior of widgets stacking their own regular popups over the modal. - s.item = ImGui.Combo("Combo", s.item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0") - ImGui.ColorEdit4("Color", s.color) + s.item = ImGui_Combo("Combo", s.item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0") + ImGui_ColorEdit4("Color", s.color) - if ImGui.Button("Add another modal..") then - ImGui.OpenPopup("Stacked 2") + if ImGui_Button("Add another modal..") then + ImGui_OpenPopup("Stacked 2") end -- Also demonstrate passing a bool* to BeginPopupModal(), this will create a regular close button which @@ -28592,37 +28648,37 @@ function DemoWindowPopups() -- of the bool actually doesn't matter here. local unused_open = true local visible - visible, unused_open = ImGui.BeginPopupModal("Stacked 2", unused_open) + visible, unused_open = ImGui_BeginPopupModal("Stacked 2", unused_open) if visible then - ImGui.Text("Hello from Stacked The Second!") - ImGui.ColorEdit4("Color", s.color) -- Allow opening another nested popup - if ImGui.Button("Close") then - ImGui.CloseCurrentPopup() + ImGui_Text("Hello from Stacked The Second!") + ImGui_ColorEdit4("Color", s.color) -- Allow opening another nested popup + if ImGui_Button("Close") then + ImGui_CloseCurrentPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end - if ImGui.Button("Close") then - ImGui.CloseCurrentPopup() + if ImGui_Button("Close") then + ImGui_CloseCurrentPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Menus inside a regular window") then IMGUI_DEMO_MARKER("Popups/Menus inside a regular window") - ImGui.TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!") - ImGui.Separator() + ImGui_TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!") + ImGui_Separator() - ImGui.MenuItem("Menu item", "Ctrl+M") - if ImGui.BeginMenu("Menu inside a regular window") then + ImGui_MenuItem("Menu item", "Ctrl+M") + if ImGui_BeginMenu("Menu inside a regular window") then ShowExampleMenuFile() - ImGui.EndMenu() + ImGui_EndMenu() end - ImGui.Separator() - ImGui.TreePop() + ImGui_Separator() + ImGui_TreePop() end end @@ -28701,13 +28757,13 @@ end -- Make the UI compact because there are so many fields function PushStyleCompact() - local style = ImGui.GetStyle() - ImGui.PushStyleVarY(11 --[[ImGuiStyleVar.FramePadding]], math.floor(style.FramePadding.y * 0.60)) - ImGui.PushStyleVarY(14 --[[ImGuiStyleVar.ItemSpacing]], math.floor(style.ItemSpacing.y * 0.60)) + local style = ImGui_GetStyle() + ImGui_PushStyleVarY(11 --[[ImGuiStyleVar.FramePadding]], math.floor(style.FramePadding.y * 0.60)) + ImGui_PushStyleVarY(14 --[[ImGuiStyleVar.ItemSpacing]], math.floor(style.ItemSpacing.y * 0.60)) end function PopStyleCompact() - ImGui.PopStyleVar(2) + ImGui_PopStyleVar(2) end S.EditTableSizingFlags = { policies = nil } @@ -28739,27 +28795,27 @@ function EditTableSizingFlags(p_flags) preview_text = policies[idx + 1].Name if idx > 0 then preview_text = string.sub(preview_text, #"ImGuiTableFlags" + 1) end end - if ImGui.BeginCombo("Sizing Policy", preview_text) then + if ImGui_BeginCombo("Sizing Policy", preview_text) then for n = 0, #policies - 1 do - if ImGui.Selectable(policies[n + 1].Name, idx == n) then + if ImGui_Selectable(policies[n + 1].Name, idx == n) then p_flags = bit32.bor(bit32.band(p_flags, bit32.bnot(57344 --[[ImGuiTableFlags.SizingMask_]])), policies[n + 1].Value) end end - ImGui.EndCombo() + ImGui_EndCombo() end - ImGui.SameLine() - ImGui.TextDisabled("(?)") - if ImGui.BeginItemTooltip() then - ImGui.PushTextWrapPos(ImGui.GetFontSize() * 50.0) + ImGui_SameLine() + ImGui_TextDisabled("(?)") + if ImGui_BeginItemTooltip() then + ImGui_PushTextWrapPos(ImGui_GetFontSize() * 50.0) for m = 0, #policies - 1 do - ImGui.Separator() - ImGui.Text("%s:", policies[m + 1].Name) - ImGui.Separator() - ImGui.SetCursorPosX(ImGui.GetCursorPosX() + ImGui.GetStyle().IndentSpacing * 0.5) - ImGui.TextUnformatted(policies[m + 1].Tooltip) + ImGui_Separator() + ImGui_Text("%s:", policies[m + 1].Name) + ImGui_Separator() + ImGui_SetCursorPosX(ImGui_GetCursorPosX() + ImGui_GetStyle().IndentSpacing * 0.5) + ImGui_TextUnformatted(policies[m + 1].Tooltip) end - ImGui.PopTextWrapPos() - ImGui.EndTooltip() + ImGui_PopTextWrapPos() + ImGui_EndTooltip() end return p_flags end @@ -28767,39 +28823,39 @@ end -- [Port] p_flags -> takes flags, returns the new flags. function EditTableColumnsFlags(p_flags) local pressed - _, p_flags = ImGui.CheckboxFlags("_Disabled", p_flags, 1 --[[ImGuiTableColumnFlags.Disabled]]); ImGui.SameLine(); HelpMarker("Master disable flag (also hide from context menu)") - _, p_flags = ImGui.CheckboxFlags("_DefaultHide", p_flags, 2 --[[ImGuiTableColumnFlags.DefaultHide]]) - _, p_flags = ImGui.CheckboxFlags("_DefaultSort", p_flags, 4 --[[ImGuiTableColumnFlags.DefaultSort]]) - pressed, p_flags = ImGui.CheckboxFlags("_WidthStretch", p_flags, 8 --[[ImGuiTableColumnFlags.WidthStretch]]) + _, p_flags = ImGui_CheckboxFlags("_Disabled", p_flags, 1 --[[ImGuiTableColumnFlags.Disabled]]); ImGui_SameLine(); HelpMarker("Master disable flag (also hide from context menu)") + _, p_flags = ImGui_CheckboxFlags("_DefaultHide", p_flags, 2 --[[ImGuiTableColumnFlags.DefaultHide]]) + _, p_flags = ImGui_CheckboxFlags("_DefaultSort", p_flags, 4 --[[ImGuiTableColumnFlags.DefaultSort]]) + pressed, p_flags = ImGui_CheckboxFlags("_WidthStretch", p_flags, 8 --[[ImGuiTableColumnFlags.WidthStretch]]) if pressed then p_flags = bit32.band(p_flags, bit32.bnot(bit32.bxor(24 --[[ImGuiTableColumnFlags.WidthMask_]], 8 --[[ImGuiTableColumnFlags.WidthStretch]]))) end - pressed, p_flags = ImGui.CheckboxFlags("_WidthFixed", p_flags, 16 --[[ImGuiTableColumnFlags.WidthFixed]]) + pressed, p_flags = ImGui_CheckboxFlags("_WidthFixed", p_flags, 16 --[[ImGuiTableColumnFlags.WidthFixed]]) if pressed then p_flags = bit32.band(p_flags, bit32.bnot(bit32.bxor(24 --[[ImGuiTableColumnFlags.WidthMask_]], 16 --[[ImGuiTableColumnFlags.WidthFixed]]))) end - _, p_flags = ImGui.CheckboxFlags("_NoResize", p_flags, 32 --[[ImGuiTableColumnFlags.NoResize]]) - _, p_flags = ImGui.CheckboxFlags("_NoReorder", p_flags, 64 --[[ImGuiTableColumnFlags.NoReorder]]) - _, p_flags = ImGui.CheckboxFlags("_NoHide", p_flags, 128 --[[ImGuiTableColumnFlags.NoHide]]) - _, p_flags = ImGui.CheckboxFlags("_NoClip", p_flags, 256 --[[ImGuiTableColumnFlags.NoClip]]) - _, p_flags = ImGui.CheckboxFlags("_NoSort", p_flags, 512 --[[ImGuiTableColumnFlags.NoSort]]) - _, p_flags = ImGui.CheckboxFlags("_NoSortAscending", p_flags, 1024 --[[ImGuiTableColumnFlags.NoSortAscending]]) - _, p_flags = ImGui.CheckboxFlags("_NoSortDescending", p_flags, 2048 --[[ImGuiTableColumnFlags.NoSortDescending]]) - _, p_flags = ImGui.CheckboxFlags("_NoHeaderLabel", p_flags, 4096 --[[ImGuiTableColumnFlags.NoHeaderLabel]]) - _, p_flags = ImGui.CheckboxFlags("_NoHeaderWidth", p_flags, 8192 --[[ImGuiTableColumnFlags.NoHeaderWidth]]) - _, p_flags = ImGui.CheckboxFlags("_PreferSortAscending", p_flags, 16384 --[[ImGuiTableColumnFlags.PreferSortAscending]]) - _, p_flags = ImGui.CheckboxFlags("_PreferSortDescending", p_flags, 32768 --[[ImGuiTableColumnFlags.PreferSortDescending]]) - _, p_flags = ImGui.CheckboxFlags("_IndentEnable", p_flags, 65536 --[[ImGuiTableColumnFlags.IndentEnable]]); ImGui.SameLine(); HelpMarker("Default for column 0") - _, p_flags = ImGui.CheckboxFlags("_IndentDisable", p_flags, 131072 --[[ImGuiTableColumnFlags.IndentDisable]]); ImGui.SameLine(); HelpMarker("Default for column >0") - _, p_flags = ImGui.CheckboxFlags("_AngledHeader", p_flags, 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) + _, p_flags = ImGui_CheckboxFlags("_NoResize", p_flags, 32 --[[ImGuiTableColumnFlags.NoResize]]) + _, p_flags = ImGui_CheckboxFlags("_NoReorder", p_flags, 64 --[[ImGuiTableColumnFlags.NoReorder]]) + _, p_flags = ImGui_CheckboxFlags("_NoHide", p_flags, 128 --[[ImGuiTableColumnFlags.NoHide]]) + _, p_flags = ImGui_CheckboxFlags("_NoClip", p_flags, 256 --[[ImGuiTableColumnFlags.NoClip]]) + _, p_flags = ImGui_CheckboxFlags("_NoSort", p_flags, 512 --[[ImGuiTableColumnFlags.NoSort]]) + _, p_flags = ImGui_CheckboxFlags("_NoSortAscending", p_flags, 1024 --[[ImGuiTableColumnFlags.NoSortAscending]]) + _, p_flags = ImGui_CheckboxFlags("_NoSortDescending", p_flags, 2048 --[[ImGuiTableColumnFlags.NoSortDescending]]) + _, p_flags = ImGui_CheckboxFlags("_NoHeaderLabel", p_flags, 4096 --[[ImGuiTableColumnFlags.NoHeaderLabel]]) + _, p_flags = ImGui_CheckboxFlags("_NoHeaderWidth", p_flags, 8192 --[[ImGuiTableColumnFlags.NoHeaderWidth]]) + _, p_flags = ImGui_CheckboxFlags("_PreferSortAscending", p_flags, 16384 --[[ImGuiTableColumnFlags.PreferSortAscending]]) + _, p_flags = ImGui_CheckboxFlags("_PreferSortDescending", p_flags, 32768 --[[ImGuiTableColumnFlags.PreferSortDescending]]) + _, p_flags = ImGui_CheckboxFlags("_IndentEnable", p_flags, 65536 --[[ImGuiTableColumnFlags.IndentEnable]]); ImGui_SameLine(); HelpMarker("Default for column 0") + _, p_flags = ImGui_CheckboxFlags("_IndentDisable", p_flags, 131072 --[[ImGuiTableColumnFlags.IndentDisable]]); ImGui_SameLine(); HelpMarker("Default for column >0") + _, p_flags = ImGui_CheckboxFlags("_AngledHeader", p_flags, 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) return p_flags end function ShowTableColumnsStatusFlags(flags) - ImGui.CheckboxFlags("_IsEnabled", flags, 16777216 --[[ImGuiTableColumnFlags.IsEnabled]]) - ImGui.CheckboxFlags("_IsVisible", flags, 33554432 --[[ImGuiTableColumnFlags.IsVisible]]) - ImGui.CheckboxFlags("_IsSorted", flags, 67108864 --[[ImGuiTableColumnFlags.IsSorted]]) - ImGui.CheckboxFlags("_IsHovered", flags, 134217728 --[[ImGuiTableColumnFlags.IsHovered]]) + ImGui_CheckboxFlags("_IsEnabled", flags, 16777216 --[[ImGuiTableColumnFlags.IsEnabled]]) + ImGui_CheckboxFlags("_IsVisible", flags, 33554432 --[[ImGuiTableColumnFlags.IsVisible]]) + ImGui_CheckboxFlags("_IsSorted", flags, 67108864 --[[ImGuiTableColumnFlags.IsSorted]]) + ImGui_CheckboxFlags("_IsHovered", flags, 134217728 --[[ImGuiTableColumnFlags.IsHovered]]) end ------------------------------------------------------------------------------- @@ -28950,28 +29006,28 @@ function DemoWindowTables() end -- Using those as a base value to create width/height that are factor of the size of our font - local TEXT_BASE_WIDTH = ImGui.CalcTextSize("A").x - local TEXT_BASE_HEIGHT = ImGui.GetTextLineHeightWithSpacing() + local TEXT_BASE_WIDTH = ImGui_CalcTextSize("A").x + local TEXT_BASE_HEIGHT = ImGui_GetTextLineHeightWithSpacing() - ImGui.PushID("Tables") + ImGui_PushID("Tables") local open_action = -1 - if ImGui.Button("Expand all") then + if ImGui_Button("Expand all") then open_action = 1 end - ImGui.SameLine() - if ImGui.Button("Collapse all") then + ImGui_SameLine() + if ImGui_Button("Collapse all") then open_action = 0 end - ImGui.SameLine() + ImGui_SameLine() -- Options - _, s.disable_indent = ImGui.Checkbox("Disable tree indentation", s.disable_indent) - ImGui.SameLine() + _, s.disable_indent = ImGui_Checkbox("Disable tree indentation", s.disable_indent) + ImGui_SameLine() HelpMarker("Disable the indenting of tree nodes so demo tables can use the full window width.") - ImGui.Separator() + ImGui_Separator() if s.disable_indent then - ImGui.PushStyleVar(16 --[[ImGuiStyleVar.IndentSpacing]], 0.0) + ImGui_PushStyleVar(16 --[[ImGuiStyleVar.IndentSpacing]], 0.0) end -- About Styling of tables @@ -28986,7 +29042,7 @@ function DemoWindowTables() -- Demos if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Basic") then IMGUI_DEMO_MARKER("Tables/Basic") @@ -28996,31 +29052,31 @@ function DemoWindowTables() -- [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column. -- In many situations, this is the most flexible and easy to use pattern. HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop.") - if ImGui.BeginTable("table1", 3) then + if ImGui_BeginTable("table1", 3) then for row = 0, 4 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("Row %d Column %d", row, column) + ImGui_TableSetColumnIndex(column) + ImGui_Text("Row %d Column %d", row, column) end end - ImGui.EndTable() + ImGui_EndTable() end -- [Method 2] Using TableNextColumn() called multiple times, instead of using a for loop + TableSetColumnIndex(). -- This is generally more convenient when you have code manually submitting the contents of each column. HelpMarker("Using TableNextRow() + calling TableNextColumn() _before_ each cell, manually.") - if ImGui.BeginTable("table2", 3) then + if ImGui_BeginTable("table2", 3) then for row = 0, 4 - 1 do - ImGui.TableNextRow() - ImGui.TableNextColumn() - ImGui.Text("Row %d", row) - ImGui.TableNextColumn() - ImGui.Text("Some contents") - ImGui.TableNextColumn() - ImGui.Text("123.456") + ImGui_TableNextRow() + ImGui_TableNextColumn() + ImGui_Text("Row %d", row) + ImGui_TableNextColumn() + ImGui_Text("Some contents") + ImGui_TableNextColumn() + ImGui_Text("123.456") end - ImGui.EndTable() + ImGui_EndTable() end -- [Method 3] We call TableNextColumn() _before_ each cell. We never call TableNextRow(), @@ -29030,19 +29086,19 @@ function DemoWindowTables() "Only using TableNextColumn(), which tends to be convenient for tables where every cell contains " .. "the same type of contents.\n This is also more similar to the old NextColumn() function of the " .. "Columns API, and provided to facilitate the Columns->Tables API transition.") - if ImGui.BeginTable("table3", 3) then + if ImGui_BeginTable("table3", 3) then for item = 0, 14 - 1 do - ImGui.TableNextColumn() - ImGui.Text("Item %d", item) + ImGui_TableNextColumn() + ImGui_Text("Item %d", item) end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Borders, background") then IMGUI_DEMO_MARKER("Tables/Borders, background") @@ -29051,63 +29107,63 @@ function DemoWindowTables() local s = s.BordersBackground PushStyleCompact() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_RowBg", s.flags, 64 --[[ImGuiTableFlags.RowBg]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Borders", s.flags, 1920 --[[ImGuiTableFlags.Borders]]) - ImGui.SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerH\n | ImGuiTableFlags_BordersOuterH") - ImGui.Indent() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_RowBg", s.flags, 64 --[[ImGuiTableFlags.RowBg]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Borders", s.flags, 1920 --[[ImGuiTableFlags.Borders]]) + ImGui_SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerH\n | ImGuiTableFlags_BordersOuterH") + ImGui_Indent() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersH", s.flags, 384 --[[ImGuiTableFlags.BordersH]]) - ImGui.Indent() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuterH", s.flags, 256 --[[ImGuiTableFlags.BordersOuterH]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInnerH", s.flags, 128 --[[ImGuiTableFlags.BordersInnerH]]) - ImGui.Unindent() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersH", s.flags, 384 --[[ImGuiTableFlags.BordersH]]) + ImGui_Indent() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuterH", s.flags, 256 --[[ImGuiTableFlags.BordersOuterH]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInnerH", s.flags, 128 --[[ImGuiTableFlags.BordersInnerH]]) + ImGui_Unindent() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersV", s.flags, 1536 --[[ImGuiTableFlags.BordersV]]) - ImGui.Indent() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags, 1024 --[[ImGuiTableFlags.BordersOuterV]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags, 512 --[[ImGuiTableFlags.BordersInnerV]]) - ImGui.Unindent() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersV", s.flags, 1536 --[[ImGuiTableFlags.BordersV]]) + ImGui_Indent() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags, 1024 --[[ImGuiTableFlags.BordersOuterV]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags, 512 --[[ImGuiTableFlags.BordersInnerV]]) + ImGui_Unindent() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuter", s.flags, 1280 --[[ImGuiTableFlags.BordersOuter]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInner", s.flags, 640 --[[ImGuiTableFlags.BordersInner]]) - ImGui.Unindent() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuter", s.flags, 1280 --[[ImGuiTableFlags.BordersOuter]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInner", s.flags, 640 --[[ImGuiTableFlags.BordersInner]]) + ImGui_Unindent() - ImGui.AlignTextToFramePadding(); ImGui.Text("Cell contents:") - ImGui.SameLine(); _, s.contents_type = ImGui.RadioButton("Text", s.contents_type, CT_Text) - ImGui.SameLine(); _, s.contents_type = ImGui.RadioButton("FillButton", s.contents_type, CT_FillButton) - _, s.display_headers = ImGui.Checkbox("Display headers", s.display_headers) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoBordersInBody", s.flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]); ImGui.SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers)") + ImGui_AlignTextToFramePadding(); ImGui_Text("Cell contents:") + ImGui_SameLine(); _, s.contents_type = ImGui_RadioButton("Text", s.contents_type, CT_Text) + ImGui_SameLine(); _, s.contents_type = ImGui_RadioButton("FillButton", s.contents_type, CT_FillButton) + _, s.display_headers = ImGui_Checkbox("Display headers", s.display_headers) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoBordersInBody", s.flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]); ImGui_SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers)") PopStyleCompact() - if ImGui.BeginTable("table1", 3, s.flags) then + if ImGui_BeginTable("table1", 3, s.flags) then -- Display headers so we can inspect their interaction with borders -- (Headers are not the main purpose of this section of the demo, so we are not elaborating on them now. See other sections for details) if s.display_headers then - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") - ImGui.TableHeadersRow() + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") + ImGui_TableHeadersRow() end for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) + ImGui_TableSetColumnIndex(column) local buf = string.format("Hello %d,%d", column, row) if s.contents_type == CT_Text then - ImGui.TextUnformatted(buf) + ImGui_TextUnformatted(buf) elseif s.contents_type == CT_FillButton then - ImGui.Button(buf, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) + ImGui_Button(buf, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) end end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Resizable, stretch") then IMGUI_DEMO_MARKER("Tables/Resizable, stretch") @@ -29115,28 +29171,28 @@ function DemoWindowTables() -- All columns maintain a sizing weight, and they will occupy all available width. local s = s.ResizableStretch PushStyleCompact() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersV", s.flags, 1536 --[[ImGuiTableFlags.BordersV]]) - ImGui.SameLine(); HelpMarker( + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersV", s.flags, 1536 --[[ImGuiTableFlags.BordersV]]) + ImGui_SameLine(); HelpMarker( "Using the _Resizable flag automatically enables the _BordersInnerV flag as well, " .. "this is why the resize borders are still showing when unchecking this.") PopStyleCompact() - if ImGui.BeginTable("table1", 3, s.flags) then + if ImGui_BeginTable("table1", 3, s.flags) then for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("Hello %d,%d", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("Hello %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Resizable, fixed") then IMGUI_DEMO_MARKER("Tables/Resizable, fixed") @@ -29150,24 +29206,24 @@ function DemoWindowTables() "Double-click a column border to auto-fit the column to its contents.") PushStyleCompact() local s = s.ResizableFixed - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) PopStyleCompact() - if ImGui.BeginTable("table1", 3, s.flags) then + if ImGui_BeginTable("table1", 3, s.flags) then for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("Hello %d,%d", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("Hello %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Resizable, mixed") then IMGUI_DEMO_MARKER("Tables/Resizable, mixed") @@ -29176,42 +29232,42 @@ function DemoWindowTables() "When combining Fixed and Stretch columns, generally you only want one, maybe two trailing columns to use _WidthStretch.") local s = s.ResizableMixed - if ImGui.BeginTable("table1", 3, s.flags) then - ImGui.TableSetupColumn("AAA", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) - ImGui.TableSetupColumn("BBB", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) - ImGui.TableSetupColumn("CCC", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) - ImGui.TableHeadersRow() + if ImGui_BeginTable("table1", 3, s.flags) then + ImGui_TableSetupColumn("AAA", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) + ImGui_TableSetupColumn("BBB", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) + ImGui_TableSetupColumn("CCC", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) + ImGui_TableHeadersRow() for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("%s %d,%d", (column == 2) and "Stretch" or "Fixed", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("%s %d,%d", (column == 2) and "Stretch" or "Fixed", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - if ImGui.BeginTable("table2", 6, s.flags) then - ImGui.TableSetupColumn("AAA", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) - ImGui.TableSetupColumn("BBB", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) - ImGui.TableSetupColumn("CCC", bit32.bor(16 --[[ImGuiTableColumnFlags.WidthFixed]], 2 --[[ImGuiTableColumnFlags.DefaultHide]])) - ImGui.TableSetupColumn("DDD", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) - ImGui.TableSetupColumn("EEE", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) - ImGui.TableSetupColumn("FFF", bit32.bor(8 --[[ImGuiTableColumnFlags.WidthStretch]], 2 --[[ImGuiTableColumnFlags.DefaultHide]])) - ImGui.TableHeadersRow() + if ImGui_BeginTable("table2", 6, s.flags) then + ImGui_TableSetupColumn("AAA", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) + ImGui_TableSetupColumn("BBB", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) + ImGui_TableSetupColumn("CCC", bit32.bor(16 --[[ImGuiTableColumnFlags.WidthFixed]], 2 --[[ImGuiTableColumnFlags.DefaultHide]])) + ImGui_TableSetupColumn("DDD", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) + ImGui_TableSetupColumn("EEE", 8 --[[ImGuiTableColumnFlags.WidthStretch]]) + ImGui_TableSetupColumn("FFF", bit32.bor(8 --[[ImGuiTableColumnFlags.WidthStretch]], 2 --[[ImGuiTableColumnFlags.DefaultHide]])) + ImGui_TableHeadersRow() for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 6 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("%s %d,%d", (column >= 3) and "Stretch" or "Fixed", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("%s %d,%d", (column >= 3) and "Stretch" or "Fixed", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Reorderable, hideable, with headers") then IMGUI_DEMO_MARKER("Tables/Reorderable, hideable, with headers") @@ -29220,52 +29276,52 @@ function DemoWindowTables() "Right-click on a header to open a context menu.") local s = s.Reorderable PushStyleCompact() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Reorderable", s.flags, 2 --[[ImGuiTableFlags.Reorderable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Hideable", s.flags, 4 --[[ImGuiTableFlags.Hideable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoBordersInBody", s.flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", s.flags, 4096 --[[ImGuiTableFlags.NoBordersInBodyUntilResize]]); ImGui.SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appear in Headers)") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", s.flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Reorderable", s.flags, 2 --[[ImGuiTableFlags.Reorderable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Hideable", s.flags, 4 --[[ImGuiTableFlags.Hideable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoBordersInBody", s.flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", s.flags, 4096 --[[ImGuiTableFlags.NoBordersInBodyUntilResize]]); ImGui_SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appear in Headers)") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", s.flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) PopStyleCompact() - if ImGui.BeginTable("table1", 3, s.flags) then + if ImGui_BeginTable("table1", 3, s.flags) then -- Submit columns name with TableSetupColumn() and call TableHeadersRow() to create a row with a header in each column. -- (Later we will show how TableSetupColumn() has other uses, optional flags, sizing weight etc.) - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") - ImGui.TableHeadersRow() + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") + ImGui_TableHeadersRow() for row = 0, 6 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("Hello %d,%d", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("Hello %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end -- Use outer_size.x == 0.0f instead of default to make the table as tight as possible -- (only valid when no scrolling and no stretch column) - if ImGui.BeginTable("table2", 3, bit32.bor(s.flags, 8192 --[[ImGuiTableFlags.SizingFixedFit]]), ImVec2(0.0, 0.0)) then - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") - ImGui.TableHeadersRow() + if ImGui_BeginTable("table2", 3, bit32.bor(s.flags, 8192 --[[ImGuiTableFlags.SizingFixedFit]]), ImVec2(0.0, 0.0)) then + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") + ImGui_TableHeadersRow() for row = 0, 6 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("Fixed %d,%d", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("Fixed %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Padding") then IMGUI_DEMO_MARKER("Tables/Padding") @@ -29283,40 +29339,40 @@ function DemoWindowTables() local s = s.Padding PushStyleCompact() - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_PadOuterX", s.flags1, 2097152 --[[ImGuiTableFlags.PadOuterX]]) - ImGui.SameLine(); HelpMarker("Enable outer-most padding (default if ImGuiTableFlags_BordersOuterV is set)") - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_NoPadOuterX", s.flags1, 4194304 --[[ImGuiTableFlags.NoPadOuterX]]) - ImGui.SameLine(); HelpMarker("Disable outer-most padding (default if ImGuiTableFlags_BordersOuterV is not set)") - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_NoPadInnerX", s.flags1, 8388608 --[[ImGuiTableFlags.NoPadInnerX]]) - ImGui.SameLine(); HelpMarker("Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off)") - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags1, 1024 --[[ImGuiTableFlags.BordersOuterV]]) - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags1, 512 --[[ImGuiTableFlags.BordersInnerV]]) - _, s.show_headers = ImGui.Checkbox("show_headers", s.show_headers) + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_PadOuterX", s.flags1, 2097152 --[[ImGuiTableFlags.PadOuterX]]) + ImGui_SameLine(); HelpMarker("Enable outer-most padding (default if ImGuiTableFlags_BordersOuterV is set)") + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_NoPadOuterX", s.flags1, 4194304 --[[ImGuiTableFlags.NoPadOuterX]]) + ImGui_SameLine(); HelpMarker("Disable outer-most padding (default if ImGuiTableFlags_BordersOuterV is not set)") + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_NoPadInnerX", s.flags1, 8388608 --[[ImGuiTableFlags.NoPadInnerX]]) + ImGui_SameLine(); HelpMarker("Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off)") + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags1, 1024 --[[ImGuiTableFlags.BordersOuterV]]) + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags1, 512 --[[ImGuiTableFlags.BordersInnerV]]) + _, s.show_headers = ImGui_Checkbox("show_headers", s.show_headers) PopStyleCompact() - if ImGui.BeginTable("table_padding", 3, s.flags1) then + if ImGui_BeginTable("table_padding", 3, s.flags1) then if s.show_headers then - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") - ImGui.TableHeadersRow() + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") + ImGui_TableHeadersRow() end for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) + ImGui_TableSetColumnIndex(column) if row == 0 then - ImGui.Text("Avail %.2f", ImGui.GetContentRegionAvail().x) + ImGui_Text("Avail %.2f", ImGui_GetContentRegionAvail().x) else local buf = string.format("Hello %d,%d", column, row) - ImGui.Button(buf, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) + ImGui_Button(buf, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) end --if bit32.band(ImGui.TableGetColumnFlags(), ImGuiTableColumnFlags.IsHovered) ~= 0 then -- ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, IM_COL32(0, 100, 0, 255)) end end end - ImGui.EndTable() + ImGui_EndTable() end -- Second example: set style.CellPadding to (0.0) or a custom value. @@ -29324,88 +29380,88 @@ function DemoWindowTables() HelpMarker("Setting style.CellPadding to (0,0) or a custom value.") PushStyleCompact() - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_Borders", s.flags2, 1920 --[[ImGuiTableFlags.Borders]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersH", s.flags2, 384 --[[ImGuiTableFlags.BordersH]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersV", s.flags2, 1536 --[[ImGuiTableFlags.BordersV]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInner", s.flags2, 640 --[[ImGuiTableFlags.BordersInner]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuter", s.flags2, 1280 --[[ImGuiTableFlags.BordersOuter]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_RowBg", s.flags2, 64 --[[ImGuiTableFlags.RowBg]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags2, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.show_widget_frame_bg = ImGui.Checkbox("show_widget_frame_bg", s.show_widget_frame_bg) - ImGui.SliderFloat2("CellPadding", s.cell_padding, 0.0, 10.0, "%.0f") + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_Borders", s.flags2, 1920 --[[ImGuiTableFlags.Borders]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersH", s.flags2, 384 --[[ImGuiTableFlags.BordersH]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersV", s.flags2, 1536 --[[ImGuiTableFlags.BordersV]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInner", s.flags2, 640 --[[ImGuiTableFlags.BordersInner]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuter", s.flags2, 1280 --[[ImGuiTableFlags.BordersOuter]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_RowBg", s.flags2, 64 --[[ImGuiTableFlags.RowBg]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags2, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.show_widget_frame_bg = ImGui_Checkbox("show_widget_frame_bg", s.show_widget_frame_bg) + ImGui_SliderFloat2("CellPadding", s.cell_padding, 0.0, 10.0, "%.0f") PopStyleCompact() - ImGui.PushStyleVar(17 --[[ImGuiStyleVar.CellPadding]], s.cell_padding) - if ImGui.BeginTable("table_padding_2", 3, s.flags2) then + ImGui_PushStyleVar(17 --[[ImGuiStyleVar.CellPadding]], s.cell_padding) + if ImGui_BeginTable("table_padding_2", 3, s.flags2) then -- static char text_bufs[3 * 5][16] -- Mini text storage for 3x5 cells if not s.show_widget_frame_bg then - ImGui.PushStyleColor(7 --[[ImGuiCol.FrameBg]], 0) + ImGui_PushStyleColor(7 --[[ImGuiCol.FrameBg]], 0) end for cell = 0, 3 * 5 - 1 do - ImGui.TableNextColumn() + ImGui_TableNextColumn() if s.init then - s.text_bufs[cell + 1] = ImGui.NewTextBuffer("edit me", 16) -- [Port] strcpy() -> new buffer + s.text_bufs[cell + 1] = ImGui_NewTextBuffer("edit me", 16) -- [Port] strcpy() -> new buffer end - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) - ImGui.PushID(cell) - ImGui.InputText("##cell", s.text_bufs[cell + 1], 16) - ImGui.PopID() + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_PushID(cell) + ImGui_InputText("##cell", s.text_bufs[cell + 1], 16) + ImGui_PopID() end if not s.show_widget_frame_bg then - ImGui.PopStyleColor() + ImGui_PopStyleColor() end s.init = false - ImGui.EndTable() + ImGui_EndTable() end - ImGui.PopStyleVar() + ImGui_PopStyleVar() - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Sizing policies") then IMGUI_DEMO_MARKER("Tables/Explicit widths") local s = s.SizingPolicies PushStyleCompact() - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags1, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags1, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags1, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags1, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) PopStyleCompact() local sizing_policy_flags = s.sizing_policy_flags -- 1-based for table_n = 0, 4 - 1 do - ImGui.PushID(table_n) - ImGui.SetNextItemWidth(TEXT_BASE_WIDTH * 30) + ImGui_PushID(table_n) + ImGui_SetNextItemWidth(TEXT_BASE_WIDTH * 30) sizing_policy_flags[table_n + 1] = EditTableSizingFlags(sizing_policy_flags[table_n + 1]) -- To make it easier to understand the different sizing policy, -- For each policy: we display one table where the columns have equal contents width, -- and one where the columns have different contents width. - if ImGui.BeginTable("table1", 3, bit32.bor(sizing_policy_flags[table_n + 1], s.flags1)) then + if ImGui_BeginTable("table1", 3, bit32.bor(sizing_policy_flags[table_n + 1], s.flags1)) then for row = 0, 3 - 1 do - ImGui.TableNextRow() - ImGui.TableNextColumn(); ImGui.Text("Oh dear") - ImGui.TableNextColumn(); ImGui.Text("Oh dear") - ImGui.TableNextColumn(); ImGui.Text("Oh dear") + ImGui_TableNextRow() + ImGui_TableNextColumn(); ImGui_Text("Oh dear") + ImGui_TableNextColumn(); ImGui_Text("Oh dear") + ImGui_TableNextColumn(); ImGui_Text("Oh dear") end - ImGui.EndTable() + ImGui_EndTable() end - if ImGui.BeginTable("table2", 3, bit32.bor(sizing_policy_flags[table_n + 1], s.flags1)) then + if ImGui_BeginTable("table2", 3, bit32.bor(sizing_policy_flags[table_n + 1], s.flags1)) then for row = 0, 3 - 1 do - ImGui.TableNextRow() - ImGui.TableNextColumn(); ImGui.Text("AAAA") - ImGui.TableNextColumn(); ImGui.Text("BBBBBBBB") - ImGui.TableNextColumn(); ImGui.Text("CCCCCCCCCCCC") + ImGui_TableNextRow() + ImGui_TableNextColumn(); ImGui_Text("AAAA") + ImGui_TableNextColumn(); ImGui_Text("BBBBBBBB") + ImGui_TableNextColumn(); ImGui_Text("CCCCCCCCCCCC") end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.PopID() + ImGui_PopID() end - ImGui.Spacing() - ImGui.TextUnformatted("Advanced") - ImGui.SameLine() + ImGui_Spacing() + ImGui_TextUnformatted("Advanced") + ImGui_SameLine() HelpMarker( "This section allows you to interact and see the effect of various sizing policies " .. "depending on whether Scroll is enabled and the contents of your columns.") @@ -29413,52 +29469,52 @@ function DemoWindowTables() local CT_ShowWidth, CT_ShortText, CT_LongText, CT_Button, CT_FillButton, CT_InputText = 0, 1, 2, 3, 4, 5 -- [Port] enum ContentsType PushStyleCompact() - ImGui.PushID("Advanced") - ImGui.PushItemWidth(TEXT_BASE_WIDTH * 30) + ImGui_PushID("Advanced") + ImGui_PushItemWidth(TEXT_BASE_WIDTH * 30) s.flags = EditTableSizingFlags(s.flags) - s.contents_type = ImGui.Combo("Contents", s.contents_type, "Show width\0Short Text\0Long Text\0Button\0Fill Button\0InputText\0") + s.contents_type = ImGui_Combo("Contents", s.contents_type, "Show width\0Short Text\0Long Text\0Button\0Fill Button\0InputText\0") if s.contents_type == CT_FillButton then - ImGui.SameLine() + ImGui_SameLine() HelpMarker( "Be mindful that using right-alignment (e.g. size.x = -FLT_MIN) creates a feedback loop " .. "where contents width can feed into auto-column width can feed into contents width.") end - s.column_count = ImGui.DragInt("Columns", s.column_count, 0.1, 1, 64, "%d", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_PreciseWidths", s.flags, 524288 --[[ImGuiTableFlags.PreciseWidths]]) - ImGui.SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoClip", s.flags, 1048576 --[[ImGuiTableFlags.NoClip]]) - ImGui.PopItemWidth() - ImGui.PopID() + s.column_count = ImGui_DragInt("Columns", s.column_count, 0.1, 1, 64, "%d", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_PreciseWidths", s.flags, 524288 --[[ImGuiTableFlags.PreciseWidths]]) + ImGui_SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoClip", s.flags, 1048576 --[[ImGuiTableFlags.NoClip]]) + ImGui_PopItemWidth() + ImGui_PopID() PopStyleCompact() - if ImGui.BeginTable("table2", s.column_count, s.flags, ImVec2(0.0, TEXT_BASE_HEIGHT * 7)) then + if ImGui_BeginTable("table2", s.column_count, s.flags, ImVec2(0.0, TEXT_BASE_HEIGHT * 7)) then for cell = 0, 10 * s.column_count - 1 do - ImGui.TableNextColumn() - local column = ImGui.TableGetColumnIndex() - local row = ImGui.TableGetRowIndex() + ImGui_TableNextColumn() + local column = ImGui_TableGetColumnIndex() + local row = ImGui_TableGetRowIndex() - ImGui.PushID(cell) + ImGui_PushID(cell) local label = string.format("Hello %d,%d", column, row) local contents_type = s.contents_type - if contents_type == CT_ShortText then ImGui.TextUnformatted(label) - elseif contents_type == CT_LongText then ImGui.Text("Some %s text %d,%d\nOver two lines..", (column == 0) and "long" or "longeeer", column, row) - elseif contents_type == CT_ShowWidth then ImGui.Text("W: %.1f", ImGui.GetContentRegionAvail().x) - elseif contents_type == CT_Button then ImGui.Button(label) - elseif contents_type == CT_FillButton then ImGui.Button(label, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) - elseif contents_type == CT_InputText then ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]); ImGui.InputText("##", s.text_buf, 32) + if contents_type == CT_ShortText then ImGui_TextUnformatted(label) + elseif contents_type == CT_LongText then ImGui_Text("Some %s text %d,%d\nOver two lines..", (column == 0) and "long" or "longeeer", column, row) + elseif contents_type == CT_ShowWidth then ImGui_Text("W: %.1f", ImGui_GetContentRegionAvail().x) + elseif contents_type == CT_Button then ImGui_Button(label) + elseif contents_type == CT_FillButton then ImGui_Button(label, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) + elseif contents_type == CT_InputText then ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]); ImGui_InputText("##", s.text_buf, 32) end - ImGui.PopID() + ImGui_PopID() end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Vertical scrolling, with clipping") then IMGUI_DEMO_MARKER("Tables/Vertical scrolling, with clipping") @@ -29468,38 +29524,38 @@ function DemoWindowTables() local s = s.VerticalScrolling PushStyleCompact() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) PopStyleCompact() -- When using ScrollX or ScrollY we need to specify a size for our table container! -- Otherwise by default the table will fit all available space, like a BeginChild() call. local outer_size = ImVec2(0.0, TEXT_BASE_HEIGHT * 8) - if ImGui.BeginTable("table_scrolly", 3, s.flags, outer_size) then - ImGui.TableSetupScrollFreeze(0, 1) -- Make top row always visible - ImGui.TableSetupColumn("One", 0 --[[ImGuiTableColumnFlags.None]]) - ImGui.TableSetupColumn("Two", 0 --[[ImGuiTableColumnFlags.None]]) - ImGui.TableSetupColumn("Three", 0 --[[ImGuiTableColumnFlags.None]]) - ImGui.TableHeadersRow() + if ImGui_BeginTable("table_scrolly", 3, s.flags, outer_size) then + ImGui_TableSetupScrollFreeze(0, 1) -- Make top row always visible + ImGui_TableSetupColumn("One", 0 --[[ImGuiTableColumnFlags.None]]) + ImGui_TableSetupColumn("Two", 0 --[[ImGuiTableColumnFlags.None]]) + ImGui_TableSetupColumn("Three", 0 --[[ImGuiTableColumnFlags.None]]) + ImGui_TableHeadersRow() -- Demonstrate using clipper for large vertical lists local clipper = ImGuiListClipper() clipper:Begin(1000) while clipper:Step() do for row = clipper.DisplayStart, clipper.DisplayEnd - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("Hello %d,%d", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("Hello %d,%d", column, row) end end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Horizontal scrolling") then IMGUI_DEMO_MARKER("Tables/Horizontal scrolling") @@ -29512,30 +29568,30 @@ function DemoWindowTables() local s = s.HorizontalScrolling PushStyleCompact() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) - ImGui.SetNextItemWidth(ImGui.GetFrameHeight()) - s.freeze_cols = ImGui.DragInt("freeze_cols", s.freeze_cols, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) - ImGui.SetNextItemWidth(ImGui.GetFrameHeight()) - s.freeze_rows = ImGui.DragInt("freeze_rows", s.freeze_rows, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) + ImGui_SetNextItemWidth(ImGui_GetFrameHeight()) + s.freeze_cols = ImGui_DragInt("freeze_cols", s.freeze_cols, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) + ImGui_SetNextItemWidth(ImGui_GetFrameHeight()) + s.freeze_rows = ImGui_DragInt("freeze_rows", s.freeze_rows, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) PopStyleCompact() -- When using ScrollX or ScrollY we need to specify a size for our table container! -- Otherwise by default the table will fit all available space, like a BeginChild() call. local outer_size = ImVec2(0.0, TEXT_BASE_HEIGHT * 8) - if ImGui.BeginTable("table_scrollx", 7, s.flags, outer_size) then - ImGui.TableSetupScrollFreeze(s.freeze_cols, s.freeze_rows) - ImGui.TableSetupColumn("Line #", 128 --[[ImGuiTableColumnFlags.NoHide]]) -- Make the first column not hideable to match our use of TableSetupScrollFreeze() - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") - ImGui.TableSetupColumn("Four") - ImGui.TableSetupColumn("Five") - ImGui.TableSetupColumn("Six") - ImGui.TableHeadersRow() + if ImGui_BeginTable("table_scrollx", 7, s.flags, outer_size) then + ImGui_TableSetupScrollFreeze(s.freeze_cols, s.freeze_rows) + ImGui_TableSetupColumn("Line #", 128 --[[ImGuiTableColumnFlags.NoHide]]) -- Make the first column not hideable to match our use of TableSetupScrollFreeze() + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") + ImGui_TableSetupColumn("Four") + ImGui_TableSetupColumn("Five") + ImGui_TableSetupColumn("Six") + ImGui_TableHeadersRow() for row = 0, 20 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 7 - 1 do repeat -- Both TableNextColumn() and TableSetColumnIndex() return true when a column is visible or performing width measurement. -- Because here we know that: @@ -29543,47 +29599,47 @@ function DemoWindowTables() -- - B) column 0 is always visible, -- We only always submit this one column and can skip others. -- More advanced per-column clipping behaviors may benefit from polling the status flags via TableGetColumnFlags(). - if not ImGui.TableSetColumnIndex(column) and column > 0 then + if not ImGui_TableSetColumnIndex(column) and column > 0 then break -- continue end if column == 0 then - ImGui.Text("Line %d", row) + ImGui_Text("Line %d", row) else - ImGui.Text("Hello world %d,%d", column, row) + ImGui_Text("Hello world %d,%d", column, row) end until true end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.Spacing() - ImGui.TextUnformatted("Stretch + ScrollX") - ImGui.SameLine() + ImGui_Spacing() + ImGui_TextUnformatted("Stretch + ScrollX") + ImGui_SameLine() HelpMarker( "Showcase using Stretch columns + ScrollX together: " .. "this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n" .. "Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns " .. "along with ScrollX doesn't make sense.") PushStyleCompact() - ImGui.PushID("flags3") - ImGui.PushItemWidth(TEXT_BASE_WIDTH * 30) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags2, 16777216 --[[ImGuiTableFlags.ScrollX]]) - s.inner_width = ImGui.DragFloat("inner_width", s.inner_width, 1.0, 0.0, 3.4028234663853e+38 --[[FLT_MAX]], "%.1f") - ImGui.PopItemWidth() - ImGui.PopID() + ImGui_PushID("flags3") + ImGui_PushItemWidth(TEXT_BASE_WIDTH * 30) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags2, 16777216 --[[ImGuiTableFlags.ScrollX]]) + s.inner_width = ImGui_DragFloat("inner_width", s.inner_width, 1.0, 0.0, 3.4028234663853e+38 --[[FLT_MAX]], "%.1f") + ImGui_PopItemWidth() + ImGui_PopID() PopStyleCompact() - if ImGui.BeginTable("table2", 7, s.flags2, outer_size, s.inner_width) then + if ImGui_BeginTable("table2", 7, s.flags2, outer_size, s.inner_width) then for cell = 0, 20 * 7 - 1 do - ImGui.TableNextColumn() - ImGui.Text("Hello world %d,%d", ImGui.TableGetColumnIndex(), ImGui.TableGetRowIndex()) + ImGui_TableNextColumn() + ImGui_Text("Hello world %d,%d", ImGui_TableGetColumnIndex(), ImGui_TableGetRowIndex()) end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Columns flags") then IMGUI_DEMO_MARKER("Tables/Columns flags") @@ -29593,25 +29649,25 @@ function DemoWindowTables() local column_flags = s.ColumnsFlags.column_flags -- 1-based local column_flags_out = s.ColumnsFlags.column_flags_out -- Output from TableGetColumnFlags() - if ImGui.BeginTable("table_columns_flags_checkboxes", column_count, 0 --[[ImGuiTableFlags.None]]) then + if ImGui_BeginTable("table_columns_flags_checkboxes", column_count, 0 --[[ImGuiTableFlags.None]]) then PushStyleCompact() for column = 0, column_count - 1 do - ImGui.TableNextColumn() - ImGui.PushID(column) - ImGui.AlignTextToFramePadding() -- FIXME-TABLE: Workaround for wrong text baseline propagation across columns - ImGui.Text("'%s'", column_names[column + 1]) - ImGui.Spacing() - ImGui.Text("Input flags:") + ImGui_TableNextColumn() + ImGui_PushID(column) + ImGui_AlignTextToFramePadding() -- FIXME-TABLE: Workaround for wrong text baseline propagation across columns + ImGui_Text("'%s'", column_names[column + 1]) + ImGui_Spacing() + ImGui_Text("Input flags:") column_flags[column + 1] = EditTableColumnsFlags(column_flags[column + 1]) - ImGui.Spacing() - ImGui.Text("Output flags:") - ImGui.BeginDisabled() + ImGui_Spacing() + ImGui_Text("Output flags:") + ImGui_BeginDisabled() ShowTableColumnsStatusFlags(column_flags_out[column + 1]) - ImGui.EndDisabled() - ImGui.PopID() + ImGui_EndDisabled() + ImGui_PopID() end PopStyleCompact() - ImGui.EndTable() + ImGui_EndTable() end -- Create the real table we care about for the example! @@ -29623,38 +29679,38 @@ function DemoWindowTables() , 64 --[[ImGuiTableFlags.RowBg]], 1280 --[[ImGuiTableFlags.BordersOuter]], 1536 --[[ImGuiTableFlags.BordersV]] , 1 --[[ImGuiTableFlags.Resizable]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]], 8 --[[ImGuiTableFlags.Sortable]]) local outer_size = ImVec2(0.0, TEXT_BASE_HEIGHT * 9) - if ImGui.BeginTable("table_columns_flags", column_count, flags, outer_size) then + if ImGui_BeginTable("table_columns_flags", column_count, flags, outer_size) then local has_angled_header = false for column = 0, column_count - 1 do has_angled_header = has_angled_header or (bit32.band(column_flags[column + 1], 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) ~= 0) - ImGui.TableSetupColumn(column_names[column + 1], column_flags[column + 1]) + ImGui_TableSetupColumn(column_names[column + 1], column_flags[column + 1]) end if has_angled_header then - ImGui.TableAngledHeadersRow() + ImGui_TableAngledHeadersRow() end - ImGui.TableHeadersRow() + ImGui_TableHeadersRow() for column = 0, column_count - 1 do - column_flags_out[column + 1] = ImGui.TableGetColumnFlags(column) + column_flags_out[column + 1] = ImGui_TableGetColumnFlags(column) end local indent_step = math.floor(math.floor(TEXT_BASE_WIDTH) / 2) for row = 0, 8 - 1 do -- Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags. - ImGui.Indent(indent_step) - ImGui.TableNextRow() + ImGui_Indent(indent_step) + ImGui_TableNextRow() for column = 0, column_count - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("%s %s", (column == 0) and "Indented" or "Hello", ImGui.TableGetColumnName(column)) + ImGui_TableSetColumnIndex(column) + ImGui_Text("%s %s", (column == 0) and "Indented" or "Hello", ImGui_TableGetColumnName(column)) end end - ImGui.Unindent(indent_step * 8.0) + ImGui_Unindent(indent_step * 8.0) - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Columns widths") then IMGUI_DEMO_MARKER("Tables/Columns widths") @@ -29662,27 +29718,27 @@ function DemoWindowTables() local s = s.ColumnsWidths PushStyleCompact() - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags1, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", s.flags1, 4096 --[[ImGuiTableFlags.NoBordersInBodyUntilResize]]) + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags1, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", s.flags1, 4096 --[[ImGuiTableFlags.NoBordersInBodyUntilResize]]) PopStyleCompact() - if ImGui.BeginTable("table1", 3, s.flags1) then + if ImGui_BeginTable("table1", 3, s.flags1) then -- We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed. - ImGui.TableSetupColumn("one", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 100.0) -- Default to 100.0f - ImGui.TableSetupColumn("two", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 200.0) -- Default to 200.0f - ImGui.TableSetupColumn("three", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) -- Default to auto - ImGui.TableHeadersRow() + ImGui_TableSetupColumn("one", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 100.0) -- Default to 100.0f + ImGui_TableSetupColumn("two", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 200.0) -- Default to 200.0f + ImGui_TableSetupColumn("three", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) -- Default to auto + ImGui_TableHeadersRow() for row = 0, 4 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableSetColumnIndex(column) + ImGui_TableSetColumnIndex(column) if row == 0 then - ImGui.Text("(w: %5.1f)", ImGui.GetContentRegionAvail().x) + ImGui_Text("(w: %5.1f)", ImGui_GetContentRegionAvail().x) else - ImGui.Text("Hello %d,%d", column, row) + ImGui_Text("Hello %d,%d", column, row) end end end - ImGui.EndTable() + ImGui_EndTable() end HelpMarker( @@ -29690,78 +29746,78 @@ function DemoWindowTables() "fixed columns with set width may still be shrunk down if there's not enough space in the host.") PushStyleCompact() - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", s.flags2, 262144 --[[ImGuiTableFlags.NoKeepColumnsVisible]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags2, 512 --[[ImGuiTableFlags.BordersInnerV]]) - _, s.flags2 = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags2, 1024 --[[ImGuiTableFlags.BordersOuterV]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", s.flags2, 262144 --[[ImGuiTableFlags.NoKeepColumnsVisible]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags2, 512 --[[ImGuiTableFlags.BordersInnerV]]) + _, s.flags2 = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags2, 1024 --[[ImGuiTableFlags.BordersOuterV]]) PopStyleCompact() - if ImGui.BeginTable("table2", 4, s.flags2) then + if ImGui_BeginTable("table2", 4, s.flags2) then -- We could also set ImGuiTableFlags_SizingFixedFit on the table and then all columns -- will default to ImGuiTableColumnFlags_WidthFixed. - ImGui.TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 100.0) - ImGui.TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 15.0) - ImGui.TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 30.0) - ImGui.TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 15.0) + ImGui_TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 100.0) + ImGui_TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 15.0) + ImGui_TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 30.0) + ImGui_TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 15.0) for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 4 - 1 do - ImGui.TableSetColumnIndex(column) + ImGui_TableSetColumnIndex(column) if row == 0 then - ImGui.Text("(w: %5.1f)", ImGui.GetContentRegionAvail().x) + ImGui_Text("(w: %5.1f)", ImGui_GetContentRegionAvail().x) else - ImGui.Text("Hello %d,%d", column, row) + ImGui_Text("Hello %d,%d", column, row) end end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Nested tables") then IMGUI_DEMO_MARKER("Tables/Nested tables") HelpMarker("This demonstrates embedding a table into another table cell.") - if ImGui.BeginTable("table_nested1", 2, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 1 --[[ImGuiTableFlags.Resizable]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]])) then - ImGui.TableSetupColumn("A0") - ImGui.TableSetupColumn("A1") - ImGui.TableHeadersRow() + if ImGui_BeginTable("table_nested1", 2, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 1 --[[ImGuiTableFlags.Resizable]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]])) then + ImGui_TableSetupColumn("A0") + ImGui_TableSetupColumn("A1") + ImGui_TableHeadersRow() - ImGui.TableNextColumn() - ImGui.Text("A0 Row 0") + ImGui_TableNextColumn() + ImGui_Text("A0 Row 0") do - local rows_height = (TEXT_BASE_HEIGHT * 2.0) + (ImGui.GetStyle().CellPadding.y * 2.0) - if ImGui.BeginTable("table_nested2", 2, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 1 --[[ImGuiTableFlags.Resizable]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]])) then - ImGui.TableSetupColumn("B0") - ImGui.TableSetupColumn("B1") - ImGui.TableHeadersRow() + local rows_height = (TEXT_BASE_HEIGHT * 2.0) + (ImGui_GetStyle().CellPadding.y * 2.0) + if ImGui_BeginTable("table_nested2", 2, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 1 --[[ImGuiTableFlags.Resizable]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]])) then + ImGui_TableSetupColumn("B0") + ImGui_TableSetupColumn("B1") + ImGui_TableHeadersRow() - ImGui.TableNextRow(0 --[[ImGuiTableRowFlags.None]], rows_height) - ImGui.TableNextColumn() - ImGui.Text("B0 Row 0") - ImGui.TableNextColumn() - ImGui.Text("B1 Row 0") - ImGui.TableNextRow(0 --[[ImGuiTableRowFlags.None]], rows_height) - ImGui.TableNextColumn() - ImGui.Text("B0 Row 1") - ImGui.TableNextColumn() - ImGui.Text("B1 Row 1") + ImGui_TableNextRow(0 --[[ImGuiTableRowFlags.None]], rows_height) + ImGui_TableNextColumn() + ImGui_Text("B0 Row 0") + ImGui_TableNextColumn() + ImGui_Text("B1 Row 0") + ImGui_TableNextRow(0 --[[ImGuiTableRowFlags.None]], rows_height) + ImGui_TableNextColumn() + ImGui_Text("B0 Row 1") + ImGui_TableNextColumn() + ImGui_Text("B1 Row 1") - ImGui.EndTable() + ImGui_EndTable() end end - ImGui.TableNextColumn(); ImGui.Text("A1 Row 0") - ImGui.TableNextColumn(); ImGui.Text("A0 Row 1") - ImGui.TableNextColumn(); ImGui.Text("A1 Row 1") - ImGui.EndTable() + ImGui_TableNextColumn(); ImGui_Text("A1 Row 0") + ImGui_TableNextColumn(); ImGui_Text("A0 Row 1") + ImGui_TableNextColumn(); ImGui_Text("A1 Row 1") + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Row height") then IMGUI_DEMO_MARKER("Tables/Row height") @@ -29769,188 +29825,188 @@ function DemoWindowTables() "You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, " .. "so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\n" .. "We cannot honor a _maximum_ row height as that would require a unique clipping rectangle per row.") - if ImGui.BeginTable("table_row_height", 1, 1920 --[[ImGuiTableFlags.Borders]]) then + if ImGui_BeginTable("table_row_height", 1, 1920 --[[ImGuiTableFlags.Borders]]) then for row = 0, 8 - 1 do - local min_row_height = math.floor(TEXT_BASE_HEIGHT * 0.30 * row + ImGui.GetStyle().CellPadding.y * 2.0) - ImGui.TableNextRow(0 --[[ImGuiTableRowFlags.None]], min_row_height) - ImGui.TableNextColumn() - ImGui.Text("min_row_height = %.2f", min_row_height) + local min_row_height = math.floor(TEXT_BASE_HEIGHT * 0.30 * row + ImGui_GetStyle().CellPadding.y * 2.0) + ImGui_TableNextRow(0 --[[ImGuiTableRowFlags.None]], min_row_height) + ImGui_TableNextColumn() + ImGui_Text("min_row_height = %.2f", min_row_height) end - ImGui.EndTable() + ImGui_EndTable() end HelpMarker( "Showcase using SameLine(0,0) to share Current Line Height between cells.\n\n" .. "Please note that Tables Row Height is not the same thing as Current Line Height, " .. "as a table cell may contains multiple lines.") - if ImGui.BeginTable("table_share_lineheight", 2, 1920 --[[ImGuiTableFlags.Borders]]) then - ImGui.TableNextRow() - ImGui.TableNextColumn() - ImGui.ColorButton("##1", ImVec4(0.13, 0.26, 0.40, 1.0), 0 --[[ImGuiColorEditFlags.None]], ImVec2(40, 40)) - ImGui.TableNextColumn() - ImGui.Text("Line 1") - ImGui.Text("Line 2") + if ImGui_BeginTable("table_share_lineheight", 2, 1920 --[[ImGuiTableFlags.Borders]]) then + ImGui_TableNextRow() + ImGui_TableNextColumn() + ImGui_ColorButton("##1", ImVec4(0.13, 0.26, 0.40, 1.0), 0 --[[ImGuiColorEditFlags.None]], ImVec2(40, 40)) + ImGui_TableNextColumn() + ImGui_Text("Line 1") + ImGui_Text("Line 2") - ImGui.TableNextRow() - ImGui.TableNextColumn() - ImGui.ColorButton("##2", ImVec4(0.13, 0.26, 0.40, 1.0), 0 --[[ImGuiColorEditFlags.None]], ImVec2(40, 40)) - ImGui.TableNextColumn() - ImGui.SameLine(0.0, 0.0) -- Reuse line height from previous column - ImGui.Text("Line 1, with SameLine(0,0)") - ImGui.Text("Line 2") + ImGui_TableNextRow() + ImGui_TableNextColumn() + ImGui_ColorButton("##2", ImVec4(0.13, 0.26, 0.40, 1.0), 0 --[[ImGuiColorEditFlags.None]], ImVec2(40, 40)) + ImGui_TableNextColumn() + ImGui_SameLine(0.0, 0.0) -- Reuse line height from previous column + ImGui_Text("Line 1, with SameLine(0,0)") + ImGui_Text("Line 2") - ImGui.EndTable() + ImGui_EndTable() end HelpMarker("Showcase altering CellPadding.y between rows. Note that CellPadding.x is locked for the entire table.") - if ImGui.BeginTable("table_changing_cellpadding_y", 1, 1920 --[[ImGuiTableFlags.Borders]]) then - local style = ImGui.GetStyle() + if ImGui_BeginTable("table_changing_cellpadding_y", 1, 1920 --[[ImGuiTableFlags.Borders]]) then + local style = ImGui_GetStyle() for row = 0, 8 - 1 do if (row % 3) == 2 then - ImGui.PushStyleVarY(17 --[[ImGuiStyleVar.CellPadding]], 20.0) + ImGui_PushStyleVarY(17 --[[ImGuiStyleVar.CellPadding]], 20.0) end - ImGui.TableNextRow(0 --[[ImGuiTableRowFlags.None]]) - ImGui.TableNextColumn() - ImGui.Text("CellPadding.y = %.2f", style.CellPadding.y) + ImGui_TableNextRow(0 --[[ImGuiTableRowFlags.None]]) + ImGui_TableNextColumn() + ImGui_Text("CellPadding.y = %.2f", style.CellPadding.y) if (row % 3) == 2 then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Outer size") then IMGUI_DEMO_MARKER("Tables/Outer size") -- Showcasing use of ImGuiTableFlags_NoHostExtendX and ImGuiTableFlags_NoHostExtendY -- Important to that note how the two flags have slightly different behaviors! - ImGui.Text("Using NoHostExtendX and NoHostExtendY:") + ImGui_Text("Using NoHostExtendX and NoHostExtendY:") PushStyleCompact() local s = s.OuterSize - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) - ImGui.SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoHostExtendY", s.flags, 131072 --[[ImGuiTableFlags.NoHostExtendY]]) - ImGui.SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) + ImGui_SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoHostExtendY", s.flags, 131072 --[[ImGuiTableFlags.NoHostExtendY]]) + ImGui_SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.") PopStyleCompact() local outer_size = ImVec2(0.0, TEXT_BASE_HEIGHT * 5.5) - if ImGui.BeginTable("table1", 3, s.flags, outer_size) then + if ImGui_BeginTable("table1", 3, s.flags, outer_size) then for row = 0, 10 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableNextColumn() - ImGui.Text("Cell %d,%d", column, row) + ImGui_TableNextColumn() + ImGui_Text("Cell %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.SameLine() - ImGui.Text("Hello!") + ImGui_SameLine() + ImGui_Text("Hello!") - ImGui.Spacing() + ImGui_Spacing() - ImGui.Text("Using explicit size:") - if ImGui.BeginTable("table2", 3, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 64 --[[ImGuiTableFlags.RowBg]]), ImVec2(TEXT_BASE_WIDTH * 30, 0.0)) then + ImGui_Text("Using explicit size:") + if ImGui_BeginTable("table2", 3, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 64 --[[ImGuiTableFlags.RowBg]]), ImVec2(TEXT_BASE_WIDTH * 30, 0.0)) then for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do - ImGui.TableNextColumn() - ImGui.Text("Cell %d,%d", column, row) + ImGui_TableNextColumn() + ImGui_Text("Cell %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.SameLine() - if ImGui.BeginTable("table3", 3, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 64 --[[ImGuiTableFlags.RowBg]]), ImVec2(TEXT_BASE_WIDTH * 30, 0.0)) then - local rows_height = TEXT_BASE_HEIGHT * 1.5 + ImGui.GetStyle().CellPadding.y * 2.0 + ImGui_SameLine() + if ImGui_BeginTable("table3", 3, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 64 --[[ImGuiTableFlags.RowBg]]), ImVec2(TEXT_BASE_WIDTH * 30, 0.0)) then + local rows_height = TEXT_BASE_HEIGHT * 1.5 + ImGui_GetStyle().CellPadding.y * 2.0 for row = 0, 3 - 1 do - ImGui.TableNextRow(0, rows_height) + ImGui_TableNextRow(0, rows_height) for column = 0, 3 - 1 do - ImGui.TableNextColumn() - ImGui.Text("Cell %d,%d", column, row) + ImGui_TableNextColumn() + ImGui_Text("Cell %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Background color") then IMGUI_DEMO_MARKER("Tables/Background color") local s = s.BackgroundColor PushStyleCompact() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Borders", s.flags, 1920 --[[ImGuiTableFlags.Borders]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_RowBg", s.flags, 64 --[[ImGuiTableFlags.RowBg]]) - ImGui.SameLine(); HelpMarker("ImGuiTableFlags_RowBg automatically sets RowBg0 to alternative colors pulled from the Style.") - s.row_bg_type = ImGui.Combo("row bg type", s.row_bg_type, "None\0Red\0Gradient\0") - s.row_bg_target = ImGui.Combo("row bg target", s.row_bg_target, "RowBg0\0RowBg1\0"); ImGui.SameLine(); HelpMarker("Target RowBg0 to override the alternating odd/even colors,\nTarget RowBg1 to blend with them.") - s.cell_bg_type = ImGui.Combo("cell bg type", s.cell_bg_type, "None\0Blue\0"); ImGui.SameLine(); HelpMarker("We are colorizing cells to B1->C2 here.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Borders", s.flags, 1920 --[[ImGuiTableFlags.Borders]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_RowBg", s.flags, 64 --[[ImGuiTableFlags.RowBg]]) + ImGui_SameLine(); HelpMarker("ImGuiTableFlags_RowBg automatically sets RowBg0 to alternative colors pulled from the Style.") + s.row_bg_type = ImGui_Combo("row bg type", s.row_bg_type, "None\0Red\0Gradient\0") + s.row_bg_target = ImGui_Combo("row bg target", s.row_bg_target, "RowBg0\0RowBg1\0"); ImGui_SameLine(); HelpMarker("Target RowBg0 to override the alternating odd/even colors,\nTarget RowBg1 to blend with them.") + s.cell_bg_type = ImGui_Combo("cell bg type", s.cell_bg_type, "None\0Blue\0"); ImGui_SameLine(); HelpMarker("We are colorizing cells to B1->C2 here.") assert(s.row_bg_type >= 0 and s.row_bg_type <= 2) assert(s.row_bg_target >= 0 and s.row_bg_target <= 1) assert(s.cell_bg_type >= 0 and s.cell_bg_type <= 1) PopStyleCompact() - if ImGui.BeginTable("table1", 5, s.flags) then + if ImGui_BeginTable("table1", 5, s.flags) then for row = 0, 6 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() -- Demonstrate setting a row background color with 'ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBgX, ...)' -- We use a transparent color so we can see the one behind in case our target is RowBg1 and RowBg0 was already targeted by the ImGuiTableFlags_RowBg flag. if s.row_bg_type ~= 0 then - local row_bg_color = ImGui.GetColorU32((s.row_bg_type == 1) and ImVec4(0.7, 0.3, 0.3, 0.65) or ImVec4(0.2 + row * 0.1, 0.2, 0.2, 0.65)) -- Flat or Gradient? - ImGui.TableSetBgColor(1 --[[ImGuiTableBgTarget.RowBg0]] + s.row_bg_target, row_bg_color) + local row_bg_color = ImGui_GetColorU32((s.row_bg_type == 1) and ImVec4(0.7, 0.3, 0.3, 0.65) or ImVec4(0.2 + row * 0.1, 0.2, 0.2, 0.65)) -- Flat or Gradient? + ImGui_TableSetBgColor(1 --[[ImGuiTableBgTarget.RowBg0]] + s.row_bg_target, row_bg_color) end -- Fill cells for column = 0, 5 - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("%c%c", string.byte("A") + row, string.byte("0") + column) + ImGui_TableSetColumnIndex(column) + ImGui_Text("%c%c", string.byte("A") + row, string.byte("0") + column) -- Change background of Cells B1->C2 -- Demonstrate setting a cell background color with 'ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, ...)' -- (the CellBg color will be blended over the RowBg and ColumnBg colors) -- We can also pass a column number as a third parameter to TableSetBgColor() and do this outside the column loop. if row >= 1 and row <= 2 and column >= 1 and column <= 2 and s.cell_bg_type == 1 then - local cell_bg_color = ImGui.GetColorU32(ImVec4(0.3, 0.3, 0.7, 0.65)) - ImGui.TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], cell_bg_color) + local cell_bg_color = ImGui_GetColorU32(ImVec4(0.3, 0.3, 0.7, 0.65)) + ImGui_TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], cell_bg_color) end end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Tree view") then IMGUI_DEMO_MARKER("Tables/Tree view") local s = s.TreeView - _, s.tree_node_flags_base = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", s.tree_node_flags_base, 4096 --[[ImGuiTreeNodeFlags.SpanFullWidth]]) - _, s.tree_node_flags_base = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_SpanLabelWidth", s.tree_node_flags_base, 8192 --[[ImGuiTreeNodeFlags.SpanLabelWidth]]) - _, s.tree_node_flags_base = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", s.tree_node_flags_base, 16384 --[[ImGuiTreeNodeFlags.SpanAllColumns]]) - _, s.tree_node_flags_base = ImGui.CheckboxFlags("ImGuiTreeNodeFlags_LabelSpanAllColumns", s.tree_node_flags_base, 32768 --[[ImGuiTreeNodeFlags.LabelSpanAllColumns]]) - ImGui.SameLine(); HelpMarker("Useful if you know that you aren't displaying contents in other columns") + _, s.tree_node_flags_base = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", s.tree_node_flags_base, 4096 --[[ImGuiTreeNodeFlags.SpanFullWidth]]) + _, s.tree_node_flags_base = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_SpanLabelWidth", s.tree_node_flags_base, 8192 --[[ImGuiTreeNodeFlags.SpanLabelWidth]]) + _, s.tree_node_flags_base = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", s.tree_node_flags_base, 16384 --[[ImGuiTreeNodeFlags.SpanAllColumns]]) + _, s.tree_node_flags_base = ImGui_CheckboxFlags("ImGuiTreeNodeFlags_LabelSpanAllColumns", s.tree_node_flags_base, 32768 --[[ImGuiTreeNodeFlags.LabelSpanAllColumns]]) + ImGui_SameLine(); HelpMarker("Useful if you know that you aren't displaying contents in other columns") HelpMarker("See \"Columns flags\" section to configure how indentation is applied to individual columns.") - if ImGui.BeginTable("3ways", 3, s.table_flags) then + if ImGui_BeginTable("3ways", 3, s.table_flags) then -- The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On - ImGui.TableSetupColumn("Name", 128 --[[ImGuiTableColumnFlags.NoHide]]) - ImGui.TableSetupColumn("Size", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 12.0) - ImGui.TableSetupColumn("Type", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 18.0) - ImGui.TableHeadersRow() + ImGui_TableSetupColumn("Name", 128 --[[ImGuiTableColumnFlags.NoHide]]) + ImGui_TableSetupColumn("Size", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 12.0) + ImGui_TableSetupColumn("Type", 16 --[[ImGuiTableColumnFlags.WidthFixed]], TEXT_BASE_WIDTH * 18.0) + ImGui_TableHeadersRow() -- Simple storage to output a dummy file-system. -- [Port] struct MyTreeNode { Name, Type, Size, ChildIdx, ChildCount } (see s.nodes) @@ -29958,8 +30014,8 @@ function DemoWindowTables() if MyTreeNode == nil then -- [Port] local struct with a static method, created once and kept in statics MyTreeNode = {} function MyTreeNode.DisplayNode(node, all_nodes) - ImGui.TableNextRow() - ImGui.TableNextColumn() + ImGui_TableNextRow() + ImGui_TableNextColumn() local is_folder = (node.ChildCount > 0) local node_flags = s.tree_node_flags_base @@ -29970,23 +30026,23 @@ function DemoWindowTables() if is_folder then local open = ImGui.TreeNodeEx(node.Name, node_flags) if bit32.band(node_flags, 32768 --[[ImGuiTreeNodeFlags.LabelSpanAllColumns]]) == 0 then - ImGui.TableNextColumn() - ImGui.TextDisabled("--") - ImGui.TableNextColumn() - ImGui.TextUnformatted(node.Type) + ImGui_TableNextColumn() + ImGui_TextDisabled("--") + ImGui_TableNextColumn() + ImGui_TextUnformatted(node.Type) end if open then for child_n = 0, node.ChildCount - 1 do MyTreeNode.DisplayNode(all_nodes[node.ChildIdx + child_n + 1], all_nodes) end - ImGui.TreePop() + ImGui_TreePop() end else ImGui.TreeNodeEx(node.Name, bit32.bor(node_flags, 256 --[[ImGuiTreeNodeFlags.Leaf]], 512 --[[ImGuiTreeNodeFlags.Bullet]], 8 --[[ImGuiTreeNodeFlags.NoTreePushOnOpen]])) - ImGui.TableNextColumn() - ImGui.Text("%d", node.Size) - ImGui.TableNextColumn() - ImGui.TextUnformatted(node.Type) + ImGui_TableNextColumn() + ImGui_Text("%d", node.Size) + ImGui_TableNextColumn() + ImGui_TextUnformatted(node.Type) end end s.MyTreeNode = MyTreeNode @@ -29995,13 +30051,13 @@ function DemoWindowTables() MyTreeNode.DisplayNode(nodes[1], nodes) - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Item width") then IMGUI_DEMO_MARKER("Tables/Item width") @@ -30009,51 +30065,51 @@ function DemoWindowTables() "Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n" .. "Note that on auto-resizing non-resizable fixed columns, querying the content width for " .. "e.g. right-alignment doesn't make sense.") - if ImGui.BeginTable("table_item_width", 3, 1920 --[[ImGuiTableFlags.Borders]]) then - ImGui.TableSetupColumn("small") - ImGui.TableSetupColumn("half") - ImGui.TableSetupColumn("right-align") - ImGui.TableHeadersRow() + if ImGui_BeginTable("table_item_width", 3, 1920 --[[ImGuiTableFlags.Borders]]) then + ImGui_TableSetupColumn("small") + ImGui_TableSetupColumn("half") + ImGui_TableSetupColumn("right-align") + ImGui_TableHeadersRow() for row = 0, 3 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() if row == 0 then -- Setup ItemWidth once (instead of setting up every time, which is also possible but less efficient) - ImGui.TableSetColumnIndex(0) - ImGui.PushItemWidth(TEXT_BASE_WIDTH * 3.0) -- Small - ImGui.TableSetColumnIndex(1) - ImGui.PushItemWidth(-ImGui.GetContentRegionAvail().x * 0.5) - ImGui.TableSetColumnIndex(2) - ImGui.PushItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) -- Right-aligned + ImGui_TableSetColumnIndex(0) + ImGui_PushItemWidth(TEXT_BASE_WIDTH * 3.0) -- Small + ImGui_TableSetColumnIndex(1) + ImGui_PushItemWidth(-ImGui_GetContentRegionAvail().x * 0.5) + ImGui_TableSetColumnIndex(2) + ImGui_PushItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) -- Right-aligned end -- Draw our contents local s = s.ItemWidth - ImGui.PushID(row) - ImGui.TableSetColumnIndex(0) - s.dummy_f = ImGui.SliderFloat("float0", s.dummy_f, 0.0, 1.0) - ImGui.TableSetColumnIndex(1) - s.dummy_f = ImGui.SliderFloat("float1", s.dummy_f, 0.0, 1.0) - ImGui.TableSetColumnIndex(2) - s.dummy_f = ImGui.SliderFloat("##float2", s.dummy_f, 0.0, 1.0) -- No visible label since right-aligned - ImGui.PopID() + ImGui_PushID(row) + ImGui_TableSetColumnIndex(0) + s.dummy_f = ImGui_SliderFloat("float0", s.dummy_f, 0.0, 1.0) + ImGui_TableSetColumnIndex(1) + s.dummy_f = ImGui_SliderFloat("float1", s.dummy_f, 0.0, 1.0) + ImGui_TableSetColumnIndex(2) + s.dummy_f = ImGui_SliderFloat("##float2", s.dummy_f, 0.0, 1.0) -- No visible label since right-aligned + ImGui_PopID() end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate using TableHeader() calls instead of TableHeadersRow() if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Custom headers") then IMGUI_DEMO_MARKER("Tables/Custom headers") local COLUMNS_COUNT = 3 - if ImGui.BeginTable("table_custom_headers", COLUMNS_COUNT, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]])) then - ImGui.TableSetupColumn("Apricot") - ImGui.TableSetupColumn("Banana") - ImGui.TableSetupColumn("Cherry") + if ImGui_BeginTable("table_custom_headers", COLUMNS_COUNT, bit32.bor(1920 --[[ImGuiTableFlags.Borders]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]])) then + ImGui_TableSetupColumn("Apricot") + ImGui_TableSetupColumn("Banana") + ImGui_TableSetupColumn("Cherry") -- Dummy entire-column selection storage -- FIXME: It would be nice to actually demonstrate full-featured selection using those checkbox. @@ -30064,36 +30120,36 @@ function DemoWindowTables() -- - Specify ImGuiTableColumnFlags_NoHeaderLabel in some TableSetupColumn() call. -- - Call TableHeadersRow() normally. This will submit TableHeader() with no name. -- - Then call TableSetColumnIndex() to position yourself in the column and submit your stuff e.g. Checkbox().) - ImGui.TableNextRow(1 --[[ImGuiTableRowFlags.Headers]]) + ImGui_TableNextRow(1 --[[ImGuiTableRowFlags.Headers]]) for column = 0, COLUMNS_COUNT - 1 do - ImGui.TableSetColumnIndex(column) - local column_name = ImGui.TableGetColumnName(column) -- Retrieve name passed to TableSetupColumn() - ImGui.PushID(column) - ImGui.PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0, 0)) - _, column_selected[column + 1] = ImGui.Checkbox("##checkall", column_selected[column + 1]) - ImGui.PopStyleVar() - ImGui.SameLine(0.0, ImGui.GetStyle().ItemInnerSpacing.x) - ImGui.TableHeader(column_name) - ImGui.PopID() + ImGui_TableSetColumnIndex(column) + local column_name = ImGui_TableGetColumnName(column) -- Retrieve name passed to TableSetupColumn() + ImGui_PushID(column) + ImGui_PushStyleVar(11 --[[ImGuiStyleVar.FramePadding]], ImVec2(0, 0)) + _, column_selected[column + 1] = ImGui_Checkbox("##checkall", column_selected[column + 1]) + ImGui_PopStyleVar() + ImGui_SameLine(0.0, ImGui_GetStyle().ItemInnerSpacing.x) + ImGui_TableHeader(column_name) + ImGui_PopID() end -- Submit table contents for row = 0, 5 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, 3 - 1 do local buf = string.format("Cell %d,%d", column, row) - ImGui.TableSetColumnIndex(column) - ImGui.Selectable(buf, column_selected[column + 1]) + ImGui_TableSetColumnIndex(column) + ImGui_Selectable(buf, column_selected[column + 1]) end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate using ImGuiTableColumnFlags_AngledHeader flag to create angled headers if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Angled headers") then IMGUI_DEMO_MARKER("Tables/Angled headers") @@ -30107,61 +30163,61 @@ function DemoWindowTables() if #bools == 0 then for n = 1, columns_count * rows_count do bools[n] = false end end - _, s.table_flags = ImGui.CheckboxFlags("_ScrollX", s.table_flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) - _, s.table_flags = ImGui.CheckboxFlags("_ScrollY", s.table_flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) - _, s.table_flags = ImGui.CheckboxFlags("_Resizable", s.table_flags, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.table_flags = ImGui.CheckboxFlags("_Sortable", s.table_flags, 8 --[[ImGuiTableFlags.Sortable]]) - _, s.table_flags = ImGui.CheckboxFlags("_NoBordersInBody", s.table_flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]) - _, s.table_flags = ImGui.CheckboxFlags("_HighlightHoveredColumn", s.table_flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - s.frozen_cols = ImGui.SliderInt("Frozen columns", s.frozen_cols, 0, 2) - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - s.frozen_rows = ImGui.SliderInt("Frozen rows", s.frozen_rows, 0, 2) - _, s.column_flags = ImGui.CheckboxFlags("Disable header contributing to column width", s.column_flags, 8192 --[[ImGuiTableColumnFlags.NoHeaderWidth]]) + _, s.table_flags = ImGui_CheckboxFlags("_ScrollX", s.table_flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) + _, s.table_flags = ImGui_CheckboxFlags("_ScrollY", s.table_flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) + _, s.table_flags = ImGui_CheckboxFlags("_Resizable", s.table_flags, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.table_flags = ImGui_CheckboxFlags("_Sortable", s.table_flags, 8 --[[ImGuiTableFlags.Sortable]]) + _, s.table_flags = ImGui_CheckboxFlags("_NoBordersInBody", s.table_flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]) + _, s.table_flags = ImGui_CheckboxFlags("_HighlightHoveredColumn", s.table_flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + s.frozen_cols = ImGui_SliderInt("Frozen columns", s.frozen_cols, 0, 2) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + s.frozen_rows = ImGui_SliderInt("Frozen rows", s.frozen_rows, 0, 2) + _, s.column_flags = ImGui_CheckboxFlags("Disable header contributing to column width", s.column_flags, 8192 --[[ImGuiTableColumnFlags.NoHeaderWidth]]) if ImGui.TreeNode("Style settings") then - ImGui.SameLine() + ImGui_SameLine() HelpMarker("Giving access to some ImGuiStyle value in this demo for convenience.") - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - ImGui.GetStyle().TableAngledHeadersAngle = ImGui.SliderAngle("style.TableAngledHeadersAngle", ImGui.GetStyle().TableAngledHeadersAngle, -50.0, 50.0) - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - ImGui.SliderFloat2("style.TableAngledHeadersTextAlign", ImGui.GetStyle().TableAngledHeadersTextAlign, 0.0, 1.0, "%.2f") - ImGui.TreePop() + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + ImGui_GetStyle().TableAngledHeadersAngle = ImGui_SliderAngle("style.TableAngledHeadersAngle", ImGui_GetStyle().TableAngledHeadersAngle, -50.0, 50.0) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + ImGui_SliderFloat2("style.TableAngledHeadersTextAlign", ImGui_GetStyle().TableAngledHeadersTextAlign, 0.0, 1.0, "%.2f") + ImGui_TreePop() end - if ImGui.BeginTable("table_angled_headers", columns_count, s.table_flags, ImVec2(0.0, TEXT_BASE_HEIGHT * 12)) then - ImGui.TableSetupColumn(column_names[1], bit32.bor(128 --[[ImGuiTableColumnFlags.NoHide]], 64 --[[ImGuiTableColumnFlags.NoReorder]])) + if ImGui_BeginTable("table_angled_headers", columns_count, s.table_flags, ImVec2(0.0, TEXT_BASE_HEIGHT * 12)) then + ImGui_TableSetupColumn(column_names[1], bit32.bor(128 --[[ImGuiTableColumnFlags.NoHide]], 64 --[[ImGuiTableColumnFlags.NoReorder]])) for n = 1, columns_count - 1 do - ImGui.TableSetupColumn(column_names[n + 1], s.column_flags) + ImGui_TableSetupColumn(column_names[n + 1], s.column_flags) end - ImGui.TableSetupScrollFreeze(s.frozen_cols, s.frozen_rows) + ImGui_TableSetupScrollFreeze(s.frozen_cols, s.frozen_rows) - ImGui.TableAngledHeadersRow() -- Draw angled headers for all columns with the ImGuiTableColumnFlags_AngledHeader flag. - ImGui.TableHeadersRow() -- Draw remaining headers and allow access to context-menu and other functions. + ImGui_TableAngledHeadersRow() -- Draw angled headers for all columns with the ImGuiTableColumnFlags_AngledHeader flag. + ImGui_TableHeadersRow() -- Draw remaining headers and allow access to context-menu and other functions. for row = 0, rows_count - 1 do - ImGui.PushID(row) - ImGui.TableNextRow() - ImGui.TableSetColumnIndex(0) - ImGui.AlignTextToFramePadding() - ImGui.Text("Track %d", row) + ImGui_PushID(row) + ImGui_TableNextRow() + ImGui_TableSetColumnIndex(0) + ImGui_AlignTextToFramePadding() + ImGui_Text("Track %d", row) for column = 1, columns_count - 1 do - if ImGui.TableSetColumnIndex(column) then - ImGui.PushID(column) - _, bools[row * columns_count + column + 1] = ImGui.Checkbox("", bools[row * columns_count + column + 1]) - ImGui.PopID() + if ImGui_TableSetColumnIndex(column) then + ImGui_PushID(column) + _, bools[row * columns_count + column + 1] = ImGui_Checkbox("", bools[row * columns_count + column + 1]) + ImGui_PopID() end end - ImGui.PopID() + ImGui_PopID() end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate creating custom context menus inside columns, -- while playing it nice with context menus provided by TableHeadersRow()/TableHeader() if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Context menus") then IMGUI_DEMO_MARKER("Tables/Context menus") @@ -30171,30 +30227,30 @@ function DemoWindowTables() local s = s.ContextMenus PushStyleCompact() - _, s.flags1 = ImGui.CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", s.flags1, 32 --[[ImGuiTableFlags.ContextMenuInBody]]) + _, s.flags1 = ImGui_CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", s.flags1, 32 --[[ImGuiTableFlags.ContextMenuInBody]]) PopStyleCompact() -- Context Menus: first example -- [1.1] Right-click on the TableHeadersRow() line to open the default table context menu. -- [1.2] Right-click in columns also open the default table context menu (if ImGuiTableFlags_ContextMenuInBody is set) local COLUMNS_COUNT = 3 - if ImGui.BeginTable("table_context_menu", COLUMNS_COUNT, s.flags1) then - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") + if ImGui_BeginTable("table_context_menu", COLUMNS_COUNT, s.flags1) then + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") -- [1.1]] Right-click on the TableHeadersRow() line to open the default table context menu. - ImGui.TableHeadersRow() + ImGui_TableHeadersRow() -- Submit dummy contents for row = 0, 4 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, COLUMNS_COUNT - 1 do - ImGui.TableSetColumnIndex(column) - ImGui.Text("Cell %d,%d", column, row) + ImGui_TableSetColumnIndex(column) + ImGui_Text("Cell %d,%d", column, row) end end - ImGui.EndTable() + ImGui_EndTable() end -- Context Menus: second example @@ -30205,32 +30261,32 @@ function DemoWindowTables() "Demonstrate mixing table context menu (over header), item context button (over button) " .. "and custom per-column context menu (over column body).") local flags2 = bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 8192 --[[ImGuiTableFlags.SizingFixedFit]], 2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]], 1920 --[[ImGuiTableFlags.Borders]]) - if ImGui.BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2) then - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") + if ImGui_BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2) then + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") -- [2.1] Right-click on the TableHeadersRow() line to open the default table context menu. - ImGui.TableHeadersRow() + ImGui_TableHeadersRow() for row = 0, 4 - 1 do - ImGui.TableNextRow() + ImGui_TableNextRow() for column = 0, COLUMNS_COUNT - 1 do -- Submit dummy contents - ImGui.TableSetColumnIndex(column) - ImGui.Text("Cell %d,%d", column, row) - ImGui.SameLine() + ImGui_TableSetColumnIndex(column) + ImGui_Text("Cell %d,%d", column, row) + ImGui_SameLine() -- [2.2] Right-click on the ".." to open a custom popup - ImGui.PushID(row * COLUMNS_COUNT + column) - ImGui.SmallButton("..") - if ImGui.BeginPopupContextItem() then - ImGui.Text("This is the popup for Button(\"..\") in Cell %d,%d", column, row) - if ImGui.Button("Close") then - ImGui.CloseCurrentPopup() + ImGui_PushID(row * COLUMNS_COUNT + column) + ImGui_SmallButton("..") + if ImGui_BeginPopupContextItem() then + ImGui_Text("This is the popup for Button(\"..\") in Cell %d,%d", column, row) + if ImGui_Button("Close") then + ImGui_CloseCurrentPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.PopID() + ImGui_PopID() end end @@ -30239,63 +30295,63 @@ function DemoWindowTables() -- to manage popup priority as the popups triggers, here "are we hovering a column" are overlapping) local hovered_column = -1 for column = 0, COLUMNS_COUNT + 1 - 1 do - ImGui.PushID(column) - if bit32.band(ImGui.TableGetColumnFlags(column), 134217728 --[[ImGuiTableColumnFlags.IsHovered]]) ~= 0 then + ImGui_PushID(column) + if bit32.band(ImGui_TableGetColumnFlags(column), 134217728 --[[ImGuiTableColumnFlags.IsHovered]]) ~= 0 then hovered_column = column end - if hovered_column == column and not ImGui.IsAnyItemHovered() and ImGui.IsMouseReleased(1) then - ImGui.OpenPopup("MyPopup") + if hovered_column == column and not ImGui_IsAnyItemHovered() and ImGui_IsMouseReleased(1) then + ImGui_OpenPopup("MyPopup") end - if ImGui.BeginPopup("MyPopup") then + if ImGui_BeginPopup("MyPopup") then if column == COLUMNS_COUNT then - ImGui.Text("This is a custom popup for unused space after the last column.") + ImGui_Text("This is a custom popup for unused space after the last column.") else - ImGui.Text("This is a custom popup for Column %d", column) + ImGui_Text("This is a custom popup for Column %d", column) end - if ImGui.Button("Close") then - ImGui.CloseCurrentPopup() + if ImGui_Button("Close") then + ImGui_CloseCurrentPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.PopID() + ImGui_PopID() end - ImGui.EndTable() - ImGui.Text("Hovered column: %d", hovered_column) + ImGui_EndTable() + ImGui_Text("Hovered column: %d", hovered_column) end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate creating multiple tables with the same ID if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Synced instances") then IMGUI_DEMO_MARKER("Tables/Synced instances") HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc.") local s = s.SyncedInstances - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_SizingFixedFit", s.flags, 8192 --[[ImGuiTableFlags.SizingFixedFit]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", s.flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_SizingFixedFit", s.flags, 8192 --[[ImGuiTableFlags.SizingFixedFit]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", s.flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) for n = 0, 3 - 1 do local buf = string.format("Synced Table %d", n) local open = ImGui.CollapsingHeader(buf, 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) - if open and ImGui.BeginTable("Table", 3, s.flags, ImVec2(0.0, ImGui.GetTextLineHeightWithSpacing() * 5)) then - ImGui.TableSetupColumn("One") - ImGui.TableSetupColumn("Two") - ImGui.TableSetupColumn("Three") - ImGui.TableHeadersRow() + if open and ImGui_BeginTable("Table", 3, s.flags, ImVec2(0.0, ImGui_GetTextLineHeightWithSpacing() * 5)) then + ImGui_TableSetupColumn("One") + ImGui_TableSetupColumn("Two") + ImGui_TableSetupColumn("Three") + ImGui_TableHeadersRow() local cell_count = (n == 1) and 27 or 9 -- Make second table have a scrollbar to verify that additional decoration is not affecting column positions. for cell = 0, cell_count - 1 do - ImGui.TableNextColumn() - ImGui.Text("this cell %d", cell) + ImGui_TableNextColumn() + ImGui_Text("this cell %d", cell) end - ImGui.EndTable() + ImGui_EndTable() end end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate using Sorting facilities @@ -30303,7 +30359,7 @@ function DemoWindowTables() -- Note that the "Advanced" example also showcase manually triggering a sort (e.g. if item quantities have been modified) local template_items_names = s.template_items_names -- 1-based if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Sorting") then IMGUI_DEMO_MARKER("Tables/Sorting") @@ -30323,13 +30379,13 @@ function DemoWindowTables() -- Options PushStyleCompact() - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_SortMulti", s.flags, 67108864 --[[ImGuiTableFlags.SortMulti]]) - ImGui.SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_SortTristate", s.flags, 134217728 --[[ImGuiTableFlags.SortTristate]]) - ImGui.SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_SortMulti", s.flags, 67108864 --[[ImGuiTableFlags.SortMulti]]) + ImGui_SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_SortTristate", s.flags, 134217728 --[[ImGuiTableFlags.SortTristate]]) + ImGui_SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).") PopStyleCompact() - if ImGui.BeginTable("table_sorting", 4, s.flags, ImVec2(0.0, TEXT_BASE_HEIGHT * 15), 0.0) then + if ImGui_BeginTable("table_sorting", 4, s.flags, ImVec2(0.0, TEXT_BASE_HEIGHT * 15), 0.0) then -- Declare columns -- We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. -- This is so our sort function can identify a column given our own identifier. We could also identify them based on their index! @@ -30337,15 +30393,15 @@ function DemoWindowTables() -- - ImGuiTableColumnFlags_DefaultSort -- - ImGuiTableColumnFlags_NoSort / ImGuiTableColumnFlags_NoSortAscending / ImGuiTableColumnFlags_NoSortDescending -- - ImGuiTableColumnFlags_PreferSortAscending / ImGuiTableColumnFlags_PreferSortDescending - ImGui.TableSetupColumn("ID", bit32.bor(4 --[[ImGuiTableColumnFlags.DefaultSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_ID) - ImGui.TableSetupColumn("Name", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 0.0, MyItemColumnID_Name) - ImGui.TableSetupColumn("Action", bit32.bor(512 --[[ImGuiTableColumnFlags.NoSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_Action) - ImGui.TableSetupColumn("Quantity", bit32.bor(32768 --[[ImGuiTableColumnFlags.PreferSortDescending]], 8 --[[ImGuiTableColumnFlags.WidthStretch]]), 0.0, MyItemColumnID_Quantity) - ImGui.TableSetupScrollFreeze(0, 1) -- Make row always visible - ImGui.TableHeadersRow() + ImGui_TableSetupColumn("ID", bit32.bor(4 --[[ImGuiTableColumnFlags.DefaultSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_ID) + ImGui_TableSetupColumn("Name", 16 --[[ImGuiTableColumnFlags.WidthFixed]], 0.0, MyItemColumnID_Name) + ImGui_TableSetupColumn("Action", bit32.bor(512 --[[ImGuiTableColumnFlags.NoSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_Action) + ImGui_TableSetupColumn("Quantity", bit32.bor(32768 --[[ImGuiTableColumnFlags.PreferSortDescending]], 8 --[[ImGuiTableColumnFlags.WidthStretch]]), 0.0, MyItemColumnID_Quantity) + ImGui_TableSetupScrollFreeze(0, 1) -- Make row always visible + ImGui_TableHeadersRow() -- Sort our data if sort specs have been changed! - local sort_specs = ImGui.TableGetSortSpecs() + local sort_specs = ImGui_TableGetSortSpecs() if sort_specs then if sort_specs.SpecsDirty then MyItem_SortWithSortSpecs(sort_specs, items.Data, items.Size) @@ -30360,22 +30416,22 @@ function DemoWindowTables() for row_n = clipper.DisplayStart, clipper.DisplayEnd - 1 do -- Display a data item local item = items.Data[row_n + 1] - ImGui.PushID(item.ID) - ImGui.TableNextRow() - ImGui.TableNextColumn() - ImGui.Text("%04d", item.ID) - ImGui.TableNextColumn() - ImGui.TextUnformatted(item.Name) - ImGui.TableNextColumn() - ImGui.SmallButton("None") - ImGui.TableNextColumn() - ImGui.Text("%d", item.Quantity) - ImGui.PopID() + ImGui_PushID(item.ID) + ImGui_TableNextRow() + ImGui_TableNextColumn() + ImGui_Text("%04d", item.ID) + ImGui_TableNextColumn() + ImGui_TextUnformatted(item.Name) + ImGui_TableNextColumn() + ImGui_SmallButton("None") + ImGui_TableNextColumn() + ImGui_Text("%d", item.Quantity) + ImGui_PopID() end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.TreePop() + ImGui_TreePop() end -- In this example we'll expose most table flags and settings. @@ -30383,7 +30439,7 @@ function DemoWindowTables() -- This section is mostly useful to experiment with combining certain flags or settings with each others. --ImGui.SetNextItemOpen(true, ImGuiCond.Once) -- [DEBUG] if open_action ~= -1 then - ImGui.SetNextItemOpen(open_action ~= 0) + ImGui_SetNextItemOpen(open_action ~= 0) end if ImGui.TreeNode("Advanced") then IMGUI_DEMO_MARKER("Tables/Advanced") @@ -30399,89 +30455,89 @@ function DemoWindowTables() if ImGui.TreeNode("Options") then -- Make the UI compact because there are so many fields PushStyleCompact() - ImGui.PushItemWidth(TEXT_BASE_WIDTH * 28.0) + ImGui_PushItemWidth(TEXT_BASE_WIDTH * 28.0) if ImGui.TreeNodeEx("Features:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Reorderable", s.flags, 2 --[[ImGuiTableFlags.Reorderable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Hideable", s.flags, 4 --[[ImGuiTableFlags.Hideable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_Sortable", s.flags, 8 --[[ImGuiTableFlags.Sortable]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoSavedSettings", s.flags, 16 --[[ImGuiTableFlags.NoSavedSettings]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", s.flags, 32 --[[ImGuiTableFlags.ContextMenuInBody]]) - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Resizable", s.flags, 1 --[[ImGuiTableFlags.Resizable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Reorderable", s.flags, 2 --[[ImGuiTableFlags.Reorderable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Hideable", s.flags, 4 --[[ImGuiTableFlags.Hideable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_Sortable", s.flags, 8 --[[ImGuiTableFlags.Sortable]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoSavedSettings", s.flags, 16 --[[ImGuiTableFlags.NoSavedSettings]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", s.flags, 32 --[[ImGuiTableFlags.ContextMenuInBody]]) + ImGui_TreePop() end if ImGui.TreeNodeEx("Decorations:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_RowBg", s.flags, 64 --[[ImGuiTableFlags.RowBg]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersV", s.flags, 1536 --[[ImGuiTableFlags.BordersV]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags, 1024 --[[ImGuiTableFlags.BordersOuterV]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags, 512 --[[ImGuiTableFlags.BordersInnerV]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersH", s.flags, 384 --[[ImGuiTableFlags.BordersH]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersOuterH", s.flags, 256 --[[ImGuiTableFlags.BordersOuterH]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_BordersInnerH", s.flags, 128 --[[ImGuiTableFlags.BordersInnerH]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoBordersInBody", s.flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]); ImGui.SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers)") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", s.flags, 4096 --[[ImGuiTableFlags.NoBordersInBodyUntilResize]]); ImGui.SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appear in Headers)") - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_RowBg", s.flags, 64 --[[ImGuiTableFlags.RowBg]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersV", s.flags, 1536 --[[ImGuiTableFlags.BordersV]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuterV", s.flags, 1024 --[[ImGuiTableFlags.BordersOuterV]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInnerV", s.flags, 512 --[[ImGuiTableFlags.BordersInnerV]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersH", s.flags, 384 --[[ImGuiTableFlags.BordersH]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersOuterH", s.flags, 256 --[[ImGuiTableFlags.BordersOuterH]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_BordersInnerH", s.flags, 128 --[[ImGuiTableFlags.BordersInnerH]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoBordersInBody", s.flags, 2048 --[[ImGuiTableFlags.NoBordersInBody]]); ImGui_SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers)") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", s.flags, 4096 --[[ImGuiTableFlags.NoBordersInBodyUntilResize]]); ImGui_SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appear in Headers)") + ImGui_TreePop() end if ImGui.TreeNodeEx("Sizing:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then s.flags = EditTableSizingFlags(s.flags) - ImGui.SameLine(); HelpMarker("In the Advanced demo we override the policy of each column so those table-wide settings have less effect that typical.") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) - ImGui.SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoHostExtendY", s.flags, 131072 --[[ImGuiTableFlags.NoHostExtendY]]) - ImGui.SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", s.flags, 262144 --[[ImGuiTableFlags.NoKeepColumnsVisible]]) - ImGui.SameLine(); HelpMarker("Only available if ScrollX is disabled.") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_PreciseWidths", s.flags, 524288 --[[ImGuiTableFlags.PreciseWidths]]) - ImGui.SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoClip", s.flags, 1048576 --[[ImGuiTableFlags.NoClip]]) - ImGui.SameLine(); HelpMarker("Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options.") - ImGui.TreePop() + ImGui_SameLine(); HelpMarker("In the Advanced demo we override the policy of each column so those table-wide settings have less effect that typical.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoHostExtendX", s.flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) + ImGui_SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoHostExtendY", s.flags, 131072 --[[ImGuiTableFlags.NoHostExtendY]]) + ImGui_SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", s.flags, 262144 --[[ImGuiTableFlags.NoKeepColumnsVisible]]) + ImGui_SameLine(); HelpMarker("Only available if ScrollX is disabled.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_PreciseWidths", s.flags, 524288 --[[ImGuiTableFlags.PreciseWidths]]) + ImGui_SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoClip", s.flags, 1048576 --[[ImGuiTableFlags.NoClip]]) + ImGui_SameLine(); HelpMarker("Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options.") + ImGui_TreePop() end if ImGui.TreeNodeEx("Padding:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_PadOuterX", s.flags, 2097152 --[[ImGuiTableFlags.PadOuterX]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoPadOuterX", s.flags, 4194304 --[[ImGuiTableFlags.NoPadOuterX]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_NoPadInnerX", s.flags, 8388608 --[[ImGuiTableFlags.NoPadInnerX]]) - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_PadOuterX", s.flags, 2097152 --[[ImGuiTableFlags.PadOuterX]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoPadOuterX", s.flags, 4194304 --[[ImGuiTableFlags.NoPadOuterX]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_NoPadInnerX", s.flags, 8388608 --[[ImGuiTableFlags.NoPadInnerX]]) + ImGui_TreePop() end if ImGui.TreeNodeEx("Scrolling:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) - ImGui.SameLine() - ImGui.SetNextItemWidth(ImGui.GetFrameHeight()) - s.freeze_cols = ImGui.DragInt("freeze_cols", s.freeze_cols, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) - ImGui.SameLine() - ImGui.SetNextItemWidth(ImGui.GetFrameHeight()) - s.freeze_rows = ImGui.DragInt("freeze_rows", s.freeze_rows, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollX", s.flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) + ImGui_SameLine() + ImGui_SetNextItemWidth(ImGui_GetFrameHeight()) + s.freeze_cols = ImGui_DragInt("freeze_cols", s.freeze_cols, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_ScrollY", s.flags, 33554432 --[[ImGuiTableFlags.ScrollY]]) + ImGui_SameLine() + ImGui_SetNextItemWidth(ImGui_GetFrameHeight()) + s.freeze_rows = ImGui_DragInt("freeze_rows", s.freeze_rows, 0.2, 0, 9, nil, 128 --[[ImGuiSliderFlags.NoInput]]) + ImGui_TreePop() end if ImGui.TreeNodeEx("Sorting:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_SortMulti", s.flags, 67108864 --[[ImGuiTableFlags.SortMulti]]) - ImGui.SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).") - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_SortTristate", s.flags, 134217728 --[[ImGuiTableFlags.SortTristate]]) - ImGui.SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).") - ImGui.TreePop() + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_SortMulti", s.flags, 67108864 --[[ImGuiTableFlags.SortMulti]]) + ImGui_SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).") + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_SortTristate", s.flags, 134217728 --[[ImGuiTableFlags.SortTristate]]) + ImGui_SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).") + ImGui_TreePop() end if ImGui.TreeNodeEx("Headers:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then - _, s.show_headers = ImGui.Checkbox("show_headers", s.show_headers) - _, s.flags = ImGui.CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", s.flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) - _, s.columns_base_flags = ImGui.CheckboxFlags("ImGuiTableColumnFlags_AngledHeader", s.columns_base_flags, 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) - ImGui.SameLine(); HelpMarker("Enable AngledHeader on all columns. Best enabled on selected narrow columns (see \"Angled headers\" section of the demo).") - ImGui.TreePop() + _, s.show_headers = ImGui_Checkbox("show_headers", s.show_headers) + _, s.flags = ImGui_CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", s.flags, 268435456 --[[ImGuiTableFlags.HighlightHoveredColumn]]) + _, s.columns_base_flags = ImGui_CheckboxFlags("ImGuiTableColumnFlags_AngledHeader", s.columns_base_flags, 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) + ImGui_SameLine(); HelpMarker("Enable AngledHeader on all columns. Best enabled on selected narrow columns (see \"Angled headers\" section of the demo).") + ImGui_TreePop() end if ImGui.TreeNodeEx("Other:", 32 --[[ImGuiTreeNodeFlags.DefaultOpen]]) then - _, s.show_wrapped_text = ImGui.Checkbox("show_wrapped_text", s.show_wrapped_text) + _, s.show_wrapped_text = ImGui_Checkbox("show_wrapped_text", s.show_wrapped_text) - ImGui.DragFloat2("##OuterSize", s.outer_size_value) - ImGui.SameLine(0.0, ImGui.GetStyle().ItemInnerSpacing.x) - _, s.outer_size_enabled = ImGui.Checkbox("outer_size", s.outer_size_enabled) - ImGui.SameLine() + ImGui_DragFloat2("##OuterSize", s.outer_size_value) + ImGui_SameLine(0.0, ImGui_GetStyle().ItemInnerSpacing.x) + _, s.outer_size_enabled = ImGui_Checkbox("outer_size", s.outer_size_enabled) + ImGui_SameLine() HelpMarker("If scrolling is disabled (ScrollX and ScrollY not set):\n" .. "- The table is output directly in the parent window.\n" .. "- OuterSize.x < 0.0f will right-align the table.\n" .. @@ -30490,21 +30546,21 @@ function DemoWindowTables() -- From a user point of view we will tend to use 'inner_width' differently depending on whether our table is embedding scrolling. -- To facilitate toying with this demo we will actually pass 0.0f to the BeginTable() when ScrollX is disabled. - s.inner_width_with_scroll = ImGui.DragFloat("inner_width (when ScrollX active)", s.inner_width_with_scroll, 1.0, 0.0, 3.4028234663853e+38 --[[FLT_MAX]]) + s.inner_width_with_scroll = ImGui_DragFloat("inner_width (when ScrollX active)", s.inner_width_with_scroll, 1.0, 0.0, 3.4028234663853e+38 --[[FLT_MAX]]) - s.row_min_height = ImGui.DragFloat("row_min_height", s.row_min_height, 1.0, 0.0, 3.4028234663853e+38 --[[FLT_MAX]]) - ImGui.SameLine(); HelpMarker("Specify height of the Selectable item.") + s.row_min_height = ImGui_DragFloat("row_min_height", s.row_min_height, 1.0, 0.0, 3.4028234663853e+38 --[[FLT_MAX]]) + ImGui_SameLine(); HelpMarker("Specify height of the Selectable item.") - s.items_count = ImGui.DragInt("items_count", s.items_count, 0.1, 0, 9999) - s.contents_type = ImGui.Combo("items_type (first column)", s.contents_type, contents_type_names, #contents_type_names) + s.items_count = ImGui_DragInt("items_count", s.items_count, 0.1, 0, 9999) + s.contents_type = ImGui_Combo("items_type (first column)", s.contents_type, contents_type_names, #contents_type_names) --filter.Draw("filter") - ImGui.TreePop() + ImGui_TreePop() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() PopStyleCompact() - ImGui.Spacing() - ImGui.TreePop() + ImGui_Spacing() + ImGui_TreePop() end -- Update item list if we changed the number of items @@ -30522,7 +30578,7 @@ function DemoWindowTables() end end - local parent_draw_list = ImGui.GetWindowDrawList() + local parent_draw_list = ImGui_GetWindowDrawList() local parent_draw_list_draw_cmd_count = parent_draw_list.CmdBuffer.Size local table_scroll_cur, table_scroll_max -- For debug display local table_draw_list = nil -- " @@ -30531,20 +30587,20 @@ function DemoWindowTables() local flags = s.flags local columns_base_flags = s.columns_base_flags local inner_width_to_use = (bit32.band(flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) ~= 0) and s.inner_width_with_scroll or 0.0 - if ImGui.BeginTable("table_advanced", 6, flags, s.outer_size_enabled and s.outer_size_value or ImVec2(0, 0), inner_width_to_use) then + if ImGui_BeginTable("table_advanced", 6, flags, s.outer_size_enabled and s.outer_size_value or ImVec2(0, 0), inner_width_to_use) then -- Declare columns -- We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. -- This is so our sort function can identify a column given our own identifier. We could also identify them based on their index! - ImGui.TableSetupColumn("ID", bit32.bor(columns_base_flags, 4 --[[ImGuiTableColumnFlags.DefaultSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]], 128 --[[ImGuiTableColumnFlags.NoHide]]), 0.0, MyItemColumnID_ID) - ImGui.TableSetupColumn("Name", bit32.bor(columns_base_flags, 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_Name) - ImGui.TableSetupColumn("Action", bit32.bor(columns_base_flags, 512 --[[ImGuiTableColumnFlags.NoSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_Action) - ImGui.TableSetupColumn("Quantity", bit32.bor(columns_base_flags, 32768 --[[ImGuiTableColumnFlags.PreferSortDescending]]), 0.0, MyItemColumnID_Quantity) - ImGui.TableSetupColumn("Description", bit32.bor(columns_base_flags, (bit32.band(flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) ~= 0) and 0 or 8 --[[ImGuiTableColumnFlags.WidthStretch]]), 0.0, MyItemColumnID_Description) - ImGui.TableSetupColumn("Hidden", bit32.bor(columns_base_flags, 2 --[[ImGuiTableColumnFlags.DefaultHide]], 512 --[[ImGuiTableColumnFlags.NoSort]])) - ImGui.TableSetupScrollFreeze(s.freeze_cols, s.freeze_rows) + ImGui_TableSetupColumn("ID", bit32.bor(columns_base_flags, 4 --[[ImGuiTableColumnFlags.DefaultSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]], 128 --[[ImGuiTableColumnFlags.NoHide]]), 0.0, MyItemColumnID_ID) + ImGui_TableSetupColumn("Name", bit32.bor(columns_base_flags, 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_Name) + ImGui_TableSetupColumn("Action", bit32.bor(columns_base_flags, 512 --[[ImGuiTableColumnFlags.NoSort]], 16 --[[ImGuiTableColumnFlags.WidthFixed]]), 0.0, MyItemColumnID_Action) + ImGui_TableSetupColumn("Quantity", bit32.bor(columns_base_flags, 32768 --[[ImGuiTableColumnFlags.PreferSortDescending]]), 0.0, MyItemColumnID_Quantity) + ImGui_TableSetupColumn("Description", bit32.bor(columns_base_flags, (bit32.band(flags, 65536 --[[ImGuiTableFlags.NoHostExtendX]]) ~= 0) and 0 or 8 --[[ImGuiTableColumnFlags.WidthStretch]]), 0.0, MyItemColumnID_Description) + ImGui_TableSetupColumn("Hidden", bit32.bor(columns_base_flags, 2 --[[ImGuiTableColumnFlags.DefaultHide]], 512 --[[ImGuiTableColumnFlags.NoSort]])) + ImGui_TableSetupScrollFreeze(s.freeze_cols, s.freeze_rows) -- Sort our data if sort specs have been changed! - local sort_specs = ImGui.TableGetSortSpecs() + local sort_specs = ImGui_TableGetSortSpecs() if sort_specs and sort_specs.SpecsDirty then s.items_need_sort = true end @@ -30556,14 +30612,14 @@ function DemoWindowTables() -- Take note of whether we are currently sorting based on the Quantity field, -- we will use this to trigger sorting when we know the data of this column has been modified. - local sorts_specs_using_quantity = bit32.band(ImGui.TableGetColumnFlags(3), 67108864 --[[ImGuiTableColumnFlags.IsSorted]]) ~= 0 + local sorts_specs_using_quantity = bit32.band(ImGui_TableGetColumnFlags(3), 67108864 --[[ImGuiTableColumnFlags.IsSorted]]) ~= 0 -- Show headers if s.show_headers and bit32.band(columns_base_flags, 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) ~= 0 then - ImGui.TableAngledHeadersRow() + ImGui_TableAngledHeadersRow() end if s.show_headers then - ImGui.TableHeadersRow() + ImGui_TableHeadersRow() end -- Show data @@ -30578,25 +30634,25 @@ function DemoWindowTables() -- continue local item_is_selected = selection:contains(item.ID) - ImGui.PushID(item.ID) - ImGui.TableNextRow(0 --[[ImGuiTableRowFlags.None]], s.row_min_height) + ImGui_PushID(item.ID) + ImGui_TableNextRow(0 --[[ImGuiTableRowFlags.None]], s.row_min_height) -- For the demo purpose we can select among different type of items submitted in the first column - ImGui.TableSetColumnIndex(0) + ImGui_TableSetColumnIndex(0) local label = string.format("%04d", item.ID) local contents_type = s.contents_type if contents_type == CT_Text then - ImGui.TextUnformatted(label) + ImGui_TextUnformatted(label) elseif contents_type == CT_Button then - ImGui.Button(label) + ImGui_Button(label) elseif contents_type == CT_SmallButton then - ImGui.SmallButton(label) + ImGui_SmallButton(label) elseif contents_type == CT_FillButton then - ImGui.Button(label, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) + ImGui_Button(label, ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) elseif contents_type == CT_Selectable or contents_type == CT_SelectableSpanRow then local selectable_flags = (contents_type == CT_SelectableSpanRow) and bit32.bor(2 --[[ImGuiSelectableFlags.SpanAllColumns]], 16 --[[ImGuiSelectableFlags.AllowOverlap]]) or 0 --[[ImGuiSelectableFlags.None]] - if ImGui.Selectable(label, item_is_selected, selectable_flags, ImVec2(0, s.row_min_height)) then - if ImGui.GetIO().KeyCtrl then + if ImGui_Selectable(label, item_is_selected, selectable_flags, ImVec2(0, s.row_min_height)) then + if ImGui_GetIO().KeyCtrl then if item_is_selected then selection:find_erase_unsorted(item.ID) else @@ -30609,68 +30665,68 @@ function DemoWindowTables() end end - if ImGui.TableSetColumnIndex(1) then - ImGui.TextUnformatted(item.Name) + if ImGui_TableSetColumnIndex(1) then + ImGui_TextUnformatted(item.Name) end -- Here we demonstrate marking our data set as needing to be sorted again if we modified a quantity, -- and we are currently sorting on the column showing the Quantity. -- To avoid triggering a sort while holding the button, we only trigger it when the button has been released. -- You will probably need some extra logic if you want to automatically sort when a specific entry changes. - if ImGui.TableSetColumnIndex(2) then - if ImGui.SmallButton("Chop") then item.Quantity = item.Quantity + 1 end - if sorts_specs_using_quantity and ImGui.IsItemDeactivated() then s.items_need_sort = true end - ImGui.SameLine() - if ImGui.SmallButton("Eat") then item.Quantity = item.Quantity - 1 end - if sorts_specs_using_quantity and ImGui.IsItemDeactivated() then s.items_need_sort = true end + if ImGui_TableSetColumnIndex(2) then + if ImGui_SmallButton("Chop") then item.Quantity = item.Quantity + 1 end + if sorts_specs_using_quantity and ImGui_IsItemDeactivated() then s.items_need_sort = true end + ImGui_SameLine() + if ImGui_SmallButton("Eat") then item.Quantity = item.Quantity - 1 end + if sorts_specs_using_quantity and ImGui_IsItemDeactivated() then s.items_need_sort = true end end - if ImGui.TableSetColumnIndex(3) then - ImGui.Text("%d", item.Quantity) + if ImGui_TableSetColumnIndex(3) then + ImGui_Text("%d", item.Quantity) end - ImGui.TableSetColumnIndex(4) + ImGui_TableSetColumnIndex(4) if s.show_wrapped_text then - ImGui.TextWrapped("Lorem ipsum dolor sit amet") + ImGui_TextWrapped("Lorem ipsum dolor sit amet") else - ImGui.Text("Lorem ipsum dolor sit amet") + ImGui_Text("Lorem ipsum dolor sit amet") end - if ImGui.TableSetColumnIndex(5) then - ImGui.Text("1234") + if ImGui_TableSetColumnIndex(5) then + ImGui_Text("1234") end - ImGui.PopID() + ImGui_PopID() end end -- Store some info to display debug details below - table_scroll_cur = ImVec2(ImGui.GetScrollX(), ImGui.GetScrollY()) - table_scroll_max = ImVec2(ImGui.GetScrollMaxX(), ImGui.GetScrollMaxY()) - table_draw_list = ImGui.GetWindowDrawList() - ImGui.EndTable() + table_scroll_cur = ImVec2(ImGui_GetScrollX(), ImGui_GetScrollY()) + table_scroll_max = ImVec2(ImGui_GetScrollMaxX(), ImGui_GetScrollMaxY()) + table_draw_list = ImGui_GetWindowDrawList() + ImGui_EndTable() end - _, s.show_debug_details = ImGui.Checkbox("Debug details", s.show_debug_details) + _, s.show_debug_details = ImGui_Checkbox("Debug details", s.show_debug_details) if s.show_debug_details and table_draw_list then - ImGui.SameLine(0.0, 0.0) + ImGui_SameLine(0.0, 0.0) local table_draw_list_draw_cmd_count = table_draw_list.CmdBuffer.Size if table_draw_list == parent_draw_list then - ImGui.Text(": DrawCmd: +%d (in same window)", + ImGui_Text(": DrawCmd: +%d (in same window)", table_draw_list_draw_cmd_count - parent_draw_list_draw_cmd_count) else - ImGui.Text(": DrawCmd: +%d (in child window), Scroll: (%.f/%.f) (%.f/%.f)", + ImGui_Text(": DrawCmd: +%d (in child window), Scroll: (%.f/%.f) (%.f/%.f)", table_draw_list_draw_cmd_count - 1, table_scroll_cur.x, table_scroll_max.x, table_scroll_cur.y, table_scroll_max.y) end end - ImGui.TreePop() + ImGui_TreePop() end - ImGui.PopID() + ImGui_PopID() DemoWindowColumns() if s.disable_indent then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end end @@ -30685,7 +30741,7 @@ S.DemoWindowColumns = { function DemoWindowColumns() local s = S.DemoWindowColumns local open = ImGui.TreeNode("Legacy Columns API") - ImGui.SameLine() + ImGui_SameLine() HelpMarker("Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!") if not open then return @@ -30694,130 +30750,130 @@ function DemoWindowColumns() -- Basic columns if ImGui.TreeNode("Basic") then IMGUI_DEMO_MARKER("Columns (legacy API)/Basic") - ImGui.Text("Without border:") - ImGui.Columns(3, "mycolumns3", false) -- 3-ways, no border - ImGui.Separator() + ImGui_Text("Without border:") + ImGui_Columns(3, "mycolumns3", false) -- 3-ways, no border + ImGui_Separator() for n = 0, 13 do local label = string.format("Item %d", n) - if ImGui.Selectable(label) then end + if ImGui_Selectable(label) then end --if (ImGui.Button(label, ImVec2(-FLT_MIN,0.0))) {} - ImGui.NextColumn() + ImGui_NextColumn() end - ImGui.Columns(1) - ImGui.Separator() + ImGui_Columns(1) + ImGui_Separator() - ImGui.Text("With border:") - ImGui.Columns(4, "mycolumns") -- 4-ways, with border - ImGui.Separator() - ImGui.Text("ID"); ImGui.NextColumn() - ImGui.Text("Name"); ImGui.NextColumn() - ImGui.Text("Path"); ImGui.NextColumn() - ImGui.Text("Hovered"); ImGui.NextColumn() - ImGui.Separator() + ImGui_Text("With border:") + ImGui_Columns(4, "mycolumns") -- 4-ways, with border + ImGui_Separator() + ImGui_Text("ID"); ImGui_NextColumn() + ImGui_Text("Name"); ImGui_NextColumn() + ImGui_Text("Path"); ImGui_NextColumn() + ImGui_Text("Hovered"); ImGui_NextColumn() + ImGui_Separator() local names = { "One", "Two", "Three" } local paths = { "/path/one", "/path/two", "/path/three" } for i = 0, 2 do local label = string.format("%04d", i) - if ImGui.Selectable(label, s.selected == i, 2 --[[ImGuiSelectableFlags.SpanAllColumns]]) then + if ImGui_Selectable(label, s.selected == i, 2 --[[ImGuiSelectableFlags.SpanAllColumns]]) then s.selected = i end - local hovered = ImGui.IsItemHovered() - ImGui.NextColumn() - ImGui.Text(names[i + 1]); ImGui.NextColumn() - ImGui.Text(paths[i + 1]); ImGui.NextColumn() - ImGui.Text("%d", hovered and 1 or 0); ImGui.NextColumn() + local hovered = ImGui_IsItemHovered() + ImGui_NextColumn() + ImGui_Text(names[i + 1]); ImGui_NextColumn() + ImGui_Text(paths[i + 1]); ImGui_NextColumn() + ImGui_Text("%d", hovered and 1 or 0); ImGui_NextColumn() end - ImGui.Columns(1) - ImGui.Separator() - ImGui.TreePop() + ImGui_Columns(1) + ImGui_Separator() + ImGui_TreePop() end if ImGui.TreeNode("Borders") then IMGUI_DEMO_MARKER("Columns (legacy API)/Borders") -- NB: Future columns API should allow automatic horizontal borders. local lines_count = 3 - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 8) - s.columns_count = ImGui.DragInt("##columns_count", s.columns_count, 0.1, 2, 10, "%d columns") + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 8) + s.columns_count = ImGui_DragInt("##columns_count", s.columns_count, 0.1, 2, 10, "%d columns") if s.columns_count < 2 then s.columns_count = 2 end - ImGui.SameLine() - _, s.h_borders = ImGui.Checkbox("horizontal", s.h_borders) - ImGui.SameLine() - _, s.v_borders = ImGui.Checkbox("vertical", s.v_borders) - ImGui.Columns(s.columns_count, nil, s.v_borders) + ImGui_SameLine() + _, s.h_borders = ImGui_Checkbox("horizontal", s.h_borders) + ImGui_SameLine() + _, s.v_borders = ImGui_Checkbox("vertical", s.v_borders) + ImGui_Columns(s.columns_count, nil, s.v_borders) for i = 0, s.columns_count * lines_count - 1 do - if s.h_borders and ImGui.GetColumnIndex() == 0 then - ImGui.Separator() + if s.h_borders and ImGui_GetColumnIndex() == 0 then + ImGui_Separator() end - ImGui.PushID(i) + ImGui_PushID(i) local c = string.char(string.byte("a") + i) - ImGui.Text("%s%s%s", c, c, c) - ImGui.Text("Width %.2f", ImGui.GetColumnWidth()) - ImGui.Text("Avail %.2f", ImGui.GetContentRegionAvail().x) - ImGui.Text("Offset %.2f", ImGui.GetColumnOffset()) - ImGui.Text("Long text that is likely to clip") - ImGui.Button("Button", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) - ImGui.PopID() - ImGui.NextColumn() + ImGui_Text("%s%s%s", c, c, c) + ImGui_Text("Width %.2f", ImGui_GetColumnWidth()) + ImGui_Text("Avail %.2f", ImGui_GetContentRegionAvail().x) + ImGui_Text("Offset %.2f", ImGui_GetColumnOffset()) + ImGui_Text("Long text that is likely to clip") + ImGui_Button("Button", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0.0)) + ImGui_PopID() + ImGui_NextColumn() end - ImGui.Columns(1) + ImGui_Columns(1) if s.h_borders then - ImGui.Separator() + ImGui_Separator() end - ImGui.TreePop() + ImGui_TreePop() end -- Create multiple items in a same cell before switching to next column if ImGui.TreeNode("Mixed items") then IMGUI_DEMO_MARKER("Columns (legacy API)/Mixed items") - ImGui.Columns(3, "mixed") - ImGui.Separator() + ImGui_Columns(3, "mixed") + ImGui_Separator() - ImGui.Text("Hello") - ImGui.Button("Banana") - ImGui.NextColumn() + ImGui_Text("Hello") + ImGui_Button("Banana") + ImGui_NextColumn() - ImGui.Text("ImGui") - ImGui.Button("Apple") - s.foo = ImGui.InputFloat("red", s.foo, 0.05, 0, "%.3f") - ImGui.Text("An extra line here.") - ImGui.NextColumn() + ImGui_Text("ImGui") + ImGui_Button("Apple") + s.foo = ImGui_InputFloat("red", s.foo, 0.05, 0, "%.3f") + ImGui_Text("An extra line here.") + ImGui_NextColumn() - ImGui.Text("Sailor") - ImGui.Button("Corniflower") - s.bar = ImGui.InputFloat("blue", s.bar, 0.05, 0, "%.3f") - ImGui.NextColumn() + ImGui_Text("Sailor") + ImGui_Button("Corniflower") + s.bar = ImGui_InputFloat("blue", s.bar, 0.05, 0, "%.3f") + ImGui_NextColumn() - if ImGui.CollapsingHeader("Category A") then ImGui.Text("Blah blah blah") end ImGui.NextColumn() - if ImGui.CollapsingHeader("Category B") then ImGui.Text("Blah blah blah") end ImGui.NextColumn() - if ImGui.CollapsingHeader("Category C") then ImGui.Text("Blah blah blah") end ImGui.NextColumn() - ImGui.Columns(1) - ImGui.Separator() - ImGui.TreePop() + if ImGui.CollapsingHeader("Category A") then ImGui_Text("Blah blah blah") end ImGui_NextColumn() + if ImGui.CollapsingHeader("Category B") then ImGui_Text("Blah blah blah") end ImGui_NextColumn() + if ImGui.CollapsingHeader("Category C") then ImGui_Text("Blah blah blah") end ImGui_NextColumn() + ImGui_Columns(1) + ImGui_Separator() + ImGui_TreePop() end -- Word wrapping if ImGui.TreeNode("Word-wrapping") then IMGUI_DEMO_MARKER("Columns (legacy API)/Word-wrapping") - ImGui.Columns(2, "word-wrapping") - ImGui.Separator() - ImGui.TextWrapped("The quick brown fox jumps over the lazy dog.") - ImGui.TextWrapped("Hello Left") - ImGui.NextColumn() - ImGui.TextWrapped("The quick brown fox jumps over the lazy dog.") - ImGui.TextWrapped("Hello Right") - ImGui.Columns(1) - ImGui.Separator() - ImGui.TreePop() + ImGui_Columns(2, "word-wrapping") + ImGui_Separator() + ImGui_TextWrapped("The quick brown fox jumps over the lazy dog.") + ImGui_TextWrapped("Hello Left") + ImGui_NextColumn() + ImGui_TextWrapped("The quick brown fox jumps over the lazy dog.") + ImGui_TextWrapped("Hello Right") + ImGui_Columns(1) + ImGui_Separator() + ImGui_TreePop() end if ImGui.TreeNode("Horizontal Scrolling") then IMGUI_DEMO_MARKER("Columns (legacy API)/Horizontal Scrolling") - ImGui.SetNextWindowContentSize(ImVec2(1500.0, 0.0)) - local child_size = ImVec2(0, ImGui.GetFontSize() * 20.0) - ImGui.BeginChild("##ScrollingRegion", child_size, 0 --[[ImGuiChildFlags.None]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) - ImGui.Columns(10) + ImGui_SetNextWindowContentSize(ImVec2(1500.0, 0.0)) + local child_size = ImVec2(0, ImGui_GetFontSize() * 20.0) + ImGui_BeginChild("##ScrollingRegion", child_size, 0 --[[ImGuiChildFlags.None]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) + ImGui_Columns(10) -- Also demonstrate using clipper for large vertical lists local ITEMS_COUNT = 2000 @@ -30826,49 +30882,49 @@ function DemoWindowColumns() while clipper:Step() do for i = clipper.DisplayStart, clipper.DisplayEnd - 1 do for j = 0, 9 do - ImGui.Text("Line %d Column %d...", i, j) - ImGui.NextColumn() + ImGui_Text("Line %d Column %d...", i, j) + ImGui_NextColumn() end end end - ImGui.Columns(1) - ImGui.EndChild() - ImGui.TreePop() + ImGui_Columns(1) + ImGui_EndChild() + ImGui_TreePop() end if ImGui.TreeNode("Tree") then IMGUI_DEMO_MARKER("Columns (legacy API)/Tree") - ImGui.Columns(2, "tree", true) + ImGui_Columns(2, "tree", true) for x = 0, 2 do local open1 = ImGui.TreeNode(x, "Node%d", x) - ImGui.NextColumn() - ImGui.Text("Node contents") - ImGui.NextColumn() + ImGui_NextColumn() + ImGui_Text("Node contents") + ImGui_NextColumn() if open1 then for y = 0, 2 do local open2 = ImGui.TreeNode(y, "Node%d.%d", x, y) - ImGui.NextColumn() - ImGui.Text("Node contents") + ImGui_NextColumn() + ImGui_Text("Node contents") if open2 then - ImGui.Text("Even more contents") + ImGui_Text("Even more contents") if ImGui.TreeNode("Tree in column") then - ImGui.Text("The quick brown fox jumps over the lazy dog") - ImGui.TreePop() + ImGui_Text("The quick brown fox jumps over the lazy dog") + ImGui_TreePop() end end - ImGui.NextColumn() + ImGui_NextColumn() if open2 then - ImGui.TreePop() + ImGui_TreePop() end end - ImGui.TreePop() + ImGui_TreePop() end end - ImGui.Columns(1) - ImGui.TreePop() + ImGui_Columns(1) + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end ------------------------------------------------------------------------------- @@ -30890,29 +30946,29 @@ S.DemoWindowInputs.mouse_cursors_names = { "Arrow", "TextInput", "ResizeAll", "R function DemoWindowInputs() local s = S.DemoWindowInputs if ImGui.CollapsingHeader("Inputs & Focus") then - local io = ImGui.GetIO() + local io = ImGui_GetIO() -- Display inputs submitted to ImGuiIO - ImGui.SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) + ImGui_SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) local inputs_opened = ImGui.TreeNode("Inputs") - ImGui.SameLine() + ImGui_SameLine() HelpMarker( "This is a simplified view. See more detailed input state:\n" .. "- in 'Tools->Metrics/Debugger->Inputs'.\n" .. "- in 'Tools->Debug Log->IO'.") if inputs_opened then IMGUI_DEMO_MARKER("Inputs & Focus/Inputs") - if ImGui.IsMousePosValid() then - ImGui.Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y) + if ImGui_IsMousePosValid() then + ImGui_Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y) else - ImGui.Text("Mouse pos: ") + ImGui_Text("Mouse pos: ") end - ImGui.Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y) - ImGui.Text("Mouse down:") - for i = 0, 5 --[[ImGuiMouseButton.COUNT]] - 1 do if ImGui.IsMouseDown(i) then ImGui.SameLine(); ImGui.Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]) end end -- [Port] IM_COUNTOF(io.MouseDown), 0-based - ImGui.Text("Mouse wheel: %.1f", io.MouseWheel) - ImGui.Text("Mouse clicked count:") - for i = 0, 5 --[[ImGuiMouseButton.COUNT]] - 1 do if io.MouseClickedCount[i] > 0 then ImGui.SameLine(); ImGui.Text("b%d: %d", i, io.MouseClickedCount[i]) end end + ImGui_Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y) + ImGui_Text("Mouse down:") + for i = 0, 5 --[[ImGuiMouseButton.COUNT]] - 1 do if ImGui_IsMouseDown(i) then ImGui_SameLine(); ImGui_Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]) end end -- [Port] IM_COUNTOF(io.MouseDown), 0-based + ImGui_Text("Mouse wheel: %.1f", io.MouseWheel) + ImGui_Text("Mouse clicked count:") + for i = 0, 5 --[[ImGuiMouseButton.COUNT]] - 1 do if io.MouseClickedCount[i] > 0 then ImGui_SameLine(); ImGui_Text("b%d: %d", i, io.MouseClickedCount[i]) end end -- We iterate both legacy native range and named ImGuiKey ranges. This is a little unusual/odd but this allows -- displaying the data for old/new backends. @@ -30920,17 +30976,17 @@ function DemoWindowInputs() -- You can generally iterate between ImGuiKey.NamedKey_BEGIN and ImGuiKey.NamedKey_END. local funcs = s.funcs local start_key = 512 --[[ImGuiKey.NamedKey_BEGIN]] - ImGui.Text("Keys down:") for key = start_key, 667 --[[ImGuiKey.NamedKey_END]] - 1 do repeat if funcs.IsLegacyNativeDupe(key) or not ImGui.IsKeyDown(key) then break end ImGui.SameLine(); if key < 512 --[[ImGuiKey.NamedKey_BEGIN]] then ImGui.Text("\"%s\"", ImGui.GetKeyName(key)) else ImGui.Text("\"%s\" %d", ImGui.GetKeyName(key), key) end until true end - ImGui.Text("Keys mods: %s%s%s%s", io.KeyCtrl and "CTRL " or "", io.KeyShift and "SHIFT " or "", io.KeyAlt and "ALT " or "", io.KeySuper and "SUPER " or "") - ImGui.Text("Chars queue:") for i = 0, io.InputQueueCharacters.Size - 1 do local c = io.InputQueueCharacters.Data[i + 1]; ImGui.SameLine(); ImGui.Text("\'%s\' (0x%04X)", (c > 32 and c <= 255) and string.char(c) or '?', c) end -- FIXME: We should convert 'c' to UTF-8 here but the functions are not public. + ImGui_Text("Keys down:") for key = start_key, 667 --[[ImGuiKey.NamedKey_END]] - 1 do repeat if funcs.IsLegacyNativeDupe(key) or not ImGui_IsKeyDown(key) then break end ImGui_SameLine(); if key < 512 --[[ImGuiKey.NamedKey_BEGIN]] then ImGui_Text("\"%s\"", ImGui_GetKeyName(key)) else ImGui_Text("\"%s\" %d", ImGui_GetKeyName(key), key) end until true end + ImGui_Text("Keys mods: %s%s%s%s", io.KeyCtrl and "CTRL " or "", io.KeyShift and "SHIFT " or "", io.KeyAlt and "ALT " or "", io.KeySuper and "SUPER " or "") + ImGui_Text("Chars queue:") for i = 0, io.InputQueueCharacters.Size - 1 do local c = io.InputQueueCharacters.Data[i + 1]; ImGui_SameLine(); ImGui_Text("\'%s\' (0x%04X)", (c > 32 and c <= 255) and string.char(c) or '?', c) end -- FIXME: We should convert 'c' to UTF-8 here but the functions are not public. - ImGui.TreePop() + ImGui_TreePop() end -- Display ImGuiIO output flags - ImGui.SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) + ImGui_SetNextItemOpen(true, 2 --[[ImGuiCond.Once]]) local outputs_opened = ImGui.TreeNode("Outputs") - ImGui.SameLine() + ImGui_SameLine() HelpMarker( "The value of io.WantCaptureMouse and io.WantCaptureKeyboard are normally set by Dear ImGui " .. "to instruct your application of how to route inputs. Typically, when a value is true, it means " .. @@ -30940,12 +30996,12 @@ function DemoWindowInputs() "rules leading to how those flags are set).") if outputs_opened then IMGUI_DEMO_MARKER("Inputs & Focus/Outputs") - ImGui.Text("io.WantCaptureMouse: %d", io.WantCaptureMouse and 1 or 0) - ImGui.Text("io.WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose and 1 or 0) - ImGui.Text("io.WantCaptureKeyboard: %d", io.WantCaptureKeyboard and 1 or 0) - ImGui.Text("io.WantTextInput: %d", io.WantTextInput and 1 or 0) - ImGui.Text("io.WantSetMousePos: %d", io.WantSetMousePos and 1 or 0) - ImGui.Text("io.NavActive: %d, io.NavVisible: %d", io.NavActive and 1 or 0, io.NavVisible and 1 or 0) + ImGui_Text("io.WantCaptureMouse: %d", io.WantCaptureMouse and 1 or 0) + ImGui_Text("io.WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose and 1 or 0) + ImGui_Text("io.WantCaptureKeyboard: %d", io.WantCaptureKeyboard and 1 or 0) + ImGui_Text("io.WantTextInput: %d", io.WantTextInput and 1 or 0) + ImGui_Text("io.WantSetMousePos: %d", io.WantSetMousePos and 1 or 0) + ImGui_Text("io.NavActive: %d, io.NavVisible: %d", io.NavActive and 1 or 0, io.NavVisible and 1 or 0) IMGUI_DEMO_MARKER("Inputs & Focus/Outputs/WantCapture override") if ImGui.TreeNode("WantCapture override") then @@ -30954,22 +31010,22 @@ function DemoWindowInputs() "Notice how normally (when set to none), the value of io.WantCaptureKeyboard would be false when hovering " .. "and true when clicking.") local capture_override_desc = { "None", "Set to false", "Set to true" } - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 15) - s.capture_override_mouse = ImGui.SliderInt("SetNextFrameWantCaptureMouse() on hover", s.capture_override_mouse, -1, 1, capture_override_desc[s.capture_override_mouse + 2], 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 15) - s.capture_override_keyboard = ImGui.SliderInt("SetNextFrameWantCaptureKeyboard() on hover", s.capture_override_keyboard, -1, 1, capture_override_desc[s.capture_override_keyboard + 2], 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 15) + s.capture_override_mouse = ImGui_SliderInt("SetNextFrameWantCaptureMouse() on hover", s.capture_override_mouse, -1, 1, capture_override_desc[s.capture_override_mouse + 2], 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 15) + s.capture_override_keyboard = ImGui_SliderInt("SetNextFrameWantCaptureKeyboard() on hover", s.capture_override_keyboard, -1, 1, capture_override_desc[s.capture_override_keyboard + 2], 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) - ImGui.ColorButton("##panel", ImVec4(0.7, 0.1, 0.7, 1.0), bit32.bor(64 --[[ImGuiColorEditFlags.NoTooltip]], 512 --[[ImGuiColorEditFlags.NoDragDrop]]), ImVec2(128.0, 96.0)) -- Dummy item - if ImGui.IsItemHovered() and s.capture_override_mouse ~= -1 then - ImGui.SetNextFrameWantCaptureMouse(s.capture_override_mouse == 1) + ImGui_ColorButton("##panel", ImVec4(0.7, 0.1, 0.7, 1.0), bit32.bor(64 --[[ImGuiColorEditFlags.NoTooltip]], 512 --[[ImGuiColorEditFlags.NoDragDrop]]), ImVec2(128.0, 96.0)) -- Dummy item + if ImGui_IsItemHovered() and s.capture_override_mouse ~= -1 then + ImGui_SetNextFrameWantCaptureMouse(s.capture_override_mouse == 1) end - if ImGui.IsItemHovered() and s.capture_override_keyboard ~= -1 then - ImGui.SetNextFrameWantCaptureKeyboard(s.capture_override_keyboard == 1) + if ImGui_IsItemHovered() and s.capture_override_keyboard ~= -1 then + ImGui_SetNextFrameWantCaptureKeyboard(s.capture_override_keyboard == 1) end - ImGui.TreePop() + ImGui_TreePop() end - ImGui.TreePop() + ImGui_TreePop() end -- Demonstrate using Shortcut() and Routing Policies. @@ -30984,52 +31040,52 @@ function DemoWindowInputs() -- - Shortcut(ImGuiMod_Ctrl | ImGuiKey.A); -- Use ImGuiInputFlags.RouteFocused policy. if ImGui.TreeNode("Shortcuts") then IMGUI_DEMO_MARKER("Inputs & Focus/Shortcuts") - _, s.route_options = ImGui.CheckboxFlags("ImGuiInputFlags_Repeat", s.route_options, 1 --[[ImGuiInputFlags.Repeat]]) - _, s.route_type = ImGui.RadioButton("ImGuiInputFlags_RouteActive", s.route_type, 1024 --[[ImGuiInputFlags.RouteActive]]) - _, s.route_type = ImGui.RadioButton("ImGuiInputFlags_RouteFocused (default)", s.route_type, 2048 --[[ImGuiInputFlags.RouteFocused]]) - ImGui.Indent() - ImGui.BeginDisabled(s.route_type ~= 2048 --[[ImGuiInputFlags.RouteFocused]]) - _, s.route_options = ImGui.CheckboxFlags("ImGuiInputFlags_RouteOverActive##0", s.route_options, 32768 --[[ImGuiInputFlags.RouteOverActive]]) - ImGui.EndDisabled() - ImGui.Unindent() - _, s.route_type = ImGui.RadioButton("ImGuiInputFlags_RouteGlobal", s.route_type, 4096 --[[ImGuiInputFlags.RouteGlobal]]) - ImGui.Indent() - ImGui.BeginDisabled(s.route_type ~= 4096 --[[ImGuiInputFlags.RouteGlobal]]) - _, s.route_options = ImGui.CheckboxFlags("ImGuiInputFlags_RouteOverFocused", s.route_options, 16384 --[[ImGuiInputFlags.RouteOverFocused]]) - _, s.route_options = ImGui.CheckboxFlags("ImGuiInputFlags_RouteOverActive", s.route_options, 32768 --[[ImGuiInputFlags.RouteOverActive]]) - _, s.route_options = ImGui.CheckboxFlags("ImGuiInputFlags_RouteUnlessBgFocused", s.route_options, 65536 --[[ImGuiInputFlags.RouteUnlessBgFocused]]) - ImGui.EndDisabled() - ImGui.Unindent() - _, s.route_type = ImGui.RadioButton("ImGuiInputFlags_RouteAlways", s.route_type, 8192 --[[ImGuiInputFlags.RouteAlways]]) + _, s.route_options = ImGui_CheckboxFlags("ImGuiInputFlags_Repeat", s.route_options, 1 --[[ImGuiInputFlags.Repeat]]) + _, s.route_type = ImGui_RadioButton("ImGuiInputFlags_RouteActive", s.route_type, 1024 --[[ImGuiInputFlags.RouteActive]]) + _, s.route_type = ImGui_RadioButton("ImGuiInputFlags_RouteFocused (default)", s.route_type, 2048 --[[ImGuiInputFlags.RouteFocused]]) + ImGui_Indent() + ImGui_BeginDisabled(s.route_type ~= 2048 --[[ImGuiInputFlags.RouteFocused]]) + _, s.route_options = ImGui_CheckboxFlags("ImGuiInputFlags_RouteOverActive##0", s.route_options, 32768 --[[ImGuiInputFlags.RouteOverActive]]) + ImGui_EndDisabled() + ImGui_Unindent() + _, s.route_type = ImGui_RadioButton("ImGuiInputFlags_RouteGlobal", s.route_type, 4096 --[[ImGuiInputFlags.RouteGlobal]]) + ImGui_Indent() + ImGui_BeginDisabled(s.route_type ~= 4096 --[[ImGuiInputFlags.RouteGlobal]]) + _, s.route_options = ImGui_CheckboxFlags("ImGuiInputFlags_RouteOverFocused", s.route_options, 16384 --[[ImGuiInputFlags.RouteOverFocused]]) + _, s.route_options = ImGui_CheckboxFlags("ImGuiInputFlags_RouteOverActive", s.route_options, 32768 --[[ImGuiInputFlags.RouteOverActive]]) + _, s.route_options = ImGui_CheckboxFlags("ImGuiInputFlags_RouteUnlessBgFocused", s.route_options, 65536 --[[ImGuiInputFlags.RouteUnlessBgFocused]]) + ImGui_EndDisabled() + ImGui_Unindent() + _, s.route_type = ImGui_RadioButton("ImGuiInputFlags_RouteAlways", s.route_type, 8192 --[[ImGuiInputFlags.RouteAlways]]) local flags = bit32.bor(s.route_type, s.route_options) -- Merged flags if s.route_type ~= 4096 --[[ImGuiInputFlags.RouteGlobal]] then flags = bit32.band(flags, bit32.bnot(bit32.bor(16384 --[[ImGuiInputFlags.RouteOverFocused]], 32768 --[[ImGuiInputFlags.RouteOverActive]], 65536 --[[ImGuiInputFlags.RouteUnlessBgFocused]]))) end - ImGui.SeparatorText("Using SetNextItemShortcut()") - ImGui.Text("Ctrl+S") - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 564 --[[ImGuiKey.S]]), bit32.bor(flags, 262144 --[[ImGuiInputFlags.Tooltip]])) - ImGui.Button("Save") - ImGui.Text("Alt+F") - ImGui.SetNextItemShortcut(bit32.bor(16384 --[[ImGuiMod_Alt]], 551 --[[ImGuiKey.F]]), bit32.bor(flags, 262144 --[[ImGuiInputFlags.Tooltip]])) - s.f = ImGui.SliderFloat("Factor", s.f, 0.0, 1.0) + ImGui_SeparatorText("Using SetNextItemShortcut()") + ImGui_Text("Ctrl+S") + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 564 --[[ImGuiKey.S]]), bit32.bor(flags, 262144 --[[ImGuiInputFlags.Tooltip]])) + ImGui_Button("Save") + ImGui_Text("Alt+F") + ImGui_SetNextItemShortcut(bit32.bor(16384 --[[ImGuiMod_Alt]], 551 --[[ImGuiKey.F]]), bit32.bor(flags, 262144 --[[ImGuiInputFlags.Tooltip]])) + s.f = ImGui_SliderFloat("Factor", s.f, 0.0, 1.0) - ImGui.SeparatorText("Using Shortcut()") - local line_height = ImGui.GetTextLineHeightWithSpacing() + ImGui_SeparatorText("Using Shortcut()") + local line_height = ImGui_GetTextLineHeightWithSpacing() local key_chord = bit32.bor(4096 --[[ImGuiMod_Ctrl]], 546 --[[ImGuiKey.A]]) - ImGui.Text("Ctrl+A") - ImGui.Text("IsWindowFocused: %d, Shortcut: %s", ImGui.IsWindowFocused() and 1 or 0, ImGui.Shortcut(key_chord, flags) and "PRESSED" or "...") + ImGui_Text("Ctrl+A") + ImGui_Text("IsWindowFocused: %d, Shortcut: %s", ImGui_IsWindowFocused() and 1 or 0, ImGui_Shortcut(key_chord, flags) and "PRESSED" or "...") - ImGui.PushStyleColor(3 --[[ImGuiCol.ChildBg]], ImVec4(1.0, 0.0, 1.0, 0.1)) + ImGui_PushStyleColor(3 --[[ImGuiCol.ChildBg]], ImVec4(1.0, 0.0, 1.0, 0.1)) - ImGui.BeginChild("WindowA", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], line_height * 14), true) - ImGui.Text("Press Ctrl+A and see who receives it!") - ImGui.Separator() + ImGui_BeginChild("WindowA", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], line_height * 14), true) + ImGui_Text("Press Ctrl+A and see who receives it!") + ImGui_Separator() -- 1: Window polling for Ctrl+A - ImGui.Text("(in WindowA)") - ImGui.Text("IsWindowFocused: %d, Shortcut: %s", ImGui.IsWindowFocused() and 1 or 0, ImGui.Shortcut(key_chord, flags) and "PRESSED" or "...") + ImGui_Text("(in WindowA)") + ImGui_Text("IsWindowFocused: %d, Shortcut: %s", ImGui_IsWindowFocused() and 1 or 0, ImGui_Shortcut(key_chord, flags) and "PRESSED" or "...") -- 2: InputText also polling for Ctrl+A: it always uses _RouteFocused internally (gets priority when active) -- (Commented because the owner-aware version of Shortcut() is still in imgui_internal.h) @@ -31041,33 +31097,33 @@ function DemoWindowInputs() --ImGui.Text("IsWindowFocused: %d, Shortcut: %s", ImGui.IsWindowFocused(), ImGui.Shortcut(key_chord, flags, item_id) ? "PRESSED" : "..."); -- 3: Dummy child is not claiming the route: focusing them shouldn't steal route away from WindowA - ImGui.BeginChild("ChildD", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], line_height * 4), true) - ImGui.Text("(in ChildD: not using same Shortcut)") - ImGui.Text("IsWindowFocused: %d", ImGui.IsWindowFocused() and 1 or 0) - ImGui.EndChild() + ImGui_BeginChild("ChildD", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], line_height * 4), true) + ImGui_Text("(in ChildD: not using same Shortcut)") + ImGui_Text("IsWindowFocused: %d", ImGui_IsWindowFocused() and 1 or 0) + ImGui_EndChild() -- 4: Child window polling for Ctrl+A. It is deeper than WindowA and gets priority when focused. - ImGui.BeginChild("ChildE", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], line_height * 4), true) - ImGui.Text("(in ChildE: using same Shortcut)") - ImGui.Text("IsWindowFocused: %d, Shortcut: %s", ImGui.IsWindowFocused() and 1 or 0, ImGui.Shortcut(key_chord, flags) and "PRESSED" or "...") - ImGui.EndChild() + ImGui_BeginChild("ChildE", ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], line_height * 4), true) + ImGui_Text("(in ChildE: using same Shortcut)") + ImGui_Text("IsWindowFocused: %d, Shortcut: %s", ImGui_IsWindowFocused() and 1 or 0, ImGui_Shortcut(key_chord, flags) and "PRESSED" or "...") + ImGui_EndChild() -- 5: In a popup - if ImGui.Button("Open Popup") then - ImGui.OpenPopup("PopupF") + if ImGui_Button("Open Popup") then + ImGui_OpenPopup("PopupF") end - if ImGui.BeginPopup("PopupF") then - ImGui.Text("(in PopupF)") - ImGui.Text("IsWindowFocused: %d, Shortcut: %s", ImGui.IsWindowFocused() and 1 or 0, ImGui.Shortcut(key_chord, flags) and "PRESSED" or "...") + if ImGui_BeginPopup("PopupF") then + ImGui_Text("(in PopupF)") + ImGui_Text("IsWindowFocused: %d, Shortcut: %s", ImGui_IsWindowFocused() and 1 or 0, ImGui_Shortcut(key_chord, flags) and "PRESSED" or "...") -- (Commented because the owner-aware version of Shortcut() is still in imgui_internal.h) --ImGui.InputText("InputTextG", str, IM_COUNTOF(str), ImGuiInputTextFlags.ReadOnly); --ImGui.Text("IsWindowFocused: %d, Shortcut: %s", ImGui.IsWindowFocused(), ImGui.Shortcut(key_chord, flags, ImGui.GetItemID()) ? "PRESSED" : "..."); - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.EndChild() - ImGui.PopStyleColor() + ImGui_EndChild() + ImGui_PopStyleColor() - ImGui.TreePop() + ImGui_TreePop() end -- Display mouse cursors @@ -31076,112 +31132,112 @@ function DemoWindowInputs() local mouse_cursors_names = s.mouse_cursors_names -- 1-based assert(#mouse_cursors_names == 11 --[[ImGuiMouseCursor.COUNT]]) - local current = ImGui.GetMouseCursor() + local current = ImGui_GetMouseCursor() local cursor_name = "N/A" if (current >= 0 --[[ImGuiMouseCursor.Arrow]]) and (current < 11 --[[ImGuiMouseCursor.COUNT]]) then cursor_name = mouse_cursors_names[current + 1] end - ImGui.Text("Current mouse cursor = %d: %s", current, cursor_name) - ImGui.BeginDisabled(true) - _, io.BackendFlags = ImGui.CheckboxFlags("io.BackendFlags: HasMouseCursors", io.BackendFlags, 2 --[[ImGuiBackendFlags.HasMouseCursors]]) - ImGui.EndDisabled() + ImGui_Text("Current mouse cursor = %d: %s", current, cursor_name) + ImGui_BeginDisabled(true) + _, io.BackendFlags = ImGui_CheckboxFlags("io.BackendFlags: HasMouseCursors", io.BackendFlags, 2 --[[ImGuiBackendFlags.HasMouseCursors]]) + ImGui_EndDisabled() - ImGui.Text("Hover to see mouse cursors:") - ImGui.SameLine(); HelpMarker( + ImGui_Text("Hover to see mouse cursors:") + ImGui_SameLine(); HelpMarker( "Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. " .. "If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, " .. "otherwise your backend needs to handle it.") for i = 0, 11 --[[ImGuiMouseCursor.COUNT]] - 1 do local label = string.format("Mouse cursor %d: %s", i, mouse_cursors_names[i + 1]) - ImGui.Bullet(); ImGui.Selectable(label, false) - if ImGui.IsItemHovered() then - ImGui.SetMouseCursor(i) + ImGui_Bullet(); ImGui_Selectable(label, false) + if ImGui_IsItemHovered() then + ImGui_SetMouseCursor(i) end end - ImGui.TreePop() + ImGui_TreePop() end if ImGui.TreeNode("Tabbing") then IMGUI_DEMO_MARKER("Inputs & Focus/Tabbing") - ImGui.Text("Use Tab/Shift+Tab to cycle through keyboard editable fields.") + ImGui_Text("Use Tab/Shift+Tab to cycle through keyboard editable fields.") local buf = s.tabbing_buf - ImGui.InputText("1", buf, 32) - ImGui.InputText("2", buf, 32) - ImGui.InputText("3", buf, 32) - ImGui.PushItemFlag(1 --[[ImGuiItemFlags.NoTabStop]], true) - ImGui.InputText("4 (tab skip)", buf, 32) - ImGui.SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.") - ImGui.PopItemFlag() - ImGui.InputText("5", buf, 32) - ImGui.TreePop() + ImGui_InputText("1", buf, 32) + ImGui_InputText("2", buf, 32) + ImGui_InputText("3", buf, 32) + ImGui_PushItemFlag(1 --[[ImGuiItemFlags.NoTabStop]], true) + ImGui_InputText("4 (tab skip)", buf, 32) + ImGui_SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.") + ImGui_PopItemFlag() + ImGui_InputText("5", buf, 32) + ImGui_TreePop() end if ImGui.TreeNode("Focus from code") then IMGUI_DEMO_MARKER("Inputs & Focus/Focus from code") - local focus_1 = ImGui.Button("Focus on 1"); ImGui.SameLine() - local focus_2 = ImGui.Button("Focus on 2"); ImGui.SameLine() - local focus_3 = ImGui.Button("Focus on 3") + local focus_1 = ImGui_Button("Focus on 1"); ImGui_SameLine() + local focus_2 = ImGui_Button("Focus on 2"); ImGui_SameLine() + local focus_3 = ImGui_Button("Focus on 3") local has_focus = 0 local buf = s.focus_buf - if focus_1 then ImGui.SetKeyboardFocusHere() end - ImGui.InputText("1", buf, 128) - if ImGui.IsItemActive() then has_focus = 1 end + if focus_1 then ImGui_SetKeyboardFocusHere() end + ImGui_InputText("1", buf, 128) + if ImGui_IsItemActive() then has_focus = 1 end - if focus_2 then ImGui.SetKeyboardFocusHere() end - ImGui.InputText("2", buf, 128) - if ImGui.IsItemActive() then has_focus = 2 end + if focus_2 then ImGui_SetKeyboardFocusHere() end + ImGui_InputText("2", buf, 128) + if ImGui_IsItemActive() then has_focus = 2 end - ImGui.PushItemFlag(1 --[[ImGuiItemFlags.NoTabStop]], true) - if focus_3 then ImGui.SetKeyboardFocusHere() end - ImGui.InputText("3 (tab skip)", buf, 128) - if ImGui.IsItemActive() then has_focus = 3 end - ImGui.SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.") - ImGui.PopItemFlag() + ImGui_PushItemFlag(1 --[[ImGuiItemFlags.NoTabStop]], true) + if focus_3 then ImGui_SetKeyboardFocusHere() end + ImGui_InputText("3 (tab skip)", buf, 128) + if ImGui_IsItemActive() then has_focus = 3 end + ImGui_SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.") + ImGui_PopItemFlag() if has_focus ~= 0 then - ImGui.Text("Item with focus: %d", has_focus) + ImGui_Text("Item with focus: %d", has_focus) else - ImGui.Text("Item with focus: ") + ImGui_Text("Item with focus: ") end -- Use >= 0 parameter to SetKeyboardFocusHere() to focus an upcoming item local f3 = s.f3 local focus_ahead = -1 - if ImGui.Button("Focus on X") then focus_ahead = 0 end ImGui.SameLine() - if ImGui.Button("Focus on Y") then focus_ahead = 1 end ImGui.SameLine() - if ImGui.Button("Focus on Z") then focus_ahead = 2 end - if focus_ahead ~= -1 then ImGui.SetKeyboardFocusHere(focus_ahead) end - ImGui.SliderFloat3("Float3", f3, 0.0, 1.0) + if ImGui_Button("Focus on X") then focus_ahead = 0 end ImGui_SameLine() + if ImGui_Button("Focus on Y") then focus_ahead = 1 end ImGui_SameLine() + if ImGui_Button("Focus on Z") then focus_ahead = 2 end + if focus_ahead ~= -1 then ImGui_SetKeyboardFocusHere(focus_ahead) end + ImGui_SliderFloat3("Float3", f3, 0.0, 1.0) - ImGui.TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code.") - ImGui.TreePop() + ImGui_TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code.") + ImGui_TreePop() end if ImGui.TreeNode("Dragging") then IMGUI_DEMO_MARKER("Inputs & Focus/Dragging") - ImGui.TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.") + ImGui_TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.") for button = 0, 2 do - ImGui.Text("IsMouseDragging(%d):", button) - ImGui.Text(" w/ default threshold: %d,", ImGui.IsMouseDragging(button) and 1 or 0) - ImGui.Text(" w/ zero threshold: %d,", ImGui.IsMouseDragging(button, 0.0) and 1 or 0) - ImGui.Text(" w/ large threshold: %d,", ImGui.IsMouseDragging(button, 20.0) and 1 or 0) + ImGui_Text("IsMouseDragging(%d):", button) + ImGui_Text(" w/ default threshold: %d,", ImGui_IsMouseDragging(button) and 1 or 0) + ImGui_Text(" w/ zero threshold: %d,", ImGui_IsMouseDragging(button, 0.0) and 1 or 0) + ImGui_Text(" w/ large threshold: %d,", ImGui_IsMouseDragging(button, 20.0) and 1 or 0) end - ImGui.Button("Drag Me") - if ImGui.IsItemActive() then - ImGui.GetForegroundDrawList():AddLine(io.MouseClickedPos[0], io.MousePos, ImGui.GetColorU32(22 --[[ImGuiCol.Button]]), 4.0) -- Draw a line between the button and the mouse cursor + ImGui_Button("Drag Me") + if ImGui_IsItemActive() then + ImGui_GetForegroundDrawList():AddLine(io.MouseClickedPos[0], io.MousePos, ImGui_GetColorU32(22 --[[ImGuiCol.Button]]), 4.0) -- Draw a line between the button and the mouse cursor end -- Drag operations gets "unlocked" when the mouse has moved past a certain threshold -- (the default threshold is stored in io.MouseDragThreshold). You can request a lower or higher -- threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta(). - local value_raw = ImGui.GetMouseDragDelta(0, 0.0) - local value_with_lock_threshold = ImGui.GetMouseDragDelta(0) + local value_raw = ImGui_GetMouseDragDelta(0, 0.0) + local value_with_lock_threshold = ImGui_GetMouseDragDelta(0) local mouse_delta = io.MouseDelta - ImGui.Text("GetMouseDragDelta(0):") - ImGui.Text(" w/ default threshold: (%.1f, %.1f)", value_with_lock_threshold.x, value_with_lock_threshold.y) - ImGui.Text(" w/ zero threshold: (%.1f, %.1f)", value_raw.x, value_raw.y) - ImGui.Text("io.MouseDelta: (%.1f, %.1f)", mouse_delta.x, mouse_delta.y) - ImGui.TreePop() + ImGui_Text("GetMouseDragDelta(0):") + ImGui_Text(" w/ default threshold: (%.1f, %.1f)", value_with_lock_threshold.x, value_with_lock_threshold.y) + ImGui_Text(" w/ zero threshold: (%.1f, %.1f)", value_raw.x, value_raw.y) + ImGui_Text("io.MouseDelta: (%.1f, %.1f)", mouse_delta.x, mouse_delta.y) + ImGui_TreePop() end end end @@ -31203,46 +31259,46 @@ function ImGui.ShowAboutWindow(p_open) return p_open end IMGUI_DEMO_MARKER("Tools/About Dear ImGui") - ImGui.Text("Dear ImGui %s (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) + ImGui_Text("Dear ImGui %s (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) - ImGui.TextLinkOpenURL("Homepage", "https://github.com/ocornut/imgui") - ImGui.SameLine() - ImGui.TextLinkOpenURL("FAQ", "https://github.com/ocornut/imgui/blob/master/docs/FAQ.md") - ImGui.SameLine() - ImGui.TextLinkOpenURL("Wiki", "https://github.com/ocornut/imgui/wiki") - ImGui.SameLine() - ImGui.TextLinkOpenURL("Extensions", "https://github.com/ocornut/imgui/wiki/Useful-Extensions") - ImGui.SameLine() - ImGui.TextLinkOpenURL("Releases", "https://github.com/ocornut/imgui/releases") - ImGui.SameLine() - ImGui.TextLinkOpenURL("Funding", "https://github.com/ocornut/imgui/wiki/Funding") + ImGui_TextLinkOpenURL("Homepage", "https://github.com/ocornut/imgui") + ImGui_SameLine() + ImGui_TextLinkOpenURL("FAQ", "https://github.com/ocornut/imgui/blob/master/docs/FAQ.md") + ImGui_SameLine() + ImGui_TextLinkOpenURL("Wiki", "https://github.com/ocornut/imgui/wiki") + ImGui_SameLine() + ImGui_TextLinkOpenURL("Extensions", "https://github.com/ocornut/imgui/wiki/Useful-Extensions") + ImGui_SameLine() + ImGui_TextLinkOpenURL("Releases", "https://github.com/ocornut/imgui/releases") + ImGui_SameLine() + ImGui_TextLinkOpenURL("Funding", "https://github.com/ocornut/imgui/wiki/Funding") - ImGui.Separator() - ImGui.Text("(c) 2014-2026 Omar Cornut") - ImGui.Text("Developed by Omar Cornut and all Dear ImGui contributors.") - ImGui.Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.") - ImGui.Text("If your company uses this, please consider funding the project.") + ImGui_Separator() + ImGui_Text("(c) 2014-2026 Omar Cornut") + ImGui_Text("Developed by Omar Cornut and all Dear ImGui contributors.") + ImGui_Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.") + ImGui_Text("If your company uses this, please consider funding the project.") - _, s.show_config_info = ImGui.Checkbox("Config/Build Information", s.show_config_info) + _, s.show_config_info = ImGui_Checkbox("Config/Build Information", s.show_config_info) if s.show_config_info then - local io = ImGui.GetIO() - local style = ImGui.GetStyle() + local io = ImGui_GetIO() + local style = ImGui_GetStyle() - local copy_to_clipboard = ImGui.Button("Copy to clipboard") - local child_size = ImVec2(0, ImGui.GetTextLineHeightWithSpacing() * 18) - ImGui.BeginChild(ImGui.GetID("cfg_infos"), child_size, 128 --[[ImGuiChildFlags.FrameStyle]]) + local copy_to_clipboard = ImGui_Button("Copy to clipboard") + local child_size = ImVec2(0, ImGui_GetTextLineHeightWithSpacing() * 18) + ImGui_BeginChild(ImGui_GetID("cfg_infos"), child_size, 128 --[[ImGuiChildFlags.FrameStyle]]) if copy_to_clipboard then - ImGui.LogToClipboard() - ImGui.LogText("// (Copy from the next line. Keep the ``` markers for formatting.)\n") - ImGui.LogText("```cpp\n") -- Back quotes will make text appears without formatting when pasting on GitHub + ImGui_LogToClipboard() + ImGui_LogText("// (Copy from the next line. Keep the ``` markers for formatting.)\n") + ImGui_LogText("```cpp\n") -- Back quotes will make text appears without formatting when pasting on GitHub end - ImGui.Text("Dear ImGui %s (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) - ImGui.Separator() + ImGui_Text("Dear ImGui %s (%d)", IMGUI_VERSION, 19298 --[[IMGUI_VERSION_NUM]]) + ImGui_Separator() -- [Port] no sizeof()/__cplusplus/compiler/OS #defines in Lua: report the Lua runtime instead - ImGui.Text("runtime: %s", tostring(_VERSION)) - ImGui.Text("define: IMGUI_HAS_VIEWPORT") - ImGui.Text("define: IMGUI_HAS_DOCK") + ImGui_Text("runtime: %s", tostring(_VERSION)) + ImGui_Text("define: IMGUI_HAS_VIEWPORT") + ImGui_Text("define: IMGUI_HAS_DOCK") -- Heuristic to detect no-op IM_ASSERT() macros -- - This is designed so people opening bug reports would convey and notice that they have disabled asserts for Dear ImGui code. @@ -31251,72 +31307,72 @@ function ImGui.ShowAboutWindow(p_open) assert((function() assert_runs_expression = assert_runs_expression + 1; return assert_runs_expression end)()) -- [Port] no ++ in expressions local assert_expand_len = 17 -- [Port] IM_ASSERT is a function, not a macro: nothing to stringify, it cannot be expanded to a no-op local assert_maybe_disabled = (assert_runs_expression == 0 or assert_expand_len <= 16) - ImGui.Text("IM_ASSERT: runs expression: %s. expand size: %s%s", + ImGui_Text("IM_ASSERT: runs expression: %s. expand size: %s%s", (assert_runs_expression ~= 0) and "OK" or "KO", (assert_expand_len > 16) and "OK" or "KO", assert_maybe_disabled and " (MAYBE DISABLED?!)" or "") if assert_maybe_disabled then - ImGui.SameLine() + ImGui_SameLine() HelpMarker("IM_ASSERT() calls assert() by default. Compiling with NDEBUG will usually strip out assert() to nothing, which is NOT recommended because we use asserts to notify of programmer mistakes!") end - ImGui.Separator() - ImGui.Text("io.BackendPlatformName: %s", io.BackendPlatformName or "NULL") - ImGui.Text("io.BackendRendererName: %s", io.BackendRendererName or "NULL") - ImGui.Text("io.ConfigFlags: 0x%08X", io.ConfigFlags) - if bit32.band(io.ConfigFlags, 1 --[[ImGuiConfigFlags.NavEnableKeyboard]]) ~= 0 then ImGui.Text(" NavEnableKeyboard") end - if bit32.band(io.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0 then ImGui.Text(" NavEnableGamepad") end - if bit32.band(io.ConfigFlags, 16 --[[ImGuiConfigFlags.NoMouse]]) ~= 0 then ImGui.Text(" NoMouse") end - if bit32.band(io.ConfigFlags, 32 --[[ImGuiConfigFlags.NoMouseCursorChange]]) ~= 0 then ImGui.Text(" NoMouseCursorChange") end - if bit32.band(io.ConfigFlags, 64 --[[ImGuiConfigFlags.NoKeyboard]]) ~= 0 then ImGui.Text(" NoKeyboard") end - if bit32.band(io.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) ~= 0 then ImGui.Text(" DockingEnable") end - if bit32.band(io.ConfigFlags, 1024 --[[ImGuiConfigFlags.ViewportsEnable]]) ~= 0 then ImGui.Text(" ViewportsEnable") end - if io.MouseDrawCursor then ImGui.Text("io.MouseDrawCursor") end - if io.ConfigDpiScaleFonts then ImGui.Text("io.ConfigDpiScaleFonts") end - if io.ConfigDpiScaleViewports then ImGui.Text("io.ConfigDpiScaleViewports") end - if io.ConfigViewportsNoAutoMerge then ImGui.Text("io.ConfigViewportsNoAutoMerge") end - if io.ConfigViewportsNoTaskBarIcon then ImGui.Text("io.ConfigViewportsNoTaskBarIcon") end - if io.ConfigViewportsNoDecoration then ImGui.Text("io.ConfigViewportsNoDecoration") end - if io.ConfigViewportsNoDefaultParent then ImGui.Text("io.ConfigViewportsNoDefaultParent") end - if io.ConfigDockingNoSplit then ImGui.Text("io.ConfigDockingNoSplit") end - if io.ConfigDockingNoDockingOver then ImGui.Text("io.ConfigDockingNoDockingOver") end - if io.ConfigDockingWithShift then ImGui.Text("io.ConfigDockingWithShift") end - if io.ConfigDockingAlwaysTabBar then ImGui.Text("io.ConfigDockingAlwaysTabBar") end - if io.ConfigDockingTransparentPayload then ImGui.Text("io.ConfigDockingTransparentPayload") end - if io.ConfigMacOSXBehaviors then ImGui.Text("io.ConfigMacOSXBehaviors") end - if io.ConfigNavMoveSetMousePos then ImGui.Text("io.ConfigNavMoveSetMousePos") end - if io.ConfigNavCaptureKeyboard then ImGui.Text("io.ConfigNavCaptureKeyboard") end - if io.ConfigInputTextCursorBlink then ImGui.Text("io.ConfigInputTextCursorBlink") end - if io.ConfigWindowsResizeFromEdges then ImGui.Text("io.ConfigWindowsResizeFromEdges") end - if io.ConfigWindowsMoveFromTitleBarOnly then ImGui.Text("io.ConfigWindowsMoveFromTitleBarOnly") end - if io.ConfigMemoryCompactTimer >= 0.0 then ImGui.Text("io.ConfigMemoryCompactTimer = %.1f", io.ConfigMemoryCompactTimer) end - ImGui.Text("io.BackendFlags: 0x%08X", io.BackendFlags) - if bit32.band(io.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0 then ImGui.Text(" HasGamepad") end - if bit32.band(io.BackendFlags, 2 --[[ImGuiBackendFlags.HasMouseCursors]]) ~= 0 then ImGui.Text(" HasMouseCursors") end - if bit32.band(io.BackendFlags, 4 --[[ImGuiBackendFlags.HasSetMousePos]]) ~= 0 then ImGui.Text(" HasSetMousePos") end - if bit32.band(io.BackendFlags, 2048 --[[ImGuiBackendFlags.PlatformHasViewports]]) ~= 0 then ImGui.Text(" PlatformHasViewports") end - if bit32.band(io.BackendFlags, 4096 --[[ImGuiBackendFlags.HasMouseHoveredViewport]]) ~= 0 then ImGui.Text(" HasMouseHoveredViewport") end - if bit32.band(io.BackendFlags, 8192 --[[ImGuiBackendFlags.HasParentViewport]]) ~= 0 then ImGui.Text(" HasParentViewport") end - if bit32.band(io.BackendFlags, 8 --[[ImGuiBackendFlags.RendererHasVtxOffset]]) ~= 0 then ImGui.Text(" RendererHasVtxOffset") end - if bit32.band(io.BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) ~= 0 then ImGui.Text(" RendererHasTextures") end - if bit32.band(io.BackendFlags, 1024 --[[ImGuiBackendFlags.RendererHasViewports]]) ~= 0 then ImGui.Text(" RendererHasViewports") end - ImGui.Separator() - ImGui.Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts.Fonts.Size, io.Fonts.Flags, io.Fonts.TexData.Width, io.Fonts.TexData.Height) - ImGui.Text("io.Fonts->FontLoaderName: %s", io.Fonts.FontLoaderName or "NULL") - ImGui.Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y) - ImGui.Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y) - ImGui.Separator() - ImGui.Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y) - ImGui.Text("style.WindowBorderSize: %.2f", style.WindowBorderSize) - ImGui.Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y) - ImGui.Text("style.FrameRounding: %.2f", style.FrameRounding) - ImGui.Text("style.FrameBorderSize: %.2f", style.FrameBorderSize) - ImGui.Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y) - ImGui.Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y) + ImGui_Separator() + ImGui_Text("io.BackendPlatformName: %s", io.BackendPlatformName or "NULL") + ImGui_Text("io.BackendRendererName: %s", io.BackendRendererName or "NULL") + ImGui_Text("io.ConfigFlags: 0x%08X", io.ConfigFlags) + if bit32.band(io.ConfigFlags, 1 --[[ImGuiConfigFlags.NavEnableKeyboard]]) ~= 0 then ImGui_Text(" NavEnableKeyboard") end + if bit32.band(io.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0 then ImGui_Text(" NavEnableGamepad") end + if bit32.band(io.ConfigFlags, 16 --[[ImGuiConfigFlags.NoMouse]]) ~= 0 then ImGui_Text(" NoMouse") end + if bit32.band(io.ConfigFlags, 32 --[[ImGuiConfigFlags.NoMouseCursorChange]]) ~= 0 then ImGui_Text(" NoMouseCursorChange") end + if bit32.band(io.ConfigFlags, 64 --[[ImGuiConfigFlags.NoKeyboard]]) ~= 0 then ImGui_Text(" NoKeyboard") end + if bit32.band(io.ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) ~= 0 then ImGui_Text(" DockingEnable") end + if bit32.band(io.ConfigFlags, 1024 --[[ImGuiConfigFlags.ViewportsEnable]]) ~= 0 then ImGui_Text(" ViewportsEnable") end + if io.MouseDrawCursor then ImGui_Text("io.MouseDrawCursor") end + if io.ConfigDpiScaleFonts then ImGui_Text("io.ConfigDpiScaleFonts") end + if io.ConfigDpiScaleViewports then ImGui_Text("io.ConfigDpiScaleViewports") end + if io.ConfigViewportsNoAutoMerge then ImGui_Text("io.ConfigViewportsNoAutoMerge") end + if io.ConfigViewportsNoTaskBarIcon then ImGui_Text("io.ConfigViewportsNoTaskBarIcon") end + if io.ConfigViewportsNoDecoration then ImGui_Text("io.ConfigViewportsNoDecoration") end + if io.ConfigViewportsNoDefaultParent then ImGui_Text("io.ConfigViewportsNoDefaultParent") end + if io.ConfigDockingNoSplit then ImGui_Text("io.ConfigDockingNoSplit") end + if io.ConfigDockingNoDockingOver then ImGui_Text("io.ConfigDockingNoDockingOver") end + if io.ConfigDockingWithShift then ImGui_Text("io.ConfigDockingWithShift") end + if io.ConfigDockingAlwaysTabBar then ImGui_Text("io.ConfigDockingAlwaysTabBar") end + if io.ConfigDockingTransparentPayload then ImGui_Text("io.ConfigDockingTransparentPayload") end + if io.ConfigMacOSXBehaviors then ImGui_Text("io.ConfigMacOSXBehaviors") end + if io.ConfigNavMoveSetMousePos then ImGui_Text("io.ConfigNavMoveSetMousePos") end + if io.ConfigNavCaptureKeyboard then ImGui_Text("io.ConfigNavCaptureKeyboard") end + if io.ConfigInputTextCursorBlink then ImGui_Text("io.ConfigInputTextCursorBlink") end + if io.ConfigWindowsResizeFromEdges then ImGui_Text("io.ConfigWindowsResizeFromEdges") end + if io.ConfigWindowsMoveFromTitleBarOnly then ImGui_Text("io.ConfigWindowsMoveFromTitleBarOnly") end + if io.ConfigMemoryCompactTimer >= 0.0 then ImGui_Text("io.ConfigMemoryCompactTimer = %.1f", io.ConfigMemoryCompactTimer) end + ImGui_Text("io.BackendFlags: 0x%08X", io.BackendFlags) + if bit32.band(io.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0 then ImGui_Text(" HasGamepad") end + if bit32.band(io.BackendFlags, 2 --[[ImGuiBackendFlags.HasMouseCursors]]) ~= 0 then ImGui_Text(" HasMouseCursors") end + if bit32.band(io.BackendFlags, 4 --[[ImGuiBackendFlags.HasSetMousePos]]) ~= 0 then ImGui_Text(" HasSetMousePos") end + if bit32.band(io.BackendFlags, 2048 --[[ImGuiBackendFlags.PlatformHasViewports]]) ~= 0 then ImGui_Text(" PlatformHasViewports") end + if bit32.band(io.BackendFlags, 4096 --[[ImGuiBackendFlags.HasMouseHoveredViewport]]) ~= 0 then ImGui_Text(" HasMouseHoveredViewport") end + if bit32.band(io.BackendFlags, 8192 --[[ImGuiBackendFlags.HasParentViewport]]) ~= 0 then ImGui_Text(" HasParentViewport") end + if bit32.band(io.BackendFlags, 8 --[[ImGuiBackendFlags.RendererHasVtxOffset]]) ~= 0 then ImGui_Text(" RendererHasVtxOffset") end + if bit32.band(io.BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) ~= 0 then ImGui_Text(" RendererHasTextures") end + if bit32.band(io.BackendFlags, 1024 --[[ImGuiBackendFlags.RendererHasViewports]]) ~= 0 then ImGui_Text(" RendererHasViewports") end + ImGui_Separator() + ImGui_Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts.Fonts.Size, io.Fonts.Flags, io.Fonts.TexData.Width, io.Fonts.TexData.Height) + ImGui_Text("io.Fonts->FontLoaderName: %s", io.Fonts.FontLoaderName or "NULL") + ImGui_Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y) + ImGui_Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y) + ImGui_Separator() + ImGui_Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y) + ImGui_Text("style.WindowBorderSize: %.2f", style.WindowBorderSize) + ImGui_Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y) + ImGui_Text("style.FrameRounding: %.2f", style.FrameRounding) + ImGui_Text("style.FrameBorderSize: %.2f", style.FrameBorderSize) + ImGui_Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y) + ImGui_Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y) if copy_to_clipboard then - ImGui.LogText("\n```\n") - ImGui.LogFinish() + ImGui_LogText("\n```\n") + ImGui_LogFinish() end - ImGui.EndChild() + ImGui_EndChild() end ImGui.End() return p_open @@ -31357,20 +31413,20 @@ function ImGui.ShowStyleSelector(label) local s = S.ShowStyleSelector local style_names = { "Dark", "Light", "Classic" } local ret = false - if ImGui.BeginCombo(label, (s.style_idx >= 0 and s.style_idx < #style_names) and style_names[s.style_idx + 1] or "") then + if ImGui_BeginCombo(label, (s.style_idx >= 0 and s.style_idx < #style_names) and style_names[s.style_idx + 1] or "") then for n = 0, #style_names - 1 do - if ImGui.Selectable(style_names[n + 1], s.style_idx == n, 64 --[[ImGuiSelectableFlags.SelectOnNav]]) then + if ImGui_Selectable(style_names[n + 1], s.style_idx == n, 64 --[[ImGuiSelectableFlags.SelectOnNav]]) then s.style_idx = n ret = true - if s.style_idx == 0 then ImGui.StyleColorsDark() - elseif s.style_idx == 1 then ImGui.StyleColorsLight() - elseif s.style_idx == 2 then ImGui.StyleColorsClassic() + if s.style_idx == 0 then ImGui_StyleColorsDark() + elseif s.style_idx == 1 then ImGui_StyleColorsLight() + elseif s.style_idx == 2 then ImGui_StyleColorsClassic() end elseif s.style_idx == n then - ImGui.SetItemDefaultFocus() + ImGui_SetItemDefaultFocus() end end - ImGui.EndCombo() + ImGui_EndCombo() end return ret end @@ -31398,7 +31454,7 @@ function ImGui.ShowStyleEditor(ref) IMGUI_DEMO_MARKER("Tools/Style Editor") -- You can pass in a reference ImGuiStyle structure to compare to, revert to and save to -- (without a reference style pointer, we will use one compared locally as a reference) - local style = ImGui.GetStyle() + local style = ImGui_GetStyle() if s.ref_saved_style == nil then s.ref_saved_style = ImGuiStyle() end -- Default to using internal storage as reference @@ -31415,241 +31471,241 @@ function ImGui.ShowStyleEditor(ref) local default_border_size = math.floor(style._MainScale) local max_border_size = ImMax(default_border_size, 2.0) - ImGui.PushItemWidth(ImGui.GetWindowWidth() * 0.50) + ImGui_PushItemWidth(ImGui_GetWindowWidth() * 0.50) do -- General - ImGui.SeparatorText("General") - if bit32.band(ImGui.GetIO().BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) == 0 then - ImGui.BulletText("Warning: Font scaling will NOT be smooth, because\nImGuiBackendFlags_RendererHasTextures is not set!") - ImGui.BulletText("For instructions, see:") - ImGui.SameLine() - ImGui.TextLinkOpenURL("docs/BACKENDS.md", "https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md") + ImGui_SeparatorText("General") + if bit32.band(ImGui_GetIO().BackendFlags, 16 --[[ImGuiBackendFlags.RendererHasTextures]]) == 0 then + ImGui_BulletText("Warning: Font scaling will NOT be smooth, because\nImGuiBackendFlags_RendererHasTextures is not set!") + ImGui_BulletText("For instructions, see:") + ImGui_SameLine() + ImGui_TextLinkOpenURL("docs/BACKENDS.md", "https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md") end - if ImGui.ShowStyleSelector("Colors##Selector") then + if ImGui_ShowStyleSelector("Colors##Selector") then ImGuiStyle_Copy(s.ref_saved_style, style) end - ImGui.ShowFontSelector("Fonts##Selector") - style.FontSizeBase, changed = ImGui.DragFloat("FontSizeBase", style.FontSizeBase, 0.20, 5.0, 100.0, "%.0f") + ImGui_ShowFontSelector("Fonts##Selector") + style.FontSizeBase, changed = ImGui_DragFloat("FontSizeBase", style.FontSizeBase, 0.20, 5.0, 100.0, "%.0f") if changed then style._NextFrameFontSizeBase = style.FontSizeBase -- FIXME: Temporary hack until we finish remaining work. end - ImGui.SameLine(0.0, 0.0); ImGui.Text(" (out %.2f)", ImGui.GetFontSize()) - style.FontScaleMain = ImGui.DragFloat("FontScaleMain", style.FontScaleMain, 0.02, 0.5, 4.0) - ImGui.BeginDisabled(ImGui.GetIO().ConfigDpiScaleFonts) - style.FontScaleDpi = ImGui.DragFloat("FontScaleDpi", style.FontScaleDpi, 0.02, 0.5, 4.0) - ImGui.SetItemTooltip("When io.ConfigDpiScaleFonts is set, this value is automatically overwritten.") - ImGui.EndDisabled() + ImGui_SameLine(0.0, 0.0); ImGui_Text(" (out %.2f)", ImGui_GetFontSize()) + style.FontScaleMain = ImGui_DragFloat("FontScaleMain", style.FontScaleMain, 0.02, 0.5, 4.0) + ImGui_BeginDisabled(ImGui_GetIO().ConfigDpiScaleFonts) + style.FontScaleDpi = ImGui_DragFloat("FontScaleDpi", style.FontScaleDpi, 0.02, 0.5, 4.0) + ImGui_SetItemTooltip("When io.ConfigDpiScaleFonts is set, this value is automatically overwritten.") + ImGui_EndDisabled() -- Simplified Settings (expose floating-pointer border sizes as boolean representing 0.0f or 1.0f) - style.FrameRounding, changed = ImGui.SliderFloat("FrameRounding", style.FrameRounding, 0.0, 12.0, "%.0f") + style.FrameRounding, changed = ImGui_SliderFloat("FrameRounding", style.FrameRounding, 0.0, 12.0, "%.0f") if changed then style.GrabRounding = style.FrameRounding -- Make GrabRounding always the same value as FrameRounding end - do local pressed, border = ImGui.Checkbox("WindowBorder", style.WindowBorderSize > 0.0); if pressed then if border then style.WindowBorderSize = default_border_size else style.WindowBorderSize = 0.0 end end end - ImGui.SameLine() - do local pressed, border = ImGui.Checkbox("FrameBorder", style.FrameBorderSize > 0.0); if pressed then if border then style.FrameBorderSize = default_border_size else style.FrameBorderSize = 0.0 end end end - ImGui.SameLine() - do local pressed, border = ImGui.Checkbox("PopupBorder", style.PopupBorderSize > 0.0); if pressed then if border then style.PopupBorderSize = default_border_size else style.PopupBorderSize = 0.0 end end end + do local pressed, border = ImGui_Checkbox("WindowBorder", style.WindowBorderSize > 0.0); if pressed then if border then style.WindowBorderSize = default_border_size else style.WindowBorderSize = 0.0 end end end + ImGui_SameLine() + do local pressed, border = ImGui_Checkbox("FrameBorder", style.FrameBorderSize > 0.0); if pressed then if border then style.FrameBorderSize = default_border_size else style.FrameBorderSize = 0.0 end end end + ImGui_SameLine() + do local pressed, border = ImGui_Checkbox("PopupBorder", style.PopupBorderSize > 0.0); if pressed then if border then style.PopupBorderSize = default_border_size else style.PopupBorderSize = 0.0 end end end end -- Save/Revert button - if ImGui.Button("Save Ref") then + if ImGui_Button("Save Ref") then ImGuiStyle_Copy(ref, ImGuiStyle_Copy(s.ref_saved_style, style)) end - ImGui.SameLine() - if ImGui.Button("Revert Ref") then + ImGui_SameLine() + if ImGui_Button("Revert Ref") then ImGuiStyle_Copy(style, ref) end - ImGui.SameLine() + ImGui_SameLine() HelpMarker( "Save/Revert in local non-persistent storage. Default Colors definition are not affected. " .. "Use \"Export\" below to save them somewhere.") - ImGui.SeparatorText("Details") - if ImGui.BeginTabBar("##tabs", 0 --[[ImGuiTabBarFlags.None]]) then + ImGui_SeparatorText("Details") + if ImGui_BeginTabBar("##tabs", 0 --[[ImGuiTabBarFlags.None]]) then if ImGui.BeginTabItem("Sizes") then - ImGui.SeparatorText("Main") - ImGui.SliderFloat2("WindowPadding", style.WindowPadding, 0.0, 20.0, "%.0f") - ImGui.SliderFloat2("FramePadding", style.FramePadding, 0.0, 20.0, "%.0f") - ImGui.SliderFloat2("ItemSpacing", style.ItemSpacing, 0.0, 20.0, "%.0f") - ImGui.SliderFloat2("ItemInnerSpacing", style.ItemInnerSpacing, 0.0, 20.0, "%.0f") - ImGui.SliderFloat2("TouchExtraPadding", style.TouchExtraPadding, 0.0, 10.0, "%.0f") - style.IndentSpacing = ImGui.SliderFloat("IndentSpacing", style.IndentSpacing, 0.0, 30.0, "%.0f") - style.GrabMinSize = ImGui.SliderFloat("GrabMinSize", style.GrabMinSize, 1.0, 20.0, "%.0f") + ImGui_SeparatorText("Main") + ImGui_SliderFloat2("WindowPadding", style.WindowPadding, 0.0, 20.0, "%.0f") + ImGui_SliderFloat2("FramePadding", style.FramePadding, 0.0, 20.0, "%.0f") + ImGui_SliderFloat2("ItemSpacing", style.ItemSpacing, 0.0, 20.0, "%.0f") + ImGui_SliderFloat2("ItemInnerSpacing", style.ItemInnerSpacing, 0.0, 20.0, "%.0f") + ImGui_SliderFloat2("TouchExtraPadding", style.TouchExtraPadding, 0.0, 10.0, "%.0f") + style.IndentSpacing = ImGui_SliderFloat("IndentSpacing", style.IndentSpacing, 0.0, 30.0, "%.0f") + style.GrabMinSize = ImGui_SliderFloat("GrabMinSize", style.GrabMinSize, 1.0, 20.0, "%.0f") - ImGui.SeparatorText("Borders") - style.WindowBorderSize = ImGui.SliderFloat("WindowBorderSize", style.WindowBorderSize, 0.0, max_border_size, "%.0f") - style.ChildBorderSize = ImGui.SliderFloat("ChildBorderSize", style.ChildBorderSize, 0.0, max_border_size, "%.0f") - style.PopupBorderSize = ImGui.SliderFloat("PopupBorderSize", style.PopupBorderSize, 0.0, max_border_size, "%.0f") - style.FrameBorderSize = ImGui.SliderFloat("FrameBorderSize", style.FrameBorderSize, 0.0, max_border_size, "%.0f") + ImGui_SeparatorText("Borders") + style.WindowBorderSize = ImGui_SliderFloat("WindowBorderSize", style.WindowBorderSize, 0.0, max_border_size, "%.0f") + style.ChildBorderSize = ImGui_SliderFloat("ChildBorderSize", style.ChildBorderSize, 0.0, max_border_size, "%.0f") + style.PopupBorderSize = ImGui_SliderFloat("PopupBorderSize", style.PopupBorderSize, 0.0, max_border_size, "%.0f") + style.FrameBorderSize = ImGui_SliderFloat("FrameBorderSize", style.FrameBorderSize, 0.0, max_border_size, "%.0f") - ImGui.SeparatorText("Rounding") - style.WindowRounding = ImGui.SliderFloat("WindowRounding", style.WindowRounding, 0.0, 12.0, "%.0f") - style.ChildRounding = ImGui.SliderFloat("ChildRounding", style.ChildRounding, 0.0, 12.0, "%.0f") - style.FrameRounding = ImGui.SliderFloat("FrameRounding", style.FrameRounding, 0.0, 12.0, "%.0f") - style.PopupRounding = ImGui.SliderFloat("PopupRounding", style.PopupRounding, 0.0, 12.0, "%.0f") - style.GrabRounding = ImGui.SliderFloat("GrabRounding", style.GrabRounding, 0.0, 12.0, "%.0f") - style.MenuItemRounding = ImGui.SliderFloat("MenuItemRounding", style.MenuItemRounding, 0.0, 12.0, "%.0f") + ImGui_SeparatorText("Rounding") + style.WindowRounding = ImGui_SliderFloat("WindowRounding", style.WindowRounding, 0.0, 12.0, "%.0f") + style.ChildRounding = ImGui_SliderFloat("ChildRounding", style.ChildRounding, 0.0, 12.0, "%.0f") + style.FrameRounding = ImGui_SliderFloat("FrameRounding", style.FrameRounding, 0.0, 12.0, "%.0f") + style.PopupRounding = ImGui_SliderFloat("PopupRounding", style.PopupRounding, 0.0, 12.0, "%.0f") + style.GrabRounding = ImGui_SliderFloat("GrabRounding", style.GrabRounding, 0.0, 12.0, "%.0f") + style.MenuItemRounding = ImGui_SliderFloat("MenuItemRounding", style.MenuItemRounding, 0.0, 12.0, "%.0f") -- NB: SelectableRounding is intentionally NOT made visible here. We don't want to encourage people using that. - ImGui.SeparatorText("Scrollbar") - style.ScrollbarSize = ImGui.SliderFloat("ScrollbarSize", style.ScrollbarSize, 1.0, 20.0, "%.0f") - style.ScrollbarRounding = ImGui.SliderFloat("ScrollbarRounding", style.ScrollbarRounding, 0.0, 12.0, "%.0f") - style.ScrollbarPadding = ImGui.SliderFloat("ScrollbarPadding", style.ScrollbarPadding, 0.0, 10.0, "%.0f") + ImGui_SeparatorText("Scrollbar") + style.ScrollbarSize = ImGui_SliderFloat("ScrollbarSize", style.ScrollbarSize, 1.0, 20.0, "%.0f") + style.ScrollbarRounding = ImGui_SliderFloat("ScrollbarRounding", style.ScrollbarRounding, 0.0, 12.0, "%.0f") + style.ScrollbarPadding = ImGui_SliderFloat("ScrollbarPadding", style.ScrollbarPadding, 0.0, 10.0, "%.0f") - ImGui.SeparatorText("Tabs") - style.TabBorderSize = ImGui.SliderFloat("TabBorderSize", style.TabBorderSize, 0.0, max_border_size, "%.0f") - style.TabBarBorderSize = ImGui.SliderFloat("TabBarBorderSize", style.TabBarBorderSize, 0.0, max_border_size, "%.0f") - style.TabBarOverlineSize = ImGui.SliderFloat("TabBarOverlineSize", style.TabBarOverlineSize, 0.0, ImMax(3.0, max_border_size), "%.0f") - ImGui.SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.") - style.TabMinWidthBase = ImGui.DragFloat("TabMinWidthBase", style.TabMinWidthBase, 0.5, 1.0, 500.0, "%.0f") - style.TabMinWidthShrink = ImGui.DragFloat("TabMinWidthShrink", style.TabMinWidthShrink, 0.5, 1.0, 500.0, "%0.f") - style.TabCloseButtonMinWidthSelected = ImGui.DragFloat("TabCloseButtonMinWidthSelected", style.TabCloseButtonMinWidthSelected, 0.5, -1.0, 100.0, (style.TabCloseButtonMinWidthSelected < 0.0) and "%.0f (Always)" or "%.0f") - style.TabCloseButtonMinWidthUnselected = ImGui.DragFloat("TabCloseButtonMinWidthUnselected", style.TabCloseButtonMinWidthUnselected, 0.5, -1.0, 100.0, (style.TabCloseButtonMinWidthUnselected < 0.0) and "%.0f (Always)" or "%.0f") - style.TabRounding = ImGui.SliderFloat("TabRounding", style.TabRounding, 0.0, 12.0, "%.0f") + ImGui_SeparatorText("Tabs") + style.TabBorderSize = ImGui_SliderFloat("TabBorderSize", style.TabBorderSize, 0.0, max_border_size, "%.0f") + style.TabBarBorderSize = ImGui_SliderFloat("TabBarBorderSize", style.TabBarBorderSize, 0.0, max_border_size, "%.0f") + style.TabBarOverlineSize = ImGui_SliderFloat("TabBarOverlineSize", style.TabBarOverlineSize, 0.0, ImMax(3.0, max_border_size), "%.0f") + ImGui_SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.") + style.TabMinWidthBase = ImGui_DragFloat("TabMinWidthBase", style.TabMinWidthBase, 0.5, 1.0, 500.0, "%.0f") + style.TabMinWidthShrink = ImGui_DragFloat("TabMinWidthShrink", style.TabMinWidthShrink, 0.5, 1.0, 500.0, "%0.f") + style.TabCloseButtonMinWidthSelected = ImGui_DragFloat("TabCloseButtonMinWidthSelected", style.TabCloseButtonMinWidthSelected, 0.5, -1.0, 100.0, (style.TabCloseButtonMinWidthSelected < 0.0) and "%.0f (Always)" or "%.0f") + style.TabCloseButtonMinWidthUnselected = ImGui_DragFloat("TabCloseButtonMinWidthUnselected", style.TabCloseButtonMinWidthUnselected, 0.5, -1.0, 100.0, (style.TabCloseButtonMinWidthUnselected < 0.0) and "%.0f (Always)" or "%.0f") + style.TabRounding = ImGui_SliderFloat("TabRounding", style.TabRounding, 0.0, 12.0, "%.0f") - ImGui.SeparatorText("Tables") - ImGui.SliderFloat2("CellPadding", style.CellPadding, 0.0, 20.0, "%.0f") - style.TableAngledHeadersAngle = ImGui.SliderAngle("TableAngledHeadersAngle", style.TableAngledHeadersAngle, -50.0, 50.0) - ImGui.SliderFloat2("TableAngledHeadersTextAlign", style.TableAngledHeadersTextAlign, 0.0, 1.0, "%.2f") + ImGui_SeparatorText("Tables") + ImGui_SliderFloat2("CellPadding", style.CellPadding, 0.0, 20.0, "%.0f") + style.TableAngledHeadersAngle = ImGui_SliderAngle("TableAngledHeadersAngle", style.TableAngledHeadersAngle, -50.0, 50.0) + ImGui_SliderFloat2("TableAngledHeadersTextAlign", style.TableAngledHeadersTextAlign, 0.0, 1.0, "%.2f") - ImGui.SeparatorText("Trees") - local combo_open = ImGui.BeginCombo("TreeLinesFlags", GetTreeLinesFlagsName(style.TreeLinesFlags)) - ImGui.SameLine() + ImGui_SeparatorText("Trees") + local combo_open = ImGui_BeginCombo("TreeLinesFlags", GetTreeLinesFlagsName(style.TreeLinesFlags)) + ImGui_SameLine() HelpMarker("[Experimental] Tree lines may not work in all situations (e.g. using a clipper) and may incurs slight traversal overhead.\n\nImGuiTreeNodeFlags_DrawLinesFull is faster than ImGuiTreeNodeFlags_DrawLinesToNode.") if combo_open then local options = { 262144 --[[ImGuiTreeNodeFlags.DrawLinesNone]], 524288 --[[ImGuiTreeNodeFlags.DrawLinesFull]], 1048576 --[[ImGuiTreeNodeFlags.DrawLinesToNodes]] } for _, option in ipairs(options) do - if ImGui.Selectable(GetTreeLinesFlagsName(option), style.TreeLinesFlags == option) then + if ImGui_Selectable(GetTreeLinesFlagsName(option), style.TreeLinesFlags == option) then style.TreeLinesFlags = option end end - ImGui.EndCombo() + ImGui_EndCombo() end - style.TreeLinesSize = ImGui.SliderFloat("TreeLinesSize", style.TreeLinesSize, 0.0, max_border_size, "%.0f") - style.TreeLinesRounding = ImGui.SliderFloat("TreeLinesRounding", style.TreeLinesRounding, 0.0, 12.0, "%.0f") + style.TreeLinesSize = ImGui_SliderFloat("TreeLinesSize", style.TreeLinesSize, 0.0, max_border_size, "%.0f") + style.TreeLinesRounding = ImGui_SliderFloat("TreeLinesRounding", style.TreeLinesRounding, 0.0, 12.0, "%.0f") - ImGui.SeparatorText("Windows") - ImGui.SliderFloat2("WindowTitleAlign", style.WindowTitleAlign, 0.0, 1.0, "%.2f") - style.WindowBorderHoverPadding = ImGui.SliderFloat("WindowBorderHoverPadding", style.WindowBorderHoverPadding, 1.0, 20.0, "%.0f") + ImGui_SeparatorText("Windows") + ImGui_SliderFloat2("WindowTitleAlign", style.WindowTitleAlign, 0.0, 1.0, "%.2f") + style.WindowBorderHoverPadding = ImGui_SliderFloat("WindowBorderHoverPadding", style.WindowBorderHoverPadding, 1.0, 20.0, "%.0f") local window_menu_button_position = style.WindowMenuButtonPosition + 1 - window_menu_button_position, changed = ImGui.Combo("WindowMenuButtonPosition", window_menu_button_position, "None\0Left\0Right\0") + window_menu_button_position, changed = ImGui_Combo("WindowMenuButtonPosition", window_menu_button_position, "None\0Left\0Right\0") if changed then style.WindowMenuButtonPosition = window_menu_button_position - 1 end - ImGui.SeparatorText("Widgets") - style.ColorMarkerSize = ImGui.SliderFloat("ColorMarkerSize", style.ColorMarkerSize, 0.0, 8.0, "%.0f") - style.ColorButtonPosition = ImGui.Combo("ColorButtonPosition", style.ColorButtonPosition, "Left\0Right\0") - ImGui.SliderFloat2("ButtonTextAlign", style.ButtonTextAlign, 0.0, 1.0, "%.2f") - ImGui.SameLine(); HelpMarker("Alignment applies when a button is larger than its text content.") - ImGui.SliderFloat2("SelectableTextAlign", style.SelectableTextAlign, 0.0, 1.0, "%.2f") - ImGui.SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content.") - style.SeparatorSize = ImGui.SliderFloat("SeparatorSize", style.SeparatorSize, 0.0, 10.0, "%.0f") - style.SeparatorTextBorderSize = ImGui.SliderFloat("SeparatorTextBorderSize", style.SeparatorTextBorderSize, 0.0, 10.0, "%.0f") - ImGui.SliderFloat2("SeparatorTextAlign", style.SeparatorTextAlign, 0.0, 1.0, "%.2f") - ImGui.SliderFloat2("SeparatorTextPadding", style.SeparatorTextPadding, 0.0, 40.0, "%.0f") - style.LogSliderDeadzone = ImGui.SliderFloat("LogSliderDeadzone", style.LogSliderDeadzone, 0.0, 12.0, "%.0f") - style.ImageRounding = ImGui.SliderFloat("ImageRounding", style.ImageRounding, 0.0, 12.0, "%.0f") - style.ImageBorderSize = ImGui.SliderFloat("ImageBorderSize", style.ImageBorderSize, 0.0, max_border_size, "%.0f") + ImGui_SeparatorText("Widgets") + style.ColorMarkerSize = ImGui_SliderFloat("ColorMarkerSize", style.ColorMarkerSize, 0.0, 8.0, "%.0f") + style.ColorButtonPosition = ImGui_Combo("ColorButtonPosition", style.ColorButtonPosition, "Left\0Right\0") + ImGui_SliderFloat2("ButtonTextAlign", style.ButtonTextAlign, 0.0, 1.0, "%.2f") + ImGui_SameLine(); HelpMarker("Alignment applies when a button is larger than its text content.") + ImGui_SliderFloat2("SelectableTextAlign", style.SelectableTextAlign, 0.0, 1.0, "%.2f") + ImGui_SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content.") + style.SeparatorSize = ImGui_SliderFloat("SeparatorSize", style.SeparatorSize, 0.0, 10.0, "%.0f") + style.SeparatorTextBorderSize = ImGui_SliderFloat("SeparatorTextBorderSize", style.SeparatorTextBorderSize, 0.0, 10.0, "%.0f") + ImGui_SliderFloat2("SeparatorTextAlign", style.SeparatorTextAlign, 0.0, 1.0, "%.2f") + ImGui_SliderFloat2("SeparatorTextPadding", style.SeparatorTextPadding, 0.0, 40.0, "%.0f") + style.LogSliderDeadzone = ImGui_SliderFloat("LogSliderDeadzone", style.LogSliderDeadzone, 0.0, 12.0, "%.0f") + style.ImageRounding = ImGui_SliderFloat("ImageRounding", style.ImageRounding, 0.0, 12.0, "%.0f") + style.ImageBorderSize = ImGui_SliderFloat("ImageBorderSize", style.ImageBorderSize, 0.0, max_border_size, "%.0f") - ImGui.SeparatorText("Docking") + ImGui_SeparatorText("Docking") --SetCursorPosX(GetCursorPosX() + CalcItemWidth() - GetFrameHeight()); - _, style.DockingNodeHasCloseButton = ImGui.Checkbox("DockingNodeHasCloseButton", style.DockingNodeHasCloseButton) - style.DockingSeparatorSize = ImGui.SliderFloat("DockingSeparatorSize", style.DockingSeparatorSize, 0.0, 12.0, "%.0f") + _, style.DockingNodeHasCloseButton = ImGui_Checkbox("DockingNodeHasCloseButton", style.DockingNodeHasCloseButton) + style.DockingSeparatorSize = ImGui_SliderFloat("DockingSeparatorSize", style.DockingSeparatorSize, 0.0, 12.0, "%.0f") - ImGui.SeparatorText("Tooltips") + ImGui_SeparatorText("Tooltips") for n = 0, 1 do if ImGui.TreeNodeEx(n == 0 and "HoverFlagsForTooltipMouse" or "HoverFlagsForTooltipNav") then local p = (n == 0) and "HoverFlagsForTooltipMouse" or "HoverFlagsForTooltipNav" -- [Port] pointer -> field name - _, style[p] = ImGui.CheckboxFlags("ImGuiHoveredFlags_DelayNone", style[p], 16384 --[[ImGuiHoveredFlags.DelayNone]]) - _, style[p] = ImGui.CheckboxFlags("ImGuiHoveredFlags_DelayShort", style[p], 32768 --[[ImGuiHoveredFlags.DelayShort]]) - _, style[p] = ImGui.CheckboxFlags("ImGuiHoveredFlags_DelayNormal", style[p], 65536 --[[ImGuiHoveredFlags.DelayNormal]]) - _, style[p] = ImGui.CheckboxFlags("ImGuiHoveredFlags_Stationary", style[p], 8192 --[[ImGuiHoveredFlags.Stationary]]) - _, style[p] = ImGui.CheckboxFlags("ImGuiHoveredFlags_NoSharedDelay", style[p], 131072 --[[ImGuiHoveredFlags.NoSharedDelay]]) - ImGui.TreePop() + _, style[p] = ImGui_CheckboxFlags("ImGuiHoveredFlags_DelayNone", style[p], 16384 --[[ImGuiHoveredFlags.DelayNone]]) + _, style[p] = ImGui_CheckboxFlags("ImGuiHoveredFlags_DelayShort", style[p], 32768 --[[ImGuiHoveredFlags.DelayShort]]) + _, style[p] = ImGui_CheckboxFlags("ImGuiHoveredFlags_DelayNormal", style[p], 65536 --[[ImGuiHoveredFlags.DelayNormal]]) + _, style[p] = ImGui_CheckboxFlags("ImGuiHoveredFlags_Stationary", style[p], 8192 --[[ImGuiHoveredFlags.Stationary]]) + _, style[p] = ImGui_CheckboxFlags("ImGuiHoveredFlags_NoSharedDelay", style[p], 131072 --[[ImGuiHoveredFlags.NoSharedDelay]]) + ImGui_TreePop() end end - ImGui.SeparatorText("Misc") - ImGui.SliderFloat2("DisplayWindowPadding", style.DisplayWindowPadding, 0.0, 30.0, "%.0f"); ImGui.SameLine(); HelpMarker("Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.") - ImGui.SliderFloat2("DisplaySafeAreaPadding", style.DisplaySafeAreaPadding, 0.0, 30.0, "%.0f"); ImGui.SameLine(); HelpMarker("Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).") + ImGui_SeparatorText("Misc") + ImGui_SliderFloat2("DisplayWindowPadding", style.DisplayWindowPadding, 0.0, 30.0, "%.0f"); ImGui_SameLine(); HelpMarker("Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.") + ImGui_SliderFloat2("DisplaySafeAreaPadding", style.DisplaySafeAreaPadding, 0.0, 30.0, "%.0f"); ImGui_SameLine(); HelpMarker("Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).") - ImGui.EndTabItem() + ImGui_EndTabItem() end if ImGui.BeginTabItem("Colors") then - if ImGui.Button("Export") then + if ImGui_Button("Export") then if s.output_dest == 0 then - ImGui.LogToClipboard() + ImGui_LogToClipboard() else - ImGui.LogToTTY() + ImGui_LogToTTY() end - ImGui.LogText("ImVec4* colors = GetStyle().Colors;" .. "\n") -- [Port] IM_NEWLINE == "\n" + ImGui_LogText("ImVec4* colors = GetStyle().Colors;" .. "\n") -- [Port] IM_NEWLINE == "\n" for i = 0, 63 --[[ImGuiCol.COUNT]] - 1 do local col = style.Colors[i] - local name = ImGui.GetStyleColorName(i) + local name = ImGui_GetStyleColorName(i) if not s.output_only_modified or col ~= ref.Colors[i] then -- [Port] memcmp -> ImVec4 __eq - ImGui.LogText("colors[ImGuiCol_%s]%s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" .. "\n", + ImGui_LogText("colors[ImGuiCol_%s]%s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" .. "\n", name, string.rep(" ", 23 - #name), col.x, col.y, col.z, col.w) -- [Port] "%*s" -> string.rep end end - ImGui.LogFinish() + ImGui_LogFinish() end - ImGui.SameLine(); ImGui.SetNextItemWidth(ImGui.GetFontSize() * 10); s.output_dest = ImGui.Combo("##output_type", s.output_dest, "To Clipboard\0To TTY\0") - ImGui.SameLine(); _, s.output_only_modified = ImGui.Checkbox("Only Modified Colors", s.output_only_modified) + ImGui_SameLine(); ImGui_SetNextItemWidth(ImGui_GetFontSize() * 10); s.output_dest = ImGui_Combo("##output_type", s.output_dest, "To Clipboard\0To TTY\0") + ImGui_SameLine(); _, s.output_only_modified = ImGui_Checkbox("Only Modified Colors", s.output_only_modified) -- [Port] RadioButton(label, bool active) overload is RadioButtonEx() in the port - if ImGui.RadioButtonEx("Opaque", s.alpha_flags == 4096 --[[ImGuiColorEditFlags.AlphaOpaque]]) then s.alpha_flags = 4096 --[[ImGuiColorEditFlags.AlphaOpaque]] end ImGui.SameLine() - if ImGui.RadioButtonEx("Alpha", s.alpha_flags == 0 --[[ImGuiColorEditFlags.None]]) then s.alpha_flags = 0 --[[ImGuiColorEditFlags.None]] end ImGui.SameLine() - if ImGui.RadioButtonEx("Both", s.alpha_flags == 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]) then s.alpha_flags = 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]] end ImGui.SameLine() + if ImGui_RadioButtonEx("Opaque", s.alpha_flags == 4096 --[[ImGuiColorEditFlags.AlphaOpaque]]) then s.alpha_flags = 4096 --[[ImGuiColorEditFlags.AlphaOpaque]] end ImGui_SameLine() + if ImGui_RadioButtonEx("Alpha", s.alpha_flags == 0 --[[ImGuiColorEditFlags.None]]) then s.alpha_flags = 0 --[[ImGuiColorEditFlags.None]] end ImGui_SameLine() + if ImGui_RadioButtonEx("Both", s.alpha_flags == 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]) then s.alpha_flags = 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]] end ImGui_SameLine() HelpMarker( "In the color list:\n" .. "Left-click on color square to open color picker,\n" .. "Right-click to open edit options menu.") if s.filter == nil then s.filter = ImGuiTextFilter() end - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) s.filter:DrawWithHint("##FilterColors", "Filter Colors (incl -excl)") - ImGui.SetNextWindowSizeConstraints(ImVec2(0.0, ImGui.GetTextLineHeightWithSpacing() * 10), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]])) - ImGui.BeginChild("##colors", ImVec2(0, 0), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 256 --[[ImGuiChildFlags.NavFlattened]]), bit32.bor(16384 --[[ImGuiWindowFlags.AlwaysVerticalScrollbar]], 32768 --[[ImGuiWindowFlags.AlwaysHorizontalScrollbar]])) - ImGui.PushItemWidth(ImGui.GetFontSize() * -12) + ImGui_SetNextWindowSizeConstraints(ImVec2(0.0, ImGui_GetTextLineHeightWithSpacing() * 10), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]])) + ImGui_BeginChild("##colors", ImVec2(0, 0), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 256 --[[ImGuiChildFlags.NavFlattened]]), bit32.bor(16384 --[[ImGuiWindowFlags.AlwaysVerticalScrollbar]], 32768 --[[ImGuiWindowFlags.AlwaysHorizontalScrollbar]])) + ImGui_PushItemWidth(ImGui_GetFontSize() * -12) for i = 0, 63 --[[ImGuiCol.COUNT]] - 1 do repeat - local name = ImGui.GetStyleColorName(i) + local name = ImGui_GetStyleColorName(i) if not s.filter:PassFilter(name) then break -- continue end - ImGui.PushID(i) - if ImGui.Button("?") then - ImGui.DebugFlashStyleColor(i) + ImGui_PushID(i) + if ImGui_Button("?") then + ImGui_DebugFlashStyleColor(i) end - ImGui.SetItemTooltip("Flash given color to identify places where it is used.") - ImGui.SameLine() - ImGui.ColorEdit4("##color", style.Colors[i], bit32.bor(262144 --[[ImGuiColorEditFlags.AlphaBar]], s.alpha_flags)) + ImGui_SetItemTooltip("Flash given color to identify places where it is used.") + ImGui_SameLine() + ImGui_ColorEdit4("##color", style.Colors[i], bit32.bor(262144 --[[ImGuiColorEditFlags.AlphaBar]], s.alpha_flags)) if style.Colors[i] ~= ref.Colors[i] then -- [Port] memcmp -> ImVec4 __eq -- Tips: in a real user application, you may want to merge and use an icon font into the main font, -- so instead of "Save"/"Revert" you'd use icons! -- Read the FAQ and docs/FONTS.md about using icon fonts. It's really easy and super convenient! - ImGui.SameLine(0.0, style.ItemInnerSpacing.x); if ImGui.Button("Save") then ImVec4_Copy(ref.Colors[i], style.Colors[i]) end - ImGui.SameLine(0.0, style.ItemInnerSpacing.x); if ImGui.Button("Revert") then ImVec4_Copy(style.Colors[i], ref.Colors[i]) end + ImGui_SameLine(0.0, style.ItemInnerSpacing.x); if ImGui_Button("Save") then ImVec4_Copy(ref.Colors[i], style.Colors[i]) end + ImGui_SameLine(0.0, style.ItemInnerSpacing.x); if ImGui_Button("Revert") then ImVec4_Copy(style.Colors[i], ref.Colors[i]) end end - ImGui.SameLine(0.0, style.ItemInnerSpacing.x) - ImGui.TextUnformatted(name) - ImGui.PopID() + ImGui_SameLine(0.0, style.ItemInnerSpacing.x) + ImGui_TextUnformatted(name) + ImGui_PopID() until true end - ImGui.PopItemWidth() - ImGui.EndChild() + ImGui_PopItemWidth() + ImGui_EndChild() - ImGui.EndTabItem() + ImGui_EndTabItem() end if ImGui.BeginTabItem("Fonts") then - local io = ImGui.GetIO() + local io = ImGui_GetIO() local atlas = io.Fonts - ImGui.ShowFontAtlas(atlas) + ImGui_ShowFontAtlas(atlas) -- Post-baking font scaling. Note that this is NOT the nice way of scaling fonts, read below. -- (we enforce hard clamping manually as by default DragFloat/SliderFloat allows Ctrl+Click text to get out of bounds). @@ -31670,61 +31726,61 @@ function ImGui.ShowStyleEditor(ref) PopItemWidth(); ]] - ImGui.EndTabItem() + ImGui_EndTabItem() end if ImGui.BeginTabItem("Rendering") then - _, style.AntiAliasedLines = ImGui.Checkbox("Anti-aliased lines", style.AntiAliasedLines) - ImGui.SameLine() + _, style.AntiAliasedLines = ImGui_Checkbox("Anti-aliased lines", style.AntiAliasedLines) + ImGui_SameLine() HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well.") - ImGui.BeginDisabled(style.AntiAliasedLines == false) - _, style.AntiAliasedLineEnds = ImGui.Checkbox("Anti-aliased line ends", style.AntiAliasedLineEnds) - ImGui.EndDisabled() + ImGui_BeginDisabled(style.AntiAliasedLines == false) + _, style.AntiAliasedLineEnds = ImGui_Checkbox("Anti-aliased line ends", style.AntiAliasedLineEnds) + ImGui_EndDisabled() - ImGui.BeginDisabled() - _, style.AntiAliasedLinesUseTex = ImGui.Checkbox("Anti-aliased lines use texture", style.AntiAliasedLinesUseTex) - ImGui.SameLine() + ImGui_BeginDisabled() + _, style.AntiAliasedLinesUseTex = ImGui_Checkbox("Anti-aliased lines use texture", style.AntiAliasedLinesUseTex) + ImGui_SameLine() HelpMarker("Faster lines using texture data. Require backend to render with bilinear filtering (not point/nearest filtering).") - ImGui.EndDisabled() + ImGui_EndDisabled() - _, style.AntiAliasedFill = ImGui.Checkbox("Anti-aliased fill", style.AntiAliasedFill) - local io = ImGui.GetIO() - _, io.ConfigDebugDrawListDefaultsToStrokeLegacy = ImGui.Checkbox("Debug: DrawList Defaults to _StrokeLegacy", io.ConfigDebugDrawListDefaultsToStrokeLegacy) + _, style.AntiAliasedFill = ImGui_Checkbox("Anti-aliased fill", style.AntiAliasedFill) + local io = ImGui_GetIO() + _, io.ConfigDebugDrawListDefaultsToStrokeLegacy = ImGui_Checkbox("Debug: DrawList Defaults to _StrokeLegacy", io.ConfigDebugDrawListDefaultsToStrokeLegacy) - ImGui.PushItemWidth(ImGui.GetFontSize() * 8) - style.CurveTessellationMaxError = ImGui.DragFloat("Curve Tessellation Max Error", style.CurveTessellationMaxError, 0.02, 0.10, 10.0, "%.2f") + ImGui_PushItemWidth(ImGui_GetFontSize() * 8) + style.CurveTessellationMaxError = ImGui_DragFloat("Curve Tessellation Max Error", style.CurveTessellationMaxError, 0.02, 0.10, 10.0, "%.2f") if style.CurveTessellationMaxError < 0.10 then style.CurveTessellationMaxError = 0.10 end -- When editing the "Circle Segment Max Error" value, draw a preview of its effect on auto-tessellated circles. - style.CircleTessellationMaxError = ImGui.DragFloat("Circle Tessellation Max Error", style.CircleTessellationMaxError, 0.005, 0.10, 5.0, "%.2f", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) - local show_samples = ImGui.IsItemActive() + style.CircleTessellationMaxError = ImGui_DragFloat("Circle Tessellation Max Error", style.CircleTessellationMaxError, 0.005, 0.10, 5.0, "%.2f", 1536 --[[ImGuiSliderFlags.AlwaysClamp]]) + local show_samples = ImGui_IsItemActive() if show_samples then - ImGui.SetNextWindowPos(ImGui.GetCursorScreenPos()) + ImGui_SetNextWindowPos(ImGui_GetCursorScreenPos()) end - if show_samples and ImGui.BeginTooltip() then - ImGui.TextUnformatted("(R = radius, N = approx number of segments)") - ImGui.Spacing() - local draw_list = ImGui.GetWindowDrawList() - local min_widget_width = ImGui.CalcTextSize("R: MMM\nN: MMM").x + if show_samples and ImGui_BeginTooltip() then + ImGui_TextUnformatted("(R = radius, N = approx number of segments)") + ImGui_Spacing() + local draw_list = ImGui_GetWindowDrawList() + local min_widget_width = ImGui_CalcTextSize("R: MMM\nN: MMM").x for n = 0, 7 do local RAD_MIN = 5.0 local RAD_MAX = 70.0 local rad = RAD_MIN + (RAD_MAX - RAD_MIN) * n / (8.0 - 1.0) - ImGui.BeginGroup() + ImGui_BeginGroup() -- N is not always exact here due to how PathArcTo() function work internally - ImGui.Text("R: %.f\nN: %d", rad, draw_list:_CalcCircleAutoSegmentCount(rad)) + ImGui_Text("R: %.f\nN: %d", rad, draw_list:_CalcCircleAutoSegmentCount(rad)) local canvas_width = ImMax(min_widget_width, rad * 2.0) local offset_x = math.floor(canvas_width * 0.5) local offset_y = math.floor(RAD_MAX) - local p1 = ImGui.GetCursorScreenPos() - draw_list:AddCircle(ImVec2(p1.x + offset_x, p1.y + offset_y), rad, ImGui.GetColorU32(0 --[[ImGuiCol.Text]])) - ImGui.Dummy(ImVec2(canvas_width, RAD_MAX * 2)) + local p1 = ImGui_GetCursorScreenPos() + draw_list:AddCircle(ImVec2(p1.x + offset_x, p1.y + offset_y), rad, ImGui_GetColorU32(0 --[[ImGuiCol.Text]])) + ImGui_Dummy(ImVec2(canvas_width, RAD_MAX * 2)) --[[ const ImVec2 p2 = GetCursorScreenPos(); @@ -31732,24 +31788,24 @@ function ImGui.ShowStyleEditor(ref) Dummy(ImVec2(canvas_width, RAD_MAX * 2)); ]] - ImGui.EndGroup() - ImGui.SameLine() + ImGui_EndGroup() + ImGui_SameLine() end - ImGui.EndTooltip() + ImGui_EndTooltip() end - ImGui.SameLine() + ImGui_SameLine() HelpMarker("When drawing circle primitives with \"num_segments == 0\" tessellation will be calculated automatically.") - style.Alpha = ImGui.DragFloat("Global Alpha", style.Alpha, 0.005, 0.20, 1.0, "%.2f") -- Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. - style.DisabledAlpha = ImGui.DragFloat("Disabled Alpha", style.DisabledAlpha, 0.005, 0.0, 1.0, "%.2f"); ImGui.SameLine(); HelpMarker("Additional alpha multiplier for disabled items (multiply over current value of Alpha).") - ImGui.PopItemWidth() + style.Alpha = ImGui_DragFloat("Global Alpha", style.Alpha, 0.005, 0.20, 1.0, "%.2f") -- Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. + style.DisabledAlpha = ImGui_DragFloat("Disabled Alpha", style.DisabledAlpha, 0.005, 0.0, 1.0, "%.2f"); ImGui_SameLine(); HelpMarker("Additional alpha multiplier for disabled items (multiply over current value of Alpha).") + ImGui_PopItemWidth() - ImGui.EndTabItem() + ImGui_EndTabItem() end - ImGui.EndTabBar() + ImGui_EndTabBar() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() end ------------------------------------------------------------------------------- @@ -31758,43 +31814,43 @@ end -- We omit the ImGui:: prefix in this function, as we don't expect user to be copy and pasting this code. function ImGui.ShowUserGuide() - local io = ImGui.GetIO() - ImGui.BulletText("Double-click on title bar to collapse window.") - ImGui.BulletText( + local io = ImGui_GetIO() + ImGui_BulletText("Double-click on title bar to collapse window.") + ImGui_BulletText( "Click and drag on lower corner or border to resize window.\n" .. "(double-click to auto fit window to its contents)") - ImGui.BulletText("Ctrl+Click on a slider or drag box to input value as text.") - ImGui.BulletText("Tab/Shift+Tab to cycle through keyboard editable fields.") - ImGui.BulletText("Ctrl+Tab/Ctrl+Shift+Tab to focus windows.") + ImGui_BulletText("Ctrl+Click on a slider or drag box to input value as text.") + ImGui_BulletText("Tab/Shift+Tab to cycle through keyboard editable fields.") + ImGui_BulletText("Ctrl+Tab/Ctrl+Shift+Tab to focus windows.") if io.FontAllowUserScaling then - ImGui.BulletText("Ctrl+Mouse Wheel to zoom window contents.") + ImGui_BulletText("Ctrl+Mouse Wheel to zoom window contents.") end - ImGui.BulletText("While inputting text:\n") - ImGui.Indent() - ImGui.BulletText("Ctrl+Left/Right to word jump.") - ImGui.BulletText("Ctrl+A or double-click to select all.") - ImGui.BulletText("Ctrl+X/C/V to use clipboard cut/copy/paste.") - ImGui.BulletText("Ctrl+Z to undo, Ctrl+Y/Ctrl+Shift+Z to redo.") - ImGui.BulletText("Escape to revert.") - ImGui.Unindent() - ImGui.BulletText("With Keyboard controls enabled:") - ImGui.Indent() - ImGui.BulletText("Arrow keys or Home/End/PageUp/PageDown to navigate.") - ImGui.BulletText("Space to activate a widget.") - ImGui.BulletText("Return to input text into a widget.") - ImGui.BulletText("Escape to deactivate a widget, close popup,\nexit a child window or the menu layer, clear focus.") - ImGui.BulletText("Alt to jump to the menu layer of a window.") - ImGui.BulletText("Menu or Shift+F10 to open a context menu.") - ImGui.Unindent() - ImGui.BulletText("With Gamepad controls enabled:") - ImGui.Indent() - ImGui.BulletText("D-Pad: Navigate / Tweak / Resize (in Windowing mode).") - ImGui.BulletText("%s Face button: Activate / Open / Toggle. Hold: activate with text input.", io.ConfigNavSwapGamepadButtons and "East" or "South") - ImGui.BulletText("%s Face button: Cancel / Close / Exit.", io.ConfigNavSwapGamepadButtons and "South" or "East") - ImGui.BulletText("West Face button: Toggle Menu. Hold for Windowing mode (Focus/Move/Resize windows).") - ImGui.BulletText("North Face button: Open Context Menu.") - ImGui.BulletText("L1/R1: Tweak Slower/Faster, Focus Previous/Next (in Windowing Mode).") - ImGui.Unindent() + ImGui_BulletText("While inputting text:\n") + ImGui_Indent() + ImGui_BulletText("Ctrl+Left/Right to word jump.") + ImGui_BulletText("Ctrl+A or double-click to select all.") + ImGui_BulletText("Ctrl+X/C/V to use clipboard cut/copy/paste.") + ImGui_BulletText("Ctrl+Z to undo, Ctrl+Y/Ctrl+Shift+Z to redo.") + ImGui_BulletText("Escape to revert.") + ImGui_Unindent() + ImGui_BulletText("With Keyboard controls enabled:") + ImGui_Indent() + ImGui_BulletText("Arrow keys or Home/End/PageUp/PageDown to navigate.") + ImGui_BulletText("Space to activate a widget.") + ImGui_BulletText("Return to input text into a widget.") + ImGui_BulletText("Escape to deactivate a widget, close popup,\nexit a child window or the menu layer, clear focus.") + ImGui_BulletText("Alt to jump to the menu layer of a window.") + ImGui_BulletText("Menu or Shift+F10 to open a context menu.") + ImGui_Unindent() + ImGui_BulletText("With Gamepad controls enabled:") + ImGui_Indent() + ImGui_BulletText("D-Pad: Navigate / Tweak / Resize (in Windowing mode).") + ImGui_BulletText("%s Face button: Activate / Open / Toggle. Hold: activate with text input.", io.ConfigNavSwapGamepadButtons and "East" or "South") + ImGui_BulletText("%s Face button: Cancel / Close / Exit.", io.ConfigNavSwapGamepadButtons and "South" or "East") + ImGui_BulletText("West Face button: Toggle Menu. Hold for Windowing mode (Focus/Move/Resize windows).") + ImGui_BulletText("North Face button: Open Context Menu.") + ImGui_BulletText("L1/R1: Tweak Slower/Faster, Focus Previous/Next (in Windowing Mode).") + ImGui_Unindent() end ------------------------------------------------------------------------------- @@ -31809,23 +31865,23 @@ end -- - BeginMenuBar() = menu-bar inside current window (which needs the ImGuiWindowFlags.MenuBar flag!) -- - BeginMainMenuBar() = helper to create menu-bar-sized window at the top of the main viewport + call BeginMenuBar() into it. function ShowExampleAppMainMenuBar() - if ImGui.BeginMainMenuBar() then - if ImGui.BeginMenu("File") then + if ImGui_BeginMainMenuBar() then + if ImGui_BeginMenu("File") then IMGUI_DEMO_MARKER("Menu/File") ShowExampleMenuFile() - ImGui.EndMenu() + ImGui_EndMenu() end - if ImGui.BeginMenu("Edit") then + if ImGui_BeginMenu("Edit") then IMGUI_DEMO_MARKER("Menu/Edit") - if ImGui.MenuItem("Undo", "Ctrl+Z") then end - if ImGui.MenuItem("Redo", "Ctrl+Y", false, false) then end -- Disabled item - ImGui.Separator() - if ImGui.MenuItem("Cut", "Ctrl+X") then end - if ImGui.MenuItem("Copy", "Ctrl+C") then end - if ImGui.MenuItem("Paste", "Ctrl+V") then end - ImGui.EndMenu() + if ImGui_MenuItem("Undo", "Ctrl+Z") then end + if ImGui_MenuItem("Redo", "Ctrl+Y", false, false) then end -- Disabled item + ImGui_Separator() + if ImGui_MenuItem("Cut", "Ctrl+X") then end + if ImGui_MenuItem("Copy", "Ctrl+C") then end + if ImGui_MenuItem("Paste", "Ctrl+V") then end + ImGui_EndMenu() end - ImGui.EndMainMenuBar() + ImGui_EndMainMenuBar() end end @@ -31840,71 +31896,71 @@ S.ShowExampleMenuFile = { function ShowExampleMenuFile() local s = S.ShowExampleMenuFile IMGUI_DEMO_MARKER("Examples/Menu") - ImGui.MenuItem("(demo menu)", nil, false, false) - if ImGui.MenuItem("New") then end - if ImGui.MenuItem("Open", "Ctrl+O") then end - if ImGui.BeginMenu("Open Recent") then - ImGui.MenuItem("fish_hat.c") - ImGui.MenuItem("fish_hat.inl") - ImGui.MenuItem("fish_hat.h") - if ImGui.BeginMenu("More..") then - ImGui.MenuItem("Hello") - ImGui.MenuItem("Sailor") - if ImGui.BeginMenu("Recurse..") then + ImGui_MenuItem("(demo menu)", nil, false, false) + if ImGui_MenuItem("New") then end + if ImGui_MenuItem("Open", "Ctrl+O") then end + if ImGui_BeginMenu("Open Recent") then + ImGui_MenuItem("fish_hat.c") + ImGui_MenuItem("fish_hat.inl") + ImGui_MenuItem("fish_hat.h") + if ImGui_BeginMenu("More..") then + ImGui_MenuItem("Hello") + ImGui_MenuItem("Sailor") + if ImGui_BeginMenu("Recurse..") then ShowExampleMenuFile() - ImGui.EndMenu() + ImGui_EndMenu() end - ImGui.EndMenu() + ImGui_EndMenu() end - ImGui.EndMenu() + ImGui_EndMenu() end - if ImGui.MenuItem("Save", "Ctrl+S") then end - if ImGui.MenuItem("Save As..") then end + if ImGui_MenuItem("Save", "Ctrl+S") then end + if ImGui_MenuItem("Save As..") then end - ImGui.Separator() - if ImGui.BeginMenu("Options") then + ImGui_Separator() + if ImGui_BeginMenu("Options") then IMGUI_DEMO_MARKER("Examples/Menu/Options") - _, s.enabled = ImGui.MenuItem("Enabled", "", s.enabled) - ImGui.BeginChild("child", ImVec2(0, ImGui.GetTextLineHeightWithSpacing() * 5.0), 1 --[[ImGuiChildFlags.Borders]]) + _, s.enabled = ImGui_MenuItem("Enabled", "", s.enabled) + ImGui_BeginChild("child", ImVec2(0, ImGui_GetTextLineHeightWithSpacing() * 5.0), 1 --[[ImGuiChildFlags.Borders]]) for i = 0, 10 - 1 do - ImGui.Text("Scrolling Text %d", i) + ImGui_Text("Scrolling Text %d", i) end - ImGui.EndChild() - s.f = ImGui.SliderFloat("Value", s.f, 0.0, 1.0) - s.f = ImGui.InputFloat("Input", s.f, 0.1) - s.n = ImGui.Combo("Combo", s.n, "Yes\0No\0Maybe\0\0") - ImGui.EndMenu() + ImGui_EndChild() + s.f = ImGui_SliderFloat("Value", s.f, 0.0, 1.0) + s.f = ImGui_InputFloat("Input", s.f, 0.1) + s.n = ImGui_Combo("Combo", s.n, "Yes\0No\0Maybe\0\0") + ImGui_EndMenu() end - if ImGui.BeginMenu("Colors") then + if ImGui_BeginMenu("Colors") then IMGUI_DEMO_MARKER("Examples/Menu/Colors") - local sz = ImGui.GetTextLineHeight() + local sz = ImGui_GetTextLineHeight() for i = 0, 63 --[[ImGuiCol.COUNT]] - 1 do - local name = ImGui.GetStyleColorName(i) - local p = ImGui.GetCursorScreenPos() - ImGui.GetWindowDrawList():AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui.GetColorU32(i)) - ImGui.Dummy(ImVec2(sz, sz)) - ImGui.SameLine() - ImGui.MenuItem(name) + local name = ImGui_GetStyleColorName(i) + local p = ImGui_GetCursorScreenPos() + ImGui_GetWindowDrawList():AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui_GetColorU32(i)) + ImGui_Dummy(ImVec2(sz, sz)) + ImGui_SameLine() + ImGui_MenuItem(name) end - ImGui.EndMenu() + ImGui_EndMenu() end -- Here we demonstrate appending again to the "Options" menu (which we already created above) -- Of course in this demo it is a little bit silly that this function calls BeginMenu("Options") twice. -- In a real code-base using it would make senses to use this feature from very different code locations. - if ImGui.BeginMenu("Options") then -- <-- Append! + if ImGui_BeginMenu("Options") then -- <-- Append! IMGUI_DEMO_MARKER("Examples/Menu/Append to an existing menu") - _, s.b = ImGui.Checkbox("SomeOption", s.b) - ImGui.EndMenu() + _, s.b = ImGui_Checkbox("SomeOption", s.b) + ImGui_EndMenu() end - if ImGui.BeginMenu("Disabled", false) then -- Disabled + if ImGui_BeginMenu("Disabled", false) then -- Disabled assert(false) end - if ImGui.MenuItem("Checked", nil, true) then end - ImGui.Separator() - if ImGui.MenuItem("Quit", "Alt+F4") then end + if ImGui_MenuItem("Checked", nil, true) then end + ImGui_Separator() + if ImGui_MenuItem("Quit", "Alt+F4") then end end ------------------------------------------------------------------------------- @@ -31927,7 +31983,7 @@ function ExampleAppConsole() self.ScrollToBottom = false self:ClearLog() - self.InputBuf = ImGui.NewTextBuffer("", 256) -- [Port] memset(InputBuf, 0, sizeof(InputBuf)) + self.InputBuf = ImGui_NewTextBuffer("", 256) -- [Port] memset(InputBuf, 0, sizeof(InputBuf)) self.HistoryPos = -1 -- "CLASSIFY" is here to provide the test case where "C"+[tab] completes to "CL" and display multiple matches. @@ -31965,7 +32021,7 @@ function ExampleAppConsoleMT:AddLog(fmt, ...) end function ExampleAppConsoleMT:Draw(title, p_open) - ImGui.SetNextWindowSize(ImVec2(520, 600), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(520, 600), 4 --[[ImGuiCond.FirstUseEver]]) local visible p_open, visible = ImGui.Begin(title, p_open) if not visible then @@ -31977,56 +32033,56 @@ function ExampleAppConsoleMT:Draw(title, p_open) -- As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. -- So e.g. IsItemHovered() will return true when hovering the title bar. -- Here we create a context menu only available from the title bar. - if ImGui.BeginPopupContextItem() then - if ImGui.MenuItem("Close Console") then + if ImGui_BeginPopupContextItem() then + if ImGui_MenuItem("Close Console") then p_open = false end - ImGui.EndPopup() + ImGui_EndPopup() end - ImGui.TextWrapped( + ImGui_TextWrapped( "This example implements a console with basic coloring, completion (TAB key) and history (Up/Down keys). A more elaborate " .. "implementation may want to store entries along with extra data such as timestamp, emitter, etc.") - ImGui.TextWrapped("Enter 'HELP' for help.") + ImGui_TextWrapped("Enter 'HELP' for help.") -- TODO: display items starting from the bottom - if ImGui.SmallButton("Add Debug Text") then self:AddLog("%d some text", self.Items.Size); self:AddLog("some more text"); self:AddLog("display very important message here!") end - ImGui.SameLine() - if ImGui.SmallButton("Add Debug Error") then self:AddLog("[error] something went wrong") end - ImGui.SameLine() - if ImGui.SmallButton("Clear") then self:ClearLog() end - ImGui.SameLine() - local copy_to_clipboard = ImGui.SmallButton("Copy") + if ImGui_SmallButton("Add Debug Text") then self:AddLog("%d some text", self.Items.Size); self:AddLog("some more text"); self:AddLog("display very important message here!") end + ImGui_SameLine() + if ImGui_SmallButton("Add Debug Error") then self:AddLog("[error] something went wrong") end + ImGui_SameLine() + if ImGui_SmallButton("Clear") then self:ClearLog() end + ImGui_SameLine() + local copy_to_clipboard = ImGui_SmallButton("Copy") --static float t = 0.0f; if (ImGui.GetTime() - t > 0.02f) { t = ImGui.GetTime(); AddLog("Spam %f", t); } - ImGui.Separator() + ImGui_Separator() -- Options menu - if ImGui.BeginPopup("Options") then - _, self.AutoScroll = ImGui.Checkbox("Auto-scroll", self.AutoScroll) - ImGui.EndPopup() + if ImGui_BeginPopup("Options") then + _, self.AutoScroll = ImGui_Checkbox("Auto-scroll", self.AutoScroll) + ImGui_EndPopup() end -- Options, Filter - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 560 --[[ImGuiKey.O]]), 262144 --[[ImGuiInputFlags.Tooltip]]) - if ImGui.Button("Options") then - ImGui.OpenPopup("Options") + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 560 --[[ImGuiKey.O]]), 262144 --[[ImGuiInputFlags.Tooltip]]) + if ImGui_Button("Options") then + ImGui_OpenPopup("Options") end - ImGui.SameLine() + ImGui_SameLine() - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 551 --[[ImGuiKey.F]]), 262144 --[[ImGuiInputFlags.Tooltip]]) - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 551 --[[ImGuiKey.F]]), 262144 --[[ImGuiInputFlags.Tooltip]]) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) self.Filter:DrawWithHint("##Filter", "Filter (incl -excl)") - ImGui.Separator() + ImGui_Separator() -- Reserve enough left-over height for 1 separator + 1 input text - local style = ImGui.GetStyle() - local footer_height_to_reserve = style.SeparatorSize + style.ItemSpacing.y + ImGui.GetFrameHeightWithSpacing() - if ImGui.BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), 256 --[[ImGuiChildFlags.NavFlattened]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) then - if ImGui.BeginPopupContextWindow() then - if ImGui.Selectable("Clear") then self:ClearLog() end - ImGui.EndPopup() + local style = ImGui_GetStyle() + local footer_height_to_reserve = style.SeparatorSize + style.ItemSpacing.y + ImGui_GetFrameHeightWithSpacing() + if ImGui_BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), 256 --[[ImGuiChildFlags.NavFlattened]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) then + if ImGui_BeginPopupContextWindow() then + if ImGui_Selectable("Clear") then self:ClearLog() end + ImGui_EndPopup() end -- Display every line as a separate entry so we can change their color or add custom widgets. @@ -32053,9 +32109,9 @@ function ExampleAppConsoleMT:Draw(title, p_open) -- If your items are of variable height: -- - Split them into same height items would be simpler and facilitate random-seeking into your list. -- - Consider using manual call to IsRectVisible() and skipping extraneous decoration from your items. - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(4, 1)) -- Tighten spacing + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(4, 1)) -- Tighten spacing if copy_to_clipboard then - ImGui.LogToClipboard() + ImGui_LogToClipboard() end for _, item in self.Items:iter() do repeat if not self.Filter:PassFilter(item) then @@ -32069,46 +32125,46 @@ function ExampleAppConsoleMT:Draw(title, p_open) if string.find(item, "[error]", 1, true) then color = ImVec4(1.0, 0.4, 0.4, 1.0); has_color = true elseif string.sub(item, 1, 2) == "# " then color = ImVec4(1.0, 0.8, 0.6, 1.0); has_color = true end if has_color then - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], color) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], color) end - ImGui.TextUnformatted(item) + ImGui_TextUnformatted(item) if has_color then - ImGui.PopStyleColor() + ImGui_PopStyleColor() end until true end if copy_to_clipboard then - ImGui.LogFinish() + ImGui_LogFinish() end -- Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame. -- Using a scrollbar or mouse-wheel will take away from the bottom edge. - if self.ScrollToBottom or (self.AutoScroll and ImGui.GetScrollY() >= ImGui.GetScrollMaxY()) then - ImGui.SetScrollHereY(1.0) + if self.ScrollToBottom or (self.AutoScroll and ImGui_GetScrollY() >= ImGui_GetScrollMaxY()) then + ImGui_SetScrollHereY(1.0) end self.ScrollToBottom = false - ImGui.PopStyleVar() + ImGui_PopStyleVar() end - ImGui.EndChild() - ImGui.Separator() + ImGui_EndChild() + ImGui_Separator() -- Command-line local reclaim_focus = false local input_text_flags = bit32.bor(64 --[[ImGuiInputTextFlags.EnterReturnsTrue]], 128 --[[ImGuiInputTextFlags.EscapeClearsAll]], 262144 --[[ImGuiInputTextFlags.CallbackCompletion]], 524288 --[[ImGuiInputTextFlags.CallbackHistory]]) - if ImGui.InputText("Input", self.InputBuf, 256, input_text_flags, ExampleAppConsoleMT.TextEditCallbackStub, self) then + if ImGui_InputText("Input", self.InputBuf, 256, input_text_flags, ExampleAppConsoleMT.TextEditCallbackStub, self) then local s = self.InputBuf ExampleAppConsoleMT.Strtrimblanks(s) if s[1] ~= 0 then - self:ExecCommand(ImGui.TextBufferToString(s)) + self:ExecCommand(ImGui_TextBufferToString(s)) end s[1] = 0 reclaim_focus = true end -- Auto-focus on window apparition - ImGui.SetItemDefaultFocus() + ImGui_SetItemDefaultFocus() if reclaim_focus then - ImGui.SetKeyboardFocusHere(-1) -- Auto focus previous widget + ImGui_SetKeyboardFocusHere(-1) -- Auto focus previous widget end ImGui.End() @@ -32273,7 +32329,7 @@ S.ShowExampleAppImageViewer = { } function ShowExampleAppImageViewer(p_open) local s = S.ShowExampleAppImageViewer - local atlas = ImGui.GetIO().Fonts + local atlas = ImGui_GetIO().Fonts local tex_ref = atlas.TexRef -- We don't have access to other textures in this demo! local tex_w = atlas.TexData.Width local tex_h = atlas.TexData.Height @@ -32282,9 +32338,9 @@ function ShowExampleAppImageViewer(p_open) if visible then if s.image_viewer == nil then s.image_viewer = ExampleImageViewerData() end ExampleImageViewer_DrawOptions(s.image_viewer) - local canvas_size = ImGui.GetContentRegionAvail() + local canvas_size = ImGui_GetContentRegionAvail() local canvas_min_size - if ImGui.IsWindowAppearing() then canvas_min_size = ImVec2(3.0 * tex_w, 4.0 * tex_h) else canvas_min_size = ImVec2(1.0, 1.0) end + if ImGui_IsWindowAppearing() then canvas_min_size = ImVec2(3.0 * tex_w, 4.0 * tex_h) else canvas_min_size = ImVec2(1.0, 1.0) end canvas_size = ImVec2(ImMax(canvas_size.x, canvas_min_size.x), ImMax(canvas_size.y, canvas_min_size.y)) ExampleImageViewer_DrawCanvas(s.image_viewer, canvas_size, tex_ref, tex_w, tex_h) end @@ -32343,34 +32399,34 @@ function ExampleAppLogMT:Draw(title, p_open) end -- Options menu - if ImGui.BeginPopup("Options") then - _, self.AutoScroll = ImGui.Checkbox("Auto-scroll", self.AutoScroll) - ImGui.EndPopup() + if ImGui_BeginPopup("Options") then + _, self.AutoScroll = ImGui_Checkbox("Auto-scroll", self.AutoScroll) + ImGui_EndPopup() end -- Main window - if ImGui.Button("Options") then - ImGui.OpenPopup("Options") + if ImGui_Button("Options") then + ImGui_OpenPopup("Options") end - ImGui.SameLine() - local clear = ImGui.Button("Clear") - ImGui.SameLine() - local copy = ImGui.Button("Copy") - ImGui.SameLine() - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SameLine() + local clear = ImGui_Button("Clear") + ImGui_SameLine() + local copy = ImGui_Button("Copy") + ImGui_SameLine() + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) self.Filter:DrawWithHint("##Filter", "Filter (incl -excl)") - ImGui.Separator() + ImGui_Separator() - if ImGui.BeginChild("scrolling", ImVec2(0, 0), 0 --[[ImGuiChildFlags.None]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) then + if ImGui_BeginChild("scrolling", ImVec2(0, 0), 0 --[[ImGuiChildFlags.None]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]]) then if clear then self:Clear() end if copy then - ImGui.LogToClipboard() + ImGui_LogToClipboard() end - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) local buf = self.Buf:c_str() local buf_end = #buf local LineOffsets = self.LineOffsets @@ -32385,7 +32441,7 @@ function ExampleAppLogMT:Draw(title, p_open) if line_no + 1 < LineOffsets.Size then line_end = LineOffsets.Data[line_no + 2] - 1 else line_end = buf_end end local line = string.sub(buf, line_start + 1, line_end) if self.Filter:PassFilter(line) then - ImGui.TextUnformatted(line) + ImGui_TextUnformatted(line) end end else @@ -32409,20 +32465,20 @@ function ExampleAppLogMT:Draw(title, p_open) local line_start = LineOffsets.Data[line_no + 1] local line_end if line_no + 1 < LineOffsets.Size then line_end = LineOffsets.Data[line_no + 2] - 1 else line_end = buf_end end - ImGui.TextUnformatted(string.sub(buf, line_start + 1, line_end)) + ImGui_TextUnformatted(string.sub(buf, line_start + 1, line_end)) end end clipper:End() end - ImGui.PopStyleVar() + ImGui_PopStyleVar() -- Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame. -- Using a scrollbar or mouse-wheel will take away from the bottom edge. - if self.AutoScroll and ImGui.GetScrollY() >= ImGui.GetScrollMaxY() then - ImGui.SetScrollHereY(1.0) + if self.AutoScroll and ImGui_GetScrollY() >= ImGui_GetScrollMaxY() then + ImGui_SetScrollHereY(1.0) end end - ImGui.EndChild() + ImGui_EndChild() ImGui.End() return p_open end @@ -32439,17 +32495,17 @@ function ShowExampleAppLog(p_open) -- For the demo: add a debug button _BEFORE_ the normal log window contents -- We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. -- Most of the contents of the window will be added by the log.Draw() call. - ImGui.SetNextWindowSize(ImVec2(500, 400), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(500, 400), 4 --[[ImGuiCond.FirstUseEver]]) p_open = ImGui.Begin("Example: Log", p_open) IMGUI_DEMO_MARKER("Examples/Log") - if ImGui.SmallButton("[Debug] Add 5 entries") then + if ImGui_SmallButton("[Debug] Add 5 entries") then local categories = { "info", "warn", "error" } local words = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" } for n = 0, 5 - 1 do local category = categories[s.counter % #categories + 1] local word = words[s.counter % #words + 1] s.log:AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", - ImGui.GetFrameCount(), category, ImGui.GetTime(), word) + ImGui_GetFrameCount(), category, ImGui_GetTime(), word) s.counter = s.counter + 1 end end @@ -32469,54 +32525,54 @@ S.ShowExampleAppLayout = { } function ShowExampleAppLayout(p_open) local s = S.ShowExampleAppLayout - ImGui.SetNextWindowSize(ImVec2(500, 440), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(500, 440), 4 --[[ImGuiCond.FirstUseEver]]) local visible p_open, visible = ImGui.Begin("Example: Simple layout", p_open, 1024 --[[ImGuiWindowFlags.MenuBar]]) if visible then IMGUI_DEMO_MARKER("Examples/Simple layout") - if ImGui.BeginMenuBar() then - if ImGui.BeginMenu("File") then - if ImGui.MenuItem("Close", "Ctrl+W") then p_open = false end - ImGui.EndMenu() + if ImGui_BeginMenuBar() then + if ImGui_BeginMenu("File") then + if ImGui_MenuItem("Close", "Ctrl+W") then p_open = false end + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end -- Left do - ImGui.BeginChild("left pane", ImVec2(150, 0), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 4 --[[ImGuiChildFlags.ResizeX]])) + ImGui_BeginChild("left pane", ImVec2(150, 0), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 4 --[[ImGuiChildFlags.ResizeX]])) for i = 0, 100 - 1 do local label = string.format("MyObject %d", i) - if ImGui.Selectable(label, s.selected == i, 64 --[[ImGuiSelectableFlags.SelectOnNav]]) then + if ImGui_Selectable(label, s.selected == i, 64 --[[ImGuiSelectableFlags.SelectOnNav]]) then s.selected = i end end - ImGui.EndChild() + ImGui_EndChild() end - ImGui.SameLine() + ImGui_SameLine() -- Right do - ImGui.BeginGroup() - ImGui.BeginChild("item view", ImVec2(0, -ImGui.GetFrameHeightWithSpacing())) -- Leave room for 1 line below us - ImGui.Text("MyObject: %d", s.selected) - ImGui.Separator() - if ImGui.BeginTabBar("##Tabs", 0 --[[ImGuiTabBarFlags.None]]) then + ImGui_BeginGroup() + ImGui_BeginChild("item view", ImVec2(0, -ImGui_GetFrameHeightWithSpacing())) -- Leave room for 1 line below us + ImGui_Text("MyObject: %d", s.selected) + ImGui_Separator() + if ImGui_BeginTabBar("##Tabs", 0 --[[ImGuiTabBarFlags.None]]) then if ImGui.BeginTabItem("Description") then - ImGui.TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ") - ImGui.EndTabItem() + ImGui_TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ") + ImGui_EndTabItem() end if ImGui.BeginTabItem("Details") then - ImGui.Text("ID: 0123456789") - ImGui.EndTabItem() + ImGui_Text("ID: 0123456789") + ImGui_EndTabItem() end - ImGui.EndTabBar() + ImGui_EndTabBar() end - ImGui.EndChild() - if ImGui.Button("Revert") then end - ImGui.SameLine() - if ImGui.Button("Save") then end - ImGui.EndGroup() + ImGui_EndChild() + if ImGui_Button("Revert") then end + ImGui_SameLine() + if ImGui_Button("Save") then end + ImGui_EndGroup() end end ImGui.End() @@ -32549,83 +32605,83 @@ function ExampleAppPropertyEditorMT:Draw(root_node) -- Left side: draw tree -- - Currently using a table to benefit from RowBg feature -- - Our tree node are all of equal height, facilitating the use of a clipper. - if ImGui.BeginChild("##tree", ImVec2(300, 0), bit32.bor(4 --[[ImGuiChildFlags.ResizeX]], 1 --[[ImGuiChildFlags.Borders]], 256 --[[ImGuiChildFlags.NavFlattened]])) then - ImGui.PushItemFlag(4 --[[ImGuiItemFlags.NoNavDefaultFocus]], true) - _, self.UseClipper = ImGui.Checkbox("Use Clipper", self.UseClipper) - ImGui.SameLine() - ImGui.Text("(%d root nodes)", #root_node.Childs) - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 551 --[[ImGuiKey.F]]), 262144 --[[ImGuiInputFlags.Tooltip]]) - if ImGui.InputTextWithHint("##Filter", "incl -excl", self.Filter.InputBuf, 256, 128 --[[ImGuiInputTextFlags.EscapeClearsAll]]) then + if ImGui_BeginChild("##tree", ImVec2(300, 0), bit32.bor(4 --[[ImGuiChildFlags.ResizeX]], 1 --[[ImGuiChildFlags.Borders]], 256 --[[ImGuiChildFlags.NavFlattened]])) then + ImGui_PushItemFlag(4 --[[ImGuiItemFlags.NoNavDefaultFocus]], true) + _, self.UseClipper = ImGui_Checkbox("Use Clipper", self.UseClipper) + ImGui_SameLine() + ImGui_Text("(%d root nodes)", #root_node.Childs) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 551 --[[ImGuiKey.F]]), 262144 --[[ImGuiInputFlags.Tooltip]]) + if ImGui_InputTextWithHint("##Filter", "incl -excl", self.Filter.InputBuf, 256, 128 --[[ImGuiInputTextFlags.EscapeClearsAll]]) then self.Filter:Build() end - ImGui.PopItemFlag() + ImGui_PopItemFlag() - if ImGui.BeginTable("##list", 1, 64 --[[ImGuiTableFlags.RowBg]]) then + if ImGui_BeginTable("##list", 1, 64 --[[ImGuiTableFlags.RowBg]]) then if self.UseClipper then self:DrawClippedTree(root_node) else self:DrawTree(root_node) end - ImGui.EndTable() + ImGui_EndTable() end end - ImGui.EndChild() + ImGui_EndChild() -- Right side: draw properties - ImGui.SameLine() + ImGui_SameLine() - ImGui.BeginGroup() -- Lock X position + ImGui_BeginGroup() -- Lock X position local node = self.SelectedNode if node then - ImGui.Text("%s", node.Name) - ImGui.TextDisabled("UID: 0x%08X", node.UID) - ImGui.Separator() - if ImGui.BeginTable("##properties", 2, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 33554432 --[[ImGuiTableFlags.ScrollY]])) then + ImGui_Text("%s", node.Name) + ImGui_TextDisabled("UID: 0x%08X", node.UID) + ImGui_Separator() + if ImGui_BeginTable("##properties", 2, bit32.bor(1 --[[ImGuiTableFlags.Resizable]], 33554432 --[[ImGuiTableFlags.ScrollY]])) then -- Push object ID after we entered the table, so table is shared for all objects - ImGui.PushID(node.UID) - ImGui.TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) - ImGui.TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]], 2.0) -- Default twice larger + ImGui_PushID(node.UID) + ImGui_TableSetupColumn("", 16 --[[ImGuiTableColumnFlags.WidthFixed]]) + ImGui_TableSetupColumn("", 8 --[[ImGuiTableColumnFlags.WidthStretch]], 2.0) -- Default twice larger if node.HasData then -- In a typical application, the structure description would be derived from a data-driven system. -- - We try to mimic this with our ExampleMemberInfo structure and the ExampleTreeNodeMemberInfos[] array. -- - Limits and some details are hard-coded to simplify the demo. for _, field_desc in ipairs(ExampleTreeNodeMemberInfos) do - ImGui.TableNextRow() - ImGui.PushID(field_desc.Name) - ImGui.TableNextColumn() - ImGui.AlignTextToFramePadding() - ImGui.TextUnformatted(field_desc.Name) - ImGui.TableNextColumn() + ImGui_TableNextRow() + ImGui_PushID(field_desc.Name) + ImGui_TableNextColumn() + ImGui_AlignTextToFramePadding() + ImGui_TextUnformatted(field_desc.Name) + ImGui_TableNextColumn() local field_ptr = field_desc.Offset -- [Port] Offset is the field name inside ExampleTreeNode if field_desc.DataType == 10 --[[ImGuiDataType.Bool]] then assert(field_desc.DataCount == 1) - _, node[field_ptr] = ImGui.Checkbox("##Editor", node[field_ptr]) + _, node[field_ptr] = ImGui_Checkbox("##Editor", node[field_ptr]) elseif field_desc.DataType == 4 --[[ImGuiDataType.S32]] then local v_min, v_max = (-2147483648) --[[INT_MIN]], 2147483647 --[[INT_MAX]] - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) if field_desc.DataCount == 1 then -- [Port] scalar fields are plain Lua values: DragScalar() returns the new value - node[field_ptr] = ImGui.DragScalar("##Editor", field_desc.DataType, node[field_ptr], 1.0, v_min, v_max) + node[field_ptr] = ImGui_DragScalar("##Editor", field_desc.DataType, node[field_ptr], 1.0, v_min, v_max) else - ImGui.DragScalarN("##Editor", field_desc.DataType, node[field_ptr], field_desc.DataCount, 1.0, v_min, v_max) + ImGui_DragScalarN("##Editor", field_desc.DataType, node[field_ptr], field_desc.DataCount, 1.0, v_min, v_max) end elseif field_desc.DataType == 8 --[[ImGuiDataType.Float]] then local v_min, v_max = 0.0, 1.0 - ImGui.SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) - ImGui.SliderScalarN("##Editor", field_desc.DataType, node[field_ptr], field_desc.DataCount, v_min, v_max) + ImGui_SetNextItemWidth(-1.1754943508223e-38 --[[FLT_MIN]]) + ImGui_SliderScalarN("##Editor", field_desc.DataType, node[field_ptr], field_desc.DataCount, v_min, v_max) elseif field_desc.DataType == 11 --[[ImGuiDataType.String]] then local buf = self.StringBufs[node] -- [Port] edit the Lua string through a 28-byte buffer - if buf == nil then buf = ImGui.NewTextBuffer(node[field_ptr], 28); self.StringBufs[node] = buf end - if ImGui.InputText("##Editor", buf, 28) then node[field_ptr] = ImGui.TextBufferToString(buf) end + if buf == nil then buf = ImGui_NewTextBuffer(node[field_ptr], 28); self.StringBufs[node] = buf end + if ImGui_InputText("##Editor", buf, 28) then node[field_ptr] = ImGui_TextBufferToString(buf) end end - ImGui.PopID() + ImGui_PopID() end end - ImGui.PopID() - ImGui.EndTable() + ImGui_PopID() + ImGui_EndTable() end end - ImGui.EndGroup() + ImGui_EndGroup() end -- Custom search filter @@ -32643,7 +32699,7 @@ function ExampleAppPropertyEditorMT:DrawTree(node) for _, child in ipairs(node.Childs) do if self:IsNodePassingFilter(child) and self:DrawTreeNode(child) then self:DrawTree(child) - ImGui.TreePop() + ImGui_TreePop() end end end @@ -32688,7 +32744,7 @@ function ExampleAppPropertyEditorMT:DrawClippedTreeNodeAndAdvanceToNext(clipper, else is_open = (#node.Childs > 0 and ImGui.TreeNodeGetOpen(node.UID)) if is_open then - ImGui.TreePush(node.Name) + ImGui_TreePush(node.Name) end end clipper.UserIndex = clipper.UserIndex + 1 @@ -32708,7 +32764,7 @@ function ExampleAppPropertyEditorMT:DrawClippedTreeNodeAndAdvanceToNext(clipper, if node.Parent == nil then break end - ImGui.TreePop() + ImGui_TreePop() end return nil end @@ -32718,8 +32774,8 @@ end -- but it would require in DrawClippedTreeNodeAndAdvanceToNext() to add PushID() before TreePush(), and PopID() after TreePop(), -- so instead we use TreeNodeEx(node.UID, tree_flags, "%s", node.Name) here) function ExampleAppPropertyEditorMT:DrawTreeNode(node) - ImGui.TableNextRow() - ImGui.TableNextColumn() + ImGui_TableNextRow() + ImGui_TableNextColumn() local tree_flags = 0 --[[ImGuiTreeNodeFlags.None]] tree_flags = bit32.bor(tree_flags, 128 --[[ImGuiTreeNodeFlags.OpenOnArrow]], 64 --[[ImGuiTreeNodeFlags.OpenOnDoubleClick]]) -- Standard opening mode as we are likely to want to add selection afterwards tree_flags = bit32.bor(tree_flags, 131072 --[[ImGuiTreeNodeFlags.NavLeftJumpsToParent]]) -- Left arrow support @@ -32732,17 +32788,17 @@ function ExampleAppPropertyEditorMT:DrawTreeNode(node) tree_flags = bit32.bor(tree_flags, 256 --[[ImGuiTreeNodeFlags.Leaf]], 512 --[[ImGuiTreeNodeFlags.Bullet]], 8 --[[ImGuiTreeNodeFlags.NoTreePushOnOpen]]) -- Use _NoTreePushOnOpen + set is_open=false to avoid unnecessarily push/pop on leaves. end if node.DataMyBool == false then - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImGui.GetStyle().Colors[1 --[[ImGuiCol.TextDisabled]]]) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImGui_GetStyle().Colors[1 --[[ImGuiCol.TextDisabled]]]) end - ImGui.SetNextItemStorageID(node.UID) -- Use node.UID as storage id + ImGui_SetNextItemStorageID(node.UID) -- Use node.UID as storage id local is_open = ImGui.TreeNodeEx(node.UID, tree_flags, "%s", node.Name) if #node.Childs == 0 then is_open = false end if node.DataMyBool == false then - ImGui.PopStyleColor() + ImGui_PopStyleColor() end - if ImGui.IsItemFocused() then + if ImGui_IsItemFocused() then self.SelectedNode = node end return is_open @@ -32755,7 +32811,7 @@ S.ShowExampleAppPropertyEditor = { } function ShowExampleAppPropertyEditor(p_open, demo_data) local s = S.ShowExampleAppPropertyEditor - ImGui.SetNextWindowSize(ImVec2(430, 450), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(430, 450), 4 --[[ImGuiCond.FirstUseEver]]) local visible p_open, visible = ImGui.Begin("Example: Property editor", p_open) if not visible then @@ -32790,7 +32846,7 @@ S.ShowExampleAppLongText = { } function ShowExampleAppLongText(p_open) local s = S.ShowExampleAppLongText - ImGui.SetNextWindowSize(ImVec2(520, 600), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(520, 600), 4 --[[ImGuiCond.FirstUseEver]]) local visible p_open, visible = ImGui.Begin("Example: Long text display", p_open) if not visible then @@ -32799,44 +32855,44 @@ function ShowExampleAppLongText(p_open) end IMGUI_DEMO_MARKER("Examples/Long text display") - ImGui.Text("Printing unusually long amount of text.") - s.test_type = ImGui.Combo("Test type", s.test_type, + ImGui_Text("Printing unusually long amount of text.") + s.test_type = ImGui_Combo("Test type", s.test_type, "Single call to TextUnformatted()\0" .. "Multiple calls to Text(), clipped\0" .. "Multiple calls to Text(), not clipped (slow)\0") - ImGui.Text("Buffer contents: %d lines, %d bytes", s.lines, s.log:size()) - if ImGui.Button("Clear") then s.log:clear(); s.lines = 0 end - ImGui.SameLine() - if ImGui.Button("Add 1000 lines") then + ImGui_Text("Buffer contents: %d lines, %d bytes", s.lines, s.log:size()) + if ImGui_Button("Clear") then s.log:clear(); s.lines = 0 end + ImGui_SameLine() + if ImGui_Button("Add 1000 lines") then for i = 0, 1000 - 1 do s.log:appendf("%i The quick brown fox jumps over the lazy dog\n", s.lines + i) end s.lines = s.lines + 1000 end - ImGui.BeginChild("Log") + ImGui_BeginChild("Log") if s.test_type == 0 then -- Single call to TextUnformatted() with a big buffer - ImGui.TextUnformatted(s.log:c_str()) -- [Port] ImGuiTextBuffer is a chunk list: c_str() instead of begin()/end() + ImGui_TextUnformatted(s.log:c_str()) -- [Port] ImGuiTextBuffer is a chunk list: c_str() instead of begin()/end() elseif s.test_type == 1 then -- Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper. - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) local clipper = ImGuiListClipper() clipper:Begin(s.lines) while clipper:Step() do for i = clipper.DisplayStart, clipper.DisplayEnd - 1 do - ImGui.Text("%i The quick brown fox jumps over the lazy dog", i) + ImGui_Text("%i The quick brown fox jumps over the lazy dog", i) end end - ImGui.PopStyleVar() + ImGui_PopStyleVar() elseif s.test_type == 2 then -- Multiple calls to Text(), not clipped (slow) - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) for i = 0, s.lines - 1 do - ImGui.Text("%i The quick brown fox jumps over the lazy dog", i) + ImGui_Text("%i The quick brown fox jumps over the lazy dog", i) end - ImGui.PopStyleVar() + ImGui_PopStyleVar() end - ImGui.EndChild() + ImGui_EndChild() ImGui.End() return p_open end @@ -32859,13 +32915,13 @@ function ShowExampleAppAutoResize(p_open) end IMGUI_DEMO_MARKER("Examples/Auto-resizing window") - ImGui.TextUnformatted( + ImGui_TextUnformatted( "Window will resize every-frame to the size of its content.\n" .. "Note that you probably don't want to query the window size to\n" .. "output your content because that would create a feedback loop.") - s.lines = ImGui.SliderInt("Number of lines", s.lines, 1, 20) + s.lines = ImGui_SliderInt("Number of lines", s.lines, 1, 20) for i = 0, s.lines - 1 do - ImGui.Text("%sThis is line %d", string.rep(" ", i * 4), i) -- Pad with space to extend size horizontally -- [Port] "%*s" -> string.rep + ImGui_Text("%sThis is line %d", string.rep(" ", i * 4), i) -- Pad with space to extend size horizontally -- [Port] "%*s" -> string.rep end ImGui.End() return p_open @@ -32919,51 +32975,51 @@ function ShowExampleAppConstrainedResize(p_open) -- Submit constraint local aspect_ratio = 16.0 / 9.0 local fixed_step = 100.0 - if s.type == 0 then ImGui.SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(500, 500)) end -- Between 100x100 and 500x500 - if s.type == 1 then ImGui.SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]])) end -- Width > 100, Height > 100 - if s.type == 2 then ImGui.SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, 3.4028234663853e+38 --[[FLT_MAX]])) end -- Resize vertical + lock current width - if s.type == 3 then ImGui.SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], -1)) end -- Resize horizontal + lock current height - if s.type == 4 then ImGui.SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)) end -- Width Between and 400 and 500 - if s.type == 5 then ImGui.SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 3.4028234663853e+38 --[[FLT_MAX]])) end -- Height at least 400 - if s.type == 6 then ImGui.SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]), CustomConstraints.AspectRatio, aspect_ratio) end -- Aspect ratio - if s.type == 7 then ImGui.SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]), CustomConstraints.Square) end -- Always Square - if s.type == 8 then ImGui.SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]), CustomConstraints.Step, fixed_step) end -- Fixed Step + if s.type == 0 then ImGui_SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(500, 500)) end -- Between 100x100 and 500x500 + if s.type == 1 then ImGui_SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]])) end -- Width > 100, Height > 100 + if s.type == 2 then ImGui_SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, 3.4028234663853e+38 --[[FLT_MAX]])) end -- Resize vertical + lock current width + if s.type == 3 then ImGui_SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], -1)) end -- Resize horizontal + lock current height + if s.type == 4 then ImGui_SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)) end -- Width Between and 400 and 500 + if s.type == 5 then ImGui_SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 3.4028234663853e+38 --[[FLT_MAX]])) end -- Height at least 400 + if s.type == 6 then ImGui_SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]), CustomConstraints.AspectRatio, aspect_ratio) end -- Aspect ratio + if s.type == 7 then ImGui_SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]), CustomConstraints.Square) end -- Always Square + if s.type == 8 then ImGui_SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], 3.4028234663853e+38 --[[FLT_MAX]]), CustomConstraints.Step, fixed_step) end -- Fixed Step -- Submit window if not s.window_padding then - ImGui.PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0.0, 0.0)) + ImGui_PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0.0, 0.0)) end local window_flags = s.auto_resize and 64 --[[ImGuiWindowFlags.AlwaysAutoResize]] or 0 local window_open p_open, window_open = ImGui.Begin("Example: Constrained Resize", p_open, window_flags) if not s.window_padding then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end IMGUI_DEMO_MARKER("Examples/Constrained Resizing window") if window_open then - if ImGui.GetIO().KeyShift then + if ImGui_GetIO().KeyShift then -- Display a dummy viewport (in your real app you would likely use ImageButton() to display a texture) - local avail_size = ImGui.GetContentRegionAvail() - local pos = ImGui.GetCursorScreenPos() - ImGui.ColorButton("viewport", ImVec4(0.5, 0.2, 0.5, 1.0), bit32.bor(64 --[[ImGuiColorEditFlags.NoTooltip]], 512 --[[ImGuiColorEditFlags.NoDragDrop]]), avail_size) - ImGui.SetCursorScreenPos(ImVec2(pos.x + 10, pos.y + 10)) - ImGui.Text("%.2f x %.2f", avail_size.x, avail_size.y) + local avail_size = ImGui_GetContentRegionAvail() + local pos = ImGui_GetCursorScreenPos() + ImGui_ColorButton("viewport", ImVec4(0.5, 0.2, 0.5, 1.0), bit32.bor(64 --[[ImGuiColorEditFlags.NoTooltip]], 512 --[[ImGuiColorEditFlags.NoDragDrop]]), avail_size) + ImGui_SetCursorScreenPos(ImVec2(pos.x + 10, pos.y + 10)) + ImGui_Text("%.2f x %.2f", avail_size.x, avail_size.y) else - ImGui.Text("(Hold Shift to display a dummy viewport)") - if ImGui.IsWindowDocked() then - ImGui.Text("Warning: Sizing Constraints won't work if the window is docked!") + ImGui_Text("(Hold Shift to display a dummy viewport)") + if ImGui_IsWindowDocked() then + ImGui_Text("Warning: Sizing Constraints won't work if the window is docked!") end - if ImGui.Button("Set 200x200") then ImGui.SetWindowSize(ImVec2(200, 200)) end ImGui.SameLine() - if ImGui.Button("Set 500x500") then ImGui.SetWindowSize(ImVec2(500, 500)) end ImGui.SameLine() - if ImGui.Button("Set 800x200") then ImGui.SetWindowSize(ImVec2(800, 200)) end - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 20) - s.type = ImGui.Combo("Constraint", s.type, test_desc, #test_desc) - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 20) - s.display_lines = ImGui.DragInt("Lines", s.display_lines, 0.2, 1, 100) - _, s.auto_resize = ImGui.Checkbox("Auto-resize", s.auto_resize) - _, s.window_padding = ImGui.Checkbox("Window padding", s.window_padding) + if ImGui_Button("Set 200x200") then ImGui_SetWindowSize(ImVec2(200, 200)) end ImGui_SameLine() + if ImGui_Button("Set 500x500") then ImGui_SetWindowSize(ImVec2(500, 500)) end ImGui_SameLine() + if ImGui_Button("Set 800x200") then ImGui_SetWindowSize(ImVec2(800, 200)) end + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 20) + s.type = ImGui_Combo("Constraint", s.type, test_desc, #test_desc) + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 20) + s.display_lines = ImGui_DragInt("Lines", s.display_lines, 0.2, 1, 100) + _, s.auto_resize = ImGui_Checkbox("Auto-resize", s.auto_resize) + _, s.window_padding = ImGui_Checkbox("Window padding", s.window_padding) for i = 0, s.display_lines - 1 do - ImGui.Text("%sHello, sailor! Making this line long enough for the example.", string.rep(" ", i * 4)) -- [Port] "%*s" -> string.rep + ImGui_Text("%sHello, sailor! Making this line long enough for the example.", string.rep(" ", i * 4)) -- [Port] "%*s" -> string.rep end end end @@ -32982,11 +33038,11 @@ S.ShowExampleAppSimpleOverlay = { } function ShowExampleAppSimpleOverlay(p_open) local s = S.ShowExampleAppSimpleOverlay - local io = ImGui.GetIO() + local io = ImGui_GetIO() local window_flags = bit32.bor(43 --[[ImGuiWindowFlags.NoDecoration]], 524288 --[[ImGuiWindowFlags.NoDocking]], 64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 256 --[[ImGuiWindowFlags.NoSavedSettings]], 4096 --[[ImGuiWindowFlags.NoFocusOnAppearing]], 196608 --[[ImGuiWindowFlags.NoNav]]) if s.location >= 0 then local PAD = 10.0 - local viewport = ImGui.GetMainViewport() + local viewport = ImGui_GetMainViewport() local work_pos = viewport.WorkPos -- Use work area to avoid menu-bar/task-bar, if any! local work_size = viewport.WorkSize local window_pos, window_pos_pivot = ImVec2(), ImVec2() @@ -32994,35 +33050,35 @@ function ShowExampleAppSimpleOverlay(p_open) window_pos.y = (bit32.band(s.location, 2) ~= 0) and (work_pos.y + work_size.y - PAD) or (work_pos.y + PAD) window_pos_pivot.x = (bit32.band(s.location, 1) ~= 0) and 1.0 or 0.0 window_pos_pivot.y = (bit32.band(s.location, 2) ~= 0) and 1.0 or 0.0 - ImGui.SetNextWindowPos(window_pos, 1 --[[ImGuiCond.Always]], window_pos_pivot) - ImGui.SetNextWindowViewport(viewport.ID) + ImGui_SetNextWindowPos(window_pos, 1 --[[ImGuiCond.Always]], window_pos_pivot) + ImGui_SetNextWindowViewport(viewport.ID) window_flags = bit32.bor(window_flags, 4 --[[ImGuiWindowFlags.NoMove]]) elseif s.location == -2 then -- Center window - ImGui.SetNextWindowPos(ImGui.GetMainViewport():GetCenter(), 1 --[[ImGuiCond.Always]], ImVec2(0.5, 0.5)) + ImGui_SetNextWindowPos(ImGui_GetMainViewport():GetCenter(), 1 --[[ImGuiCond.Always]], ImVec2(0.5, 0.5)) window_flags = bit32.bor(window_flags, 4 --[[ImGuiWindowFlags.NoMove]]) end - ImGui.SetNextWindowBgAlpha(0.35) -- Transparent background + ImGui_SetNextWindowBgAlpha(0.35) -- Transparent background local visible p_open, visible = ImGui.Begin("Example: Simple overlay", p_open, window_flags) if visible then IMGUI_DEMO_MARKER("Examples/Simple overlay") -- Scroll up to the beginning of this function to see overlay flags - ImGui.Text("Simple overlay\n" .. "(right-click to change position)") - ImGui.Separator() - if ImGui.IsMousePosValid() then - ImGui.Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y) + ImGui_Text("Simple overlay\n" .. "(right-click to change position)") + ImGui_Separator() + if ImGui_IsMousePosValid() then + ImGui_Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y) else - ImGui.Text("Mouse Position: ") + ImGui_Text("Mouse Position: ") end - if ImGui.BeginPopupContextWindow() then - if ImGui.MenuItem("Custom", nil, s.location == -1) then s.location = -1 end - if ImGui.MenuItem("Center", nil, s.location == -2) then s.location = -2 end - if ImGui.MenuItem("Top-left", nil, s.location == 0) then s.location = 0 end - if ImGui.MenuItem("Top-right", nil, s.location == 1) then s.location = 1 end - if ImGui.MenuItem("Bottom-left", nil, s.location == 2) then s.location = 2 end - if ImGui.MenuItem("Bottom-right", nil, s.location == 3) then s.location = 3 end - if p_open ~= nil and ImGui.MenuItem("Close") then p_open = false end - ImGui.EndPopup() + if ImGui_BeginPopupContextWindow() then + if ImGui_MenuItem("Custom", nil, s.location == -1) then s.location = -1 end + if ImGui_MenuItem("Center", nil, s.location == -2) then s.location = -2 end + if ImGui_MenuItem("Top-left", nil, s.location == 0) then s.location = 0 end + if ImGui_MenuItem("Top-right", nil, s.location == 1) then s.location = 1 end + if ImGui_MenuItem("Bottom-left", nil, s.location == 2) then s.location = 2 end + if ImGui_MenuItem("Bottom-right", nil, s.location == 3) then s.location = 3 end + if p_open ~= nil and ImGui_MenuItem("Close") then p_open = false end + ImGui_EndPopup() end end ImGui.End() @@ -33043,27 +33099,27 @@ function ShowExampleAppFullscreen(p_open) -- We demonstrate using the full viewport area or the work area (without menu-bars, task-bars etc.) -- Based on your use case you may want one or the other. - local viewport = ImGui.GetMainViewport() - ImGui.SetNextWindowPos(s.use_work_area and viewport.WorkPos or viewport.Pos) - ImGui.SetNextWindowSize(s.use_work_area and viewport.WorkSize or viewport.Size) + local viewport = ImGui_GetMainViewport() + ImGui_SetNextWindowPos(s.use_work_area and viewport.WorkPos or viewport.Pos) + ImGui_SetNextWindowSize(s.use_work_area and viewport.WorkSize or viewport.Size) local visible p_open, visible = ImGui.Begin("Example: Fullscreen window", p_open, s.flags) if visible then IMGUI_DEMO_MARKER("Examples/Fullscreen window") - _, s.use_work_area = ImGui.Checkbox("Use work area instead of main area", s.use_work_area) - ImGui.SameLine() + _, s.use_work_area = ImGui_Checkbox("Use work area instead of main area", s.use_work_area) + ImGui_SameLine() HelpMarker("Main Area = entire viewport,\nWork Area = entire viewport minus sections used by the main menu bars, task bars etc.\n\nEnable the main-menu bar in Examples menu to see the difference.") - _, s.flags = ImGui.CheckboxFlags("ImGuiWindowFlags_NoBackground", s.flags, 128 --[[ImGuiWindowFlags.NoBackground]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiWindowFlags_NoDecoration", s.flags, 43 --[[ImGuiWindowFlags.NoDecoration]]) - ImGui.Indent() - _, s.flags = ImGui.CheckboxFlags("ImGuiWindowFlags_NoTitleBar", s.flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiWindowFlags_NoCollapse", s.flags, 32 --[[ImGuiWindowFlags.NoCollapse]]) - _, s.flags = ImGui.CheckboxFlags("ImGuiWindowFlags_NoScrollbar", s.flags, 8 --[[ImGuiWindowFlags.NoScrollbar]]) - ImGui.Unindent() + _, s.flags = ImGui_CheckboxFlags("ImGuiWindowFlags_NoBackground", s.flags, 128 --[[ImGuiWindowFlags.NoBackground]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiWindowFlags_NoDecoration", s.flags, 43 --[[ImGuiWindowFlags.NoDecoration]]) + ImGui_Indent() + _, s.flags = ImGui_CheckboxFlags("ImGuiWindowFlags_NoTitleBar", s.flags, 1 --[[ImGuiWindowFlags.NoTitleBar]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiWindowFlags_NoCollapse", s.flags, 32 --[[ImGuiWindowFlags.NoCollapse]]) + _, s.flags = ImGui_CheckboxFlags("ImGuiWindowFlags_NoScrollbar", s.flags, 8 --[[ImGuiWindowFlags.NoScrollbar]]) + ImGui_Unindent() - if p_open ~= nil and ImGui.Button("Close this window") then + if p_open ~= nil and ImGui_Button("Close this window") then p_open = false end end @@ -33079,32 +33135,32 @@ end -- This applies to all regular items as well. -- Read FAQ section "How can I have multiple widgets with the same label?" for details. function ShowExampleAppWindowTitles(p_open) - local viewport = ImGui.GetMainViewport() + local viewport = ImGui_GetMainViewport() local base_pos = viewport.Pos -- By default, Windows are uniquely identified by their title. -- You can use the "##" and "###" markers to manipulate the display/ID. -- Using "##" to display same title but have unique identifier. - ImGui.SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 100), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 100), 4 --[[ImGuiCond.FirstUseEver]]) ImGui.Begin("Same title as another window##1") IMGUI_DEMO_MARKER("Examples/Manipulating window titles##1") - ImGui.Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.") + ImGui_Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.") ImGui.End() - ImGui.SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 200), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 200), 4 --[[ImGuiCond.FirstUseEver]]) ImGui.Begin("Same title as another window##2") IMGUI_DEMO_MARKER("Examples/Manipulating window titles##2") - ImGui.Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.") + ImGui_Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.") ImGui.End() -- Using "###" to display a changing title but keep a static identifier "AnimatedTitle" - local spin_i = bit32.band(math.floor(ImGui.GetTime() / 0.25), 3) + 1 - local buf = string.format("Animated title %s %d###AnimatedTitle", string.sub("|/-\\", spin_i, spin_i), ImGui.GetFrameCount()) - ImGui.SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 300), 4 --[[ImGuiCond.FirstUseEver]]) + local spin_i = bit32.band(math.floor(ImGui_GetTime() / 0.25), 3) + 1 + local buf = string.format("Animated title %s %d###AnimatedTitle", string.sub("|/-\\", spin_i, spin_i), ImGui_GetFrameCount()) + ImGui_SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 300), 4 --[[ImGuiCond.FirstUseEver]]) ImGui.Begin(buf) IMGUI_DEMO_MARKER("Examples/Manipulating window titles##3") - ImGui.Text("This window has a changing title.") + ImGui_Text("This window has a changing title.") ImGui.End() return p_open end @@ -33161,95 +33217,95 @@ function ShowExampleAppCustomRendering(p_open) -- types and ImVec2/ImVec4. Dear ImGui defines overloaded operators but they are internal to imgui.cpp and not -- exposed outside (to avoid messing with your types) In this example we are not using the maths operators! - if ImGui.BeginTabBar("##TabBar") then + if ImGui_BeginTabBar("##TabBar") then if ImGui.BeginTabItem("Primitives") then IMGUI_DEMO_MARKER("Examples/Custom rendering/Primitives") - ImGui.PushItemWidth(-ImGui.GetFontSize() * 15) - ImGui.PushItemFlag(384 --[[ImGuiItemFlags.LiveEditOnInput]], true) - local draw_list = ImGui.GetWindowDrawList() + ImGui_PushItemWidth(-ImGui_GetFontSize() * 15) + ImGui_PushItemFlag(384 --[[ImGuiItemFlags.LiveEditOnInput]], true) + local draw_list = ImGui_GetWindowDrawList() -- Draw gradients -- (note that those are currently exacerbating our sRGB/Linear issues) -- Calling ImGui.GetColorU32() multiplies the given colors by the current Style Alpha, but you may pass the IM_COL32() directly as well.. -- [Port] GetColorU32(u32, nil, true): the ImU32 overload is selected explicitly - ImGui.Text("Gradients") - local gradient_size = ImVec2(ImGui.CalcItemWidth(), ImGui.GetFrameHeight()) + ImGui_Text("Gradients") + local gradient_size = ImVec2(ImGui_CalcItemWidth(), ImGui_GetFrameHeight()) do - ImGui.InvisibleButton("##gradient1", gradient_size) - local col_a = ImGui.GetColorU32(IM_COL32(0, 0, 0, 255), nil, true) - local col_b = ImGui.GetColorU32(IM_COL32(255, 255, 255, 255), nil, true) - draw_list:AddRectFilledMultiColor(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), col_a, col_b, col_b, col_a) + ImGui_InvisibleButton("##gradient1", gradient_size) + local col_a = ImGui_GetColorU32(IM_COL32(0, 0, 0, 255), nil, true) + local col_b = ImGui_GetColorU32(IM_COL32(255, 255, 255, 255), nil, true) + draw_list:AddRectFilledMultiColor(ImGui_GetItemRectMin(), ImGui_GetItemRectMax(), col_a, col_b, col_b, col_a) end do - ImGui.InvisibleButton("##gradient2", gradient_size) - local col_a = ImGui.GetColorU32(IM_COL32(0, 255, 0, 255), nil, true) - local col_b = ImGui.GetColorU32(IM_COL32(255, 0, 0, 255), nil, true) - draw_list:AddRectFilledMultiColor(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), col_a, col_b, col_b, col_a) + ImGui_InvisibleButton("##gradient2", gradient_size) + local col_a = ImGui_GetColorU32(IM_COL32(0, 255, 0, 255), nil, true) + local col_b = ImGui_GetColorU32(IM_COL32(255, 0, 0, 255), nil, true) + draw_list:AddRectFilledMultiColor(ImGui_GetItemRectMin(), ImGui_GetItemRectMax(), col_a, col_b, col_b, col_a) end -- Draw a bunch of primitives - ImGui.Text("All primitives") + ImGui_Text("All primitives") - s.sz = ImGui.DragFloat("Size", s.sz, 0.2, 0.2, 100.0, "%.0f") + s.sz = ImGui_DragFloat("Size", s.sz, 0.2, 0.2, 100.0, "%.0f") local rounding_anim_period = 3.0 - local rounding_wave = 1.0 - math.abs(math.fmod(ImGui.GetTime(), rounding_anim_period) * (2.0 / rounding_anim_period) - 1.0) + local rounding_wave = 1.0 - math.abs(math.fmod(ImGui_GetTime(), rounding_anim_period) * (2.0 / rounding_anim_period) - 1.0) local rounding = s.animate_rounding and math.floor(rounding_wave * s.base_rounding * 10.0) / 10.0 or s.base_rounding -- Sub-integer rounding works but has discontinuities in small values, so best disable we - s.base_rounding = ImGui.DragFloat("Rounding", s.base_rounding, 0.02, 0.0, 32.0, "%.1f"); ImGui.SameLine() - _, s.animate_rounding = ImGui.Checkbox("Animate##rounding", s.animate_rounding); ImGui.SameLine() - ImGui.Text("%.2f", rounding) + s.base_rounding = ImGui_DragFloat("Rounding", s.base_rounding, 0.02, 0.0, 32.0, "%.1f"); ImGui_SameLine() + _, s.animate_rounding = ImGui_Checkbox("Animate##rounding", s.animate_rounding); ImGui_SameLine() + ImGui_Text("%.2f", rounding) local thickness_anim_period = 5.0 - local thickness_wave = 1.0 - math.abs(math.fmod(ImGui.GetTime(), thickness_anim_period) * (2.0 / thickness_anim_period) - 1.0) + local thickness_wave = 1.0 - math.abs(math.fmod(ImGui_GetTime(), thickness_anim_period) * (2.0 / thickness_anim_period) - 1.0) local thickness = s.animate_thickness and thickness_wave * s.base_thickness or s.base_thickness - s.base_thickness = ImGui.DragFloat("Thickness", s.base_thickness, 0.02, 0.0, 32.0, "%.02f"); ImGui.SameLine() - _, s.animate_thickness = ImGui.Checkbox("Animate##thickness", s.animate_thickness); ImGui.SameLine() - ImGui.Text("%.2f", thickness) + s.base_thickness = ImGui_DragFloat("Thickness", s.base_thickness, 0.02, 0.0, 32.0, "%.02f"); ImGui_SameLine() + _, s.animate_thickness = ImGui_Checkbox("Animate##thickness", s.animate_thickness); ImGui_SameLine() + ImGui_Text("%.2f", thickness) local changed - s.ngon_segments = ImGui.SliderInt("N-gon sides", s.ngon_segments, 3, 12) - _, s.circle_segments_override = ImGui.Checkbox("##CircleSegmentOverride", s.circle_segments_override) - ImGui.SameLine(0.0, ImGui.GetStyle().ItemInnerSpacing.x) - s.circle_segments_override_v, changed = ImGui.SliderInt("Circle segments override", s.circle_segments_override_v, 3, 30) + s.ngon_segments = ImGui_SliderInt("N-gon sides", s.ngon_segments, 3, 12) + _, s.circle_segments_override = ImGui_Checkbox("##CircleSegmentOverride", s.circle_segments_override) + ImGui_SameLine(0.0, ImGui_GetStyle().ItemInnerSpacing.x) + s.circle_segments_override_v, changed = ImGui_SliderInt("Circle segments override", s.circle_segments_override_v, 3, 30) s.circle_segments_override = s.circle_segments_override or changed - _, s.curve_segments_override = ImGui.Checkbox("##CurvesSegmentOverride", s.curve_segments_override) - ImGui.SameLine(0.0, ImGui.GetStyle().ItemInnerSpacing.x) - s.curve_segments_override_v, changed = ImGui.SliderInt("Curves segments override", s.curve_segments_override_v, 3, 30) + _, s.curve_segments_override = ImGui_Checkbox("##CurvesSegmentOverride", s.curve_segments_override) + ImGui_SameLine(0.0, ImGui_GetStyle().ItemInnerSpacing.x) + s.curve_segments_override_v, changed = ImGui_SliderInt("Curves segments override", s.curve_segments_override_v, 3, 30) s.curve_segments_override = s.curve_segments_override or changed - ImGui.ColorEdit4("Stroke Color", s.colf_stroke) - ImGui.ColorEdit4("Fill Color", s.colf_fill) + ImGui_ColorEdit4("Stroke Color", s.colf_stroke) + ImGui_ColorEdit4("Fill Color", s.colf_fill) - ImGui.SeparatorText("Per primitive flags (AddXXX functions)") - _, s.prim_stroke_flags = ImGui.RadioButton("Default", s.prim_stroke_flags, 0 --[[ImDrawFlags.None]]); ImGui.SameLine() - _, s.prim_stroke_flags = ImGui.RadioButton("Inside", s.prim_stroke_flags, 131072 --[[ImDrawFlags.StrokeInside]]); ImGui.SameLine() - _, s.prim_stroke_flags = ImGui.RadioButton("Center", s.prim_stroke_flags, 262144 --[[ImDrawFlags.StrokeCenter]]); ImGui.SameLine() - _, s.prim_stroke_flags = ImGui.RadioButton("CenterBiased", s.prim_stroke_flags, 393216 --[[ImDrawFlags.StrokeCenterBiased]]); ImGui.SameLine() - _, s.prim_stroke_flags = ImGui.RadioButton("Outside", s.prim_stroke_flags, 524288 --[[ImDrawFlags.StrokeOutside]]); ImGui.SameLine() - _, s.prim_stroke_flags = ImGui.RadioButton("Legacy", s.prim_stroke_flags, 917504 --[[ImDrawFlags.StrokeLegacy]]) - _, s.prim_other_flags = ImGui.CheckboxFlags("AAFill", s.prim_other_flags, 4096 --[[ImDrawFlags.AAFill]]); ImGui.SameLine() -- Note: Only for functions taking flags. - _, s.prim_other_flags = ImGui.CheckboxFlags("AALines", s.prim_other_flags, 8192 --[[ImDrawFlags.AALines]]); ImGui.SameLine() -- Note: Only for functions taking flags. - _, s.prim_other_flags = ImGui.CheckboxFlags("AALineEnds", s.prim_other_flags, 16384 --[[ImDrawFlags.AALineEnds]]); ImGui.SameLine() - _, s.prim_other_flags = ImGui.CheckboxFlags("JoinMiter", s.prim_other_flags, 1024 --[[ImDrawFlags.JoinMiter]]); ImGui.SameLine() - _, s.prim_other_flags = ImGui.CheckboxFlags("CapSquare", s.prim_other_flags, 2048 --[[ImDrawFlags.CapSquare]]) + ImGui_SeparatorText("Per primitive flags (AddXXX functions)") + _, s.prim_stroke_flags = ImGui_RadioButton("Default", s.prim_stroke_flags, 0 --[[ImDrawFlags.None]]); ImGui_SameLine() + _, s.prim_stroke_flags = ImGui_RadioButton("Inside", s.prim_stroke_flags, 131072 --[[ImDrawFlags.StrokeInside]]); ImGui_SameLine() + _, s.prim_stroke_flags = ImGui_RadioButton("Center", s.prim_stroke_flags, 262144 --[[ImDrawFlags.StrokeCenter]]); ImGui_SameLine() + _, s.prim_stroke_flags = ImGui_RadioButton("CenterBiased", s.prim_stroke_flags, 393216 --[[ImDrawFlags.StrokeCenterBiased]]); ImGui_SameLine() + _, s.prim_stroke_flags = ImGui_RadioButton("Outside", s.prim_stroke_flags, 524288 --[[ImDrawFlags.StrokeOutside]]); ImGui_SameLine() + _, s.prim_stroke_flags = ImGui_RadioButton("Legacy", s.prim_stroke_flags, 917504 --[[ImDrawFlags.StrokeLegacy]]) + _, s.prim_other_flags = ImGui_CheckboxFlags("AAFill", s.prim_other_flags, 4096 --[[ImDrawFlags.AAFill]]); ImGui_SameLine() -- Note: Only for functions taking flags. + _, s.prim_other_flags = ImGui_CheckboxFlags("AALines", s.prim_other_flags, 8192 --[[ImDrawFlags.AALines]]); ImGui_SameLine() -- Note: Only for functions taking flags. + _, s.prim_other_flags = ImGui_CheckboxFlags("AALineEnds", s.prim_other_flags, 16384 --[[ImDrawFlags.AALineEnds]]); ImGui_SameLine() + _, s.prim_other_flags = ImGui_CheckboxFlags("JoinMiter", s.prim_other_flags, 1024 --[[ImDrawFlags.JoinMiter]]); ImGui_SameLine() + _, s.prim_other_flags = ImGui_CheckboxFlags("CapSquare", s.prim_other_flags, 2048 --[[ImDrawFlags.CapSquare]]) --ImGui.CheckboxFlags("UseTexForRoundCorners", &prim_other_flags, ImDrawFlags_UseTexForRoundCorners); if s.scope_flags == nil then s.scope_flags = bit32.band(draw_list.Flags, 8286704 --[[ImDrawFlags.AllowInPushScope_]]) end -- First init copy current state. - ImGui.SeparatorText("Current ImDrawList flags (e.g. PushDrawFlag function)") - ImGui.PushID("ScopeFlags") - _, s.scope_flags = ImGui.CheckboxFlags("AAFill", s.scope_flags, 4096 --[[ImDrawFlags.AAFill]]); ImGui.SameLine() - _, s.scope_flags = ImGui.CheckboxFlags("AALines", s.scope_flags, 8192 --[[ImDrawFlags.AALines]]); ImGui.SameLine() - _, s.scope_flags = ImGui.CheckboxFlags("AALineEnds", s.scope_flags, 16384 --[[ImDrawFlags.AALineEnds]]); ImGui.SameLine() - _, s.scope_flags = ImGui.CheckboxFlags("StrokeLegacy", s.scope_flags, 917504 --[[ImDrawFlags.StrokeLegacy]]) + ImGui_SeparatorText("Current ImDrawList flags (e.g. PushDrawFlag function)") + ImGui_PushID("ScopeFlags") + _, s.scope_flags = ImGui_CheckboxFlags("AAFill", s.scope_flags, 4096 --[[ImDrawFlags.AAFill]]); ImGui_SameLine() + _, s.scope_flags = ImGui_CheckboxFlags("AALines", s.scope_flags, 8192 --[[ImDrawFlags.AALines]]); ImGui_SameLine() + _, s.scope_flags = ImGui_CheckboxFlags("AALineEnds", s.scope_flags, 16384 --[[ImDrawFlags.AALineEnds]]); ImGui_SameLine() + _, s.scope_flags = ImGui_CheckboxFlags("StrokeLegacy", s.scope_flags, 917504 --[[ImDrawFlags.StrokeLegacy]]) --ImGui.CheckboxFlags("UseTexForRoundCorners", &scope_flags, ImDrawFlags_UseTexForRoundCorners); - ImGui.PopID() - ImGui.Spacing() + ImGui_PopID() + ImGui_Spacing() draw_list:PushDrawFlag(8286704 --[[ImDrawFlags.AllowInPushScope_]], false) -- Reset all existing (very unusual: done for this demo) draw_list:PushDrawFlag(s.scope_flags, true) local flags = bit32.bor(s.prim_stroke_flags, s.prim_other_flags) local sz = s.sz - local start_pos = ImGui.GetCursorScreenPos() + local start_pos = ImGui_GetCursorScreenPos() local pi = 3.141592 local step = sz + 10.0 local corners_tl_br = bit32.bor(16 --[[ImDrawFlags.RoundTopLeft]], 128 --[[ImDrawFlags.RoundBottomRight]]) @@ -33262,7 +33318,7 @@ function ShowExampleAppCustomRendering(p_open) local zigzag_shape = { ImVec2(0.0, 0.0), ImVec2(0.9, 0.0), ImVec2(1.0, 0.1), ImVec2(1.0, 0.9), ImVec2(0.9, 1.0), ImVec2(0.3, 1.0), ImVec2(0.3, 0.4), ImVec2(0.9, 0.4) } local rotating_square = {} -- 1-based for side = 0, 4 - 1 do - local t = ImGui.GetTime() * 0.1 + side * pi * 0.5 + local t = ImGui_GetTime() * 0.1 + side * pi * 0.5 rotating_square[side + 1] = ImVec2(math.cos(t) * half_sz, math.sin(t) * half_sz) end @@ -33406,16 +33462,16 @@ function ShowExampleAppCustomRendering(p_open) y = y + step end - ImGui.Dummy(ImVec2(step * 15.5, step * 4.0)) + ImGui_Dummy(ImVec2(step * 15.5, step * 4.0)) draw_list:PopDrawFlag() draw_list:PopDrawFlag() - ImGui.Text("ImDrawList Vector Rendering Reference:") - ImGui.TextLinkOpenURL("https://github.com/ocornut/imgui/wiki/Draw-List") + ImGui_Text("ImDrawList Vector Rendering Reference:") + ImGui_TextLinkOpenURL("https://github.com/ocornut/imgui/wiki/Draw-List") - ImGui.PopItemFlag() - ImGui.PopItemWidth() - ImGui.EndTabItem() + ImGui_PopItemFlag() + ImGui_PopItemWidth() + ImGui_EndTabItem() end if ImGui.BeginTabItem("Canvas") then @@ -33423,9 +33479,9 @@ function ShowExampleAppCustomRendering(p_open) local points = s.points local scrolling = s.scrolling - _, s.opt_enable_grid = ImGui.Checkbox("Enable grid", s.opt_enable_grid) - _, s.opt_enable_context_menu = ImGui.Checkbox("Enable context menu", s.opt_enable_context_menu) - ImGui.Text("Mouse Left: drag to add lines,\nMouse Right: drag to scroll, click for context menu.") + _, s.opt_enable_grid = ImGui_Checkbox("Enable grid", s.opt_enable_grid) + _, s.opt_enable_context_menu = ImGui_Checkbox("Enable context menu", s.opt_enable_context_menu) + ImGui_Text("Mouse Left: drag to add lines,\nMouse Right: drag to scroll, click for context menu.") -- Typically you would use a BeginChild()/EndChild() pair to benefit from a clipping region + own scrolling. -- Here we demonstrate that this can be replaced by simple offsetting + custom drawing + PushClipRect/PopClipRect() calls. @@ -33439,34 +33495,34 @@ function ShowExampleAppCustomRendering(p_open) -- ImGui.EndChild() -- Using InvisibleButton() as a convenience 1) it will advance the layout cursor and 2) allows us to use IsItemHovered()/IsItemActive() - local canvas_p0 = ImGui.GetCursorScreenPos() -- ImDrawList API uses screen coordinates! - local canvas_sz = ImGui.GetContentRegionAvail() -- Resize canvas to what's available + local canvas_p0 = ImGui_GetCursorScreenPos() -- ImDrawList API uses screen coordinates! + local canvas_sz = ImGui_GetContentRegionAvail() -- Resize canvas to what's available if canvas_sz.x < 50.0 then canvas_sz.x = 50.0 end if canvas_sz.y < 50.0 then canvas_sz.y = 50.0 end local canvas_p1 = ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y) -- Draw border and background color - local io = ImGui.GetIO() - local draw_list = ImGui.GetWindowDrawList() + local io = ImGui_GetIO() + local draw_list = ImGui_GetWindowDrawList() draw_list:AddRectFilled(canvas_p0, canvas_p1, IM_COL32(50, 50, 50, 255)) draw_list:AddRect(canvas_p0, canvas_p1, IM_COL32(255, 255, 255, 255)) -- This will catch our interactions - ImGui.InvisibleButton("canvas", canvas_sz, bit32.bor(1 --[[ImGuiButtonFlags.MouseButtonLeft]], 2 --[[ImGuiButtonFlags.MouseButtonRight]])) - local is_hovered = ImGui.IsItemHovered() -- Hovered - local is_active = ImGui.IsItemActive() -- Held + ImGui_InvisibleButton("canvas", canvas_sz, bit32.bor(1 --[[ImGuiButtonFlags.MouseButtonLeft]], 2 --[[ImGuiButtonFlags.MouseButtonRight]])) + local is_hovered = ImGui_IsItemHovered() -- Hovered + local is_active = ImGui_IsItemActive() -- Held local origin = ImVec2(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y) -- Lock scrolled origin local mouse_pos_in_canvas = ImVec2(io.MousePos.x - origin.x, io.MousePos.y - origin.y) -- Add first and second point - if is_hovered and not s.adding_line and ImGui.IsMouseClicked(0 --[[ImGuiMouseButton.Left]]) then + if is_hovered and not s.adding_line and ImGui_IsMouseClicked(0 --[[ImGuiMouseButton.Left]]) then points:push_back(ImVec2(mouse_pos_in_canvas.x, mouse_pos_in_canvas.y)) -- [Port] copies: ImVector stores references points:push_back(ImVec2(mouse_pos_in_canvas.x, mouse_pos_in_canvas.y)) s.adding_line = true end if s.adding_line then ImVec2_Copy(points:back(), mouse_pos_in_canvas) - if not ImGui.IsMouseDown(0 --[[ImGuiMouseButton.Left]]) then + if not ImGui_IsMouseDown(0 --[[ImGuiMouseButton.Left]]) then s.adding_line = false end end @@ -33474,24 +33530,24 @@ function ShowExampleAppCustomRendering(p_open) -- Pan (we use a zero mouse threshold when there's no context menu) -- You may decide to make that threshold dynamic based on whether the mouse is hovering something etc. local mouse_threshold_for_pan = s.opt_enable_context_menu and -1.0 or 0.0 - if is_active and ImGui.IsMouseDragging(1 --[[ImGuiMouseButton.Right]], mouse_threshold_for_pan) then + if is_active and ImGui_IsMouseDragging(1 --[[ImGuiMouseButton.Right]], mouse_threshold_for_pan) then scrolling.x = scrolling.x + io.MouseDelta.x scrolling.y = scrolling.y + io.MouseDelta.y end -- Context menu (under default mouse threshold) - local drag_delta = ImGui.GetMouseDragDelta(1 --[[ImGuiMouseButton.Right]]) + local drag_delta = ImGui_GetMouseDragDelta(1 --[[ImGuiMouseButton.Right]]) if s.opt_enable_context_menu and drag_delta.x == 0.0 and drag_delta.y == 0.0 then - ImGui.OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) + ImGui_OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) end - if ImGui.BeginPopup("context") then + if ImGui_BeginPopup("context") then if s.adding_line then points:resize(points.Size - 2) end s.adding_line = false - if ImGui.MenuItem("Remove one", nil, false, points.Size > 0) then points:resize(points.Size - 2) end - if ImGui.MenuItem("Remove all", nil, false, points.Size > 0) then points:clear() end - ImGui.EndPopup() + if ImGui_MenuItem("Remove one", nil, false, points.Size > 0) then points:resize(points.Size - 2) end + if ImGui_MenuItem("Remove all", nil, false, points.Size > 0) then points:clear() end + ImGui_EndPopup() end -- Draw grid + all lines in the canvas @@ -33514,25 +33570,25 @@ function ShowExampleAppCustomRendering(p_open) end draw_list:PopClipRect() - ImGui.EndTabItem() + ImGui_EndTabItem() end if ImGui.BeginTabItem("BG/FG draw lists") then IMGUI_DEMO_MARKER("Examples/Custom rendering/BG & FG draw lists") - _, s.draw_bg = ImGui.Checkbox("Draw in Background draw list", s.draw_bg) - ImGui.SameLine(); HelpMarker("The Background draw list will be rendered below every Dear ImGui windows.") - _, s.draw_fg = ImGui.Checkbox("Draw in Foreground draw list", s.draw_fg) - ImGui.SameLine(); HelpMarker("The Foreground draw list will be rendered over every Dear ImGui windows.") - local window_pos = ImGui.GetWindowPos() - local window_size = ImGui.GetWindowSize() + _, s.draw_bg = ImGui_Checkbox("Draw in Background draw list", s.draw_bg) + ImGui_SameLine(); HelpMarker("The Background draw list will be rendered below every Dear ImGui windows.") + _, s.draw_fg = ImGui_Checkbox("Draw in Foreground draw list", s.draw_fg) + ImGui_SameLine(); HelpMarker("The Foreground draw list will be rendered over every Dear ImGui windows.") + local window_pos = ImGui_GetWindowPos() + local window_size = ImGui_GetWindowSize() local window_center = ImVec2(window_pos.x + window_size.x * 0.5, window_pos.y + window_size.y * 0.5) if s.draw_bg then - ImGui.GetBackgroundDrawList():AddCircle(window_center, window_size.x * 0.6, IM_COL32(255, 0, 0, 200), 0, 10 + 4) + ImGui_GetBackgroundDrawList():AddCircle(window_center, window_size.x * 0.6, IM_COL32(255, 0, 0, 200), 0, 10 + 4) end if s.draw_fg then - ImGui.GetForegroundDrawList():AddCircle(window_center, window_size.y * 0.6, IM_COL32(0, 255, 0, 200), 0, 10) + ImGui_GetForegroundDrawList():AddCircle(window_center, window_size.y * 0.6, IM_COL32(0, 255, 0, 200), 0, 10) end - ImGui.EndTabItem() + ImGui_EndTabItem() end -- Demonstrate out-of-order rendering via channels splitting @@ -33540,20 +33596,20 @@ function ShowExampleAppCustomRendering(p_open) -- but you can also instantiate your own ImDrawListSplitter if you need to nest them. if ImGui.BeginTabItem("Draw Channels") then IMGUI_DEMO_MARKER("Examples/Custom rendering/Draw Channels") - local draw_list = ImGui.GetWindowDrawList() + local draw_list = ImGui_GetWindowDrawList() do - ImGui.Text("Blue shape is drawn first: appears in back") - ImGui.Text("Red shape is drawn after: appears in front") - local p0 = ImGui.GetCursorScreenPos() + ImGui_Text("Blue shape is drawn first: appears in back") + ImGui_Text("Red shape is drawn after: appears in front") + local p0 = ImGui_GetCursorScreenPos() draw_list:AddRectFilled(ImVec2(p0.x, p0.y), ImVec2(p0.x + 50, p0.y + 50), IM_COL32(0, 0, 255, 255)) -- Blue draw_list:AddRectFilled(ImVec2(p0.x + 25, p0.y + 25), ImVec2(p0.x + 75, p0.y + 75), IM_COL32(255, 0, 0, 255)) -- Red - ImGui.Dummy(ImVec2(75, 75)) + ImGui_Dummy(ImVec2(75, 75)) end - ImGui.Separator() + ImGui_Separator() do - ImGui.Text("Blue shape is drawn first, into channel 1: appears in front") - ImGui.Text("Red shape is drawn after, into channel 0: appears in back") - local p1 = ImGui.GetCursorScreenPos() + ImGui_Text("Blue shape is drawn first, into channel 1: appears in front") + ImGui_Text("Red shape is drawn after, into channel 0: appears in back") + local p1 = ImGui_GetCursorScreenPos() -- Create 2 channels and draw a Blue shape THEN a Red shape. -- You can create any number of channels. Tables API use 1 channel per column in order to better batch draw calls. @@ -33566,13 +33622,13 @@ function ShowExampleAppCustomRendering(p_open) -- Flatten/reorder channels. Red shape is in channel 0 and it appears below the Blue shape in channel 1. -- This works by copying draw indices only (vertices are not copied). draw_list:ChannelsMerge() - ImGui.Dummy(ImVec2(75, 75)) - ImGui.Text("After reordering, contents of channel 0 appears below channel 1.") + ImGui_Dummy(ImVec2(75, 75)) + ImGui_Text("After reordering, contents of channel 0 appears below channel 1.") end - ImGui.EndTabItem() + ImGui_EndTabItem() end - ImGui.EndTabBar() + ImGui_EndTabBar() end ImGui.End() @@ -33612,12 +33668,12 @@ function ShowExampleAppDockSpaceAdvanced(args, p_open) local window_flags = 524288 --[[ImGuiWindowFlags.NoDocking]] if args.IsFullscreen then -- Fullscreen dockspace: practically the same as calling DockSpaceOverViewport(); - local viewport = ImGui.GetMainViewport() - ImGui.SetNextWindowPos(viewport.WorkPos) - ImGui.SetNextWindowSize(viewport.WorkSize) - ImGui.SetNextWindowViewport(viewport.ID) - ImGui.PushStyleVar(3 --[[ImGuiStyleVar.WindowRounding]], 0.0) - ImGui.PushStyleVar(4 --[[ImGuiStyleVar.WindowBorderSize]], 0.0) + local viewport = ImGui_GetMainViewport() + ImGui_SetNextWindowPos(viewport.WorkPos) + ImGui_SetNextWindowSize(viewport.WorkSize) + ImGui_SetNextWindowViewport(viewport.ID) + ImGui_PushStyleVar(3 --[[ImGuiStyleVar.WindowRounding]], 0.0) + ImGui_PushStyleVar(4 --[[ImGuiStyleVar.WindowBorderSize]], 0.0) window_flags = bit32.bor(window_flags, 1 --[[ImGuiWindowFlags.NoTitleBar]], 32 --[[ImGuiWindowFlags.NoCollapse]], 2 --[[ImGuiWindowFlags.NoResize]], 4 --[[ImGuiWindowFlags.NoMove]]) window_flags = bit32.bor(window_flags, 8192 --[[ImGuiWindowFlags.NoBringToFrontOnFocus]], 131072 --[[ImGuiWindowFlags.NoNavFocus]]) window_flags = bit32.bor(window_flags, 128 --[[ImGuiWindowFlags.NoBackground]]) @@ -33632,22 +33688,22 @@ function ShowExampleAppDockSpaceAdvanced(args, p_open) -- We cannot preserve the docking relationship between an active window and an inactive docking, otherwise -- any change of dockspace/settings would lead to windows being stuck in limbo and never being visible. if not args.KeepWindowPadding then - ImGui.PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0.0, 0.0)) + ImGui_PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0.0, 0.0)) end p_open = ImGui.Begin("Window with a DockSpace", p_open, window_flags) if not args.KeepWindowPadding then - ImGui.PopStyleVar() + ImGui_PopStyleVar() end if args.IsFullscreen then - ImGui.PopStyleVar(2) + ImGui_PopStyleVar(2) end -- Submit the DockSpace widget inside our window -- - Note that the id here is different from the one used by DockSpaceOverViewport(), so docking state won't get transfered between "Basic" and "Advanced" demos. -- - If we made the ShowExampleAppDockSpaceBasic() calculate its own ID and pass it to DockSpaceOverViewport() the ID could easily match. - local dockspace_id = ImGui.GetID("MyDockSpace") - ImGui.DockSpace(dockspace_id, ImVec2(0.0, 0.0), dockspace_flags) + local dockspace_id = ImGui_GetID("MyDockSpace") + ImGui_DockSpace(dockspace_id, ImVec2(0.0, 0.0), dockspace_flags) ImGui.End() return p_open @@ -33663,7 +33719,7 @@ function ShowExampleAppDockSpaceBasic(flags) -- local viewport = ImGui.GetMainViewport(); -- ImGui.DockSpaceOverViewport(0, viewport, ImGuiDockNodeFlags.None); - ImGui.DockSpaceOverViewport(0, nil, flags) + ImGui_DockSpaceOverViewport(0, nil, flags) end S.ShowExampleAppDockSpace = { @@ -33683,56 +33739,56 @@ function ShowExampleAppDockSpace(p_open) -- Refocus our window to minimize perceived loss of focus when changing mode (caused by the fact that each use a different window, which would not happen in a real app) if s.opt_demo_mode_changed then - ImGui.SetNextWindowFocus() + ImGui_SetNextWindowFocus() end p_open = ImGui.Begin("Examples: Dockspace", p_open, 1024 --[[ImGuiWindowFlags.MenuBar]]) s.opt_demo_mode_changed = false local pressed - pressed, s.opt_demo_mode = ImGui.RadioButton("Basic demo mode", s.opt_demo_mode, 0) + pressed, s.opt_demo_mode = ImGui_RadioButton("Basic demo mode", s.opt_demo_mode, 0) s.opt_demo_mode_changed = s.opt_demo_mode_changed or pressed - pressed, s.opt_demo_mode = ImGui.RadioButton("Advanced demo mode", s.opt_demo_mode, 1) + pressed, s.opt_demo_mode = ImGui_RadioButton("Advanced demo mode", s.opt_demo_mode, 1) s.opt_demo_mode_changed = s.opt_demo_mode_changed or pressed - ImGui.SeparatorText("Options") + ImGui_SeparatorText("Options") - if bit32.band(ImGui.GetIO().ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) == 0 then + if bit32.band(ImGui_GetIO().ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) == 0 then ShowDockingDisabledMessage() elseif s.opt_demo_mode == 0 then args.DockSpaceFlags = bit32.band(args.DockSpaceFlags, 8 --[[ImGuiDockNodeFlags.PassthruCentralNode]]) -- Allowed flags - _, args.DockSpaceFlags = ImGui.CheckboxFlags("Flag: PassthruCentralNode", args.DockSpaceFlags, 8 --[[ImGuiDockNodeFlags.PassthruCentralNode]]) + _, args.DockSpaceFlags = ImGui_CheckboxFlags("Flag: PassthruCentralNode", args.DockSpaceFlags, 8 --[[ImGuiDockNodeFlags.PassthruCentralNode]]) elseif s.opt_demo_mode == 1 then - _, args.IsFullscreen = ImGui.Checkbox("Fullscreen", args.IsFullscreen) - _, args.KeepWindowPadding = ImGui.Checkbox("Keep Window Padding", args.KeepWindowPadding) - ImGui.SameLine() + _, args.IsFullscreen = ImGui_Checkbox("Fullscreen", args.IsFullscreen) + _, args.KeepWindowPadding = ImGui_Checkbox("Keep Window Padding", args.KeepWindowPadding) + ImGui_SameLine() HelpMarker("This is mostly exposed to facilitate understanding that a DockSpace() is _inside_ a window.") - ImGui.BeginDisabled(args.IsFullscreen == false) - _, args.DockSpaceFlags = ImGui.CheckboxFlags("Flag: PassthruCentralNode", args.DockSpaceFlags, 8 --[[ImGuiDockNodeFlags.PassthruCentralNode]]) - ImGui.EndDisabled() - _, args.DockSpaceFlags = ImGui.CheckboxFlags("Flag: NoDockingOverCentralNode", args.DockSpaceFlags, 4 --[[ImGuiDockNodeFlags.NoDockingOverCentralNode]]) - _, args.DockSpaceFlags = ImGui.CheckboxFlags("Flag: NoDockingSplit", args.DockSpaceFlags, 16 --[[ImGuiDockNodeFlags.NoDockingSplit]]) - _, args.DockSpaceFlags = ImGui.CheckboxFlags("Flag: NoUndocking", args.DockSpaceFlags, 128 --[[ImGuiDockNodeFlags.NoUndocking]]) - _, args.DockSpaceFlags = ImGui.CheckboxFlags("Flag: NoResize", args.DockSpaceFlags, 32 --[[ImGuiDockNodeFlags.NoResize]]) - _, args.DockSpaceFlags = ImGui.CheckboxFlags("Flag: AutoHideTabBar", args.DockSpaceFlags, 64 --[[ImGuiDockNodeFlags.AutoHideTabBar]]) + ImGui_BeginDisabled(args.IsFullscreen == false) + _, args.DockSpaceFlags = ImGui_CheckboxFlags("Flag: PassthruCentralNode", args.DockSpaceFlags, 8 --[[ImGuiDockNodeFlags.PassthruCentralNode]]) + ImGui_EndDisabled() + _, args.DockSpaceFlags = ImGui_CheckboxFlags("Flag: NoDockingOverCentralNode", args.DockSpaceFlags, 4 --[[ImGuiDockNodeFlags.NoDockingOverCentralNode]]) + _, args.DockSpaceFlags = ImGui_CheckboxFlags("Flag: NoDockingSplit", args.DockSpaceFlags, 16 --[[ImGuiDockNodeFlags.NoDockingSplit]]) + _, args.DockSpaceFlags = ImGui_CheckboxFlags("Flag: NoUndocking", args.DockSpaceFlags, 128 --[[ImGuiDockNodeFlags.NoUndocking]]) + _, args.DockSpaceFlags = ImGui_CheckboxFlags("Flag: NoResize", args.DockSpaceFlags, 32 --[[ImGuiDockNodeFlags.NoResize]]) + _, args.DockSpaceFlags = ImGui_CheckboxFlags("Flag: AutoHideTabBar", args.DockSpaceFlags, 64 --[[ImGuiDockNodeFlags.AutoHideTabBar]]) end -- Show demo options and help - if ImGui.BeginMenuBar() then - if ImGui.BeginMenu("Help") then - ImGui.TextUnformatted( + if ImGui_BeginMenuBar() then + if ImGui_BeginMenu("Help") then + ImGui_TextUnformatted( "This demonstrates the use of ImGui::DockSpace() which allows you to manually\ncreate a docking node _within_ another window." .. "\n" .. "The \"Basic\" version uses the ImGui::DockSpaceOverViewport() helper. Most applications can probably use this.") - ImGui.Separator() - ImGui.TextUnformatted("When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" .. "\n" .. + ImGui_Separator() + ImGui_TextUnformatted("When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" .. "\n" .. "- Drag from window title bar or their tab to dock/undock." .. "\n" .. "- Drag from window menu button (upper-left button) to undock an entire node (all windows)." .. "\n" .. "- Hold SHIFT to disable docking (if io.ConfigDockingWithShift == false, default)" .. "\n" .. "- Hold SHIFT to enable docking (if io.ConfigDockingWithShift == true)") - ImGui.Separator() - ImGui.TextUnformatted("More details:"); ImGui.Bullet(); ImGui.SameLine(); ImGui.TextLinkOpenURL("Docking Wiki page", "https://github.com/ocornut/imgui/wiki/Docking") - ImGui.BulletText("Read comments in ShowExampleAppDockSpace()") - ImGui.EndMenu() + ImGui_Separator() + ImGui_TextUnformatted("More details:"); ImGui_Bullet(); ImGui_SameLine(); ImGui_TextLinkOpenURL("Docking Wiki page", "https://github.com/ocornut/imgui/wiki/Docking") + ImGui_BulletText("Read comments in ShowExampleAppDockSpace()") + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end ImGui.End() @@ -33757,7 +33813,7 @@ function MyDocument(uid, name, open, color) if color == nil then color = ImVec4(1.0, 1.0, 1.0, 1.0) end local self = setmetatable({}, MyDocumentMT) self.UID = uid - self.Name = ImGui.NewTextBuffer(name, 32) + self.Name = ImGui_NewTextBuffer(name, 32) self.Open = open; self.OpenPrev = open self.Dirty = false self.Color = color @@ -33787,61 +33843,61 @@ end -- As we allow to change document name, we append a never-changing document ID so tabs are stable function ExampleAppDocumentsMT:GetTabName(doc) -- [Port] returns the string instead of filling out_buf - return string.format("%s###doc%d", ImGui.TextBufferToString(doc.Name), doc.UID) + return string.format("%s###doc%d", ImGui_TextBufferToString(doc.Name), doc.UID) end -- Display placeholder contents for the Document function ExampleAppDocumentsMT:DisplayDocContents(doc) - ImGui.PushID(doc.UID) -- [Port] PushID(doc): no pointer IDs, UID is unique - ImGui.Text("Document \"%s\"", ImGui.TextBufferToString(doc.Name)) - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], doc.Color) - ImGui.TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.") - ImGui.PopStyleColor() + ImGui_PushID(doc.UID) -- [Port] PushID(doc): no pointer IDs, UID is unique + ImGui_Text("Document \"%s\"", ImGui_TextBufferToString(doc.Name)) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], doc.Color) + ImGui_TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.") + ImGui_PopStyleColor() - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 563 --[[ImGuiKey.R]]), 262144 --[[ImGuiInputFlags.Tooltip]]) - if ImGui.Button("Rename..") then + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 563 --[[ImGuiKey.R]]), 262144 --[[ImGuiInputFlags.Tooltip]]) + if ImGui_Button("Rename..") then self.RenamingDoc = doc self.RenamingStarted = true end - ImGui.SameLine() + ImGui_SameLine() - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 558 --[[ImGuiKey.M]]), 262144 --[[ImGuiInputFlags.Tooltip]]) - if ImGui.Button("Modify") then + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 558 --[[ImGuiKey.M]]), 262144 --[[ImGuiInputFlags.Tooltip]]) + if ImGui_Button("Modify") then doc.Dirty = true end - ImGui.SameLine() - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 564 --[[ImGuiKey.S]]), 262144 --[[ImGuiInputFlags.Tooltip]]) - if ImGui.Button("Save") then + ImGui_SameLine() + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 564 --[[ImGuiKey.S]]), 262144 --[[ImGuiInputFlags.Tooltip]]) + if ImGui_Button("Save") then doc:DoSave() end - ImGui.SameLine() - ImGui.SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 568 --[[ImGuiKey.W]]), 262144 --[[ImGuiInputFlags.Tooltip]]) - if ImGui.Button("Close") then + ImGui_SameLine() + ImGui_SetNextItemShortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 568 --[[ImGuiKey.W]]), 262144 --[[ImGuiInputFlags.Tooltip]]) + if ImGui_Button("Close") then self.CloseQueue:push_back(doc) end - ImGui.ColorEdit3("color", doc.Color) -- Useful to test drag and drop and hold-dragged-to-open-tab behavior. - ImGui.PopID() + ImGui_ColorEdit3("color", doc.Color) -- Useful to test drag and drop and hold-dragged-to-open-tab behavior. + ImGui_PopID() end -- Display context menu for the Document function ExampleAppDocumentsMT:DisplayDocContextMenu(doc) - if not ImGui.BeginPopupContextItem() then + if not ImGui_BeginPopupContextItem() then return end - local buf = string.format("Save %s", ImGui.TextBufferToString(doc.Name)) - if ImGui.MenuItem(buf, "Ctrl+S", false, doc.Open) then + local buf = string.format("Save %s", ImGui_TextBufferToString(doc.Name)) + if ImGui_MenuItem(buf, "Ctrl+S", false, doc.Open) then doc:DoSave() end - if ImGui.MenuItem("Rename...", "Ctrl+R", false, doc.Open) then + if ImGui_MenuItem("Rename...", "Ctrl+R", false, doc.Open) then self.RenamingDoc = doc end - if ImGui.MenuItem("Close", "Ctrl+W", false, doc.Open) then + if ImGui_MenuItem("Close", "Ctrl+W", false, doc.Open) then self.CloseQueue:push_back(doc) end - ImGui.EndPopup() + ImGui_EndPopup() end -- [Optional] Notify the system of Tabs/Windows closure that happened outside the regular tab interface. @@ -33855,7 +33911,7 @@ end function ExampleAppDocumentsMT:NotifyOfDocumentsClosedElsewhere() for _, doc in self.Documents:iter() do if not doc.Open and doc.OpenPrev then - ImGui.SetTabItemClosed(ImGui.TextBufferToString(doc.Name)) + ImGui_SetTabItemClosed(ImGui_TextBufferToString(doc.Name)) end doc.OpenPrev = doc.Open end @@ -33894,58 +33950,58 @@ function ShowExampleAppDocuments(p_open) IMGUI_DEMO_MARKER("Examples/Documents") -- Menu - if ImGui.BeginMenuBar() then - if ImGui.BeginMenu("File") then + if ImGui_BeginMenuBar() then + if ImGui_BeginMenu("File") then local open_count = 0 for _, doc in app.Documents:iter() do open_count = open_count + (doc.Open and 1 or 0) end - if ImGui.BeginMenu("Open", open_count < app.Documents.Size) then + if ImGui_BeginMenu("Open", open_count < app.Documents.Size) then for _, doc in app.Documents:iter() do - if not doc.Open and ImGui.MenuItem(ImGui.TextBufferToString(doc.Name)) then + if not doc.Open and ImGui_MenuItem(ImGui_TextBufferToString(doc.Name)) then doc:DoOpen() end end - ImGui.EndMenu() + ImGui_EndMenu() end - if ImGui.MenuItem("Close All Documents", nil, false, open_count > 0) then + if ImGui_MenuItem("Close All Documents", nil, false, open_count > 0) then for _, doc in app.Documents:iter() do app.CloseQueue:push_back(doc) end end - if ImGui.MenuItem("Exit") and p_open ~= nil then + if ImGui_MenuItem("Exit") and p_open ~= nil then p_open = false end - ImGui.EndMenu() + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end -- [Debug] List documents with one checkbox for each for doc_n = 0, app.Documents.Size - 1 do local doc = app.Documents.Data[doc_n + 1] if doc_n > 0 then - ImGui.SameLine() + ImGui_SameLine() end - ImGui.PushID(doc.UID) -- [Port] PushID(&doc): no pointer IDs, UID is unique + ImGui_PushID(doc.UID) -- [Port] PushID(&doc): no pointer IDs, UID is unique local pressed - pressed, doc.Open = ImGui.Checkbox(ImGui.TextBufferToString(doc.Name), doc.Open) + pressed, doc.Open = ImGui_Checkbox(ImGui_TextBufferToString(doc.Name), doc.Open) if pressed then if not doc.Open then doc:DoForceClose() end end - ImGui.PopID() + ImGui_PopID() end - ImGui.PushItemWidth(ImGui.GetFontSize() * 12) - s.opt_target = ImGui.Combo("Output", s.opt_target, "None\0TabBar+Tabs\0DockSpace+Window\0") - ImGui.PopItemWidth() + ImGui_PushItemWidth(ImGui_GetFontSize() * 12) + s.opt_target = ImGui_Combo("Output", s.opt_target, "None\0TabBar+Tabs\0DockSpace+Window\0") + ImGui_PopItemWidth() local redock_all = false - if s.opt_target == Target_Tab then ImGui.SameLine(); _, s.opt_reorderable = ImGui.Checkbox("Reorderable Tabs", s.opt_reorderable) end - if s.opt_target == Target_DockSpaceAndWindow then ImGui.SameLine(); redock_all = ImGui.Button("Redock all") end + if s.opt_target == Target_Tab then ImGui_SameLine(); _, s.opt_reorderable = ImGui_Checkbox("Reorderable Tabs", s.opt_reorderable) end + if s.opt_target == Target_DockSpaceAndWindow then ImGui_SameLine(); redock_all = ImGui_Button("Redock all") end - ImGui.Separator() + ImGui_Separator() -- About the ImGuiWindowFlags.UnsavedDocument / ImGuiTabItemFlags.UnsavedDocument flags. -- They have multiple effects: @@ -33961,7 +34017,7 @@ function ShowExampleAppDocuments(p_open) if s.opt_target == Target_Tab then local tab_bar_flags = bit32.bor(s.opt_fitting_flags, s.opt_reorderable and 1 --[[ImGuiTabBarFlags.Reorderable]] or 0) tab_bar_flags = bit32.bor(tab_bar_flags, 64 --[[ImGuiTabBarFlags.DrawSelectedOverline]]) - if ImGui.BeginTabBar("##tabs", tab_bar_flags) then + if ImGui_BeginTabBar("##tabs", tab_bar_flags) then if s.opt_reorderable then app:NotifyOfDocumentsClosedElsewhere() end @@ -33991,19 +34047,19 @@ function ShowExampleAppDocuments(p_open) app:DisplayDocContextMenu(doc) if visible then app:DisplayDocContents(doc) - ImGui.EndTabItem() + ImGui_EndTabItem() end until true end - ImGui.EndTabBar() + ImGui_EndTabBar() end elseif s.opt_target == Target_DockSpaceAndWindow then - if bit32.band(ImGui.GetIO().ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) ~= 0 then + if bit32.band(ImGui_GetIO().ConfigFlags, 128 --[[ImGuiConfigFlags.DockingEnable]]) ~= 0 then app:NotifyOfDocumentsClosedElsewhere() -- Create a DockSpace node where any window can be docked - local dockspace_id = ImGui.GetID("MyDockSpace") - ImGui.DockSpace(dockspace_id) + local dockspace_id = ImGui_GetID("MyDockSpace") + ImGui_DockSpace(dockspace_id) -- Create Windows for doc_n = 0, app.Documents.Size - 1 do repeat @@ -34012,10 +34068,10 @@ function ShowExampleAppDocuments(p_open) break -- continue end - ImGui.SetNextWindowDockID(dockspace_id, redock_all and 1 --[[ImGuiCond.Always]] or 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowDockID(dockspace_id, redock_all and 1 --[[ImGuiCond.Always]] or 4 --[[ImGuiCond.FirstUseEver]]) local window_flags = (doc.Dirty and 262144 --[[ImGuiWindowFlags.UnsavedDocument]] or 0) local visible - doc.Open, visible = ImGui.Begin(ImGui.TextBufferToString(doc.Name), doc.Open, window_flags) + doc.Open, visible = ImGui.Begin(ImGui_TextBufferToString(doc.Name), doc.Open, window_flags) -- Cancel attempt to close when unsaved add to save queue so we can display a popup. if not doc.Open and doc.Dirty then @@ -34044,18 +34100,18 @@ function ShowExampleAppDocuments(p_open) -- Display renaming UI if app.RenamingDoc ~= nil then if app.RenamingStarted then - ImGui.OpenPopup("Rename") + ImGui_OpenPopup("Rename") end - if ImGui.BeginPopup("Rename") then - ImGui.SetNextItemWidth(ImGui.GetFontSize() * 30) - if ImGui.InputText("###Name", app.RenamingDoc.Name, 32, 64 --[[ImGuiInputTextFlags.EnterReturnsTrue]]) then - ImGui.CloseCurrentPopup() + if ImGui_BeginPopup("Rename") then + ImGui_SetNextItemWidth(ImGui_GetFontSize() * 30) + if ImGui_InputText("###Name", app.RenamingDoc.Name, 32, 64 --[[ImGuiInputTextFlags.EnterReturnsTrue]]) then + ImGui_CloseCurrentPopup() app.RenamingDoc = nil end if app.RenamingStarted then - ImGui.SetKeyboardFocusHere(-1) + ImGui_SetKeyboardFocusHere(-1) end - ImGui.EndPopup() + ImGui_EndPopup() else app.RenamingDoc = nil end @@ -34078,23 +34134,23 @@ function ShowExampleAppDocuments(p_open) end app.CloseQueue:clear() else - if not ImGui.IsPopupOpen("Save?") then - ImGui.OpenPopup("Save?") + if not ImGui_IsPopupOpen("Save?") then + ImGui_OpenPopup("Save?") end - if ImGui.BeginPopupModal("Save?", nil, 64 --[[ImGuiWindowFlags.AlwaysAutoResize]]) then - ImGui.Text("Save change to the following items?") - local item_height = ImGui.GetTextLineHeightWithSpacing() - if ImGui.BeginChild(ImGui.GetID("frame"), ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 6.25 * item_height), 128 --[[ImGuiChildFlags.FrameStyle]]) then + if ImGui_BeginPopupModal("Save?", nil, 64 --[[ImGuiWindowFlags.AlwaysAutoResize]]) then + ImGui_Text("Save change to the following items?") + local item_height = ImGui_GetTextLineHeightWithSpacing() + if ImGui_BeginChild(ImGui_GetID("frame"), ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 6.25 * item_height), 128 --[[ImGuiChildFlags.FrameStyle]]) then for _, doc in app.CloseQueue:iter() do if doc.Dirty then - ImGui.Text("%s", ImGui.TextBufferToString(doc.Name)) + ImGui_Text("%s", ImGui_TextBufferToString(doc.Name)) end end end - ImGui.EndChild() + ImGui_EndChild() - local button_size = ImVec2(ImGui.GetFontSize() * 7.0, 0.0) - if ImGui.Button("Yes", button_size) then + local button_size = ImVec2(ImGui_GetFontSize() * 7.0, 0.0) + if ImGui_Button("Yes", button_size) then for _, doc in app.CloseQueue:iter() do if doc.Dirty then doc:DoSave() @@ -34102,22 +34158,22 @@ function ShowExampleAppDocuments(p_open) doc:DoForceClose() end app.CloseQueue:clear() - ImGui.CloseCurrentPopup() + ImGui_CloseCurrentPopup() end - ImGui.SameLine() - if ImGui.Button("No", button_size) then + ImGui_SameLine() + if ImGui_Button("No", button_size) then for _, doc in app.CloseQueue:iter() do doc:DoForceClose() end app.CloseQueue:clear() - ImGui.CloseCurrentPopup() + ImGui_CloseCurrentPopup() end - ImGui.SameLine() - if ImGui.Button("Cancel", button_size) then + ImGui_SameLine() + if ImGui_Button("Cancel", button_size) then app.CloseQueue:clear() - ImGui.CloseCurrentPopup() + ImGui_CloseCurrentPopup() end - ImGui.EndPopup() + ImGui_EndPopup() end end end @@ -34265,10 +34321,10 @@ local function ExampleAssetsBrowser_AdapterIndexToStorageId(self_, idx) local se -- [Port] returns the new p_open function ExampleAssetsBrowserMT:Draw(title, p_open) if self.IconSize <= 0.0 then - self.IconSize = ImGui.CalcTextSize("99999").x + self.IconSize = ImGui_CalcTextSize("99999").x end - ImGui.SetNextWindowSize(ImVec2(self.IconSize * 25, self.IconSize * 15), 4 --[[ImGuiCond.FirstUseEver]]) + ImGui_SetNextWindowSize(ImVec2(self.IconSize * 25, self.IconSize * 15), 4 --[[ImGuiCond.FirstUseEver]]) local visible p_open, visible = ImGui.Begin(title, p_open, 1024 --[[ImGuiWindowFlags.MenuBar]]) if not visible then @@ -34279,90 +34335,90 @@ function ExampleAssetsBrowserMT:Draw(title, p_open) local Selection = self.Selection -- Menu bar - if ImGui.BeginMenuBar() then - if ImGui.BeginMenu("File") then - if ImGui.MenuItem("Add 10000 items") then + if ImGui_BeginMenuBar() then + if ImGui_BeginMenu("File") then + if ImGui_MenuItem("Add 10000 items") then self:AddItems(10000) end - if ImGui.MenuItem("Clear items") then + if ImGui_MenuItem("Clear items") then self:ClearItems() end - ImGui.Separator() - if ImGui.MenuItem("Close", nil, false, p_open ~= nil) then + ImGui_Separator() + if ImGui_MenuItem("Close", nil, false, p_open ~= nil) then p_open = false end - ImGui.EndMenu() + ImGui_EndMenu() end - if ImGui.BeginMenu("Edit") then - if ImGui.MenuItem("Delete", "Del", false, Selection.Size > 0) then + if ImGui_BeginMenu("Edit") then + if ImGui_MenuItem("Delete", "Del", false, Selection.Size > 0) then self.RequestDelete = true end - ImGui.EndMenu() + ImGui_EndMenu() end - if ImGui.BeginMenu("Options") then - ImGui.PushItemWidth(ImGui.GetFontSize() * 10) + if ImGui_BeginMenu("Options") then + ImGui_PushItemWidth(ImGui_GetFontSize() * 10) - ImGui.SeparatorText("Contents") - _, self.ShowTypeOverlay = ImGui.Checkbox("Show Type Overlay", self.ShowTypeOverlay) - _, self.AllowSorting = ImGui.Checkbox("Allow Sorting", self.AllowSorting) + ImGui_SeparatorText("Contents") + _, self.ShowTypeOverlay = ImGui_Checkbox("Show Type Overlay", self.ShowTypeOverlay) + _, self.AllowSorting = ImGui_Checkbox("Allow Sorting", self.AllowSorting) - ImGui.SeparatorText("Selection Behavior") - _, self.AllowBoxSelect = ImGui.Checkbox("Allow box-selection", self.AllowBoxSelect) + ImGui_SeparatorText("Selection Behavior") + _, self.AllowBoxSelect = ImGui_Checkbox("Allow box-selection", self.AllowBoxSelect) local pressed - pressed, self.AllowBoxSelectInsideSelection = ImGui.Checkbox("Allow box-selection from selected items", self.AllowBoxSelectInsideSelection) + pressed, self.AllowBoxSelectInsideSelection = ImGui_Checkbox("Allow box-selection from selected items", self.AllowBoxSelectInsideSelection) if pressed and self.AllowBoxSelectInsideSelection then self.AllowDragUnselected = false end - pressed, self.AllowDragUnselected = ImGui.Checkbox("Allow dragging unselected item", self.AllowDragUnselected) + pressed, self.AllowDragUnselected = ImGui_Checkbox("Allow dragging unselected item", self.AllowDragUnselected) if pressed and self.AllowDragUnselected then self.AllowBoxSelectInsideSelection = false end - ImGui.SeparatorText("Layout") - self.IconSize = ImGui.SliderFloat("Icon Size", self.IconSize, 16.0, 128.0, "%.0f") - ImGui.SameLine(); HelpMarker("Use Ctrl+Wheel to zoom") - self.IconSpacing = ImGui.SliderInt("Icon Spacing", self.IconSpacing, 0, 32) - self.IconHitSpacing = ImGui.SliderInt("Icon Hit Spacing", self.IconHitSpacing, 0, 32) - _, self.StretchSpacing = ImGui.Checkbox("Stretch Spacing", self.StretchSpacing) - _, self.UseScrollX = ImGui.Checkbox("Use ScrollX", self.UseScrollX) - ImGui.PopItemWidth() - ImGui.EndMenu() + ImGui_SeparatorText("Layout") + self.IconSize = ImGui_SliderFloat("Icon Size", self.IconSize, 16.0, 128.0, "%.0f") + ImGui_SameLine(); HelpMarker("Use Ctrl+Wheel to zoom") + self.IconSpacing = ImGui_SliderInt("Icon Spacing", self.IconSpacing, 0, 32) + self.IconHitSpacing = ImGui_SliderInt("Icon Hit Spacing", self.IconHitSpacing, 0, 32) + _, self.StretchSpacing = ImGui_Checkbox("Stretch Spacing", self.StretchSpacing) + _, self.UseScrollX = ImGui_Checkbox("Use ScrollX", self.UseScrollX) + ImGui_PopItemWidth() + ImGui_EndMenu() end - ImGui.EndMenuBar() + ImGui_EndMenuBar() end -- Show a table with ONLY one header row to showcase the idea/possibility of using this to provide a sorting UI if self.AllowSorting then - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) local table_flags_for_sort_specs = bit32.bor(8 --[[ImGuiTableFlags.Sortable]], 67108864 --[[ImGuiTableFlags.SortMulti]], 8192 --[[ImGuiTableFlags.SizingFixedFit]], 1920 --[[ImGuiTableFlags.Borders]]) - if ImGui.BeginTable("for_sort_specs_only", 2, table_flags_for_sort_specs, ImVec2(0.0, ImGui.GetFrameHeight())) then - ImGui.TableSetupColumn("Index") - ImGui.TableSetupColumn("Type") - ImGui.TableHeadersRow() - local sort_specs = ImGui.TableGetSortSpecs() + if ImGui_BeginTable("for_sort_specs_only", 2, table_flags_for_sort_specs, ImVec2(0.0, ImGui_GetFrameHeight())) then + ImGui_TableSetupColumn("Index") + ImGui_TableSetupColumn("Type") + ImGui_TableHeadersRow() + local sort_specs = ImGui_TableGetSortSpecs() if sort_specs then if sort_specs.SpecsDirty or self.RequestSort then ExampleAsset_SortWithSortSpecs(sort_specs, self.Items.Data, self.Items.Size) sort_specs.SpecsDirty = false; self.RequestSort = false end end - ImGui.EndTable() + ImGui_EndTable() end - ImGui.PopStyleVar() + ImGui_PopStyleVar() end - local io = ImGui.GetIO() - ImGui.SetNextWindowContentSize(ImVec2(0.0, self.LayoutOuterPadding + self.LayoutLineCount * (self.LayoutItemSize.y + self.LayoutItemSpacing))) - if ImGui.BeginChild("Assets", ImVec2(0.0, -ImGui.GetTextLineHeightWithSpacing()), 1 --[[ImGuiChildFlags.Borders]], bit32.bor(4 --[[ImGuiWindowFlags.NoMove]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]])) then - local draw_list = ImGui.GetWindowDrawList() + local io = ImGui_GetIO() + ImGui_SetNextWindowContentSize(ImVec2(0.0, self.LayoutOuterPadding + self.LayoutLineCount * (self.LayoutItemSize.y + self.LayoutItemSpacing))) + if ImGui_BeginChild("Assets", ImVec2(0.0, -ImGui_GetTextLineHeightWithSpacing()), 1 --[[ImGuiChildFlags.Borders]], bit32.bor(4 --[[ImGuiWindowFlags.NoMove]], 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]])) then + local draw_list = ImGui_GetWindowDrawList() - local avail_width = ImGui.GetContentRegionAvail().x + local avail_width = ImGui_GetContentRegionAvail().x self:UpdateLayoutSizes(avail_width) -- Calculate and store start position. - local start_pos = ImGui.GetCursorScreenPos() + local start_pos = ImGui_GetCursorScreenPos() start_pos = ImVec2(start_pos.x + self.LayoutOuterPadding, start_pos.y + self.LayoutOuterPadding) - ImGui.SetCursorScreenPos(start_pos) + ImGui_SetCursorScreenPos(start_pos) -- Multi-select local ms_flags = bit32.bor(512 --[[ImGuiMultiSelectFlags.ClearOnEscape]], 1024 --[[ImGuiMultiSelectFlags.ClearOnClickVoid]]) @@ -34385,14 +34441,14 @@ function ExampleAssetsBrowserMT:Draw(title, p_open) -- When we finish implementing a more general API for this, we will obsolete this flag in favor of the new system) ms_flags = bit32.bor(ms_flags, 65536 --[[ImGuiMultiSelectFlags.NavWrapX]]) - local ms_io = ImGui.BeginMultiSelect(ms_flags, Selection.Size, self.Items.Size) + local ms_io = ImGui_BeginMultiSelect(ms_flags, Selection.Size, self.Items.Size) -- Use custom selection adapter: store ID in selection (recommended) Selection.UserData = self Selection.AdapterIndexToStorageId = ExampleAssetsBrowser_AdapterIndexToStorageId Selection:ApplyRequests(ms_io) - local want_delete = (ImGui.Shortcut(522 --[[ImGuiKey.Delete]], 1 --[[ImGuiInputFlags.Repeat]]) and (Selection.Size > 0)) or self.RequestDelete + local want_delete = (ImGui_Shortcut(522 --[[ImGuiKey.Delete]], 1 --[[ImGuiInputFlags.Repeat]]) and (Selection.Size > 0)) or self.RequestDelete local item_curr_idx_to_focus = want_delete and Selection:ApplyDeletionPreLoop(ms_io, self.Items.Size) or -1 self.RequestDelete = false @@ -34401,13 +34457,13 @@ function ExampleAssetsBrowserMT:Draw(title, p_open) -- But it is necessary for two reasons: -- - Selectables uses it by default to visually fill the space between two items. -- - The vertical spacing would be measured by Clipper to calculate line height if we didn't provide it explicitly (here we do). - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(self.LayoutSelectableSpacing, self.LayoutSelectableSpacing)) + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(self.LayoutSelectableSpacing, self.LayoutSelectableSpacing)) -- Rendering parameters local icon_type_overlay_colors = { 0, IM_COL32(200, 70, 70, 255), IM_COL32(70, 170, 70, 255) } - local icon_bg_color = ImGui.GetColorU32(IM_COL32(35, 35, 35, 220), nil, true) -- [Port] ImU32 overload selected explicitly + local icon_bg_color = ImGui_GetColorU32(IM_COL32(35, 35, 35, 220), nil, true) -- [Port] ImU32 overload selected explicitly local icon_type_overlay_size = ImVec2(4.0, 4.0) - local display_label = (self.LayoutItemSize.x >= ImGui.CalcTextSize("999").x) + local display_label = (self.LayoutItemSize.x >= ImGui_CalcTextSize("999").x) local column_count = self.LayoutColumnCount local clipper = ImGuiListClipper() @@ -34424,33 +34480,33 @@ function ExampleAssetsBrowserMT:Draw(title, p_open) local item_max_idx_for_current_line = ImMin((line_idx + 1) * column_count, self.Items.Size) for item_idx = item_min_idx_for_current_line, item_max_idx_for_current_line - 1 do local item_data = self.Items.Data[item_idx + 1] - ImGui.PushID(item_data.ID) + ImGui_PushID(item_data.ID) -- Position item local pos = ImVec2(start_pos.x + (item_idx % column_count) * self.LayoutItemStep.x, start_pos.y + line_idx * self.LayoutItemStep.y) - ImGui.SetCursorScreenPos(pos) + ImGui_SetCursorScreenPos(pos) - ImGui.SetNextItemSelectionUserData(item_idx) + ImGui_SetNextItemSelectionUserData(item_idx) local item_is_selected = Selection:Contains(item_data.ID) - local item_is_visible = ImGui.IsRectVisible(self.LayoutItemSize) - ImGui.Selectable("", item_is_selected, 0 --[[ImGuiSelectableFlags.None]], self.LayoutItemSize) + local item_is_visible = ImGui_IsRectVisible(self.LayoutItemSize) + ImGui_Selectable("", item_is_selected, 0 --[[ImGuiSelectableFlags.None]], self.LayoutItemSize) -- Update our selection state immediately (without waiting for EndMultiSelect() requests) -- because we use this to alter the color of our text/icon. - if ImGui.IsItemToggledSelection() then + if ImGui_IsItemToggledSelection() then item_is_selected = not item_is_selected end -- Focus (for after deletion) if item_curr_idx_to_focus == item_idx then - ImGui.SetKeyboardFocusHere(-1) + ImGui_SetKeyboardFocusHere(-1) end -- Drag and drop - if ImGui.BeginDragDropSource() then + if ImGui_BeginDragDropSource() then -- Create payload with full selection OR single unselected item. -- (the later is only possible when using ImGuiMultiSelectFlags.SelectOnClickRelease) - if ImGui.GetDragDropPayload() == nil then + if ImGui_GetDragDropPayload() == nil then local payload_items = ImVector() local it = nil local id = 0 @@ -34464,16 +34520,16 @@ function ExampleAssetsBrowserMT:Draw(title, p_open) payload_items:push_back(id) end end - ImGui.SetDragDropPayload("ASSETS_BROWSER_ITEMS", payload_items.Data, payload_items.Size * 4) -- [Port] size_in_bytes() with sizeof(ImGuiID) == 4, payload carries the Lua array + ImGui_SetDragDropPayload("ASSETS_BROWSER_ITEMS", payload_items.Data, payload_items.Size * 4) -- [Port] size_in_bytes() with sizeof(ImGuiID) == 4, payload carries the Lua array end -- Display payload content in tooltip, by extracting it from the payload data -- (we could read from selection, but it is more correct and reusable to read from payload) - local payload = ImGui.GetDragDropPayload() + local payload = ImGui_GetDragDropPayload() local payload_count = math.floor(payload.DataSize / 4) -- [Port] sizeof(ImGuiID) == 4 - ImGui.Text("%d assets", payload_count) + ImGui_Text("%d assets", payload_count) - ImGui.EndDragDropSource() + ImGui_EndDragDropSource() end -- Render icon (a real app would likely display an image/thumbnail here) @@ -34487,43 +34543,43 @@ function ExampleAssetsBrowserMT:Draw(title, p_open) draw_list:AddRectFilled(ImVec2(box_max.x - 2 - icon_type_overlay_size.x, box_min.y + 2), ImVec2(box_max.x - 2, box_min.y + 2 + icon_type_overlay_size.y), type_col) end if display_label then - local label_col = ImGui.GetColorU32(item_is_selected and 0 --[[ImGuiCol.Text]] or 1 --[[ImGuiCol.TextDisabled]]) + local label_col = ImGui_GetColorU32(item_is_selected and 0 --[[ImGuiCol.Text]] or 1 --[[ImGuiCol.TextDisabled]]) local label = string.format("%d", item_data.ID) - draw_list:AddText(ImVec2(box_min.x, box_max.y - ImGui.GetFontSize()), label_col, label) + draw_list:AddText(ImVec2(box_min.x, box_max.y - ImGui_GetFontSize()), label_col, label) end end - ImGui.PopID() + ImGui_PopID() end end end clipper:End() if self.Items.Size == 0 then - ImGui.Dummy(ImVec2(0, 0)) + ImGui_Dummy(ImVec2(0, 0)) end - ImGui.PopStyleVar() -- ImGuiStyleVar.ItemSpacing + ImGui_PopStyleVar() -- ImGuiStyleVar.ItemSpacing -- Context menu - if ImGui.BeginPopupContextWindow() then - ImGui.Text("Selection: %d items", Selection.Size) - ImGui.Separator() - if ImGui.MenuItem("Delete", "Del", false, Selection.Size > 0) then + if ImGui_BeginPopupContextWindow() then + ImGui_Text("Selection: %d items", Selection.Size) + ImGui_Separator() + if ImGui_MenuItem("Delete", "Del", false, Selection.Size > 0) then self.RequestDelete = true end - ImGui.EndPopup() + ImGui_EndPopup() end - ms_io = ImGui.EndMultiSelect() + ms_io = ImGui_EndMultiSelect() Selection:ApplyRequests(ms_io) if want_delete then Selection:ApplyDeletionPostLoop(ms_io, self.Items, item_curr_idx_to_focus) end -- Zooming with Ctrl+Wheel - if ImGui.IsWindowAppearing() then + if ImGui_IsWindowAppearing() then self.ZoomWheelAccum = 0.0 end - if ImGui.IsWindowHovered() and io.MouseWheel ~= 0.0 and ImGui.IsKeyDown(4096 --[[ImGuiMod_Ctrl]]) and ImGui.IsAnyItemActive() == false then + if ImGui_IsWindowHovered() and io.MouseWheel ~= 0.0 and ImGui_IsKeyDown(4096 --[[ImGuiMod_Ctrl]]) and ImGui_IsAnyItemActive() == false then self.ZoomWheelAccum = self.ZoomWheelAccum + io.MouseWheel if math.abs(self.ZoomWheelAccum) >= 1.0 then -- Calculate hovered item index from mouse location @@ -34543,15 +34599,15 @@ function ExampleAssetsBrowserMT:Draw(title, p_open) -- - Calculate next frame position of item under mouse -- - Set new scroll position to be used in next ImGui.BeginChild() call. local hovered_item_rel_pos_y = (ImTrunc(hovered_item_idx / self.LayoutColumnCount) + math.fmod(hovered_item_ny, 1.0)) * self.LayoutItemStep.y - hovered_item_rel_pos_y = hovered_item_rel_pos_y + ImGui.GetStyle().WindowPadding.y - local mouse_local_y = io.MousePos.y - ImGui.GetWindowPos().y - ImGui.SetScrollY(hovered_item_rel_pos_y - mouse_local_y) + hovered_item_rel_pos_y = hovered_item_rel_pos_y + ImGui_GetStyle().WindowPadding.y + local mouse_local_y = io.MousePos.y - ImGui_GetWindowPos().y + ImGui_SetScrollY(hovered_item_rel_pos_y - mouse_local_y) end end end - ImGui.EndChild() + ImGui_EndChild() - ImGui.Text("Selected: %d/%d items", Selection.Size, self.Items.Size) + ImGui_Text("Selected: %d/%d items", Selection.Size, self.Items.Size) ImGui.End() return p_open end @@ -34567,9 +34623,12 @@ function ShowExampleAppAssetsBrowser(p_open) end return true -end +end end)() -__FILES['imgui_draw.lua'] = function() +__FILES['imgui_draw.lua'] = (function() +local ImGui_AddDrawListToDrawDataEx, ImGui_GetCurrentContext, ImGui_GetStyle, ImGui_SetCurrentContext, ImGui_SetCurrentFont, ImGui_ShadeVertsLinearUV +__BIND[#__BIND + 1] = function() if ImGui then ImGui_AddDrawListToDrawDataEx = ImGui.AddDrawListToDrawDataEx ImGui_GetCurrentContext = ImGui.GetCurrentContext ImGui_GetStyle = ImGui.GetStyle ImGui_SetCurrentContext = ImGui.SetCurrentContext ImGui_SetCurrentFont = ImGui.SetCurrentFont ImGui_ShadeVertsLinearUV = ImGui.ShadeVertsLinearUV end end; __BIND[#__BIND]() +return function() --- Dear ImGui WIP -- (drawing and font code) @@ -34700,7 +34759,7 @@ local function ImLerpV4V4F(a, b, t) return ImVec4(a.x + (b.x - a.x) * t, a.y + ( --- @param dst? ImGuiStyle function ImGui.StyleColorsDark(dst) - local style = dst and dst or ImGui.GetStyle() + local style = dst and dst or ImGui_GetStyle() local colors = style.Colors colors[0 --[[ImGuiCol.Text]]] = ImVec4(1.00, 1.00, 1.00, 1.00) @@ -34770,7 +34829,7 @@ end --- @param dst? ImGuiStyle function ImGui.StyleColorsClassic(dst) - local style = dst and dst or ImGui.GetStyle() + local style = dst and dst or ImGui_GetStyle() local colors = style.Colors colors[0 --[[ImGuiCol.Text]]] = ImVec4(0.90, 0.90, 0.90, 1.00) @@ -34841,7 +34900,7 @@ end -- Those light colors are better suited with a thicker font than the default one + FrameBorder --- @param dst? ImGuiStyle function ImGui.StyleColorsLight(dst) - local style = dst and dst or ImGui.GetStyle() + local style = dst and dst or ImGui_GetStyle() local colors = style.Colors colors[0 --[[ImGuiCol.Text]]] = ImVec4(0.00, 0.00, 0.00, 1.00) @@ -37169,14 +37228,14 @@ function ImFontAtlasBuildNotifySetFont(atlas, old_font, new_font) ctx.IO.FontDefault = new_font end if ctx.Font == old_font then - local curr_ctx = ImGui.GetCurrentContext() + local curr_ctx = ImGui_GetCurrentContext() local need_bind_ctx = ctx ~= curr_ctx if need_bind_ctx then - ImGui.SetCurrentContext(ctx) + ImGui_SetCurrentContext(ctx) end - ImGui.SetCurrentFont(new_font, ctx.FontSizeBase, ctx.FontSize) + ImGui_SetCurrentFont(new_font, ctx.FontSizeBase, ctx.FontSize) if need_bind_ctx then - ImGui.SetCurrentContext(curr_ctx) + ImGui_SetCurrentContext(curr_ctx) end end for _, font_stack_data in ctx.FontStack:iter() do @@ -38781,7 +38840,7 @@ end function MT.ImDrawData:AddDrawList(draw_list) draw_list:_PopUnusedDrawCmd() - ImGui.AddDrawListToDrawDataEx(self, self.CmdLists, draw_list) + ImGui_AddDrawListToDrawDataEx(self, self.CmdLists, draw_list) end -- 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! @@ -38893,7 +38952,12 @@ function MT.ImDrawList:_ResetForNewFrame() self.Flags = self._Data.InitialDrawFlags assert(bit32.band(self.Flags, bit32.bnot(16675312 --[[ImDrawFlags.AllowInFrameScope_]])) == 0) - self._CmdHeader = ImDrawCmdHeader() -- memset(&_CmdHeader, 0, sizeof(_CmdHeader)) + -- memset(&_CmdHeader, 0, sizeof(_CmdHeader)) -- [Luau] in place, no new table per frame + local header = self._CmdHeader + local hcr = header.ClipRect + hcr.x = 0; hcr.y = 0; hcr.z = 0; hcr.w = 0 + header.TexRef = nil + header.VtxOffset = 0 self._VtxCurrentIdx = 1 self._VtxWritePtr = 1 @@ -38904,7 +38968,7 @@ function MT.ImDrawList:_ResetForNewFrame() self._DrawFlagsStack.Size = 0 -- [Port] _DrawFlagsStack.clear() (ImSmallStack_) self._Path:resize(0) - self.CmdBuffer:push_back(ImDrawCmd()) + self:AddDrawCmd() -- [Luau] C++ push_back(ImDrawCmd()): same zeroed command (the header was just zeroed), reuses last frame's object -- Caller needs to bet _SetPixelDensity() as well. end @@ -38952,17 +39016,31 @@ end @native function MT.ImDrawList:AddDrawCmd() - local draw_cmd = ImDrawCmd() - - ImVec4_Copy(draw_cmd.ClipRect, self._CmdHeader.ClipRect) -- Same as calling ImDrawCmd_HeaderCopy() - draw_cmd.TexRef = self._CmdHeader.TexRef - draw_cmd.VtxOffset = self._CmdHeader.VtxOffset - draw_cmd.IdxOffset = self.IdxBuffer.Size - - assert(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z and draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w) - -- [Luau] inline self.CmdBuffer:push_back(draw_cmd) + -- [Luau] C++ constructs the command in the vector's storage, which keeps last frame's memory: reuse the command + -- object left past Size by resize(0)/pop_back() (Merge() takes channel commands out of their slots, nothing else + -- shares them) instead of allocating 3 tables per command per frame local cmd_buffer = self.CmdBuffer local n = cmd_buffer.Size + 1 + local draw_cmd = (n <= cmd_buffer.Capacity) and cmd_buffer.Data[n] or nil + if draw_cmd then + draw_cmd.ElemCount = 0 + draw_cmd.UserCallback = nil + draw_cmd.UserCallbackData = nil + draw_cmd.UserCallbackDataSize = 0 + draw_cmd.UserCallbackDataOffset = 0 + else + draw_cmd = ImDrawCmd() + end + + local header = self._CmdHeader + local dcr, hcr = draw_cmd.ClipRect, header.ClipRect + dcr.x = hcr.x; dcr.y = hcr.y; dcr.z = hcr.z; dcr.w = hcr.w -- Same as calling ImDrawCmd_HeaderCopy() + draw_cmd.TexRef = header.TexRef + draw_cmd.VtxOffset = header.VtxOffset + draw_cmd.IdxOffset = self.IdxBuffer.Size + + assert(dcr.x <= dcr.z and dcr.y <= dcr.w) + -- [Luau] inline self.CmdBuffer:push_back(draw_cmd) if n > cmd_buffer.Capacity then cmd_buffer:push_back(draw_cmd) else cmd_buffer.Data[n] = draw_cmd; cmd_buffer.Size = n end end @@ -39244,7 +39322,11 @@ function MT.ImDrawListSplitter:Merge(draw_list) -- Merge previous channel last draw command with current channel first draw command if matching. last_cmd.ElemCount = last_cmd.ElemCount + next_cmd.ElemCount idx_offset = idx_offset + next_cmd.ElemCount - cmds:erase(1) -- FIXME-OPT: Improve for multiple merges. + -- [Luau] cmds:erase(1), keeping the erased command object past Size for AddDrawCmd() to reuse + local d = cmds.Data + for k = 1, cmds.Size - 1 do d[k] = d[k + 1] end + d[cmds.Size] = next_cmd + cmds.Size = cmds.Size - 1 -- FIXME-OPT: Improve for multiple merges. end end if cmds.Size > 0 then @@ -39271,8 +39353,9 @@ function MT.ImDrawListSplitter:Merge(draw_list) if ch._CmdBuffer.Size > 0 then local src_cmds = ch._CmdBuffer.Data for n = 1, ch._CmdBuffer.Size do - dst_cmds[cmd_write] = src_cmds[n] - src_cmds[n] = nil -- [Port] ownership moved to the draw list + -- [Port] ownership moved to the draw list; [Luau] the unused command object that was in the draw list's + -- slot goes to the channel's slot instead of nil (AddDrawCmd() reuses it: each object stays in one slot) + dst_cmds[cmd_write], src_cmds[n] = src_cmds[n], dst_cmds[cmd_write] cmd_write = cmd_write + 1 end end @@ -41591,7 +41674,7 @@ function MT.ImDrawList:AddImageRounded(tex_ref, p_min, p_max, uv_min, uv_max, co self:PathRect(p_min, p_max, rounding, flags) self:PathFillConvex(col, 1024 --[[ImDrawFlags.JoinMiter]]) local vert_end_idx = self.VtxBuffer.Size + 1 - ImGui.ShadeVertsLinearUV(self, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true) + ImGui_ShadeVertsLinearUV(self, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true) if push_texture_id then self:PopTexture() @@ -42960,9 +43043,11 @@ end end return true -- [Port] [Roblox] ModuleScripts must return exactly one value -end +end end)() __FILES['imgui_h.lua'] = function() +local ImGui_ColorConvertFloat4ToU32, ImGui_ColorConvertHSVtoRGB, ImGui_MemFree +__BIND[#__BIND + 1] = function() if ImGui then ImGui_ColorConvertFloat4ToU32 = ImGui.ColorConvertFloat4ToU32 ImGui_ColorConvertHSVtoRGB = ImGui.ColorConvertHSVtoRGB ImGui_MemFree = ImGui.MemFree end end; __BIND[#__BIND]() -- dear imgui, v1.93.0 WIP -- (headers) @@ -43100,7 +43185,7 @@ IM_FREE = ImGui.MemFree --- @param owner table --- @param field string|int -IM_DELETE = function(owner, field) if owner[field] ~= nil then owner[field] = nil; ImGui.MemFree(owner, field); end end +IM_DELETE = function(owner, field) if owner[field] ~= nil then owner[field] = nil; ImGui_MemFree(owner, field); end end ------------------------------------------------------------------------------- -- [Port] [SECTION] METATABLE MANAGEMENT @@ -45831,10 +45916,10 @@ ImColor = setmetatable({}, { __call = function(_, r, g, b, a) end return self end }) -function ImColorMT:U32() return ImGui.ColorConvertFloat4ToU32(self.Value) end +function ImColorMT:U32() return ImGui_ColorConvertFloat4ToU32(self.Value) end -- FIXME-OBSOLETE: May need to obsolete/cleanup those helpers. -function ImColorMT:SetHSV(h, s, v, a) self.Value.x, self.Value.y, self.Value.z = ImGui.ColorConvertHSVtoRGB(h, s, v); self.Value.w = a or 1.0 end -function ImColor.HSV(h, s, v, a) local r, g, b = ImGui.ColorConvertHSVtoRGB(h, s, v); return ImColor(r, g, b, a or 1.0) end +function ImColorMT:SetHSV(h, s, v, a) self.Value.x, self.Value.y, self.Value.z = ImGui_ColorConvertHSVtoRGB(h, s, v); self.Value.w = a or 1.0 end +function ImColor.HSV(h, s, v, a) local r, g, b = ImGui_ColorConvertHSVtoRGB(h, s, v); return ImColor(r, g, b, a or 1.0) end ------------------------------------------------------------------------------- -- [SECTION] Multi-Select API flags and structures (ImGuiMultiSelectFlags, ImGuiSelectionRequestType, ImGuiSelectionRequest, ImGuiMultiSelectIO, ImGuiSelectionBasicStorage) @@ -45964,7 +46049,7 @@ return true -- [Port] [Roblox] ModuleScripts must return exactly one value end __FILES['imgui_impl_roblox.lua'] = function() -local Raster, Textures, Layers, Overlays, Render, Parallel +local Raster, Textures, Layers, Overlays, Render, Parallel, Patches do -- Software rasterizer: pure buffer code shared by the backend and the parallel worker (inlined into ImGuiWorker). -- Target: RGBA8 row-major (ImU32 is already R | G<<8 | B<<16 | A<<24), non-premultiplied "over" onto transparent. @@ -46449,9 +46534,34 @@ local function DrawTriangle(dbuf: buffer, vbuf: buffer, va: number, vb: number, if yt > yb then continue end local o = (yt * TargetWidth + x) * 4 + TargetBase if flat then - for _ = yt, yb do - BlendPixel(dbuf, o, ra, ga, ba, aa) - o += stride + -- the row path's flat spans (BlendPixel's math, per-span constants, cached per destination value) + local o1 = o + (yb - yt) * stride + if f_opaque then + for oo = o, o1, stride do writeu32(dbuf, oo, f_packed) end + continue + end + local last_d, last_v = -1, 0 + for oo = o, o1, stride do + local d = readu32(dbuf, oo) + if d == last_d then + writeu32(dbuf, oo, last_v) + elseif d < 16777216 then + writeu32(dbuf, oo, f_packed) + else + last_d = d + local dr, dg, db = band(d, 255), band(rshift(d, 8), 255), band(rshift(d, 16), 255) + if d >= 4278190080 then + last_v = floor(f_rs + dr * f_ns + 0.5) + floor(f_gs + dg * f_ns + 0.5) * 256 + + floor(f_bs + db * f_ns + 0.5) * 65536 + 4278190080 + else + local k = rshift(d, 24) * f_c1 + local oa = f_sa + k + local inv2 = 1 / oa + last_v = floor((f_rs + dr * k) * inv2 + 0.5) + floor((f_gs + dg * k) * inv2 + 0.5) * 256 + + floor((f_bs + db * k) * inv2 + 0.5) * 65536 + floor(oa * 255 + 0.5) * 16777216 + end + writeu32(dbuf, oo, last_v) + end end continue end @@ -46987,9 +47097,18 @@ end local Records = {} M.Records = Records +-- The buffer of the last destroyed atlas texture record: the next one of the same size (an atlas repack: same size +-- every time) reuses it. buffer.create of an atlas is slow in Studio (~0.2-1.8 ms for 512 KB, spiky). +local SpareBuffer: buffer? = nil + local function CreateTextureRecord(tex) local w, h = tex.Width, tex.Height - local b = buffer.create(w * h * 4) + local b, reused = SpareBuffer, false + if b and buffer.len(b) == w * h * 4 then + SpareBuffer, reused = nil, true + else + b = buffer.create(w * h * 4) + end -- The current font atlas texture: pixels outside the packed rects (MaxRectBounds) and the queued uploads (UsedRect) -- are still zero (repack's BlockCopy doesn't queue, but every copied rect is packed). Fill them with what zero -- converts to, convert only the used corner. A fresh/grown atlas is mostly empty. Any other texture: everything. @@ -47001,7 +47120,9 @@ local function CreateTextureRecord(tex) ch = math.min(h, math.max(u.y + u.h, m.y)) end if cw < w or ch < h then - if tex.BytesPerPixel ~= 4 then -- Alpha8 zero -> 0x00FFFFFF; RGBA zero -> 0 (buffer.create's fill) + if tex.BytesPerPixel == 4 then + if reused then buffer.fill(b, 0, 0) end + else -- Alpha8 zero -> 0x00FFFFFF; RGBA zero -> 0 (buffer.create's fill) local n, total = 4, w * h * 4 writeu32(b, 0, 16777215) while n < total do @@ -47053,7 +47174,9 @@ function M.UpdateTexture(tex) elseif tex.Status == 4 --[[ImTextureStatus.WantDestroy]] then if tex.BackendUserData then local id = tex.BackendUserData - if EditableImages.TextureDropped then EditableImages.TextureDropped(id, Records[id]) end + local rec = Records[id] + if EditableImages.TextureDropped then EditableImages.TextureDropped(id, rec) end + if rec and rec.FillRow then SpareBuffer = rec.Buffer end -- (FillRow: a buffer CreateTextureRecord made) Records[id] = nil tex.BackendUserData = nil end @@ -47141,7 +47264,7 @@ do -local floor, max = math.floor, math.max +local floor, ceil, max = math.floor, math.ceil, math.max local readu32, writeu32, readf64, writef64 = buffer.readu32, buffer.writeu32, buffer.readf64, buffer.writef64 local TILE = Raster.TILE local EditableImages = Textures.EditableImages @@ -47233,47 +47356,55 @@ function EditableImages.FreeTile(layer, key, recycle) nil, nil, nil, nil, nil end +-- A new tile (transparent image, hidden unparented label), nil over the EditableImage budget +local function NewTile() + local img = EditableImages.Create(TILE, TILE) + if not img then return nil end + local label = Instance.new("ImageLabel") + label.Name = "Tile" + label.BackgroundTransparency = 1 + label.BorderSizePixel = 0 + label.ResampleMode = Enum.ResamplerMode.Pixelated + label.ImageContent = Content.fromObject(img) + label.Visible = false + return { + Image = img, Label = label, + Hash1 = -1, Hash2 = -1, Visible = false, Used = 0, + ContentX0 = TILE, ContentY0 = TILE, ContentX1 = 0, ContentY1 = 0, + ValidX0 = 0, ValidY0 = 0, ValidX1 = TILE, ValidY1 = TILE, + Scale = false, Active = nil, Parent = nil, + DrawnCount = -1, DrawnHash1 = {}, DrawnHash2 = {}, DrawnFlat = {}, + DrawnX0 = {}, DrawnY0 = {}, DrawnX1 = {}, DrawnY1 = {}, + } +end + +-- Keeps PREWARM tiles in the free list (Heartbeat, one per call, never evicting): a layer that grows takes them instead +-- of creating EditableImages + labels mid-frame (~90 us per tile in Studio, ~7 us from the free list) +local PREWARM = 4 +function M.Prewarm() + local pool = EditableImages.Pool + if #pool < PREWARM and EditableImages.Bytes + TILE * TILE * 4 <= EditableImages.Cap then + local tile = NewTile() + if tile then table.insert(pool, 1, tile) end -- (at the bottom: recycled tiles keep their parent, used first) + end +end + function M.GetTile(BackendData, layer, key, tx, ty) local tile = layer.Tiles[key] if tile then return tile end local scale = BackendData.Scale - local old = table.remove(EditableImages.Pool) - local label, img - if old then - label, img = old.Label, old.Image - else - img = EditableImages.Create(TILE, TILE) - if not img then return nil end -- over the budget even after eviction: the caller skips this tile this frame - label = Instance.new("ImageLabel") - label.Name = "Tile" - label.BackgroundTransparency = 1 - label.BorderSizePixel = 0 - label.ResampleMode = Enum.ResamplerMode.Pixelated - label.ImageContent = Content.fromObject(img) - label.Visible = false - end - if not old or old.Scale ~= scale then label.Size = UDim2.fromOffset(TILE / scale, TILE / scale) end + -- Content*: content bounds; Valid*: where the image pixels are current. A recycled tile keeps both (they still + -- describe its image): its first draw is a full one (DrawnCount -1) that only clears old + new content bounds. + tile = table.remove(EditableImages.Pool) or NewTile() + if not tile then return nil end -- over the budget even after eviction: the caller skips this tile this frame + local label = tile.Label + if tile.Scale ~= scale then label.Size = UDim2.fromOffset(TILE / scale, TILE / scale) end label.Position = UDim2.fromOffset(tx * TILE / scale, ty * TILE / scale) - if not old or old.Active ~= BackendData.TilesActive then label.Active = BackendData.TilesActive end - if not old or old.Parent ~= layer.Frame then label.Parent = layer.Frame end - -- Content*: content bounds; Valid*: where the image pixels are current. A recycled tile keeps both (they still describe - -- its image): its first draw is a full one (DrawnCount -1) that only clears old + new content bounds. - if old then - tile = old - tile.Hash1, tile.Hash2, tile.Visible, tile.Used, tile.Deferred, tile.DrawnCount = - -1, -1, false, BackendData.FrameNo, nil, -1 - tile.Scale, tile.Active, tile.Parent = scale, BackendData.TilesActive, layer.Frame - else - tile = { - Image = img, Label = label, - Hash1 = -1, Hash2 = -1, Visible = false, Used = BackendData.FrameNo, - ContentX0 = TILE, ContentY0 = TILE, ContentX1 = 0, ContentY1 = 0, - ValidX0 = 0, ValidY0 = 0, ValidX1 = TILE, ValidY1 = TILE, - Scale = scale, Active = BackendData.TilesActive, Parent = layer.Frame, - DrawnCount = -1, DrawnHash1 = {}, DrawnHash2 = {}, DrawnFlat = {}, - DrawnX0 = {}, DrawnY0 = {}, DrawnX1 = {}, DrawnY1 = {}, - } - end + if tile.Active ~= BackendData.TilesActive then label.Active = BackendData.TilesActive end + if tile.Parent ~= layer.Frame then label.Parent = layer.Frame end + tile.Hash1, tile.Hash2, tile.Visible, tile.Used, tile.Deferred, tile.DrawnCount = + -1, -1, false, BackendData.FrameNo, nil, -1 + tile.Scale, tile.Active, tile.Parent = scale, BackendData.TilesActive, layer.Frame layer.Tiles[key] = tile if EditableImages.StageTiming then EditableImages.AddStat("TilesCreated", 1) end return tile @@ -47401,8 +47532,14 @@ local function ShiftedExact(a, d, b) return (a - (s - bb)) + (d - bb) == 0 end +-- vertex byte offsets of the last CompareDrawList's drifted vertices (moved by about an ulp off the exact shift) +local MAX_DRIFT = 256 +local Drift = table.create(MAX_DRIFT, 0) +M.Drift, M.DriftCount = Drift, 0 + @native function M.CompareDrawList(set, draw_list, ox, oy, ScreenWidth, ScreenHeight) + M.DriftCount = 0 if not set or not set.SnapOK then return 0 end local nv = draw_list.VtxBuffer.Size * 36 --[[VTX_STRIDE]] local ni, ncmd = draw_list.IdxBuffer.Size, draw_list.CmdBuffer.Size @@ -47494,13 +47631,27 @@ function M.CompareDrawList(set, draw_list, ox, oy, ScreenWidth, ScreenHeight) and ShiftedExact(set.SnapContentY1, dy, draw_list._ContentClipY1) and ShiftedExact(set.SnapScrollX, dx, draw_list._ScrollOriginX) and ShiftedExact(set.SnapScrollY, dy, draw_list._ScrollOriginY)) then return 0 end + -- vertices off the exact shift ("drift": trig-generated ones round differently, often when a coordinate crosses a + -- power of two) are listed. All their floor / ceil / ceil(- 0.5) (CollectPrims' bounds) shifted: 3, only the tiles + -- of their primitives change; else 0 (the full path still gets the list: tile hashes don't see an ulp) + local nd, consistent = 0, true for v = 0, nv - 36 --[[VTX_STRIDE]], 36 --[[VTX_STRIDE]] do - if not ShiftedExact(readf64(sv, v), dx, readf64(vb, v)) - or not ShiftedExact(readf64(sv, v + 8), dy, readf64(vb, v + 8)) - or readf64(vb, v + 16) ~= readf64(sv, v + 16) or readf64(vb, v + 24) ~= readf64(sv, v + 24) + if readf64(vb, v + 16) ~= readf64(sv, v + 16) or readf64(vb, v + 24) ~= readf64(sv, v + 24) or readu32(vb, v + 32) ~= readu32(sv, v + 32) then return 0 end + local ax, ay, bx, by = readf64(sv, v), readf64(sv, v + 8), readf64(vb, v), readf64(vb, v + 8) + if not ShiftedExact(ax, dx, bx) or not ShiftedExact(ay, dy, by) then + if nd >= MAX_DRIFT then return 0 end + nd += 1 + Drift[nd] = v + if floor(bx) ~= floor(ax) + dx or ceil(bx) ~= ceil(ax) + dx or ceil(bx - 0.5) ~= ceil(ax - 0.5) + dx + or floor(by) ~= floor(ay) + dy or ceil(by) ~= ceil(ay) + dy or ceil(by - 0.5) ~= ceil(ay - 0.5) + dy then + consistent = false + end + end end - return 2, dx, dy + M.DriftCount = nd + if nd == 0 then return 2, dx, dy end + return consistent and 3 or 0, dx, dy end function M.ShiftLayer(layer, dx, dy, scale) @@ -47675,6 +47826,10 @@ function EditableImages.AddRect(n: number, a: number, b: number, c: number, d: n return n end +-- Primitives with a vertex CompareDrawList found drifted (DriftSet[vertex offset // VTX_STRIDE + 1], current draw list): +-- their hashes get DriftMark* (new every frame) added, so their tiles are redrawn even when the hash doesn't see the ulp +local DriftSet, DriftOn, DriftMark1, DriftMark2 = table.create(4096, false), false, 0, 0 + -- HashTiles scratch, per touched tile (slot = its index in layer.Touched): tile key -> slot, its list, count, hashes local KeySlot, SlotCount, SlotHash1, SlotHash2 = {}, {}, {}, {} local SlotList, SlotListHash1, SlotListHash2, SlotListFlat = {}, {}, {}, {} @@ -47740,6 +47895,11 @@ local function HashTiles(layer, plist, np, lx0, ly0, ox, oy) h2 = (h2 * 16807 + gk * 3) % P2 end end + if DriftOn and (DriftSet[va // 36 --[[VTX_STRIDE]] + 1] or DriftSet[PrimB[p] // 36 --[[VTX_STRIDE]] + 1] + or DriftSet[PrimC[p] // 36 --[[VTX_STRIDE]] + 1] or (vd and DriftSet[vd // 36 --[[VTX_STRIDE]] + 1])) then + h1 = (h1 + DriftMark1) % P1 + h2 = (h2 + DriftMark2) % P2 + end end -- the tiles it touches, row by row (one loop, no nested for: most primitives touch one tile; never empty) local tx0, tx1, ty1 = cx0 // TILE, (cx1 - 1) // TILE, (cy1 - 1) // TILE @@ -47923,7 +48083,11 @@ local function DirtyRects(tile, layer, key, count, x0, y0, force, exposed, vx0, for k = i, count - j do local a, b, c, d = NX0[k], NY0[k], NX1[k], NY1[k] local oa, ob, oc, od = DrawnX0[k], DrawnY0[k], DrawnX1[k], DrawnY1[k] - if paired and lf[k] >= 0 and lf[k] == of[k] then + if paired and DrawnHash1[k] == ListHash1[k] and DrawnHash2[k] == ListHash2[k] then + -- same primitive at the same place in both lists: every pixel it covers is either in a changed one's + -- rect or drawn by the same primitives in the same order + continue + elseif paired and lf[k] >= 0 and lf[k] == of[k] then -- same flat rect, new bounds: only the strips between the old and new edges can differ local uy0, uy1 = min(b, ob), max(d, od) local ux0, ux1 = min(a, oa), max(c, oc) @@ -48372,6 +48536,132 @@ local function DrawLists(BackendData, draw_list, z, ox, oy, force, LimitX0, Limi return z, ListDeferred end +-- The layer origin of each kind (DrawLists' DrawLayer arguments), from the last CollectPrims +local function LayerOrigin(draw_list, kind, ox, oy) + if kind == 1 then return Kind1X, Kind1Y end + if kind == 3 then return Kind3X, Kind3Y end + return floor(draw_list._ScrollOriginX - ox), floor(draw_list._ScrollOriginY - oy) +end + +local PatchLayers, PatchKeys, PatchPrim = {}, {}, {} + +-- CompareDrawList 3: moved by whole pixels, but a few vertices drifted off the exact shift (same bounds). CollectPrims +-- ran and gave the primitive sequence the tile lists were built from: the lists stay (indices moved to this frame's) +-- and every tile keeps its pixels, except those with a primitive using a drifted vertex: those entries' hashes change +-- (DriftMark), so the tile redraws just them. Changes nothing when it returns false (the caller takes the full path). +@native +local function PatchDrawList(BackendData, set, draw_list, n0, n, dx, dy, ox, oy, LimitX0, LimitY0, LimitX1, LimitY1) + table.clear(PatchPrim) + local SigA, SigD = set.PrimSigA, set.PrimSigD + if not SigA or set.PrimN ~= n - n0 then return false end + for m = 1, n - n0 do + local p = n0 + m + if PrimA[p] ~= SigA[m] or PrimD[p] ~= SigD[m] then return false end + end + local np = 0 + for kind = 1, 3 do + local layer = set[kind] + local count = kind == 1 and Kind1Count or kind == 2 and Kind2Count or Kind3Count + if count == 0 then + if layer and layer.Visible then return false end + continue + end + if not (layer and layer.Visible and layer.X) then return false end + local lx0, ly0 = LayerOrigin(draw_list, kind, ox, oy) + if lx0 ~= layer.X + dx or ly0 ~= layer.Y + dy then return false end + if layer.Root ~= layer.Frame then + local ccx0 = draw_list._ContentClipX0 + if not ccx0 or not layer.ClipX0 then return false end + if max(floor(ccx0 - ox), LimitX0) ~= layer.ClipX0 + dx + or max(floor(draw_list._ContentClipY0 - oy), LimitY0) ~= layer.ClipY0 + dy + or min(floor(draw_list._ContentClipX1 - ox), LimitX1) ~= layer.ClipX1 + dx + or min(floor(draw_list._ContentClipY1 - oy), LimitY1) ~= layer.ClipY1 + dy then + return false + end + end + -- the tiles of the primitives with a drifted vertex (flat rects: drawn from their bounds only, unchanged) + local plist = kind == 1 and LayerPrims1 or kind == 2 and LayerPrims2 or LayerPrims3 + local TileCounts, Tiles = layer.TileCounts, layer.Tiles + for m = 1, count do + local p = plist[m] + local vd = PrimD[p] + if PrimFlat[p] + or not (DriftSet[PrimA[p] // 36 --[[VTX_STRIDE]] + 1] or DriftSet[PrimB[p] // 36 --[[VTX_STRIDE]] + 1] + or DriftSet[PrimC[p] // 36 --[[VTX_STRIDE]] + 1] or (vd and DriftSet[vd // 36 --[[VTX_STRIDE]] + 1])) then + continue + end + PatchPrim[p] = true + local cx0, cy0, cx1, cy1 = PrimBoundsX0[p] - lx0, PrimBoundsY0[p] - ly0, PrimBoundsX1[p] - lx0, + PrimBoundsY1[p] - ly0 + for ty = cy0 // TILE, (cy1 - 1) // TILE do + for tx = cx0 // TILE, (cx1 - 1) // TILE do + local key = (ty + 32768) * 65536 + tx + 32768 + local c, tile = TileCounts[key], Tiles[key] + if not c or c == 0 or not tile then continue end -- not drawn (outside the content clip) + if tile.DrawnCount ~= c or tile.Hash1 ~= layer.TileHash1[key] or tile.Hash2 ~= layer.TileHash2[key] + or (tile.Deferred or 0) > 0 then + return false + end + np += 1 + PatchLayers[np], PatchKeys[np] = kind, key + end + end + end + end + + -- the lists: this frame's primitive indices + local delta = n0 - set.PrimBase + set.PrimBase = n0 + for kind = 1, 3 do + local layer = set[kind] + if delta == 0 or not (layer and layer.Visible) then continue end + local TileCounts, TileLists, Touched = layer.TileCounts, layer.TileLists, layer.Touched + for kk = 1, layer.TouchedCount do + local key = Touched[kk] + local c = TileCounts[key] + if c and c > 0 then + local list = TileLists[key] + for k = 1, c do list[k] += delta end + end + end + end + + -- the patched tiles: their drawn entries, the drifted primitives' hashes changed, redrawn + local FrameNo = BackendData.FrameNo + for i = 1, np do + local kind, key = PatchLayers[i], PatchKeys[i] + local layer = set[kind] + local tile = layer.Tiles[key] + if tile.Used == FrameNo then continue end -- (done: a tile of several drifted primitives) + tile.Used = FrameNo + local count = layer.TileCounts[key] + local list, LH1, LH2 = layer.TileLists[key], layer.TileListHash1[key], layer.TileListHash2[key] + table.move(tile.DrawnHash1, 1, count, 1, LH1) + table.move(tile.DrawnHash2, 1, count, 1, LH2) + table.move(tile.DrawnFlat, 1, count, 1, layer.TileListFlat[key]) + local h1, h2 = 0, 0 + for k = 1, count do + if PatchPrim[list[k]] then + LH1[k], LH2[k] = (LH1[k] + DriftMark1) % P1, (LH2[k] + DriftMark2) % P2 + end + h1 = (h1 * 48271 + LH1[k]) % P1 + h2 = (h2 * 16807 + LH2[k] + k) % P2 + end + layer.TileHash1[key], layer.TileHash2[key] = h1, h2 + local lx0, ly0 = LayerOrigin(draw_list, kind, ox, oy) + local x0, y0 = lx0 + layer.TileX[key] * TILE, ly0 + layer.TileY[key] * TILE + local vx0, vy0, vx1, vy1 = 0, 0, TILE, TILE + if layer.Root ~= layer.Frame then + vx0, vy0 = max(layer.ClipX0 + dx - x0, 0), max(layer.ClipY0 + dy - y0, 0) + vx1, vy1 = min(layer.ClipX1 + dx - x0, TILE), min(layer.ClipY1 + dy - y0, TILE) + end + local exposed = vx0 < tile.ValidX0 or vy0 < tile.ValidY0 or vx1 > tile.ValidX1 or vy1 > tile.ValidY1 + RedrawTile(BackendData, layer, key, tile, count, x0, y0, ox, oy, false, exposed, vx0, vy0, vx1, vy1) + end + table.clear(PatchPrim) + return true +end + -- Overlay frames are only hidden (the user owns them); unused layers hidden, long unused ones freed local function SweepLayers(BackendData, FrameNo) for frame, shown in pairs(BackendData.OverlayShown) do @@ -48436,7 +48726,7 @@ function M.RenderDrawData(draw_data) local set = BackendData.Layers[draw_list] local same, sdx, sdy = 0, 0, 0 if not force then same, sdx, sdy = CompareDrawList(set, draw_list, ox, oy, ScreenWidth, ScreenHeight) end - if same ~= 0 then + if same == 1 or same == 2 then z = ReuseDrawList(BackendData, set, draw_list, same, sdx, sdy, z, ox, oy, ScreenWidth, ScreenHeight) if EditableImages.StageTiming then EditableImages.EndStage("Compare") end PE() @@ -48448,13 +48738,38 @@ function M.RenderDrawData(draw_data) PB("ImGui collect") if EditableImages.StageTiming then EditableImages.BeginStage() end local LimitFree, ex0, ey0, ex1, ey1 + local n0 = n n, LimitFree, ex0, ey0, ex1, ey1 = CollectPrims(BackendData, draw_list, n, ox, oy, LimitX0, LimitY0, LimitX1, LimitY1) if EditableImages.StageTiming then EditableImages.EndStage("Collect") end PE() + local nd = Layers.DriftCount + if nd > 0 then + local Drift = Layers.Drift + for k = 1, nd do DriftSet[Drift[k] // 36 --[[VTX_STRIDE]] + 1] = true end + DriftOn, DriftMark1, DriftMark2 = true, (FrameNo * 7907 + 12345) % P1, (FrameNo * 7919 + 54321) % P2 + end + if same == 3 then + PB("ImGui drift patch") + if EditableImages.StageTiming then EditableImages.BeginStage() end + local patched = PatchDrawList(BackendData, set, draw_list, n0, n, sdx, sdy, ox, oy, LimitX0, LimitY0, + LimitX1, LimitY1) + if EditableImages.StageTiming then EditableImages.EndStage("Raster") end + PE() + if patched then + for k = 1, nd do DriftSet[Layers.Drift[k] // 36 --[[VTX_STRIDE]] + 1] = false end + DriftOn = false + z = ReuseDrawList(BackendData, set, draw_list, 2, sdx, sdy, z, ox, oy, ScreenWidth, ScreenHeight) + continue + end + end local ListDeferred z, ListDeferred = DrawLists(BackendData, draw_list, z, ox, oy, force, LimitX0, LimitY0, LimitX1, LimitY1) + if nd > 0 then + for k = 1, nd do DriftSet[Layers.Drift[k] // 36 --[[VTX_STRIDE]] + 1] = false end + DriftOn = false + end set = BackendData.Layers[draw_list] -- deferred tiles: not "unchanged" next frame, so they get redrawn if set then @@ -48463,6 +48778,10 @@ function M.RenderDrawData(draw_data) Snapshot(set, draw_list, ox, oy, ScreenWidth, ScreenHeight) set.SnapLimitFree = LimitFree set.SnapExtentX0, set.SnapExtentY0, set.SnapExtentX1, set.SnapExtentY1 = ex0, ey0, ex1, ey1 + -- the primitive sequence the tile lists were built from (PatchDrawList) + set.PrimBase, set.PrimN = n0, n - n0 + set.PrimSigA = table.move(PrimA, n0 + 1, n, 1, set.PrimSigA or {}) + set.PrimSigD = table.move(PrimD, n0 + 1, n, 1, set.PrimSigD or {}) end end if ListDeferred then AnyDeferred = true end @@ -49025,12 +49344,300 @@ end Parallel = M end +do +-- Patches: Luau/Roblox-tuned replacements of hot library internals, installed when the backend loads. +-- The library sources stay a 1:1 port (and run on LÖVE); these versions use buffers, typed natives and specialized fast +-- paths instead. Every patch must be exactly equivalent (same draw data, IDs, pixels): uncommon cases are handed back to +-- the original function. Only method tables / globals the callers look up at call time are replaced (MT.*), never a +-- library local. Enabled holds one switch per patch (bisecting: set one to false and rebuild; M.Set() switches at run +-- time for A/B timing). + +local M = {} +M.Enabled = { + RenderText = true, -- MT.ImFont.RenderText: Lua string, no CPU fine clip + AddText = true, -- MT.ImDrawList.AddText: same, calling the RenderText core directly + CalcTextSize = true, -- ImFontCalcTextSizeXY: cache hit of an unwrapped whole string, checked first +} + +local MT = ImGui.GetMetatables() +local byte, floor = string.byte, math.floor +local band, bor = bit32.band, bit32.bor +local writef64, writeu32 = buffer.writef64, buffer.writeu32 + +local IM_FONTGLYPH_INDEX_UNUSED = 0xFFFF -- same values as imgui_draw.lua's locals +local IM_FONTGLYPH_INDEX_NOT_FOUND = 0xFFFE + +------------------------------------------------------------------------------------------------------------------------ +-- Text: ImFont:RenderText() for a Lua string without CPU fine clip (and < 10k bytes unless wrapped) as one function +-- taking the clip rect as numbers, PrimReserve() inlined, no fine clip branches in the glyph loop. Same vertex/index +-- writes in the same order. ImDrawList:AddText() calls it directly (no clip rect copy, one call less). +------------------------------------------------------------------------------------------------------------------------ +local RenderText_Orig = MT.ImFont.RenderText +local AddText_Orig = MT.ImDrawList.AddText +local text_clip_rect = ImVec4() -- only for the texture-change fallback + +-- imgui_draw.lua's local ImTextCalcWordWrapNextLineStart() for a Lua string: trim trailing blanks, skip one '\n' +local function WordWrapNextLineStart(text: string, pos: number, text_end: number, flags: number): number + if band(flags, 2 --[[ImDrawTextFlags.WrapKeepBlanks]]) == 0 then + while pos < text_end do + local c = byte(text, pos) + if c ~= 32 and c ~= 9 then break end + pos += 1 + end + end + if pos < text_end and byte(text, pos) == 10 then + pos += 1 + end + return pos +end + +-- Returns false (nothing done) when the original must handle it: CPU fine clip, or unloaded glyphs changed the texture +@native +local function RenderTextCore(font, draw_list, size: number, x: number, y: number, col: number, clip_x1: number, clip_y1: number, clip_x2: number, clip_y2: number, text: string, s: number, text_end: number, wrap_width: number, flags: number): boolean + if y > clip_y2 then + return true + end + flags = bor(flags, draw_list.Flags) + if band(flags, 1 --[[ImDrawTextFlags.CpuFineClip]]) ~= 0 then + return false + end + if band(flags, 1048576 --[[ImDrawFlags.TextNoPixelSnap]]) == 0 then + x = floor(x) + y = floor(y) + end + + local baked = font.LastBaked + if not (baked and baked.Size == floor(size + 0.5) and baked.RasterizerDensity == font.CurrentRasterizerDensity) then + baked = font:GetFontBaked(size) + end + local scale: number = size / baked.Size + local origin_x = x + local line_height = size + local word_wrap_enabled = wrap_width > 0.0 + + -- Fast-forward to first visible line + if y + line_height < clip_y1 then + while y + line_height < clip_y1 and s < text_end do + local line_end = ImMemchr(text, '\n', s) + if word_wrap_enabled then + s = ImFontCalcWordWrapPositionEx(font, size, text, s, (line_end ~= nil) and line_end or text_end, wrap_width, flags) + s = WordWrapNextLineStart(text, s, text_end, flags) + else + s = (line_end ~= nil) and (line_end + 1) or text_end + end + y = y + line_height + end + end + if s == text_end then + return true + end + + local vtx_count_max = (text_end - s) * 4 + local idx_count_max = (text_end - s) * 6 + -- PrimReserve(idx_count_max, vtx_count_max) inlined + if (draw_list._VtxCurrentIdx + vtx_count_max >= 65536) and (band(draw_list.Flags, 4194304 --[[ImDrawFlags.UseVtxOffset]]) ~= 0) then + draw_list._CmdHeader.VtxOffset = draw_list.VtxBuffer.Size + 1 + draw_list:_OnChangedVtxOffset() + end + local cmd_buffer = draw_list.CmdBuffer + local cmd_count = cmd_buffer.Size + local draw_cmd = cmd_buffer.Data[cmd_count] + local elem_count = draw_cmd.ElemCount + idx_count_max + draw_cmd.ElemCount = elem_count + local vtx_buffer = draw_list.VtxBuffer + local vtx_write: number = vtx_buffer.Size + 1 + local vtx_new_size = vtx_write - 1 + vtx_count_max + if vtx_new_size > vtx_buffer.Capacity then vtx_buffer:resize(vtx_new_size) else vtx_buffer.Size = vtx_new_size end + local idx_buffer = draw_list.IdxBuffer + local idx_write: number = idx_buffer.Size + 1 + local idx_new_size = idx_write - 1 + idx_count_max + if idx_new_size > idx_buffer.Capacity then idx_buffer:resize(idx_new_size) else idx_buffer.Size = idx_new_size end + local idx_begin = idx_write + + local vtx_index: number = draw_list._VtxCurrentIdx + local idx_data = idx_buffer.Data + local vtx_data: buffer = vtx_buffer.Buf + local color_untinted = bor(col, 0x00FFFFFF) + local lookup, lookup_n, glyphs = baked.IndexLookup.Data, baked.IndexLookup.Size, baked.Glyphs.Data + local word_wrap_eol: number? = nil + + while s < text_end do + if word_wrap_enabled then + if not word_wrap_eol then + word_wrap_eol = ImFontCalcWordWrapPositionEx(font, size, text, s, text_end, wrap_width - (x - origin_x), flags) + lookup, lookup_n, glyphs = baked.IndexLookup.Data, baked.IndexLookup.Size, baked.Glyphs.Data + end + if s >= word_wrap_eol then + x = origin_x + y += line_height + if y > clip_y2 then + break + end + word_wrap_eol = nil + s = WordWrapNextLineStart(text, s, text_end, flags) -- Wrapping skips upcoming blanks + continue + end + end + local c: number = byte(text, s) + if c < 0x80 then + s += 1 + else + local wanted, out_char = ImStd.ImTextCharFromUtf8(text, s, text_end) + c = out_char + s += wanted + end + if c < 32 then + if c == 10 then + x = origin_x + y += line_height + if y > clip_y2 then + break + end + continue + end + if c == 13 then + continue + end + end + + local glyph + local gi = (c < lookup_n) and lookup[c + 1] or nil + if gi ~= nil and gi ~= IM_FONTGLYPH_INDEX_NOT_FOUND and gi ~= IM_FONTGLYPH_INDEX_UNUSED then + glyph = glyphs[gi] + else + glyph = baked:FindGlyph(c) + lookup, lookup_n, glyphs = baked.IndexLookup.Data, baked.IndexLookup.Size, baked.Glyphs.Data + end + + local char_width: number = glyph.AdvanceX * scale + if glyph.Visible then + local x1: number = x + glyph.X0 * scale + local x2: number = x + glyph.X1 * scale + if x1 <= clip_x2 and x2 >= clip_x1 then + local y1: number = y + glyph.Y0 * scale + local y2: number = y + glyph.Y1 * scale + local u1: number, v1: number, u2: number, v2: number = glyph.U0, glyph.V0, glyph.U1, glyph.V1 + local glyph_col = glyph.Colored and color_untinted or col + local o = (vtx_write - 1) * 36 + writef64(vtx_data, o, x1); writef64(vtx_data, o + 8, y1); writef64(vtx_data, o + 16, u1); writef64(vtx_data, o + 24, v1); writeu32(vtx_data, o + 32, glyph_col) + writef64(vtx_data, o + 36, x2); writef64(vtx_data, o + 44, y1); writef64(vtx_data, o + 52, u2); writef64(vtx_data, o + 60, v1); writeu32(vtx_data, o + 68, glyph_col) + writef64(vtx_data, o + 72, x2); writef64(vtx_data, o + 80, y2); writef64(vtx_data, o + 88, u2); writef64(vtx_data, o + 96, v2); writeu32(vtx_data, o + 104, glyph_col) + writef64(vtx_data, o + 108, x1); writef64(vtx_data, o + 116, y2); writef64(vtx_data, o + 124, u1); writef64(vtx_data, o + 132, v2); writeu32(vtx_data, o + 140, glyph_col) + idx_data[idx_write] = vtx_index; idx_data[idx_write + 1] = vtx_index + 1; idx_data[idx_write + 2] = vtx_index + 2 + idx_data[idx_write + 3] = vtx_index; idx_data[idx_write + 4] = vtx_index + 2; idx_data[idx_write + 5] = vtx_index + 3 + vtx_write += 4 + vtx_index += 4 + idx_write += 6 + end + end + x += char_width + end + + if cmd_count ~= cmd_buffer.Size then + -- Unloaded glyphs changed the texture: undo (like the original's edge case), the caller redoes it with the original + assert(cmd_buffer.Data[cmd_buffer.Size].ElemCount == 0) + cmd_buffer:pop_back() + draw_list:PrimUnreserve(idx_count_max, vtx_count_max) + draw_list:AddDrawCmd() + return false + end + + -- Give back unused vertices (clipped ones, blanks) + vtx_buffer.Size = vtx_write - 1 + idx_buffer.Size = idx_write - 1 + draw_cmd.ElemCount = elem_count - (idx_count_max - (idx_write - idx_begin)) + draw_list._VtxWritePtr = vtx_write + draw_list._IdxWritePtr = idx_write + draw_list._VtxCurrentIdx = vtx_index + return true +end + +@native +local function RenderText(self, draw_list, size: number, pos, col: number, clip_rect, text, text_begin: number, text_end: number, wrap_width: number?, flags: number?) + if type(text) ~= "string" or (text_end - text_begin > 1e4 and not (wrap_width ~= nil and wrap_width > 0.0)) + or not RenderTextCore(self, draw_list, size, pos.x, pos.y, col, clip_rect.x, clip_rect.y, clip_rect.z, clip_rect.w, text, text_begin, text_end, wrap_width or 0.0, flags or 0) then + return RenderText_Orig(self, draw_list, size, pos, col, clip_rect, text, text_begin, text_end, wrap_width, flags) + end +end + +@native +local function AddText(self, font, font_size, pos, col, text, text_begin, text_end, wrap_width, cpu_fine_clip_rect) + if cpu_fine_clip_rect ~= nil or type(text) ~= "string" or text_end == nil + or (type(font) == "table" and type(font[1]) == "number") then + return AddText_Orig(self, font, font_size, pos, col, text, text_begin, text_end, wrap_width, cpu_fine_clip_rect) + end + if text_begin == nil then text_begin = 1 end + if band(col, 0xFF000000) == 0 or text_begin == text_end then + return + end + if font == nil then + font = self._Data.Font + end + if font_size == 0.0 then + font_size = self._Data.FontSize + end + local cr = self._CmdHeader.ClipRect + if (text_end - text_begin > 1e4 and not (wrap_width ~= nil and wrap_width > 0.0)) + or not RenderTextCore(font, self, font_size, pos.x, pos.y, col, cr.x, cr.y, cr.z, cr.w, text, text_begin, text_end, wrap_width or 0.0, 0) then + local clip_rect = text_clip_rect + clip_rect.x = cr.x; clip_rect.y = cr.y; clip_rect.z = cr.z; clip_rect.w = cr.w + RenderText_Orig(font, self, font_size, pos, col, clip_rect, text, text_begin, text_end, wrap_width, 0) + end +end + +------------------------------------------------------------------------------------------------------------------------ +-- CalcTextSize: ImFontCalcTextSizeXY() answers most calls from its per baked font cache (whole string, no wrap/limit); +-- check that case first, with the same conditions, and hand everything else to the original. +------------------------------------------------------------------------------------------------------------------------ +local CalcTextSizeXY_Orig = ImFontCalcTextSizeXY +local TEXT_SIZE_CACHE_MAX = 4096 -- imgui_draw.lua's local: a full cache is reset by the original before looking up + +@native +local function CalcTextSizeXY(font, size: number, max_width: number, wrap_width: number, text, text_begin, text_end_display, text_end, out_offset, flags) + if wrap_width <= 0.0 and text_begin == 1 and type(text) == "string" and out_offset == nil and max_width >= 3.4028234663853e+38 --[[FLT_MAX]] + and (flags == nil or band(flags, 4 --[[ImDrawTextFlags.StopOnNewLine]]) == 0) then + local baked = font.LastBaked + if baked and baked.Size == floor(size + 0.5) and baked.RasterizerDensity == font.CurrentRasterizerDensity then + local cache = baked._TextSizeCache + if cache ~= nil and baked._TextSizeCacheN < TEXT_SIZE_CACHE_MAX then + local e = cache[text] + if e then + local text_len1 = string.len(text) + 1 + if (text_end == nil or text_end == text_len1) and (text_end_display == nil or text_end_display == text_len1) then + return e[1] * (size / baked.Size), e[2] * size, text_len1 + end + end + end + end + end + return CalcTextSizeXY_Orig(font, size, max_width, wrap_width, text, text_begin, text_end_display, text_end, out_offset, flags) +end + +------------------------------------------------------------------------------------------------------------------------ +-- name -> function(on) installing the patch or restoring the original +local Install = { + RenderText = function(on) MT.ImFont.RenderText = on and RenderText or RenderText_Orig end, + AddText = function(on) MT.ImDrawList.AddText = on and AddText or AddText_Orig end, + CalcTextSize = function(on) ImFontCalcTextSizeXY = on and CalcTextSizeXY or CalcTextSizeXY_Orig end, +} +-- Switches a patch at run time (tests time both versions in one process) +function M.Set(name: string, on: boolean) + Install[name](on) +end +for name in Install do + M.Set(name, M.Enabled[name]) +end + +Patches = M +end -- ImGui backend for Roblox: platform, input, files, Init/Shutdown and the public API; rendering in render.lua. -- Requires "Allow Mesh / Image APIs" (EditableImage) in game settings. +-- Luau-tuned replacements of hot library internals, installed when this file loads (see patches.lua) + local UserInputService = game:GetService("UserInputService") local Players = game:GetService("Players") @@ -49238,6 +49845,7 @@ function ImGui_ImplRoblox_Init(parent, render_scale) elseif BackendData.Stale and BackendData.HeartbeatCount > BackendData.StaleHeartbeat then ImGui_ImplRoblox_RenderDrawData(BackendData.Stale) end + Layers.Prewarm() BackendData.HeartbeatCount += 1 end) @@ -55929,6 +56537,8 @@ ffff001300090013001d002700310033003d004a0054005e00680072007c00860090009a00a400ae end __FILES['imgui_internal.lua'] = function() +local ImGui_ConvertSingleModFlagToKey, ImGui_DebugLog, ImGui_ErrorLog, ImGui_GetFrameCount, ImGui_IsNamedKey, ImGui_ScrollToRect, ImGui_StyleColorsDark +__BIND[#__BIND + 1] = function() if ImGui then ImGui_ConvertSingleModFlagToKey = ImGui.ConvertSingleModFlagToKey ImGui_DebugLog = ImGui.DebugLog ImGui_ErrorLog = ImGui.ErrorLog ImGui_GetFrameCount = ImGui.GetFrameCount ImGui_IsNamedKey = ImGui.IsNamedKey ImGui_ScrollToRect = ImGui.ScrollToRect ImGui_StyleColorsDark = ImGui.StyleColorsDark end end; __BIND[#__BIND]() -- dear imgui, v1.93.0 WIP -- (internal structures/api) @@ -56467,13 +57077,13 @@ IM_DRAWLIST_TEX_LINES_DETAILED_WIDTH_COUNT = ((IM_DRAWLIST_TEX_LINES_DETAILED_WI -- - See 'Demo->Configuration->Error Handling' and ImGuiIO definitions for details on error handling. -- - Read https://github.com/ocornut/imgui/wiki/Error-Handling for details on error handling. -- [Port] Upstream: `if (!(expr) && ErrorLog(msg)) IM_ASSERT(0)`. ErrorLog() returns io.ConfigErrorRecoveryEnableAssert. -function IM_ASSERT_USER_ERROR(_EXPR, _MSG) if not (_EXPR) or (_EXPR) == 0 then if not ImGui.ErrorLog or ImGui.ErrorLog(_MSG) then error(_MSG, 2) end end end -- Recoverable User Error +function IM_ASSERT_USER_ERROR(_EXPR, _MSG) if not (_EXPR) or (_EXPR) == 0 then if not ImGui_ErrorLog or ImGui_ErrorLog(_MSG) then error(_MSG, 2) end end end -- Recoverable User Error function IM_ASSERT_USER_ERROR_RET(_EXPR, _MSG) if not (_EXPR) or (_EXPR) == 0 then error(_MSG, 2) end end -- Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam. local function DebugLogIf(flag, fmt, ...) local g = GImGui - if g and bitAnd(g.DebugLogFlags, flag) ~= 0 then ImGui.DebugLog(fmt, ...) end + if g and bitAnd(g.DebugLogFlags, flag) ~= 0 then ImGui_DebugLog(fmt, ...) end end function IMGUI_DEBUG_LOG_ACTIVEID(...) DebugLogIf(2 --[[ImGuiDebugLogFlags.EventActiveId]], ...) end function IMGUI_DEBUG_LOG_POPUP(...) DebugLogIf(8 --[[ImGuiDebugLogFlags.EventPopup]], ...) end @@ -56573,8 +57183,8 @@ end --- @param ctx ImGuiContext --- @param key ImGuiKey function ImGui.GetKeyOwnerData(ctx, key) - if bitAnd(key, 61440 --[[ImGuiMod_Mask_]]) ~= 0 then key = ImGui.ConvertSingleModFlagToKey(key) end - assert(ImGui.IsNamedKey(key)) + if bitAnd(key, 61440 --[[ImGuiMod_Mask_]]) ~= 0 then key = ImGui_ConvertSingleModFlagToKey(key) end + assert(ImGui_IsNamedKey(key)) return ctx.KeysOwnerData[key - 512 --[[ImGuiKey.NamedKey_BEGIN]]] end @@ -57661,7 +58271,7 @@ function ImGuiStyle() } -- Default theme - ImGui.StyleColorsDark(this) + ImGui_StyleColorsDark(this) setmetatable(this, MT.ImGuiStyle) @@ -58924,7 +59534,7 @@ end --- @return ImRect --- @nodiscard function MT.ImGuiWindow:TitleBarRect() - return ImRect(self.Pos, ImVec2(self.Pos.x + self.SizeFull.x, self.Pos.y + self.TitleBarHeight)) + return ImRect(self.Pos.x, self.Pos.y, self.Pos.x + self.SizeFull.x, self.Pos.y + self.TitleBarHeight) -- [Luau] scalar form: no temporary ImVec2 end --- @return ImRect @@ -59811,7 +60421,7 @@ function ImGuiFocusScopeData() return { ID = nil, WindowID = nil } end -- [Luau] no operator bool(): call the object, e.g. 'if once() then ... end' MT.ImGuiOnceUponAFrame = {} MT.ImGuiOnceUponAFrame.__index = MT.ImGuiOnceUponAFrame -MT.ImGuiOnceUponAFrame.__call = function(self) local current_frame = ImGui.GetFrameCount(); if self.RefFrame == current_frame then return false end; self.RefFrame = current_frame; return true end +MT.ImGuiOnceUponAFrame.__call = function(self) local current_frame = ImGui_GetFrameCount(); if self.RefFrame == current_frame then return false end; self.RefFrame = current_frame; return true end function ImGuiOnceUponAFrame() return setmetatable({ RefFrame = -1 }, MT.ImGuiOnceUponAFrame) end -- [Internal] ImGuiTextFilter item @@ -59884,7 +60494,7 @@ function ImGui.GetCurrentTable() local g = GImGui; return g.CurrentTable end --- @param parent_window ImGuiWindow? function ImGui.SetWindowParentWindowForFocusRoute(window, parent_window) window.ParentWindowForFocusRoute = parent_window end -- You may also use SetNextWindowClass()'s FocusRouteParentWindowId field. function ImGui.GetPixelDensity() return GImGui.CurrentPixelDensity end -function ImGui.ScrollToBringRectIntoView(window, rect) ImGui.ScrollToRect(window, rect, 2 --[[ImGuiScrollFlags.KeepVisibleEdgeY]]) end +function ImGui.ScrollToBringRectIntoView(window, rect) ImGui_ScrollToRect(window, rect, 2 --[[ImGuiScrollFlags.KeepVisibleEdgeY]]) end function ImGui.GetItemStatusFlags() local g = GImGui; return g.LastItemData.StatusFlags end function ImGui.GetActiveID() local g = GImGui; return g.ActiveId end function ImGui.GetFocusID() local g = GImGui; return g.NavId end @@ -59899,7 +60509,10 @@ function ImGui.IsItemActiveAsInputText() local g = GImGui; return g.ActiveId ~= return true -- [Port] [Roblox] ModuleScripts must return exactly one value end -__FILES['imgui_tables.lua'] = function() +__FILES['imgui_tables.lua'] = (function() +local ImGui_AddSettingsHandler, ImGui_BeginChildEx, ImGui_BeginColumns, ImGui_BeginDisabled, ImGui_BeginMenu, ImGui_BeginPopupEx, ImGui_BeginTableEx, ImGui_ButtonBehavior, ImGui_CalcTextSize, ImGui_ClearActiveID, ImGui_DebugLog, ImGui_EndChild, ImGui_EndColumns, ImGui_EndDisabled, ImGui_EndMenu, ImGui_EndPopup, ImGui_ErrorCheckUsingSetCursorPosToExtendParentBoundaries, ImGui_FindOrCreateColumns, ImGui_FindRenderedTextEnd, ImGui_GetColorU32, ImGui_GetColumnNormFromOffset, ImGui_GetColumnOffset, ImGui_GetColumnOffsetFromNorm, ImGui_GetColumnsID, ImGui_GetContentRegionAvail, ImGui_GetCurrentWindow, ImGui_GetCurrentWindowRead, ImGui_GetCursorScreenPos, ImGui_GetID, ImGui_GetIDWithSeed, ImGui_GetMousePos, ImGui_IsAnyItemHovered, ImGui_IsClippedEx, ImGui_IsItemActive, ImGui_IsItemHovered, ImGui_IsMouseDoubleClicked, ImGui_IsMouseDragging, ImGui_IsMouseReleased, ImGui_IsPopupOpenRequestForItem, ImGui_KeepAliveID, ImGui_LocalizeGetMsg, ImGui_LogRenderedText, ImGui_MarkIniSettingsDirty, ImGui_MenuItem, ImGui_NavUpdateCurrentWindowIsScrollPushableX, ImGui_OpenPopupEx, ImGui_PopClipRect, ImGui_PopID, ImGui_PopItemFlag, ImGui_PopItemWidth, ImGui_PopStyleColor, ImGui_PushClipRect, ImGui_PushColumnClipRect, ImGui_PushID, ImGui_PushItemFlag, ImGui_PushItemWidth, ImGui_PushOverrideID, ImGui_PushStyleColor, ImGui_RenderArrow, ImGui_RenderCheckMark, ImGui_RenderNavCursor, ImGui_RenderText, ImGui_RenderTextEllipsis, ImGui_Selectable, ImGui_Separator, ImGui_SetColumnOffset, ImGui_SetItemTooltip, ImGui_SetMouseCursor, ImGui_SetNextWindowContentSize, ImGui_SetNextWindowScroll, ImGui_SetScrollFromPosX, ImGui_SetWindowClipRectBeforeSetChannel, ImGui_ShadeVertsTransformPos, ImGui_TableAngledHeadersRowEx, ImGui_TableApplyExternalUnclipRect, ImGui_TableApplyQueuedRequests, ImGui_TableBeginCell, ImGui_TableBeginContextMenuPopup, ImGui_TableBeginInitMemory, ImGui_TableBeginRow, ImGui_TableCalcMaxColumnWidth, ImGui_TableDrawBorders, ImGui_TableDrawDefaultContextMenu, ImGui_TableEndCell, ImGui_TableEndRow, ImGui_TableFixColumnSortDirection, ImGui_TableFixDisplayOrder, ImGui_TableGetBoundSettings, ImGui_TableGetCellBgRect, ImGui_TableGetColumnCount, ImGui_TableGetColumnFlags, ImGui_TableGetColumnName, ImGui_TableGetColumnNextSortDirection, ImGui_TableGetColumnResizeID, ImGui_TableGetColumnWidthAuto, ImGui_TableGetHeaderAngledMaxLabelWidth, ImGui_TableGetHeaderRowHeight, ImGui_TableGetHoveredColumn, ImGui_TableGetInstanceData, ImGui_TableGetInstanceID, ImGui_TableHeader, ImGui_TableInitColumnDefaults, ImGui_TableLoadSettings, ImGui_TableLoadSettingsForColumn, ImGui_TableLoadSettingsForColumns, ImGui_TableMergeDrawChannels, ImGui_TableNextColumn, ImGui_TableNextRow, ImGui_TableOpenContextMenu, ImGui_TableQueueSetColumnDisplayOrder, ImGui_TableReconcileColumns, ImGui_TableResetSettings, ImGui_TableSaveSettings, ImGui_TableSetBgColor, ImGui_TableSetColumnDisplayOrder, ImGui_TableSetColumnIndex, ImGui_TableSetColumnSortDirection, ImGui_TableSetColumnWidth, ImGui_TableSetColumnWidthAutoAll, ImGui_TableSetColumnWidthAutoSingle, ImGui_TableSettingsCreate, ImGui_TableSettingsFindByID, ImGui_TableSetupDrawChannels, ImGui_TableSortSpecsBuild, ImGui_TableSortSpecsSanitize, ImGui_TableUpdateBorders, ImGui_TableUpdateColumnsWeightFromWidth, ImGui_TableUpdateLayout, ImGui__CalcItemSizeXY +__BIND[#__BIND + 1] = function() if ImGui then ImGui_AddSettingsHandler = ImGui.AddSettingsHandler ImGui_BeginChildEx = ImGui.BeginChildEx ImGui_BeginColumns = ImGui.BeginColumns ImGui_BeginDisabled = ImGui.BeginDisabled ImGui_BeginMenu = ImGui.BeginMenu ImGui_BeginPopupEx = ImGui.BeginPopupEx ImGui_BeginTableEx = ImGui.BeginTableEx ImGui_ButtonBehavior = ImGui.ButtonBehavior ImGui_CalcTextSize = ImGui.CalcTextSize ImGui_ClearActiveID = ImGui.ClearActiveID ImGui_DebugLog = ImGui.DebugLog ImGui_EndChild = ImGui.EndChild ImGui_EndColumns = ImGui.EndColumns ImGui_EndDisabled = ImGui.EndDisabled ImGui_EndMenu = ImGui.EndMenu ImGui_EndPopup = ImGui.EndPopup ImGui_ErrorCheckUsingSetCursorPosToExtendParentBoundaries = ImGui.ErrorCheckUsingSetCursorPosToExtendParentBoundaries ImGui_FindOrCreateColumns = ImGui.FindOrCreateColumns ImGui_FindRenderedTextEnd = ImGui.FindRenderedTextEnd ImGui_GetColorU32 = ImGui.GetColorU32 ImGui_GetColumnNormFromOffset = ImGui.GetColumnNormFromOffset ImGui_GetColumnOffset = ImGui.GetColumnOffset ImGui_GetColumnOffsetFromNorm = ImGui.GetColumnOffsetFromNorm ImGui_GetColumnsID = ImGui.GetColumnsID ImGui_GetContentRegionAvail = ImGui.GetContentRegionAvail ImGui_GetCurrentWindow = ImGui.GetCurrentWindow ImGui_GetCurrentWindowRead = ImGui.GetCurrentWindowRead ImGui_GetCursorScreenPos = ImGui.GetCursorScreenPos ImGui_GetID = ImGui.GetID ImGui_GetIDWithSeed = ImGui.GetIDWithSeed ImGui_GetMousePos = ImGui.GetMousePos ImGui_IsAnyItemHovered = ImGui.IsAnyItemHovered ImGui_IsClippedEx = ImGui.IsClippedEx ImGui_IsItemActive = ImGui.IsItemActive ImGui_IsItemHovered = ImGui.IsItemHovered ImGui_IsMouseDoubleClicked = ImGui.IsMouseDoubleClicked ImGui_IsMouseDragging = ImGui.IsMouseDragging ImGui_IsMouseReleased = ImGui.IsMouseReleased ImGui_IsPopupOpenRequestForItem = ImGui.IsPopupOpenRequestForItem ImGui_KeepAliveID = ImGui.KeepAliveID ImGui_LocalizeGetMsg = ImGui.LocalizeGetMsg ImGui_LogRenderedText = ImGui.LogRenderedText ImGui_MarkIniSettingsDirty = ImGui.MarkIniSettingsDirty ImGui_MenuItem = ImGui.MenuItem ImGui_NavUpdateCurrentWindowIsScrollPushableX = ImGui.NavUpdateCurrentWindowIsScrollPushableX ImGui_OpenPopupEx = ImGui.OpenPopupEx ImGui_PopClipRect = ImGui.PopClipRect ImGui_PopID = ImGui.PopID ImGui_PopItemFlag = ImGui.PopItemFlag ImGui_PopItemWidth = ImGui.PopItemWidth ImGui_PopStyleColor = ImGui.PopStyleColor ImGui_PushClipRect = ImGui.PushClipRect ImGui_PushColumnClipRect = ImGui.PushColumnClipRect ImGui_PushID = ImGui.PushID ImGui_PushItemFlag = ImGui.PushItemFlag ImGui_PushItemWidth = ImGui.PushItemWidth ImGui_PushOverrideID = ImGui.PushOverrideID ImGui_PushStyleColor = ImGui.PushStyleColor ImGui_RenderArrow = ImGui.RenderArrow ImGui_RenderCheckMark = ImGui.RenderCheckMark ImGui_RenderNavCursor = ImGui.RenderNavCursor ImGui_RenderText = ImGui.RenderText ImGui_RenderTextEllipsis = ImGui.RenderTextEllipsis ImGui_Selectable = ImGui.Selectable ImGui_Separator = ImGui.Separator ImGui_SetColumnOffset = ImGui.SetColumnOffset ImGui_SetItemTooltip = ImGui.SetItemTooltip ImGui_SetMouseCursor = ImGui.SetMouseCursor ImGui_SetNextWindowContentSize = ImGui.SetNextWindowContentSize ImGui_SetNextWindowScroll = ImGui.SetNextWindowScroll ImGui_SetScrollFromPosX = ImGui.SetScrollFromPosX ImGui_SetWindowClipRectBeforeSetChannel = ImGui.SetWindowClipRectBeforeSetChannel ImGui_ShadeVertsTransformPos = ImGui.ShadeVertsTransformPos ImGui_TableAngledHeadersRowEx = ImGui.TableAngledHeadersRowEx ImGui_TableApplyExternalUnclipRect = ImGui.TableApplyExternalUnclipRect ImGui_TableApplyQueuedRequests = ImGui.TableApplyQueuedRequests ImGui_TableBeginCell = ImGui.TableBeginCell ImGui_TableBeginContextMenuPopup = ImGui.TableBeginContextMenuPopup ImGui_TableBeginInitMemory = ImGui.TableBeginInitMemory ImGui_TableBeginRow = ImGui.TableBeginRow ImGui_TableCalcMaxColumnWidth = ImGui.TableCalcMaxColumnWidth ImGui_TableDrawBorders = ImGui.TableDrawBorders ImGui_TableDrawDefaultContextMenu = ImGui.TableDrawDefaultContextMenu ImGui_TableEndCell = ImGui.TableEndCell ImGui_TableEndRow = ImGui.TableEndRow ImGui_TableFixColumnSortDirection = ImGui.TableFixColumnSortDirection ImGui_TableFixDisplayOrder = ImGui.TableFixDisplayOrder ImGui_TableGetBoundSettings = ImGui.TableGetBoundSettings ImGui_TableGetCellBgRect = ImGui.TableGetCellBgRect ImGui_TableGetColumnCount = ImGui.TableGetColumnCount ImGui_TableGetColumnFlags = ImGui.TableGetColumnFlags ImGui_TableGetColumnName = ImGui.TableGetColumnName ImGui_TableGetColumnNextSortDirection = ImGui.TableGetColumnNextSortDirection ImGui_TableGetColumnResizeID = ImGui.TableGetColumnResizeID ImGui_TableGetColumnWidthAuto = ImGui.TableGetColumnWidthAuto ImGui_TableGetHeaderAngledMaxLabelWidth = ImGui.TableGetHeaderAngledMaxLabelWidth ImGui_TableGetHeaderRowHeight = ImGui.TableGetHeaderRowHeight ImGui_TableGetHoveredColumn = ImGui.TableGetHoveredColumn ImGui_TableGetInstanceData = ImGui.TableGetInstanceData ImGui_TableGetInstanceID = ImGui.TableGetInstanceID ImGui_TableHeader = ImGui.TableHeader ImGui_TableInitColumnDefaults = ImGui.TableInitColumnDefaults ImGui_TableLoadSettings = ImGui.TableLoadSettings ImGui_TableLoadSettingsForColumn = ImGui.TableLoadSettingsForColumn ImGui_TableLoadSettingsForColumns = ImGui.TableLoadSettingsForColumns ImGui_TableMergeDrawChannels = ImGui.TableMergeDrawChannels ImGui_TableNextColumn = ImGui.TableNextColumn ImGui_TableNextRow = ImGui.TableNextRow ImGui_TableOpenContextMenu = ImGui.TableOpenContextMenu ImGui_TableQueueSetColumnDisplayOrder = ImGui.TableQueueSetColumnDisplayOrder ImGui_TableReconcileColumns = ImGui.TableReconcileColumns ImGui_TableResetSettings = ImGui.TableResetSettings ImGui_TableSaveSettings = ImGui.TableSaveSettings ImGui_TableSetBgColor = ImGui.TableSetBgColor ImGui_TableSetColumnDisplayOrder = ImGui.TableSetColumnDisplayOrder ImGui_TableSetColumnIndex = ImGui.TableSetColumnIndex ImGui_TableSetColumnSortDirection = ImGui.TableSetColumnSortDirection ImGui_TableSetColumnWidth = ImGui.TableSetColumnWidth ImGui_TableSetColumnWidthAutoAll = ImGui.TableSetColumnWidthAutoAll ImGui_TableSetColumnWidthAutoSingle = ImGui.TableSetColumnWidthAutoSingle ImGui_TableSettingsCreate = ImGui.TableSettingsCreate ImGui_TableSettingsFindByID = ImGui.TableSettingsFindByID ImGui_TableSetupDrawChannels = ImGui.TableSetupDrawChannels ImGui_TableSortSpecsBuild = ImGui.TableSortSpecsBuild ImGui_TableSortSpecsSanitize = ImGui.TableSortSpecsSanitize ImGui_TableUpdateBorders = ImGui.TableUpdateBorders ImGui_TableUpdateColumnsWeightFromWidth = ImGui.TableUpdateColumnsWeightFromWidth ImGui_TableUpdateLayout = ImGui.TableUpdateLayout ImGui__CalcItemSizeXY = ImGui._CalcItemSizeXY end end; __BIND[#__BIND]() +return function() --- Dear ImGui WIP -- (tables and columns code) -- 1:1 port of imgui_tables.cpp (docking branch, 1.93 WIP) @@ -60109,7 +60722,7 @@ IMGUI_TABLE_MAX_COLUMNS = 512 -- Arbitrary "safety" maximum, may be lifted in th local function IMGUI_DEBUG_LOG_TABLE(fmt, ...) local g = GImGui - if band(g.DebugLogFlags, 4096 --[[ImGuiDebugLogFlags.EventTable]]) ~= 0 then ImGui.DebugLog(fmt, ...) end + if band(g.DebugLogFlags, 4096 --[[ImGuiDebugLogFlags.EventTable]]) ~= 0 then ImGui_DebugLog(fmt, ...) end end ------------------------------------------------------------------------------- @@ -60257,6 +60870,8 @@ end ImGuiTableColumnFlags.NoDirectResize_ = ImGuiTableColumnFlags.NoDirectResize_ or lshift(1, 30) -- [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge) local function Rect(r) return ImRect(r.Min.x, r.Min.y, r.Max.x, r.Max.y) end +-- [Luau] scratch rects for TableUpdateLayout()/TableMergeDrawChannels() locals that never escape +local TableUpdateLayout_work_rect, TableUpdateLayout_host_clip_rect, TableUpdateLayout_mouse_hit_rect, TableMergeDrawChannels_merge_clip_rect = ImRect(), ImRect(), ImRect(), ImRect() local function V2(v) return ImVec2(v.x, v.y) end ------------------------------------------------------------------------------- @@ -60340,7 +60955,7 @@ function ImGui.TableGetInstanceData(table_, instance_no) end function ImGui.TableGetInstanceID(table_, instance_no) - return ImGui.TableGetInstanceData(table_, instance_no).TableInstanceID + return ImGui_TableGetInstanceData(table_, instance_no).TableInstanceID end -- Read about "TABLE SIZING" at the top of this file. @@ -60350,17 +60965,18 @@ end --- @param outer_size? ImVec2 --- @param inner_width? float function ImGui.BeginTable(str_id, columns_count, flags, outer_size, inner_width) - local id = ImGui.GetID(str_id) - return ImGui.BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width) + local id = ImGui_GetID(str_id) + return ImGui_BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width) end +local BeginTableEx_outer_size_default = ImVec2(0.0, 0.0) -- [Luau] shared read-only default (only read below) function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_width) if flags == nil then flags = 0 end - if outer_size == nil then outer_size = ImVec2(0.0, 0.0) end + if outer_size == nil then outer_size = BeginTableEx_outer_size_default end if inner_width == nil then inner_width = 0.0 end local g = GImGui - local outer_window = ImGui.GetCurrentWindow() + local outer_window = ImGui_GetCurrentWindow() if outer_window.SkipItems then -- Consistent with other tables + beneficial side effect that assert on miscalling EndTable() will be more visible. return false end @@ -60379,11 +60995,13 @@ function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_wi -- - always reserving the pooled ImGuiTable data ahead for a fully clipped table (minor IMHO). Also the 'outer_window_is_measuring_size' criteria may already be defeating this in some situations. -- - always performing the GetOrAddByKey() O(log N) query in g.Tables.Map[]. local use_child_window = band(flags, bor(16777216 --[[ImGuiTableFlags.ScrollX]], 33554432 --[[ImGuiTableFlags.ScrollY]])) ~= 0 - local avail_size = ImGui.GetContentRegionAvail() - local actual_outer_size = ImTrunc(ImGui.CalcItemSize(outer_size, mathMax(avail_size.x, 4 --[[IMGUI_WINDOW_HARD_MIN_SIZE]]), use_child_window and mathMax(avail_size.y, 4 --[[IMGUI_WINDOW_HARD_MIN_SIZE]]) or 0.0)) - local outer_rect = ImRect(outer_window.DC.CursorPos, outer_window.DC.CursorPos + actual_outer_size) + local avail_size = ImGui_GetContentRegionAvail() + local actual_outer_size_x, actual_outer_size_y = ImGui__CalcItemSizeXY(outer_size.x, outer_size.y, mathMax(avail_size.x, 4 --[[IMGUI_WINDOW_HARD_MIN_SIZE]]), use_child_window and mathMax(avail_size.y, 4 --[[IMGUI_WINDOW_HARD_MIN_SIZE]]) or 0.0) + actual_outer_size_x, actual_outer_size_y = ImTrunc(actual_outer_size_x), ImTrunc(actual_outer_size_y) -- [Luau] scalar ImTrunc(CalcItemSize(...)) + local outer_cursor = outer_window.DC.CursorPos + local outer_rect = ImRect(outer_cursor.x, outer_cursor.y, outer_cursor.x + actual_outer_size_x, outer_cursor.y + actual_outer_size_y) -- [Luau] scalar form: no temporary ImVec2 local outer_window_is_measuring_size = (outer_window.AutoFitFramesX > 0) or (outer_window.AutoFitFramesY > 0) -- Doesn't apply to AlwaysAutoResize windows! - if use_child_window and ImGui.IsClippedEx(outer_rect, 0) and not outer_window_is_measuring_size then + if use_child_window and ImGui_IsClippedEx(outer_rect, 0) and not outer_window_is_measuring_size then ImGui.ItemSize(outer_rect) ImGui.ItemAdd(outer_rect, id) g.NextWindowData:ClearFlags() @@ -60437,11 +61055,11 @@ function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_wi if table_.InstanceDataExtra.Size < instance_no then table_.InstanceDataExtra:push_back(ImGuiTableInstanceData()) end - instance_id = ImGui.GetIDWithSeed(instance_no, ImGui.GetIDWithSeed("##Instances", nil, id)) -- Push "##Instances" followed by (int)instance_no in ID stack. + instance_id = ImGui_GetIDWithSeed(instance_no, ImGui_GetIDWithSeed("##Instances", nil, id)) -- Push "##Instances" followed by (int)instance_no in ID stack. else instance_id = id end - local table_instance = ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) + local table_instance = ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) table_instance.TableInstanceID = instance_id -- When not using a child window, WorkRect.Max will grow as we append contents. @@ -60462,19 +61080,19 @@ function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_wi end if override_content_size.x ~= 3.4028234663853e+38 --[[FLT_MAX]] or override_content_size.y ~= 3.4028234663853e+38 --[[FLT_MAX]] then - ImGui.SetNextWindowContentSize(ImVec2((override_content_size.x ~= 3.4028234663853e+38 --[[FLT_MAX]]) and override_content_size.x or 0.0, (override_content_size.y ~= 3.4028234663853e+38 --[[FLT_MAX]]) and override_content_size.y or 0.0)) + ImGui_SetNextWindowContentSize(ImVec2((override_content_size.x ~= 3.4028234663853e+38 --[[FLT_MAX]]) and override_content_size.x or 0.0, (override_content_size.y ~= 3.4028234663853e+38 --[[FLT_MAX]]) and override_content_size.y or 0.0)) end -- Reset scroll if we are reactivating it if band(previous_flags, bor(16777216 --[[ImGuiTableFlags.ScrollX]], 33554432 --[[ImGuiTableFlags.ScrollY]])) == 0 then if band(g.NextWindowData.HasFlags, 128 --[[ImGuiNextWindowDataFlags.HasScroll]]) == 0 then - ImGui.SetNextWindowScroll(ImVec2(0.0, 0.0)) + ImGui_SetNextWindowScroll(ImVec2(0.0, 0.0)) end end -- Create scrolling region (without border and zero window padding) local child_window_flags = (band(flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) ~= 0) and 2048 --[[ImGuiWindowFlags.HorizontalScrollbar]] or 0 --[[ImGuiWindowFlags.None]] - ImGui.BeginChildEx(name, instance_id, outer_rect:GetSize(), 0 --[[ImGuiChildFlags.None]], child_window_flags) + ImGui_BeginChildEx(name, instance_id, outer_rect:GetSize(), 0 --[[ImGuiChildFlags.None]], child_window_flags) table_.InnerWindow = g.CurrentWindow ImRect_Copy(table_.WorkRect, table_.InnerWindow.WorkRect) ImRect_Copy(table_.OuterRect, table_.InnerWindow:Rect()) @@ -60504,9 +61122,9 @@ function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_wi end -- Push a standardized ID for both child-using and not-child-using tables - ImGui.PushOverrideID(id) + ImGui_PushOverrideID(id) if instance_no > 0 then - ImGui.PushOverrideID(instance_id) -- FIXME: Somehow this is not resolved by stack-tool, even tho GetIDWithSeed() submitted the symbol. + ImGui_PushOverrideID(instance_id) -- FIXME: Somehow this is not resolved by stack-tool, even tho GetIDWithSeed() submitted the symbol. end -- Backup a copy of host window members we will modify @@ -60594,8 +61212,8 @@ function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_wi temp_data.AngledHeadersExtraWidth = 0.0 -- Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders() - table_.BorderColorStrong = ImGui.GetColorU32(49 --[[ImGuiCol.TableBorderStrong]]) - table_.BorderColorLight = ImGui.GetColorU32(50 --[[ImGuiCol.TableBorderLight]]) + table_.BorderColorStrong = ImGui_GetColorU32(49 --[[ImGuiCol.TableBorderStrong]]) + table_.BorderColorLight = ImGui_GetColorU32(50 --[[ImGuiCol.TableBorderLight]]) -- Make table current g.CurrentTable = table_ @@ -60632,11 +61250,11 @@ function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_wi table_.RawData = nil end if table_.RawData == nil then - ImGui.TableBeginInitMemory(table_, columns_count) + ImGui_TableBeginInitMemory(table_, columns_count) table_.IsInitializing = true end if table_.IsResetAllRequest then - ImGui.TableResetSettings(table_) + ImGui_TableResetSettings(table_) end if table_.IsInitializing then -- Initialize @@ -60670,7 +61288,7 @@ function ImGui.BeginTableEx(name, id, columns_count, flags, outer_size, inner_wi -- Load settings if table_.IsSettingsRequestLoad then - ImGui.TableLoadSettings(table_) + ImGui_TableLoadSettings(table_) end -- Disable output until user calls TableNextRow() or TableNextColumn() leading to the TableUpdateLayout() call.. @@ -60711,7 +61329,7 @@ function ImGui.TableApplyQueuedRequests(table_) -- FIXME-TABLE: Contains columns if our work area doesn't allow for scrolling? if table_.InstanceCurrent == 0 then if table_.ResizedColumn ~= -1 and table_.ResizedColumnNextWidth ~= 3.4028234663853e+38 --[[FLT_MAX]] then - ImGui.TableSetColumnWidth(table_.ResizedColumn, table_.ResizedColumnNextWidth) + ImGui_TableSetColumnWidth(table_.ResizedColumn, table_.ResizedColumnNextWidth) end table_.LastResizedColumn = table_.ResizedColumn table_.ResizedColumnNextWidth = 3.4028234663853e+38 --[[FLT_MAX]] @@ -60720,7 +61338,7 @@ function ImGui.TableApplyQueuedRequests(table_) -- Process auto-fit for single column, which is a special case for stretch columns and fixed columns with FixedSame policy. -- FIXME-TABLE: Would be nice to redistribute available stretch space accordingly to other weights, instead of giving it all to siblings. if table_.AutoFitSingleColumn ~= -1 then - ImGui.TableSetColumnWidth(table_.AutoFitSingleColumn, table_.Columns[table_.AutoFitSingleColumn].WidthAuto) + ImGui_TableSetColumnWidth(table_.AutoFitSingleColumn, table_.Columns[table_.AutoFitSingleColumn].WidthAuto) table_.AutoFitSingleColumn = -1 end end @@ -60731,7 +61349,7 @@ function ImGui.TableApplyQueuedRequests(table_) table_.LastHeldHeaderColumn = table_.HeldHeaderColumn table_.HeldHeaderColumn = -1 if table_.ReorderColumn ~= -1 and table_.ReorderColumnDstOrder ~= -1 then - ImGui.TableSetColumnDisplayOrder(table_, table_.ReorderColumn, table_.ReorderColumnDstOrder) + ImGui_TableSetColumnDisplayOrder(table_, table_.ReorderColumn, table_.ReorderColumnDstOrder) table_.ReorderColumnDstOrder = -1 end @@ -60882,7 +61500,7 @@ local function TableSetupColumnFlags(table_, column, column_n, flags_in) column.SortDirectionsAvailList = band(list, 0xFF) column.SortDirectionsAvailMask = band(mask, 0xFF) column.SortDirectionsAvailCount = count - ImGui.TableFixColumnSortDirection(table_, column) + ImGui_TableFixColumnSortDirection(table_, column) end end @@ -60898,7 +61516,7 @@ function ImGui.TableUpdateLayout(table_) -- Reconcile moved columns if temp_data.ReconcileColumnsRequests.Size > 0 then - ImGui.TableReconcileColumns(table_) + ImGui_TableReconcileColumns(table_) end if temp_data.OldColumnsRawData then temp_data.OldColumnsRawData = nil @@ -60908,7 +61526,7 @@ function ImGui.TableUpdateLayout(table_) -- Apply columns settings if table_.IsSettingsRequestLoad then - ImGui.TableLoadSettingsForColumns(table_) + ImGui_TableLoadSettingsForColumns(table_) end if table_.IsInitializing or table_.IsSettingsRequestLoad then for n = 0, table_.ColumnsSize - 1 do @@ -60919,14 +61537,14 @@ function ImGui.TableUpdateLayout(table_) else init_flags = column.IsJustCreated and bnot(0) or 0 end - ImGui.TableInitColumnDefaults(table_, column, n, init_flags) + ImGui_TableInitColumnDefaults(table_, column, n, init_flags) end - ImGui.TableFixDisplayOrder(table_) -- Call even for non _Reorderable table as we loaded .ini data. + ImGui_TableFixDisplayOrder(table_) -- Call even for non _Reorderable table as we loaded .ini data. table_.IsSettingsRequestLoad = false end -- Apply queued resizing/reordering/hiding requests - ImGui.TableApplyQueuedRequests(table_) + ImGui_TableApplyQueuedRequests(table_) -- Handle DPI/font resize -- This is designed to facilitate DPI changes with the assumption that e.g. style.CellPadding has been scaled as well. @@ -61031,7 +61649,7 @@ function ImGui.TableUpdateLayout(table_) -- Calculate ideal/auto column width (that's the width required for all contents to be visible without clipping) -- Combine width from regular rows + width from headers unless requested not to. if not column.IsPreserveWidthAuto and table_.InstanceCurrent == 0 then - column.WidthAuto = ImGui.TableGetColumnWidthAuto(table_, column) + column.WidthAuto = ImGui_TableGetColumnWidthAuto(table_, column) end -- Non-resizable columns keep their requested width (apply user value regardless of IsPreserveWidthAuto) @@ -61133,7 +61751,7 @@ function ImGui.TableUpdateLayout(table_) table_.ColumnsStretchSumWeights = stretch_sum_weights -- [Part 4] Apply final widths based on requested widths - local work_rect = Rect(table_.WorkRect) + local work_rect = TableUpdateLayout_work_rect; ImRect_Copy(work_rect, table_.WorkRect) -- [Luau] scratch copy local width_spacings = (table_.OuterPaddingX * 2.0) + (table_.CellSpacingX1 + table_.CellSpacingX2) * (table_.ColumnsEnabledCount - 1) local width_removed = (table_.HasScrollbarYPrev and not table_.InnerWindow.ScrollbarY) and g.Style.ScrollbarSize or 0.0 -- To synchronize decoration width of synced tables with mismatching scrollbar state (#5920) local width_avail = mathMax(1.0, ((band(table_.Flags, 16777216 --[[ImGuiTableFlags.ScrollX]]) ~= 0 and table_.InnerWidth == 0.0) and table_.InnerClipRect:GetWidth() or work_rect:GetWidth()) - width_removed) @@ -61185,11 +61803,12 @@ function ImGui.TableUpdateLayout(table_) -- but because our item is partially submitted at this point we use ItemHoverable() and a workaround (temporarily -- clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem). -- - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop. - local table_instance = ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) + local table_instance = ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) table_instance.HoveredRowLast = table_instance.HoveredRowNext table_instance.HoveredRowNext = -1 table_.HoveredColumnBody = -1; table_.HoveredColumnBorder = -1 - local mouse_hit_rect = ImRect(table_.OuterRect.Min.x, table_.OuterRect.Min.y, table_.OuterRect.Max.x, mathMax(table_.OuterRect.Max.y, table_.OuterRect.Min.y + table_instance.LastOuterHeight)) + local mouse_hit_rect = TableUpdateLayout_mouse_hit_rect -- [Luau] scratch, ItemHoverable() only reads it + mouse_hit_rect.Min.x, mouse_hit_rect.Min.y, mouse_hit_rect.Max.x, mouse_hit_rect.Max.y = table_.OuterRect.Min.x, table_.OuterRect.Min.y, table_.OuterRect.Max.x, mathMax(table_.OuterRect.Max.y, table_.OuterRect.Min.y + table_instance.LastOuterHeight) local backup_active_id = g.ActiveId g.ActiveId = 0 local is_hovering_table = ImGui.ItemHoverable(mouse_hit_rect, 0, 0 --[[ImGuiItemFlags.None]]) @@ -61208,7 +61827,7 @@ function ImGui.TableUpdateLayout(table_) local has_at_least_one_column_requesting_output = false local offset_x_frozen = (table_.FreezeColumnsCount > 0) local offset_x = ((table_.FreezeColumnsCount > 0) and table_.OuterRect.Min.x or work_rect.Min.x) + table_.OuterPaddingX - table_.CellSpacingX1 - local host_clip_rect = Rect(table_.InnerClipRect) + local host_clip_rect = TableUpdateLayout_host_clip_rect; ImRect_Copy(host_clip_rect, table_.InnerClipRect) -- [Luau] scratch copy --host_clip_rect.Max.x += table.CellPaddingX + table.CellSpacingX2 BitArrayClearAll(table_.VisibleMaskByIndex) for order_n = 0, columns_count - 1 do @@ -61243,7 +61862,7 @@ function ImGui.TableUpdateLayout(table_) column.MinX = offset_x -- Lock width based on start position and minimum/maximum width for this position - column.WidthMax = ImGui.TableCalcMaxColumnWidth(table_, column_n) + column.WidthMax = ImGui_TableCalcMaxColumnWidth(table_, column_n) column.WidthGiven = mathMin(column.WidthGiven, column.WidthMax) column.WidthGiven = mathMax(column.WidthGiven, mathMin(column.WidthRequest, table_.MinColumnWidth)) column.MaxX = offset_x + column.WidthGiven + table_.CellSpacingX1 + table_.CellSpacingX2 + table_.CellPaddingX * 2.0 @@ -61389,11 +62008,11 @@ function ImGui.TableUpdateLayout(table_) table_.InnerWindow.WorkRect.Max.y = ImClamp(window_content_max_y - g.Style.CellPadding.y, table_.InnerWindow.WorkRect.Min.y, table_.InnerWindow.WorkRect.Max.y) -- [Part 9] Allocate draw channels and setup background cliprect - ImGui.TableSetupDrawChannels(table_) + ImGui_TableSetupDrawChannels(table_) -- [Part 10] Hit testing on borders if band(table_.Flags, 1 --[[ImGuiTableFlags.Resizable]]) ~= 0 then - ImGui.TableUpdateBorders(table_) + ImGui_TableUpdateBorders(table_) end table_instance.LastTopHeadersRowHeight = 0.0 table_.IsLayoutLocked = true @@ -61414,15 +62033,15 @@ function ImGui.TableUpdateLayout(table_) -- - To modify or replace this: set table.DisableDefaultContextMenu = true, then call TableBeginContextMenuPopup()/.../EndPopup(). -- - You may call TableDrawDefaultContextMenu() with selected flags to display specific sections of the default menu, -- e.g. TableDrawDefaultContextMenu(table, table.Flags & ~ImGuiTableFlags.Hideable) will display everything EXCEPT columns visibility options. - if table_.DisableDefaultContextMenu == false and ImGui.TableBeginContextMenuPopup(table_) then - ImGui.TableDrawDefaultContextMenu(table_, table_.Flags) - ImGui.EndPopup() + if table_.DisableDefaultContextMenu == false and ImGui_TableBeginContextMenuPopup(table_) then + ImGui_TableDrawDefaultContextMenu(table_, table_.Flags) + ImGui_EndPopup() end -- [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 and band(table_.Flags, 8 --[[ImGuiTableFlags.Sortable]]) ~= 0 then - ImGui.TableSortSpecsBuild(table_) + ImGui_TableSortSpecsBuild(table_) end -- [Part 13] Setup inner window decoration size (for scrolling / nav tracking to properly take account of frozen rows/columns) @@ -61437,7 +62056,7 @@ function ImGui.TableUpdateLayout(table_) local inner_window = table_.InnerWindow local bs = g.BoxSelectState if bs.Window == inner_window and bs.UnclipMode then - ImGui.TableApplyExternalUnclipRect(table_, bs.UnclipRect) + ImGui_TableApplyExternalUnclipRect(table_, bs.UnclipRect) end -- Initial state @@ -61473,7 +62092,7 @@ function ImGui.TableUpdateBorders(table_) -- use the final height from last frame. Because this is only affecting _interaction_ with columns, it is not -- really problematic (whereas the actual visual will be displayed in EndTable() and using the current frame height). -- Actual columns highlight/render will be performed in EndTable() and not be affected. - local table_instance = ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) + local table_instance = ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) local hit_half_width = ImTrunc(TABLE_RESIZE_SEPARATOR_HALF_THICKNESS * g.CurrentDpiScale) local hit_y1 = ((table_.FreezeRowsCount >= 1) and table_.OuterRect.Min.y or table_.WorkRect.Min.y) + table_.AngledHeadersHeight local hit_y2_body = mathMax(table_.OuterRect.Max.y, hit_y1 + table_instance.LastOuterHeight - table_.AngledHeadersHeight) @@ -61501,15 +62120,15 @@ function ImGui.TableUpdateBorders(table_) break end - local column_id = ImGui.TableGetColumnResizeID(table_, column_n, table_.InstanceCurrent) + local column_id = ImGui_TableGetColumnResizeID(table_, column_n, table_.InstanceCurrent) local hit_rect = ImRect(column.MaxX - hit_half_width, hit_y1, column.MaxX + hit_half_width, border_y2_hit) ImGui.ItemAdd(hit_rect, column_id, nil, 2 --[[ImGuiItemFlags.NoNav]]) --ImGui.GetForegroundDrawList():AddRect(hit_rect.Min, hit_rect.Max, IM_COL32(255, 0, 0, 100)) - local pressed, hovered, held = ImGui.ButtonBehavior(hit_rect, column_id, bor(2048 --[[ImGuiButtonFlags.FlattenChildren]], 16 --[[ImGuiButtonFlags.PressedOnClick]], 256 --[[ImGuiButtonFlags.PressedOnDoubleClick]], 262144 --[[ImGuiButtonFlags.NoNavFocus]])) - if pressed and ImGui.IsMouseDoubleClicked(0) then - ImGui.TableSetColumnWidthAutoSingle(table_, column_n) - ImGui.ClearActiveID() + local pressed, hovered, held = ImGui_ButtonBehavior(hit_rect, column_id, bor(2048 --[[ImGuiButtonFlags.FlattenChildren]], 16 --[[ImGuiButtonFlags.PressedOnClick]], 256 --[[ImGuiButtonFlags.PressedOnDoubleClick]], 262144 --[[ImGuiButtonFlags.NoNavFocus]])) + if pressed and ImGui_IsMouseDoubleClicked(0) then + ImGui_TableSetColumnWidthAutoSingle(table_, column_n) + ImGui_ClearActiveID() held = false end if held then @@ -61521,7 +62140,7 @@ function ImGui.TableUpdateBorders(table_) end if (hovered and g.HoveredIdTimer > TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER) or held then table_.HoveredColumnBorder = column_n - ImGui.SetMouseCursor(4 --[[ImGuiMouseCursor.ResizeEW]]) + ImGui_SetMouseCursor(4 --[[ImGuiMouseCursor.ResizeEW]]) end until true end @@ -61539,7 +62158,7 @@ function ImGui.EndTable() -- If the user never got to call TableNextRow() or TableNextColumn(), we call layout ourselves to ensure all our -- code paths are consistent (instead of just hoping that TableBegin/TableEnd will work), get borders drawn, etc. if not table_.IsLayoutLocked then - ImGui.TableUpdateLayout(table_) + ImGui_TableUpdateLayout(table_) end local flags = table_.Flags @@ -61550,18 +62169,18 @@ function ImGui.EndTable() assert(outer_window == inner_window or outer_window == inner_window.ParentWindow) if table_.IsInsideRow then - ImGui.TableEndRow(table_) + ImGui_TableEndRow(table_) end -- Context menu in columns body if band(flags, 32 --[[ImGuiTableFlags.ContextMenuInBody]]) ~= 0 then - if table_.HoveredColumnBody ~= -1 and not ImGui.IsAnyItemHovered() and ImGui.IsMouseReleased(1 --[[ImGuiMouseButton.Right]]) then - ImGui.TableOpenContextMenu(table_.HoveredColumnBody) + if table_.HoveredColumnBody ~= -1 and not ImGui_IsAnyItemHovered() and ImGui_IsMouseReleased(1 --[[ImGuiMouseButton.Right]]) then + ImGui_TableOpenContextMenu(table_.HoveredColumnBody) end end -- Finalize table height - local table_instance = ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) + local table_instance = ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) ImVec2_Copy(inner_window.DC.PrevLineSize, temp_data.HostBackupPrevLineSize) ImVec2_Copy(inner_window.DC.CurrLineSize, temp_data.HostBackupCurrLineSize) ImVec2_Copy(inner_window.DC.CursorMaxPos, temp_data.HostBackupCursorMaxPos) @@ -61599,14 +62218,14 @@ function ImGui.EndTable() -- Draw borders if band(flags, 1920 --[[ImGuiTableFlags.Borders]]) ~= 0 then - ImGui.TableDrawBorders(table_) + ImGui_TableDrawBorders(table_) end -- Flatten channels and merge draw calls local splitter = table_.DrawSplitter splitter:SetCurrentChannel(inner_window.DrawList, 0) if band(table_.Flags, 1048576 --[[ImGuiTableFlags.NoClip]]) == 0 then - ImGui.TableMergeDrawChannels(table_) + ImGui_TableMergeDrawChannels(table_) end splitter:Merge(inner_window.DrawList) @@ -61621,7 +62240,7 @@ function ImGui.EndTable() if band(column.Flags, 16 --[[ImGuiTableColumnFlags.WidthFixed]]) ~= 0 and band(column.Flags, 32 --[[ImGuiTableColumnFlags.NoResize]]) == 0 then column_width_request = column.WidthRequest else - column_width_request = ImGui.TableGetColumnWidthAuto(table_, column) + column_width_request = ImGui_TableGetColumnWidthAuto(table_, column) end if band(column.Flags, 16 --[[ImGuiTableColumnFlags.WidthFixed]]) ~= 0 then auto_fit_width_for_fixed = auto_fit_width_for_fixed + column_width_request @@ -61644,9 +62263,9 @@ function ImGui.EndTable() local neighbor_width_to_keep_visible = table_.MinColumnWidth + table_.CellPaddingX * 2.0 local column = table_.Columns[table_.LastResizedColumn] if column.MaxX < table_.InnerClipRect.Min.x then - ImGui.SetScrollFromPosX(inner_window, column.MaxX - inner_window.Pos.x - neighbor_width_to_keep_visible, 1.0) + ImGui_SetScrollFromPosX(inner_window, column.MaxX - inner_window.Pos.x - neighbor_width_to_keep_visible, 1.0) elseif column.MaxX > table_.InnerClipRect.Max.x then - ImGui.SetScrollFromPosX(inner_window, column.MaxX - inner_window.Pos.x + neighbor_width_to_keep_visible, 1.0) + ImGui_SetScrollFromPosX(inner_window, column.MaxX - inner_window.Pos.x + neighbor_width_to_keep_visible, 1.0) end end @@ -61664,9 +62283,9 @@ function ImGui.EndTable() IM_ASSERT_USER_ERROR(inner_window.IDStack:back() == table_instance.TableInstanceID, "Mismatching PushID/PopID!") IM_ASSERT_USER_ERROR(outer_window.DC.ItemWidthStack.Size >= temp_data.HostBackupItemWidthStackSize, "Too many PopItemWidth!") if table_.InstanceCurrent > 0 then - ImGui.PopID() + ImGui_PopID() end - ImGui.PopID() + ImGui_PopID() -- Restore window data that we modified local backup_outer_max_pos = V2(outer_window.DC.CursorMaxPos) @@ -61685,7 +62304,7 @@ function ImGui.EndTable() local backup_nav_layers_active_mask = inner_window.DC.NavLayersActiveMask inner_window.DC.NavLayersActiveMask = bor(inner_window.DC.NavLayersActiveMask, lshift(1, table_.NavLayer)) -- So empty table don't appear to navigate differently. g.CurrentTable = nil -- To avoid error recovery recursing - ImGui.EndChild() + ImGui_EndChild() g.CurrentTable = table_ inner_window.DC.NavLayersActiveMask = backup_nav_layers_active_mask else @@ -61724,7 +62343,7 @@ function ImGui.EndTable() -- Save settings if table_.IsSettingsDirty then - ImGui.TableSaveSettings(table_) + ImGui_TableSaveSettings(table_) end table_.IsInitializing = false @@ -61739,7 +62358,7 @@ function ImGui.EndTable() g.CurrentTable.DrawSplitter = temp_data.DrawSplitter end outer_window.DC.CurrentTableIdx = g.CurrentTable and g.Tables:GetIndex(g.CurrentTable) or -1 - ImGui.NavUpdateCurrentWindowIsScrollPushableX() + ImGui_NavUpdateCurrentWindowIsScrollPushableX() end -- Called in TableUpdateLayout() when initializing/after loading settings. @@ -61922,7 +62541,7 @@ function ImGui.TableReconcileColumns(table_) TableColumnCopy(table_.Columns[reconcile_data.ColumnNewIdx], reconcile_data.ColumnOldData) -- When old column was not found clear anyway with default-constructed data (which will set IsJustCreated=true) TableSetupColumnApply(table_, reconcile_data.ColumnNewIdx, reconcile_data.ID, reconcile_data.NameOffset, reconcile_data.Flags, reconcile_data.InitWidthOrWeight, reconcile_data.UserData) end - ImGui.TableFixDisplayOrder(table_) + ImGui_TableFixDisplayOrder(table_) table_.IsSettingsDirty = true -- FIXME-RECONCILE: Necessary? table_.IsReconcileMode = false reconcile_requests:resize(0) -- GC-ed once in NewFrame() @@ -62073,7 +62692,7 @@ end function ImGui.TableGetColumnResizeID(table_, column_n, instance_no) if instance_no == nil then instance_no = 0 end assert(column_n >= 0 and column_n < table_.ColumnsCount) - local instance_id = ImGui.TableGetInstanceID(table_, instance_no) + local instance_id = ImGui_TableGetInstanceID(table_, instance_no) return band(instance_id + 1 + column_n, 0xFFFFFFFF) -- FIXME: #6140: still not ideal end @@ -62096,7 +62715,7 @@ function ImGui.TableGetHoveredRow() if not table_ then return -1 end - local table_instance = ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) + local table_instance = ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) return table_instance.HoveredRowLast end @@ -62171,17 +62790,17 @@ function ImGui.TableNextRow(row_flags, row_min_height) local table_ = g.CurrentTable if not table_.IsLayoutLocked then - ImGui.TableUpdateLayout(table_) + ImGui_TableUpdateLayout(table_) end if table_.IsInsideRow then - ImGui.TableEndRow(table_) + ImGui_TableEndRow(table_) end table_.LastRowFlags = table_.RowFlags table_.RowFlags = row_flags table_.RowCellPaddingY = g.Style.CellPadding.y table_.RowMinHeight = row_min_height - ImGui.TableBeginRow(table_) + ImGui_TableBeginRow(table_) -- We honor min_row_height requested by user, but cannot guarantee per-row maximum height, -- because that would essentially require a unique clipping rectangle per-cell. @@ -62226,7 +62845,7 @@ function ImGui.TableBeginRow(table_) -- Making the header BG color non-transparent will allow us to overlay it multiple times when handling smooth dragging. if band(table_.RowFlags, 1 --[[ImGuiTableRowFlags.Headers]]) ~= 0 then - ImGui.TableSetBgColor(1 --[[ImGuiTableBgTarget.RowBg0]], ImGui.GetColorU32(48 --[[ImGuiCol.TableHeaderBg]])) + ImGui_TableSetBgColor(1 --[[ImGuiTableBgTarget.RowBg0]], ImGui_GetColorU32(48 --[[ImGuiCol.TableHeaderBg]])) if table_.CurrentRow == 0 then table_.IsUsingHeaders = true end @@ -62245,13 +62864,13 @@ function ImGui.TableEndRow(table_) assert(table_.IsInsideRow) if table_.CurrentColumn ~= -1 then - ImGui.TableEndCell(table_) + ImGui_TableEndCell(table_) table_.CurrentColumn = -1 end -- Logging if g.LogEnabled then - ImGui.LogRenderedText(nil, "|") + ImGui_LogRenderedText(nil, "|") end -- Position cursor at the bottom of our row so it can be used for e.g. clipping calculation. However it is @@ -62263,7 +62882,7 @@ function ImGui.TableEndRow(table_) local bg_y2 = table_.RowPosY2 local unfreeze_rows_actual = (table_.CurrentRow + 1 == table_.FreezeRowsCount) local unfreeze_rows_request = (table_.CurrentRow + 1 == table_.FreezeRowsRequest) - local table_instance = (table_.InstanceCurrent == 0) and table_.InstanceDataFirst or ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) -- [Luau] inline common case + local table_instance = (table_.InstanceCurrent == 0) and table_.InstanceDataFirst or ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) -- [Luau] inline common case if band(table_.RowFlags, 1 --[[ImGuiTableRowFlags.Headers]]) ~= 0 and (table_.CurrentRow == 0 or band(table_.LastRowFlags, 1 --[[ImGuiTableRowFlags.Headers]]) ~= 0) then table_instance.LastTopHeadersRowHeight = table_instance.LastTopHeadersRowHeight + bg_y2 - bg_y1 end @@ -62281,7 +62900,7 @@ function ImGui.TableEndRow(table_) if table_.RowBgColor[0] ~= 16777216 --[[IM_COL32_DISABLE]] then bg_col0 = table_.RowBgColor[0] elseif band(table_.Flags, 64 --[[ImGuiTableFlags.RowBg]]) ~= 0 then - bg_col0 = ImGui.GetColorU32((band(table_.RowBgColorCounter, 1) ~= 0) and 52 --[[ImGuiCol.TableRowBgAlt]] or 51 --[[ImGuiCol.TableRowBg]]) + bg_col0 = ImGui_GetColorU32((band(table_.RowBgColorCounter, 1) ~= 0) and 52 --[[ImGuiCol.TableRowBgAlt]] or 51 --[[ImGuiCol.TableRowBg]]) end if table_.RowBgColor[1] ~= 16777216 --[[IM_COL32_DISABLE]] then bg_col1 = table_.RowBgColor[1] @@ -62330,7 +62949,7 @@ function ImGui.TableEndRow(table_) -- As we render the BG here we need to clip things (for layout we would not) -- FIXME: This cancels the OuterPadding addition done by TableGetCellBgRect(), need to keep it while rendering correctly while scrolling. local column = table_.Columns[cell_data.Column] - local cell_bg_rect = ImGui.TableGetCellBgRect(table_, cell_data.Column) + local cell_bg_rect = ImGui_TableGetCellBgRect(table_, cell_data.Column) cell_bg_rect:ClipWith(table_.BgClipRect) cell_bg_rect.Min.x = mathMax(cell_bg_rect.Min.x, column.ClipRect.Min.x) -- So that first column after frozen one gets clipped when scrolling cell_bg_rect.Max.x = mathMin(cell_bg_rect.Max.x, column.MaxX) @@ -62384,7 +63003,7 @@ function ImGui.TableEndRow(table_) end -- Update cliprect ahead of TableBeginCell() so clipper can access to new ClipRect.Min.y - ImGui.SetWindowClipRectBeforeSetChannel(window, table_.Columns[0].ClipRect) + ImGui_SetWindowClipRectBeforeSetChannel(window, table_.Columns[0].ClipRect) table_.DrawSplitter:SetCurrentChannel(window.DrawList, table_.Columns[0].DrawChannelCurrent) end end @@ -62425,13 +63044,13 @@ function ImGui.TableSetColumnIndex(column_n) if table_.CurrentColumn ~= column_n then if table_.CurrentColumn ~= -1 then - ImGui.TableEndCell(table_) + ImGui_TableEndCell(table_) end if not (column_n >= 0 and column_n < table_.ColumnsCount) then IM_ASSERT_USER_ERROR(false, "TableSetColumnIndex() invalid column index!") return false end - ImGui.TableBeginCell(table_, column_n) + ImGui_TableBeginCell(table_, column_n) end -- Return whether the column is visible. User may choose to skip submitting items based on this return value, @@ -62452,14 +63071,14 @@ function ImGui.TableNextColumn() local next_column if table_.IsInsideRow and current_column + 1 < table_.ColumnsCount then if current_column ~= -1 then - ImGui.TableEndCell(table_) + ImGui_TableEndCell(table_) end next_column = current_column + 1 else - ImGui.TableNextRow() + ImGui_TableNextRow() next_column = 0 end - ImGui.TableBeginCell(table_, next_column) + ImGui_TableBeginCell(table_, next_column) -- Return whether the column is visible. User may choose to skip submitting items based on this return value, -- however they shouldn't skip submitting for columns that may have the tallest contribution to row height. @@ -62540,7 +63159,7 @@ function ImGui.TableBeginCell(table_, column_n) -- Logging if g.LogEnabled and not column.IsSkipItems then - ImGui.LogRenderedText(window.DC.CursorPos, "|") + ImGui_LogRenderedText(window.DC.CursorPos, "|") g.LogLinePosY = 3.4028234663853e+38 --[[FLT_MAX]] end end @@ -62553,7 +63172,7 @@ function ImGui.TableEndCell(table_) local dc = window.DC -- [Luau] cache; mathMax() inlined as math.max below if dc.IsSetPos then - ImGui.ErrorCheckUsingSetCursorPosToExtendParentBoundaries() + ImGui_ErrorCheckUsingSetCursorPosToExtendParentBoundaries() end -- Report maximum position so we can infer content size per column. @@ -62717,7 +63336,7 @@ function ImGui.TableSetColumnWidth(column_n, width) column_0.WidthRequest = column_0_width column_1.WidthRequest = column_1_width if band(bor(column_0.Flags, column_1.Flags), 8 --[[ImGuiTableColumnFlags.WidthStretch]]) ~= 0 then - ImGui.TableUpdateColumnsWeightFromWidth(table_) + ImGui_TableUpdateColumnsWeightFromWidth(table_) end table_.IsSettingsDirty = true end @@ -62795,7 +63414,7 @@ function ImGui.TablePushBackgroundChannel() -- Optimization: avoid SetCurrentChannel() + PushClipRect() ImRect_Copy(table_.HostBackupInnerClipRect, window.ClipRect) - ImGui.SetWindowClipRectBeforeSetChannel(window, table_.Bg2ClipRectForDrawCmd) + ImGui_SetWindowClipRectBeforeSetChannel(window, table_.Bg2ClipRectForDrawCmd) table_.DrawSplitter:SetCurrentChannel(window.DrawList, table_.Bg2DrawChannelCurrent) end @@ -62805,7 +63424,7 @@ function ImGui.TablePopBackgroundChannel() local table_ = g.CurrentTable -- Optimization: avoid PopClipRect() + SetCurrentChannel() - ImGui.SetWindowClipRectBeforeSetChannel(window, table_.HostBackupInnerClipRect) + ImGui_SetWindowClipRectBeforeSetChannel(window, table_.HostBackupInnerClipRect) table_.DrawSplitter:SetCurrentChannel(window.DrawList, table_.Columns[table_.CurrentColumn].DrawChannelCurrent) end @@ -62820,7 +63439,7 @@ function ImGui.TablePushColumnChannel(column_n) end local window = g.CurrentWindow local column = table_.Columns[column_n] - ImGui.SetWindowClipRectBeforeSetChannel(window, column.ClipRect) + ImGui_SetWindowClipRectBeforeSetChannel(window, column.ClipRect) table_.DrawSplitter:SetCurrentChannel(window.DrawList, column.DrawChannelCurrent) end @@ -62834,7 +63453,7 @@ function ImGui.TablePopColumnChannel() end local window = g.CurrentWindow local column = table_.Columns[table_.CurrentColumn] - ImGui.SetWindowClipRectBeforeSetChannel(window, column.ClipRect) + ImGui_SetWindowClipRectBeforeSetChannel(window, column.ClipRect) table_.DrawSplitter:SetCurrentChannel(window.DrawList, column.DrawChannelCurrent) end @@ -63035,7 +63654,7 @@ function ImGui.TableMergeDrawChannels(table_) local merge_channels_count = merge_groups[merge_group_n].ChannelsCount if merge_channels_count ~= 0 then local merge_group = merge_groups[merge_group_n] - local merge_clip_rect = Rect(merge_group.ClipRect) + local merge_clip_rect = TableMergeDrawChannels_merge_clip_rect; ImRect_Copy(merge_clip_rect, merge_group.ClipRect) -- [Luau] scratch copy -- Extend outer-most clip limits to match those of host, so draw calls can be merged even if -- outer-most columns have some outer padding offsetting them from their parent ClipRect. @@ -63108,7 +63727,7 @@ local function TableGetColumnBorderCol(table_, order_n, column_n) local is_resized = (table_.ResizedColumn == column_n) and (table_.InstanceInteracted == table_.InstanceCurrent) local is_frozen_separator = (table_.FreezeColumnsCount == order_n + 1) if is_resized or is_hovered then - return ImGui.GetColorU32(is_resized and 30 --[[ImGuiCol.SeparatorActive]] or 29 --[[ImGuiCol.SeparatorHovered]]) + return ImGui_GetColorU32(is_resized and 30 --[[ImGuiCol.SeparatorActive]] or 29 --[[ImGuiCol.SeparatorHovered]]) end if is_frozen_separator or band(table_.Flags, bor(2048 --[[ImGuiTableFlags.NoBordersInBody]], 4096 --[[ImGuiTableFlags.NoBordersInBodyUntilResize]])) ~= 0 then return table_.BorderColorStrong @@ -63128,7 +63747,7 @@ function ImGui.TableDrawBorders(table_) inner_drawlist:PushClipRect(table_.Bg0ClipRectForDrawCmd.Min, table_.Bg0ClipRectForDrawCmd.Max, false) -- Draw inner border and resizing feedback - local table_instance = ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) + local table_instance = ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) local border_size = TABLE_BORDER_SIZE local draw_y1 = mathMax(table_.InnerRect.Min.y, ((table_.FreezeRowsCount >= 1) and table_.InnerRect.Min.y or table_.WorkRect.Min.y) + table_.AngledHeadersHeight) + ((band(table_.Flags, 256 --[[ImGuiTableFlags.BordersOuterH]]) ~= 0) and border_size or 0.0) local draw_y2_body = table_.InnerRect.Max.y @@ -63234,10 +63853,10 @@ function ImGui.TableGetSortSpecs() -- Require layout (in case TableHeadersRow() hasn't been called) as it may alter IsSortSpecsDirty in some paths. if not table_.IsLayoutLocked then - ImGui.TableUpdateLayout(table_) + ImGui_TableUpdateLayout(table_) end - ImGui.TableSortSpecsBuild(table_) + ImGui_TableSortSpecsBuild(table_) return table_.SortSpecs end @@ -63305,7 +63924,7 @@ function ImGui.TableSetColumnSortDirection(column_n, sort_direction, append_to_s if other_column ~= column and not append_to_sort_specs then other_column.SortOrder = -1 end - ImGui.TableFixColumnSortDirection(table_, other_column) + ImGui_TableFixColumnSortDirection(table_, other_column) end table_.IsSettingsDirty = true table_.IsSortSpecsDirty = true @@ -63386,7 +64005,7 @@ end function ImGui.TableSortSpecsBuild(table_) local dirty = table_.IsSortSpecsDirty if dirty then - ImGui.TableSortSpecsSanitize(table_) + ImGui_TableSortSpecsSanitize(table_) local multi = table_.SortSpecsMulti local want = (table_.SortSpecsCount <= 1) and 0 or table_.SortSpecsCount for n = #multi + 1, want do multi[n] = ImGuiTableColumnSortSpecs() end @@ -63446,7 +64065,7 @@ function ImGui.TableGetHeaderRowHeight() for column_n = 0, table_.ColumnsCount - 1 do if BitTest(table_.EnabledMaskByIndex, column_n) then if band(table_.Columns[column_n].Flags, 4096 --[[ImGuiTableColumnFlags.NoHeaderLabel]]) == 0 then - row_height = mathMax(row_height, ImGui.CalcTextSize(ImGui.TableGetColumnName(table_, column_n)).y) + row_height = mathMax(row_height, ImGui_CalcTextSize(ImGui_TableGetColumnName(table_, column_n)).y) end end end @@ -63460,7 +64079,7 @@ function ImGui.TableGetHeaderAngledMaxLabelWidth() for column_n = 0, table_.ColumnsCount - 1 do if BitTest(table_.EnabledMaskByIndex, column_n) then if band(table_.Columns[column_n].Flags, 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) ~= 0 then - width = mathMax(width, ImGui.CalcTextSize(ImGui.TableGetColumnName(table_, column_n), nil, true).x) + width = mathMax(width, ImGui_CalcTextSize(ImGui_TableGetColumnName(table_, column_n), nil, true).x) end end end @@ -63482,33 +64101,33 @@ function ImGui.TableHeadersRow() -- Call layout if not already done. This is automatically done by TableNextRow: we do it here _only_ to make -- it easier to debug-step in TableUpdateLayout(). Your own version of this function doesn't need this. if not table_.IsLayoutLocked then - ImGui.TableUpdateLayout(table_) + ImGui_TableUpdateLayout(table_) end -- Open row - local row_height = ImGui.TableGetHeaderRowHeight() - ImGui.TableNextRow(1 --[[ImGuiTableRowFlags.Headers]], row_height) - local row_y1 = ImGui.GetCursorScreenPos().y + local row_height = ImGui_TableGetHeaderRowHeight() + ImGui_TableNextRow(1 --[[ImGuiTableRowFlags.Headers]], row_height) + local row_y1 = ImGui_GetCursorScreenPos().y if table_.HostSkipItems then -- Merely an optimization, you may skip in your own code. return end - local columns_count = ImGui.TableGetColumnCount() + local columns_count = ImGui_TableGetColumnCount() for column_n = 0, columns_count - 1 do - if ImGui.TableSetColumnIndex(column_n) or table_.LastHeldHeaderColumn == column_n then + if ImGui_TableSetColumnIndex(column_n) or table_.LastHeldHeaderColumn == column_n then -- Push an id to allow empty/unnamed headers. This is also idiomatic as it ensure there is a consistent ID path to access columns (for e.g. automation) - local name = (band(ImGui.TableGetColumnFlags(column_n), 4096 --[[ImGuiTableColumnFlags.NoHeaderLabel]]) ~= 0) and "" or ImGui.TableGetColumnName(column_n) - ImGui.PushID(column_n) - ImGui.TableHeader(name) - ImGui.PopID() + local name = (band(ImGui_TableGetColumnFlags(column_n), 4096 --[[ImGuiTableColumnFlags.NoHeaderLabel]]) ~= 0) and "" or ImGui_TableGetColumnName(column_n) + ImGui_PushID(column_n) + ImGui_TableHeader(name) + ImGui_PopID() end end -- Allow opening popup from the right-most section after the last column. - local mouse_pos = ImGui.GetMousePos() - if ImGui.IsMouseReleased(1) and ImGui.TableGetHoveredColumn() == columns_count then + local mouse_pos = ImGui_GetMousePos() + if ImGui_IsMouseReleased(1) and ImGui_TableGetHoveredColumn() == columns_count then if mouse_pos.y >= row_y1 and mouse_pos.y < row_y1 + row_height then - ImGui.TableOpenContextMenu(columns_count) -- Will open a non-column-specific popup. + ImGui_TableOpenContextMenu(columns_count) -- Will open a non-column-specific popup. end end end @@ -63533,8 +64152,8 @@ function ImGui.TableHeader(label) if label == nil then label = "" end - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = ImGui_CalcTextSize(label, label_end, false) local label_pos = V2(window.DC.CursorPos) -- If we already got a row height, there's use that. @@ -63558,7 +64177,7 @@ function ImGui.TableHeader(label) end if column.SortOrder > 0 then sort_order_suf = string.format("%d", column.SortOrder + 1) - w_sort_text = g.Style.ItemInnerSpacing.x + ImGui.CalcTextSize(sort_order_suf).x + w_sort_text = g.Style.ItemInnerSpacing.x + ImGui_CalcTextSize(sort_order_suf).x end end @@ -63580,18 +64199,18 @@ function ImGui.TableHeader(label) -- Using AllowOverlap mode because we cover the whole cell, and we want user to be able to submit subsequent items. local highlight = (table_.HighlightColumnHeader == column_n) - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id, 4096 --[[ImGuiButtonFlags.AllowOverlap]]) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id, 4096 --[[ImGuiButtonFlags.AllowOverlap]]) if held or hovered or highlight then - local col = ImGui.GetColorU32(held and 27 --[[ImGuiCol.HeaderActive]] or (hovered and 26 --[[ImGuiCol.HeaderHovered]] or 25 --[[ImGuiCol.Header]])) + local col = ImGui_GetColorU32(held and 27 --[[ImGuiCol.HeaderActive]] or (hovered and 26 --[[ImGuiCol.HeaderHovered]] or 25 --[[ImGuiCol.Header]])) --RenderFrame(bb.Min, bb.Max, col, false, 0.0) - ImGui.TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], col, table_.CurrentColumn) + ImGui_TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], col, table_.CurrentColumn) else -- Submit single cell bg color in the case we didn't submit a full header row if band(table_.RowFlags, 1 --[[ImGuiTableRowFlags.Headers]]) == 0 then - ImGui.TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], ImGui.GetColorU32(48 --[[ImGuiCol.TableHeaderBg]]), table_.CurrentColumn) + ImGui_TableSetBgColor(3 --[[ImGuiTableBgTarget.CellBg]], ImGui_GetColorU32(48 --[[ImGuiCol.TableHeaderBg]]), table_.CurrentColumn) end end - ImGui.RenderNavCursor(bb, id, 2 --[[ImGuiNavRenderCursorFlags.Compact]], 0.0) + ImGui_RenderNavCursor(bb, id, 2 --[[ImGuiNavRenderCursorFlags.Compact]], 0.0) if held then table_.HeldHeaderColumn = column_n end @@ -63599,7 +64218,7 @@ function ImGui.TableHeader(label) -- Drag and drop to re-order columns. -- FIXME-TABLE: Scroll request while reordering a column and it lands out of the scrolling zone. - if held and band(table_.Flags, 2 --[[ImGuiTableFlags.Reorderable]]) ~= 0 and ImGui.IsMouseDragging(0) and not g.DragDropActive then + if held and band(table_.Flags, 2 --[[ImGuiTableFlags.Reorderable]]) ~= 0 and ImGui_IsMouseDragging(0) and not g.DragDropActive then -- - While moving a column it will jump on the other side of the mouse, so we also test for MouseDelta.x -- - We need to handle reordering across hidden columns. -- In the configuration below, moving C to the right of E will lead to: @@ -63610,13 +64229,13 @@ function ImGui.TableHeader(label) if g.IO.MouseDelta.x < 0.0 and g.IO.MousePos.x < cell_x1 then local prev_column = (column.PrevEnabledColumn ~= -1) and table_.Columns[column.PrevEnabledColumn] or nil if prev_column then - ImGui.TableQueueSetColumnDisplayOrder(table_, column_n, prev_column.DisplayOrder) + ImGui_TableQueueSetColumnDisplayOrder(table_, column_n, prev_column.DisplayOrder) end end if g.IO.MouseDelta.x > 0.0 and g.IO.MousePos.x > cell_x2 then local next_column = (column.NextEnabledColumn ~= -1) and table_.Columns[column.NextEnabledColumn] or nil if next_column then - ImGui.TableQueueSetColumnDisplayOrder(table_, column_n, next_column.DisplayOrder) + ImGui_TableQueueSetColumnDisplayOrder(table_, column_n, next_column.DisplayOrder) end end end @@ -63630,34 +64249,34 @@ function ImGui.TableHeader(label) local x = mathMax(cell_x1, cell_x2 - w_arrow - w_sort_text) local y = label_pos.y if column.SortOrder > 0 then - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImGui.GetColorU32(0 --[[ImGuiCol.Text]], 0.70)) - ImGui.RenderText(ImVec2(x + g.Style.ItemInnerSpacing.x, y), sort_order_suf) - ImGui.PopStyleColor() + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImGui_GetColorU32(0 --[[ImGuiCol.Text]], 0.70)) + ImGui_RenderText(ImVec2(x + g.Style.ItemInnerSpacing.x, y), sort_order_suf) + ImGui_PopStyleColor() x = x + w_sort_text end - ImGui.RenderArrow(window.DrawList, ImVec2(x, y), ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), (column.SortDirection == 1 --[[ImGuiSortDirection.Ascending]]) and 2 --[[ImGuiDir.Up]] or 3 --[[ImGuiDir.Down]], ARROW_SCALE) + ImGui_RenderArrow(window.DrawList, ImVec2(x, y), ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), (column.SortDirection == 1 --[[ImGuiSortDirection.Ascending]]) and 2 --[[ImGuiDir.Up]] or 3 --[[ImGuiDir.Down]], ARROW_SCALE) end -- Handle clicking on column header to adjust Sort Order if pressed and table_.ReorderColumn ~= column_n then - local sort_direction = ImGui.TableGetColumnNextSortDirection(column) - ImGui.TableSetColumnSortDirection(column_n, sort_direction, g.IO.KeyShift) + local sort_direction = ImGui_TableGetColumnNextSortDirection(column) + ImGui_TableSetColumnSortDirection(column_n, sort_direction, g.IO.KeyShift) end end -- Render clipped label. Clipping here ensure that in the majority of situations, all our header cells will -- be merged into a single draw call. --window.DrawList:AddCircleFilled(ImVec2(ellipsis_max, label_pos.y), 40, IM_COL32_WHITE) - ImGui.RenderTextEllipsis(window.DrawList, label_pos, ImVec2(ellipsis_max, bb.Max.y), ellipsis_max, label, label_end, label_size) + ImGui_RenderTextEllipsis(window.DrawList, label_pos, ImVec2(ellipsis_max, bb.Max.y), ellipsis_max, label, label_end, label_size) local text_clipped = label_size.x > (ellipsis_max - label_pos.x) if text_clipped and hovered and g.ActiveId == 0 then - ImGui.SetItemTooltip("%s", string.sub(label, 1, label_end - 1)) + ImGui_SetItemTooltip("%s", string.sub(label, 1, label_end - 1)) end -- We don't use BeginPopupContextItem() because we want the popup to stay up even after the column is hidden - if ImGui.IsPopupOpenRequestForItem(0 --[[ImGuiPopupFlags.None]], id) then - ImGui.TableOpenContextMenu(column_n) + if ImGui_IsPopupOpenRequestForItem(0 --[[ImGuiPopupFlags.None]], id) then + ImGui_TableOpenContextMenu(column_n) end end @@ -63670,8 +64289,8 @@ function ImGui.TableAngledHeadersRow() temp_data.AngledHeadersRequests:resize(0) -- Which column needs highlight? - local row_id = ImGui.GetID("##AngledHeaders") - local table_instance = ImGui.TableGetInstanceData(table_, table_.InstanceCurrent) + local row_id = ImGui_GetID("##AngledHeaders") + local table_instance = ImGui_TableGetInstanceData(table_, table_.InstanceCurrent) local highlight_column_n = (table_.LastHeldHeaderColumn ~= -1) and table_.LastHeldHeaderColumn or table_.HighlightColumnHeader if highlight_column_n == -1 and table_.HoveredColumnBody ~= -1 then if table_instance.HoveredRowLast == 0 and table_.HoveredColumnBorder == -1 and (g.ActiveId == 0 or g.ActiveId == row_id or (table_.IsActiveIdInTable or g.DragDropActive)) then @@ -63680,20 +64299,20 @@ function ImGui.TableAngledHeadersRow() end -- Build up request - local col_header_bg = ImGui.GetColorU32(48 --[[ImGuiCol.TableHeaderBg]]) - local col_text = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) + local col_header_bg = ImGui_GetColorU32(48 --[[ImGuiCol.TableHeaderBg]]) + local col_text = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) for order_n = 0, table_.ColumnsCount - 1 do if BitTest(table_.EnabledMaskByDisplayOrder, order_n) then local column_n = table_.DisplayOrderToIndex[order_n] local column = table_.Columns[column_n] if band(column.Flags, 262144 --[[ImGuiTableColumnFlags.AngledHeader]]) ~= 0 then -- Note: can't rely on ImGuiTableColumnFlags.IsVisible test here. - temp_data.AngledHeadersRequests:push_back({ Index = column_n, TextColor = col_text, BgColor0 = col_header_bg, BgColor1 = (column_n == highlight_column_n) and ImGui.GetColorU32(25 --[[ImGuiCol.Header]]) or 0 }) + temp_data.AngledHeadersRequests:push_back({ Index = column_n, TextColor = col_text, BgColor0 = col_header_bg, BgColor1 = (column_n == highlight_column_n) and ImGui_GetColorU32(25 --[[ImGuiCol.Header]]) or 0 }) end end end -- Render row - ImGui.TableAngledHeadersRowEx(row_id, g.Style.TableAngledHeadersAngle, 0.0, temp_data.AngledHeadersRequests.Data, temp_data.AngledHeadersRequests.Size) + ImGui_TableAngledHeadersRowEx(row_id, g.Style.TableAngledHeadersAngle, 0.0, temp_data.AngledHeadersRequests.Data, temp_data.AngledHeadersRequests.Size) end local function ImTextCountLines(text, text_begin, text_end) @@ -63719,7 +64338,7 @@ function ImGui.TableAngledHeadersRowEx(row_id, angle, max_label_width, data, dat assert(table_.CurrentRow == -1, "Must be first row") if max_label_width == 0.0 then - max_label_width = ImGui.TableGetHeaderAngledMaxLabelWidth() + max_label_width = ImGui_TableGetHeaderAngledMaxLabelWidth() end -- Angle argument expressed in (-IM_PI/2 .. +IM_PI/2) as it is easier to think about for user. @@ -63741,21 +64360,21 @@ function ImGui.TableAngledHeadersRowEx(row_id, angle, max_label_width, data, dat -- Declare row, override and draw our own background -- FIXME-TABLE: Generally broken when overlapping frozen columns limit. - ImGui.TableNextRow(1 --[[ImGuiTableRowFlags.Headers]], row_height) - ImGui.TableNextColumn() + ImGui_TableNextRow(1 --[[ImGuiTableRowFlags.Headers]], row_height) + ImGui_TableNextColumn() local row_r = ImRect(table_.WorkRect.Min.x, table_.BgClipRect.Min.y, table_.WorkRect.Max.x, table_.RowPosY2) table_.DrawSplitter:SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0) local clip_rect_min_x = table_.BgClipRect.Min.x if table_.FreezeColumnsCount > 0 then clip_rect_min_x = ImMax(clip_rect_min_x, table_.Columns[table_.DisplayOrderToIndex[table_.FreezeColumnsCount - 1]].MaxX) end - ImGui.TableSetBgColor(1 --[[ImGuiTableBgTarget.RowBg0]], 0) -- Cancel - ImGui.PushClipRect(table_.BgClipRect.Min, table_.BgClipRect.Max, false) -- Span all columns - draw_list:AddRectFilled(ImVec2(table_.BgClipRect.Min.x, row_r.Min.y), ImVec2(table_.BgClipRect.Max.x, row_r.Max.y), ImGui.GetColorU32(48 --[[ImGuiCol.TableHeaderBg]], 0.25)) -- FIXME-STYLE: Change row background with an arbitrary color. - ImGui.PushClipRect(ImVec2(clip_rect_min_x, table_.BgClipRect.Min.y), table_.BgClipRect.Max, true) -- Span all columns + ImGui_TableSetBgColor(1 --[[ImGuiTableBgTarget.RowBg0]], 0) -- Cancel + ImGui_PushClipRect(table_.BgClipRect.Min, table_.BgClipRect.Max, false) -- Span all columns + draw_list:AddRectFilled(ImVec2(table_.BgClipRect.Min.x, row_r.Min.y), ImVec2(table_.BgClipRect.Max.x, row_r.Max.y), ImGui_GetColorU32(48 --[[ImGuiCol.TableHeaderBg]], 0.25)) -- FIXME-STYLE: Change row background with an arbitrary color. + ImGui_PushClipRect(ImVec2(clip_rect_min_x, table_.BgClipRect.Min.y), table_.BgClipRect.Max, true) -- Span all columns - ImGui.ButtonBehavior(row_r, row_id) - ImGui.KeepAliveID(row_id) + ImGui_ButtonBehavior(row_r, row_id) + ImGui_KeepAliveID(row_id) local ascent_scaled = g.FontBaked.Ascent * g.FontBakedScale -- FIXME: Standardize those scaling factors better local line_off_for_ascent_x = (ImMax((g.FontSize - ascent_scaled) * 0.5, 0.0) / -sin_a) * (flip_label and -1.0 or 1.0) @@ -63784,8 +64403,8 @@ function ImGui.TableAngledHeadersRowEx(row_id, angle, max_label_width, data, dat -- Draw label -- - First draw at an offset where RenderTextXXX() function won't meddle with applying current ClipRect, then transform to final offset. -- - Handle multiple lines manually, as we want each lines to follow on the horizontal border, rather than see a whole block rotated. - local label_name = ImGui.TableGetColumnName(table_, column_n) - local label_name_end = ImGui.FindRenderedTextEnd(label_name) + local label_name = ImGui_TableGetColumnName(table_, column_n) + local label_name_end = ImGui_FindRenderedTextEnd(label_name) local line_off_step_x = (g.FontSize / -sin_a) local label_lines = ImTextCountLines(label_name, 1, label_name_end) @@ -63807,14 +64426,14 @@ function ImGui.TableAngledHeadersRowEx(row_id, angle, max_label_width, data, dat local line = string.sub(label_name, p, label_name_eol - 1) -- FIXME: Individual line clipping for right-most column is broken for negative angles. - local label_size = ImGui.CalcTextSize(line) + local label_size = ImGui_CalcTextSize(line) local clip_width = max_label_width - padding.y -- Using padding.y*2.0f would be symmetrical but hide more text. local clip_height = ImMin(label_size.y, column.ClipRect.Max.x - column.WorkMinX - line_off_curr_x) local clip_r = ImRect(window.ClipRect.Min, window.ClipRect.Min + ImVec2(clip_width, clip_height)) local vtx_idx_begin = draw_list._VtxCurrentIdx - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], request.TextColor) - ImGui.RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, line, #line + 1, label_size) - ImGui.PopStyleColor() + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], request.TextColor) + ImGui_RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, line, #line + 1, label_size) + ImGui_PopStyleColor() local vtx_idx_end = draw_list._VtxCurrentIdx -- Up<>Down alignment @@ -63830,7 +64449,7 @@ function ImGui.TableAngledHeadersRowEx(row_id, angle, max_label_width, data, dat pivot_out = pivot_out + unit_right * (clip_width - ImMax(0.0, clip_width - label_size.x)) end pivot_out.x = pivot_out.x + (flip_label and (line_off_curr_x + line_off_step_x) or line_off_curr_x) - ImGui.ShadeVertsTransformPos(draw_list, vtx_idx_begin, vtx_idx_end, pivot_in, label_cos_a, label_sin_a, pivot_out) -- Rotate and offset + ImGui_ShadeVertsTransformPos(draw_list, vtx_idx_begin, vtx_idx_end, pivot_in, label_cos_a, label_sin_a, pivot_out) -- Rotate and offset --if g.IO.KeyShift then local fg_dl = GetForegroundDrawList(); vtx_idx_begin = fg_dl._VtxCurrentIdx; fg_dl:AddRect(clip_r.Min, clip_r.Max, IM_COL32(0, 255, 0, 255), 0.0, 0, 1.0); ShadeVertsTransformPos(fg_dl, vtx_idx_begin, fg_dl._VtxCurrentIdx, pivot_in, label_cos_a, label_sin_a, pivot_out) end p = label_name_eol + 1 @@ -63843,8 +64462,8 @@ function ImGui.TableAngledHeadersRowEx(row_id, angle, max_label_width, data, dat end end end - ImGui.PopClipRect() - ImGui.PopClipRect() + ImGui_PopClipRect() + ImGui_PopClipRect() table_.TempData.AngledHeadersExtraWidth = ImMax(0.0, max_x - table_.Columns[table_.RightMostEnabledColumn].MaxX) end @@ -63873,7 +64492,7 @@ function ImGui.TableOpenContextMenu(column_n) table_.ContextPopupColumn = column_n table_.InstanceInteracted = table_.InstanceCurrent local context_menu_id = ImHashStr("##ContextMenu", nil, table_.ID) - ImGui.OpenPopupEx(context_menu_id, 0 --[[ImGuiPopupFlags.None]]) + ImGui_OpenPopupEx(context_menu_id, 0 --[[ImGuiPopupFlags.None]]) end end @@ -63882,7 +64501,7 @@ function ImGui.TableBeginContextMenuPopup(table_) return false end local context_menu_id = ImHashStr("##ContextMenu", nil, table_.ID) - if ImGui.BeginPopupEx(context_menu_id, bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) then + if ImGui_BeginPopupEx(context_menu_id, bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]])) then return true end table_.IsContextPopupOpen = false @@ -63894,26 +64513,26 @@ local function MenuItemForColumnReorder(label, selected, enabled) local g = GImGui local window = g.CurrentWindow - local label_size = ImGui.CalcTextSize(label, nil, true) + local label_size = ImGui_CalcTextSize(label, nil, true) local offsets = window.DC.MenuColumns local checkmark_w = IM_TRUNC(g.FontSize * 1.20) local min_w = offsets:DeclColumns(0.0, label_size.x, 0.0, checkmark_w) -- Feedback for next frame - local stretch_w = ImMax(0.0, ImGui.GetContentRegionAvail().x - min_w) + local stretch_w = ImMax(0.0, ImGui_GetContentRegionAvail().x - min_w) local text_pos = ImVec2(window.DC.CursorPos.x, window.DC.CursorPos.y + window.DC.CurrLineTextBaseOffset) - local id = ImGui.GetID(label) + local id = ImGui_GetID(label) local selectable_flags = bor(8388608 --[[ImGuiSelectableFlags.SelectOnRelease]], 16777216 --[[ImGuiSelectableFlags.SpanAvailWidth]]) if g.ActiveId == id then selectable_flags = bor(selectable_flags, 32 --[[ImGuiSelectableFlags.Highlight]]) -- Stays highlighted while dragging. end local has_been_moved = (g.ActiveId == id) and g.ActiveIdHasBeenEditedBefore -- But disable toggling once moved. - ImGui.BeginDisabled(not enabled) -- Don't use ImGuiSelectableFlags.Disabled so that Check mark is also affected. - local ret = ImGui.Selectable(label, false, selectable_flags, ImVec2(min_w, label_size.y)) and not has_been_moved -- Can't use IsMouseDragging(0) as button is released already. + ImGui_BeginDisabled(not enabled) -- Don't use ImGuiSelectableFlags.Disabled so that Check mark is also affected. + local ret = ImGui_Selectable(label, false, selectable_flags, ImVec2(min_w, label_size.y)) and not has_been_moved -- Can't use IsMouseDragging(0) as button is released already. if band(g.LastItemData.StatusFlags, 256 --[[ImGuiItemStatusFlags.Visible]]) ~= 0 and selected then - ImGui.RenderCheckMark(window.DrawList, text_pos + ImVec2(offsets.OffsetMark + stretch_w + g.FontSize * 0.40, g.FontSize * 0.134 * 0.5), ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), g.FontSize * 0.866) + ImGui_RenderCheckMark(window.DrawList, text_pos + ImVec2(offsets.OffsetMark + stretch_w + g.FontSize * 0.40, g.FontSize * 0.134 * 0.5), ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), g.FontSize * 0.866) end - ImGui.EndDisabled() + ImGui_EndDisabled() return ret end @@ -63941,40 +64560,40 @@ function ImGui.TableDrawDefaultContextMenu(table_, flags_for_section_to_display) if band(flags_for_section_to_display, 1 --[[ImGuiTableFlags.Resizable]]) ~= 0 then if context_column ~= nil then local can_resize = band(context_column.Flags, 32 --[[ImGuiTableColumnFlags.NoResize]]) == 0 and context_column.IsEnabled - if ImGui.MenuItem(ImGui.LocalizeGetMsg(2 --[[ImGuiLocKey.TableSizeOne]]), nil, false, can_resize) then -- "###SizeOne" - ImGui.TableSetColumnWidthAutoSingle(table_, context_column_n) + if ImGui_MenuItem(ImGui_LocalizeGetMsg(2 --[[ImGuiLocKey.TableSizeOne]]), nil, false, can_resize) then -- "###SizeOne" + ImGui_TableSetColumnWidthAutoSingle(table_, context_column_n) end end local size_all_desc if table_.ColumnsEnabledFixedCount == table_.ColumnsEnabledCount and band(table_.Flags, 57344 --[[ImGuiTableFlags.SizingMask_]]) ~= 16384 --[[ImGuiTableFlags.SizingFixedSame]] then - size_all_desc = ImGui.LocalizeGetMsg(3 --[[ImGuiLocKey.TableSizeAllFit]]) -- "###SizeAll" All fixed + size_all_desc = ImGui_LocalizeGetMsg(3 --[[ImGuiLocKey.TableSizeAllFit]]) -- "###SizeAll" All fixed else - size_all_desc = ImGui.LocalizeGetMsg(4 --[[ImGuiLocKey.TableSizeAllDefault]]) -- "###SizeAll" All stretch or mixed + size_all_desc = ImGui_LocalizeGetMsg(4 --[[ImGuiLocKey.TableSizeAllDefault]]) -- "###SizeAll" All stretch or mixed end - if ImGui.MenuItem(size_all_desc, nil) then - ImGui.TableSetColumnWidthAutoAll(table_) + if ImGui_MenuItem(size_all_desc, nil) then + ImGui_TableSetColumnWidthAutoAll(table_) end want_separator = true end -- Reset Order/Visibility etc. if band(flags_for_section_to_display, bor(2 --[[ImGuiTableFlags.Reorderable]], 4 --[[ImGuiTableFlags.Hideable]])) ~= 0 then - if ImGui.BeginMenu(ImGui.LocalizeGetMsg(5 --[[ImGuiLocKey.TableReset]])) then + if ImGui_BeginMenu(ImGui_LocalizeGetMsg(5 --[[ImGuiLocKey.TableReset]])) then --if ImGui.MenuItem(ImGui.LocalizeGetMsg(ImGuiLocKey.TableResetAll)) then -- FIXME: Hiding because altering Sort Order + requesting auto-fit simultaneously has a tendency to exhibit a sizing glitch. -- table_.IsResetAllRequest = true --end if band(flags_for_section_to_display, 2 --[[ImGuiTableFlags.Reorderable]]) ~= 0 then - if ImGui.MenuItem(ImGui.LocalizeGetMsg(6 --[[ImGuiLocKey.TableResetOrder]]), nil, false, not table_.IsDefaultDisplayOrder) then -- PS: cannot be hidden because it would mess with drag reordering. + if ImGui_MenuItem(ImGui_LocalizeGetMsg(6 --[[ImGuiLocKey.TableResetOrder]]), nil, false, not table_.IsDefaultDisplayOrder) then -- PS: cannot be hidden because it would mess with drag reordering. table_.IsResetDisplayOrderRequest = true end end if band(flags_for_section_to_display, 4 --[[ImGuiTableFlags.Hideable]]) ~= 0 then - if ImGui.MenuItem(ImGui.LocalizeGetMsg(7 --[[ImGuiLocKey.TableResetVisibility]]), nil, false, not table_.IsDefaultVisibility) then + if ImGui_MenuItem(ImGui_LocalizeGetMsg(7 --[[ImGuiLocKey.TableResetVisibility]]), nil, false, not table_.IsDefaultVisibility) then table_.IsResetVisibilityRequest = true end end - ImGui.EndMenu() + ImGui_EndMenu() end end @@ -63997,7 +64616,7 @@ function ImGui.TableDrawDefaultContextMenu(table_, flags_for_section_to_display) -- Hiding / Visibility if band(flags_for_section_to_display, 4 --[[ImGuiTableFlags.Hideable]]) ~= 0 then if want_separator then - ImGui.Separator() + ImGui_Separator() end want_separator = true @@ -64007,12 +64626,12 @@ function ImGui.TableDrawDefaultContextMenu(table_, flags_for_section_to_display) local reorder_src_order = is_reordering and table_.Columns[table_.ReorderColumn].DisplayOrder or -1 local reorder_min_order = is_reordering and TableGetMaxDisplayOrderAllowed(table_, reorder_src_order, 0) or 0 local reorder_max_order = is_reordering and TableGetMaxDisplayOrderAllowed(table_, reorder_src_order, table_.ColumnsCount - 1) or (table_.ColumnsCount - 1) - ImGui.PushItemFlag(16 --[[ImGuiItemFlags.AutoClosePopups]], false) + ImGui_PushItemFlag(16 --[[ImGuiItemFlags.AutoClosePopups]], false) for order_n = 0, table_.ColumnsCount - 1 do local column_n = table_.DisplayOrderToIndex[order_n] local column = table_.Columns[column_n] if band(column.Flags, 1 --[[ImGuiTableColumnFlags.Disabled]]) == 0 then - local name = ImGui.TableGetColumnName(table_, column_n) + local name = ImGui_TableGetColumnName(table_, column_n) if name == nil or name == "" then name = "" end @@ -64031,19 +64650,19 @@ function ImGui.TableDrawDefaultContextMenu(table_, flags_for_section_to_display) -- Drag to reorder -- FIXME: It is currently not possible to reorder columns marked with ImGuiTableColumnFlags.NoHide. - if ImGui.IsItemActive() and ImGui.IsMouseDragging(0) and g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and band(table_.Flags, 2 --[[ImGuiTableFlags.Reorderable]]) ~= 0 then + if ImGui_IsItemActive() and ImGui_IsMouseDragging(0) and g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and band(table_.Flags, 2 --[[ImGuiTableFlags.Reorderable]]) ~= 0 then g.ActiveIdHasBeenEditedBefore = true -- Disable toggle in MenuItemForColumnReorder() + start dimming to display allowed reorder targets. table_.ReorderColumn = column_n - if not ImGui.IsItemHovered() then + if not ImGui_IsItemHovered() then local reorder_dir = (g.IO.MousePos.y < (g.LastItemData.Rect.Min.y + g.LastItemData.Rect.Max.y) * 0.5) and -1 or 1 local reorder_amount = ((reorder_dir < 0) and (g.LastItemData.Rect.Min.y - g.IO.MousePos.y) or (g.IO.MousePos.y - g.LastItemData.Rect.Max.y)) / g.LastItemData.Rect:GetHeight() local dst_order = column.DisplayOrder + ImTrunc(ImCeil(reorder_amount)) * reorder_dir -- Estimated target order, will be validated and clamped. - ImGui.TableQueueSetColumnDisplayOrder(table_, column_n, dst_order) + ImGui_TableQueueSetColumnDisplayOrder(table_, column_n, dst_order) end end end end - ImGui.PopItemFlag() + ImGui_PopItemFlag() end end @@ -64087,7 +64706,7 @@ end function ImGui.TableSettingsCreate(id, columns_count) local g = GImGui - local settings = ImGui.TableSettingsFindByID(id) + local settings = ImGui_TableSettingsFindByID(id) if settings then if settings.ColumnsCountMax >= columns_count then TableSettingsInit(settings, id, columns_count, settings.ColumnsCountMax) -- Recycle @@ -64144,13 +64763,13 @@ function ImGui.TableSaveSettings(table_) end -- Bind or create settings data - local settings = ImGui.TableGetBoundSettings(table_) + local settings = ImGui_TableGetBoundSettings(table_) if settings ~= nil and table_.ColumnsCount > settings.ColumnsCountMax then settings.ID = 0 -- Invalidate storage, we won't fit because of a count change settings = nil end if settings == nil then - settings = ImGui.TableSettingsCreate(table_.ID, table_.ColumnsCount) + settings = ImGui_TableSettingsCreate(table_.ID, table_.ColumnsCount) table_.SettingsOffset = SettingsTablesOffsetFromPtr(settings) end settings.ColumnsCount = table_.ColumnsCount @@ -64197,7 +64816,7 @@ function ImGui.TableSaveSettings(table_) settings.SaveFlags = band(settings.SaveFlags, table_.Flags) settings.RefScale = save_ref_scale and table_.RefScale or 0.0 - ImGui.MarkIniSettingsDirty() + ImGui_MarkIniSettingsDirty() end function ImGui.TableLoadSettings(table_) @@ -64209,7 +64828,7 @@ function ImGui.TableLoadSettings(table_) -- Bind settings local settings if table_.SettingsOffset == -1 then - settings = ImGui.TableSettingsFindByID(table_.ID) + settings = ImGui_TableSettingsFindByID(table_.ID) if settings == nil then return end @@ -64218,7 +64837,7 @@ function ImGui.TableLoadSettings(table_) end table_.SettingsOffset = SettingsTablesOffsetFromPtr(settings) else - settings = ImGui.TableGetBoundSettings(table_) + settings = ImGui_TableGetBoundSettings(table_) end table_.SettingsLoadedFlags = settings.SaveFlags @@ -64232,7 +64851,7 @@ function ImGui.TableLoadSettingsForColumns(table_) for n = 0, table_.ColumnsSize - 1 do table_.Columns[n].IsLoadedSettings = false end - local settings = ImGui.TableGetBoundSettings(table_) + local settings = ImGui_TableGetBoundSettings(table_) if settings == nil then return end @@ -64248,7 +64867,7 @@ function ImGui.TableLoadSettingsForColumns(table_) if n >= settings.ColumnsCount or column_settings[n].ID ~= table_.Columns[n].ID then break end - ImGui.TableLoadSettingsForColumn(table_.Columns[n], column_settings[n], settings.SaveFlags) + ImGui_TableLoadSettingsForColumn(table_.Columns[n], column_settings[n], settings.SaveFlags) matches = matches + 1 end if matches == settings.ColumnsCount then @@ -64265,7 +64884,7 @@ function ImGui.TableLoadSettingsForColumns(table_) if column.ID ~= 0 and not column.IsLoadedSettings then for n = settings_start_n, settings.ColumnsCount - 1 do if column_settings[n].ID == column.ID and not column_settings[n].IsLoaded then - ImGui.TableLoadSettingsForColumn(column, column_settings[n], settings.SaveFlags) + ImGui_TableLoadSettingsForColumn(column, column_settings[n], settings.SaveFlags) matches = matches + 1 break end @@ -64283,7 +64902,7 @@ function ImGui.TableLoadSettingsForColumns(table_) if dst_idx >= table_.ColumnsCount then break end - ImGui.TableLoadSettingsForColumn(table_.Columns[dst_idx], column_settings[n], settings.SaveFlags) + ImGui_TableLoadSettingsForColumn(table_.Columns[dst_idx], column_settings[n], settings.SaveFlags) dst_idx = dst_idx + 1 end end @@ -64402,7 +65021,7 @@ local function TableSettingsHandler_ReadOpen(ctx, handler, name) if columns_count <= 0 or columns_count >= 512 --[[IMGUI_TABLE_MAX_COLUMNS]] then return nil end - return ImGui.TableSettingsCreate(id, columns_count) + return ImGui_TableSettingsCreate(id, columns_count) end local function TableSettingsHandler_ReadLine(ctx, handler, settings, line) @@ -64494,7 +65113,7 @@ function ImGui.TableSettingsAddSettingsHandler() ini_handler.ApplyAllFn = TableSettingsHandler_ApplyAll ini_handler.WriteAllFn = TableSettingsHandler_WriteAll ini_handler.CleanupFn = TableSettingsHandler_Cleanup - ImGui.AddSettingsHandler(ini_handler) + ImGui_AddSettingsHandler(ini_handler) end ------------------------------------------------------------------------------- @@ -64596,12 +65215,12 @@ end -- [Port] (Lua: columns.Columns is an ImVector, column n lives in .Data[n + 1]) function ImGui.GetColumnIndex() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() return window.DC.CurrentColumns and window.DC.CurrentColumns.Current or 0 end function ImGui.GetColumnsCount() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() return window.DC.CurrentColumns and window.DC.CurrentColumns.Count or 1 end @@ -64624,9 +65243,9 @@ local function GetDraggedColumnOffset(columns, column_index) assert(g.ActiveId == band(columns.ID + column_index, 0xFFFFFFFF)) local x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + ImTrunc(COLUMNS_HIT_RECT_HALF_THICKNESS * g.CurrentDpiScale) - window.Pos.x - x = ImMax(x, ImGui.GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing) + x = ImMax(x, ImGui_GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing) if band(columns.Flags, 4 --[[ImGuiOldColumnFlags.NoPreserveWidths]]) ~= 0 then - x = ImMin(x, ImGui.GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing) + x = ImMin(x, ImGui_GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing) end return x @@ -64634,7 +65253,7 @@ end function ImGui.GetColumnOffset(column_index) if column_index == nil then column_index = -1 end - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() local columns = window.DC.CurrentColumns if columns == nil then return 0.0 @@ -64662,7 +65281,7 @@ local function GetColumnWidthEx(columns, column_index, before_resize) else offset_norm = d[column_index + 2].OffsetNorm - d[column_index + 1].OffsetNorm end - return ImGui.GetColumnOffsetFromNorm(columns, offset_norm) + return ImGui_GetColumnOffsetFromNorm(columns, offset_norm) end function ImGui.GetColumnWidth(column_index) @@ -64671,14 +65290,14 @@ function ImGui.GetColumnWidth(column_index) local window = g.CurrentWindow local columns = window.DC.CurrentColumns if columns == nil then - return ImGui.GetContentRegionAvail().x + return ImGui_GetContentRegionAvail().x end if column_index < 0 then column_index = columns.Current end local d = columns.Columns.Data - return ImGui.GetColumnOffsetFromNorm(columns, d[column_index + 2].OffsetNorm - d[column_index + 1].OffsetNorm) + return ImGui_GetColumnOffsetFromNorm(columns, d[column_index + 2].OffsetNorm - d[column_index + 1].OffsetNorm) end function ImGui.SetColumnOffset(column_index, offset) @@ -64698,38 +65317,38 @@ function ImGui.SetColumnOffset(column_index, offset) if band(columns.Flags, 8 --[[ImGuiOldColumnFlags.NoForceWithinWindow]]) == 0 then offset = ImMin(offset, columns.OffMaxX - g.Style.ColumnsMinSpacing * (columns.Count - column_index)) end - columns.Columns.Data[column_index + 1].OffsetNorm = ImGui.GetColumnNormFromOffset(columns, offset - columns.OffMinX) + columns.Columns.Data[column_index + 1].OffsetNorm = ImGui_GetColumnNormFromOffset(columns, offset - columns.OffMinX) if preserve_width then - ImGui.SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width)) + ImGui_SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width)) end end function ImGui.SetColumnWidth(column_index, width) - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() local columns = window.DC.CurrentColumns assert(columns ~= nil) if column_index < 0 then column_index = columns.Current end - ImGui.SetColumnOffset(column_index + 1, ImGui.GetColumnOffset(column_index) + width) + ImGui_SetColumnOffset(column_index + 1, ImGui_GetColumnOffset(column_index) + width) end function ImGui.PushColumnClipRect(column_index) - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() local columns = window.DC.CurrentColumns if column_index < 0 then column_index = columns.Current end local column = columns.Columns.Data[column_index + 1] - ImGui.PushClipRect(column.ClipRect.Min, column.ClipRect.Max, false) + ImGui_PushClipRect(column.ClipRect.Min, column.ClipRect.Max, false) end -- Get into the columns background draw command (which is generally the same draw command as before we called BeginColumns) function ImGui.PushColumnsBackground() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() local columns = window.DC.CurrentColumns if columns.Count == 1 then return @@ -64737,19 +65356,19 @@ function ImGui.PushColumnsBackground() -- Optimization: avoid SetCurrentChannel() + PushClipRect() ImRect_Copy(columns.HostBackupClipRect, window.ClipRect) - ImGui.SetWindowClipRectBeforeSetChannel(window, columns.HostInitialClipRect) + ImGui_SetWindowClipRectBeforeSetChannel(window, columns.HostInitialClipRect) columns.Splitter:SetCurrentChannel(window.DrawList, 0) end function ImGui.PopColumnsBackground() - local window = ImGui.GetCurrentWindowRead() + local window = ImGui_GetCurrentWindowRead() local columns = window.DC.CurrentColumns if columns.Count == 1 then return end -- Optimization: avoid PopClipRect() + SetCurrentChannel() - ImGui.SetWindowClipRectBeforeSetChannel(window, columns.HostBackupClipRect) + ImGui_SetWindowClipRectBeforeSetChannel(window, columns.HostBackupClipRect) columns.Splitter:SetCurrentChannel(window.DrawList, columns.Current + 1) end @@ -64768,13 +65387,13 @@ function ImGui.FindOrCreateColumns(window, id) end function ImGui.GetColumnsID(str_id, columns_count) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() -- Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. -- In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer. - ImGui.PushID(0x11223347 + (str_id and 0 or columns_count)) + ImGui_PushID(0x11223347 + (str_id and 0 or columns_count)) local id = window:GetID(str_id or "columns") - ImGui.PopID() + ImGui_PopID() return id end @@ -64782,14 +65401,14 @@ end function ImGui.BeginColumns(str_id, columns_count, flags) if flags == nil then flags = 0 end local g = GImGui - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() assert(columns_count >= 1) assert(window.DC.CurrentColumns == nil) -- Nested columns are currently not supported -- Acquire storage for the columns set - local id = ImGui.GetColumnsID(str_id, columns_count) - local columns = ImGui.FindOrCreateColumns(window, id) + local id = ImGui_GetColumnsID(str_id, columns_count) + local columns = ImGui_FindOrCreateColumns(window, id) assert(columns.ID == id) columns.Current = 0 columns.Count = columns_count @@ -64831,8 +65450,8 @@ function ImGui.BeginColumns(str_id, columns_count, flags) for n = 0, columns_count - 1 do -- Compute clipping rectangle local column = columns.Columns.Data[n + 1] - local clip_x1 = IM_ROUND(window.Pos.x + ImGui.GetColumnOffset(n)) - local clip_x2 = IM_ROUND(window.Pos.x + ImGui.GetColumnOffset(n + 1) - 1.0) + local clip_x1 = IM_ROUND(window.Pos.x + ImGui_GetColumnOffset(n)) + local clip_x2 = IM_ROUND(window.Pos.x + ImGui_GetColumnOffset(n + 1) - 1.0) column.ClipRect = ImRect(clip_x1, -3.4028234663853e+38 --[[FLT_MAX]], clip_x2, 3.4028234663853e+38 --[[FLT_MAX]]) column.ClipRect:ClipWithFull(window.ClipRect) end @@ -64840,14 +65459,14 @@ function ImGui.BeginColumns(str_id, columns_count, flags) if columns.Count > 1 then columns.Splitter:Split(window.DrawList, 1 + columns.Count) columns.Splitter:SetCurrentChannel(window.DrawList, 1) - ImGui.PushColumnClipRect(0) + ImGui_PushColumnClipRect(0) end -- We don't generally store Indent.x inside ColumnsOffset because it may be manipulated by the user. - local offset_0 = ImGui.GetColumnOffset(columns.Current) - local offset_1 = ImGui.GetColumnOffset(columns.Current + 1) + local offset_0 = ImGui_GetColumnOffset(columns.Current) + local offset_1 = ImGui_GetColumnOffset(columns.Current + 1) local width = offset_1 - offset_0 - ImGui.PushItemWidth(width * 0.65) + ImGui_PushItemWidth(width * 0.65) window.DC.ColumnsOffset.x = ImMax(column_padding - window.WindowPadding.x, 0.0) window.DC.CursorPos.x = IM_TRUNC(window.Pos.x + window.DC.Indent.x + window.DC.ColumnsOffset.x) window.WorkRect.Max.x = window.Pos.x + offset_1 - column_padding @@ -64855,7 +65474,7 @@ function ImGui.BeginColumns(str_id, columns_count, flags) end function ImGui.NextColumn() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems or window.DC.CurrentColumns == nil then return end @@ -64875,12 +65494,12 @@ function ImGui.NextColumn() columns.Current = 0 end - ImGui.PopItemWidth() + ImGui_PopItemWidth() -- Optimization: avoid PopClipRect() + SetCurrentChannel() + PushClipRect() -- (which would needlessly attempt to update commands in the wrong channel, then pop or overwrite them), local column = columns.Columns.Data[columns.Current + 1] - ImGui.SetWindowClipRectBeforeSetChannel(window, column.ClipRect) + ImGui_SetWindowClipRectBeforeSetChannel(window, column.ClipRect) columns.Splitter:SetCurrentChannel(window.DrawList, columns.Current + 1) local column_padding = g.Style.ItemSpacing.x @@ -64888,7 +65507,7 @@ function ImGui.NextColumn() if columns.Current > 0 then -- Columns 1+ ignore IndentX (by canceling it out) -- FIXME-COLUMNS: Unnecessary, could be locked? - window.DC.ColumnsOffset.x = ImGui.GetColumnOffset(columns.Current) - window.DC.Indent.x + column_padding + window.DC.ColumnsOffset.x = ImGui_GetColumnOffset(columns.Current) - window.DC.Indent.x + column_padding else -- New row/line: column 0 honor IndentX. window.DC.ColumnsOffset.x = ImMax(column_padding - window.WindowPadding.x, 0.0) @@ -64901,22 +65520,22 @@ function ImGui.NextColumn() window.DC.CurrLineTextBaseOffset = 0.0 -- FIXME-COLUMNS: Share code with BeginColumns() - move code on columns setup. - local offset_0 = ImGui.GetColumnOffset(columns.Current) - local offset_1 = ImGui.GetColumnOffset(columns.Current + 1) + local offset_0 = ImGui_GetColumnOffset(columns.Current) + local offset_1 = ImGui_GetColumnOffset(columns.Current + 1) local width = offset_1 - offset_0 - ImGui.PushItemWidth(width * 0.65) + ImGui_PushItemWidth(width * 0.65) window.WorkRect.Max.x = window.Pos.x + offset_1 - column_padding end function ImGui.EndColumns() local g = GImGui - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() local columns = window.DC.CurrentColumns assert(columns ~= nil) - ImGui.PopItemWidth() + ImGui_PopItemWidth() if columns.Count > 1 then - ImGui.PopClipRect() + ImGui_PopClipRect() columns.Splitter:Merge(window.DrawList) end @@ -64937,7 +65556,7 @@ function ImGui.EndColumns() local dragging_column = -1 for n = 1, columns.Count - 1 do local column = columns.Columns.Data[n + 1] - local x = window.Pos.x + ImGui.GetColumnOffset(n) + local x = window.Pos.x + ImGui_GetColumnOffset(n) local column_id = band(columns.ID + n, 0xFFFFFFFF) local column_hit_hw = ImTrunc(COLUMNS_HIT_RECT_HALF_THICKNESS * g.CurrentDpiScale) local column_hit_rect = ImRect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2)) @@ -64945,9 +65564,9 @@ function ImGui.EndColumns() local hovered, held = false, false if band(flags, 2 --[[ImGuiOldColumnFlags.NoResize]]) == 0 then local _ - _, hovered, held = ImGui.ButtonBehavior(column_hit_rect, column_id) + _, hovered, held = ImGui_ButtonBehavior(column_hit_rect, column_id) if hovered or held then - ImGui.SetMouseCursor(4 --[[ImGuiMouseCursor.ResizeEW]]) + ImGui_SetMouseCursor(4 --[[ImGuiMouseCursor.ResizeEW]]) end if held and band(column.Flags, 2 --[[ImGuiOldColumnFlags.NoResize]]) == 0 then dragging_column = n @@ -64955,7 +65574,7 @@ function ImGui.EndColumns() end -- Draw column - local col = ImGui.GetColorU32(held and 30 --[[ImGuiCol.SeparatorActive]] or (hovered and 29 --[[ImGuiCol.SeparatorHovered]] or 28 --[[ImGuiCol.Separator]])) + local col = ImGui_GetColorU32(held and 30 --[[ImGuiCol.SeparatorActive]] or (hovered and 29 --[[ImGuiCol.SeparatorHovered]] or 28 --[[ImGuiCol.Separator]])) local xi = IM_TRUNC(x) window.DrawList:AddLineV(xi, y1 + 1.0, y2, col) end @@ -64971,7 +65590,7 @@ function ImGui.EndColumns() end columns.IsBeingResized = true; is_being_resized = true local x = GetDraggedColumnOffset(columns, dragging_column) - ImGui.SetColumnOffset(dragging_column, x) + ImGui_SetColumnOffset(dragging_column, x) end end columns.IsBeingResized = is_being_resized @@ -64981,7 +65600,7 @@ function ImGui.EndColumns() window.DC.CurrentColumns = nil window.DC.ColumnsOffset.x = 0.0 window.DC.CursorPos.x = IM_TRUNC(window.Pos.x + window.DC.Indent.x + window.DC.ColumnsOffset.x) - ImGui.NavUpdateCurrentWindowIsScrollPushableX() + ImGui_NavUpdateCurrentWindowIsScrollPushableX() end --- @param columns_count? int @@ -64990,7 +65609,7 @@ end function ImGui.Columns(columns_count, id, borders) if columns_count == nil then columns_count = 1 end if borders == nil then borders = true end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() assert(columns_count >= 1) local flags = borders and 0 or 1 --[[ImGuiOldColumnFlags.NoBorder]] @@ -65001,18 +65620,23 @@ function ImGui.Columns(columns_count, id, borders) end if columns ~= nil then - ImGui.EndColumns() + ImGui_EndColumns() end if columns_count ~= 1 then - ImGui.BeginColumns(id, columns_count, flags) + ImGui_BeginColumns(id, columns_count, flags) end end return true -- [Port] [Roblox] ModuleScripts must return exactly one value -end +end end)() -__FILES['imgui_widgets.lua'] = function() +__FILES['imgui_widgets.lua'] = (function() +local ImGui_ArrowButtonEx, ImGui_BeginDisabled, ImGui_BeginGroup, ImGui_BeginPopup, ImGui_ButtonBehavior, ImGui_ButtonEx, ImGui_CalcItemSize, ImGui_CalcItemWidth, ImGui_CalcTextSize, ImGui_CalcTextSizeEx, ImGui_CalcTextSizeXY, ImGui_ClearActiveID, ImGui_ColorButton, ImGui_ColorConvertFloat4ToU32, ImGui_ColorConvertHSVtoRGB, ImGui_ColorConvertRGBtoHSV, ImGui_ColorEdit4, ImGui_ColorPicker4, ImGui_DataTypeApplyFromText, ImGui_DataTypeCompare, ImGui_DataTypeGetInfo, ImGui_DragBehaviorT, ImGui_DragScalar, ImGui_EndChild, ImGui_EndDisabled, ImGui_EndGroup, ImGui_EndPopup, ImGui_FindRenderedTextEnd, ImGui_FindWindowByName, ImGui_FocusWindow, ImGui_GetColorU32, ImGui_GetContentRegionAvail, ImGui_GetCurrentContext, ImGui_GetCurrentWindow, ImGui_GetFrameHeight, ImGui_GetInputTextState, ImGui_GetKeyData, ImGui_GetNavTweakPressedAmount, ImGui_GetTextLineHeightWithSpacing, ImGui_GetWindowScrollbarID, ImGui_InputScalar, ImGui_InputScalarN, ImGui_InputText, ImGui_InputTextEx, ImGui_InvisibleButton, ImGui_IsItemActive, ImGui_IsItemHovered, ImGui_IsKeyDown, ImGui_IsKeyPressed, ImGui_IsMouseClicked, ImGui_IsMouseClickedEx, ImGui_IsMouseDragPastThreshold, ImGui_IsMouseDragging, ImGui_IsMouseReleased, ImGui_IsPopupOpen, ImGui_KeepAliveID, ImGui_LogRenderedText, ImGui_LogSetNextTextDecoration, ImGui_MarkItemEdited, ImGui_MultiSelectAddSetAll, ImGui_MultiSelectItemFooter, ImGui_MultiSelectItemHeader, ImGui_NavMoveRequestButNoResultYet, ImGui_NavMoveRequestCancel, ImGui_OpenPopup, ImGui_OpenPopupOnItemClick, ImGui_PlotEx, ImGui_PopClipRect, ImGui_PopID, ImGui_PopItemFlag, ImGui_PopItemWidth, ImGui_PopStyleColor, ImGui_PopStyleVar, ImGui_PushClipRect, ImGui_PushID, ImGui_PushItemFlag, ImGui_PushMultiItemsWidths, ImGui_PushOverrideID, ImGui_PushStyleColor, ImGui_PushStyleVar, ImGui_PushStyleVarX, ImGui_RadioButtonEx, ImGui_RenderArrow, ImGui_RenderArrowPointingAt, ImGui_RenderBullet, ImGui_RenderColorRectWithAlphaCheckerboard, ImGui_RenderFrame, ImGui_RenderFrameBorder, ImGui_RenderNavCursor, ImGui_RenderText, ImGui_RenderTextClipped, ImGui_RenderTextEllipsis, ImGui_RoundScalarWithFormatT, ImGui_SameLine, ImGui_ScaleRatioFromValueT, ImGui_ScaleValueFromRatioT, ImGui_Selectable, ImGui_Separator, ImGui_SetActiveID, ImGui_SetClipboardText, ImGui_SetCursorScreenPos, ImGui_SetFocusID, ImGui_SetKeyOwner, ImGui_SetNavCursorVisibleAfterMove, ImGui_SetNavID, ImGui_SetNextItemColorMarker, ImGui_SetNextItemWidth, ImGui_SetNextWindowPos, ImGui_SetScrollY, ImGui_SetTooltip, ImGui_Shortcut, ImGui_SliderBehaviorT, ImGui_SliderScalar, ImGui_SliderScalarN, ImGui_TabBarCalcTabID, ImGui_TabBarFindTabByID, ImGui_TabBarGetTabOrder, ImGui_TabBarQueueFocus, ImGui_TabBarScrollClamp, ImGui_TabItemCalcSize, ImGui_TabItemEx, ImGui_TablePopBackgroundChannel, ImGui_Text, ImGui_TextEx, ImGui__ByteArrayToString, ImGui__CalcItemSizeXY +__BIND[#__BIND + 1] = function() if ImGui then ImGui_ArrowButtonEx = ImGui.ArrowButtonEx ImGui_BeginDisabled = ImGui.BeginDisabled ImGui_BeginGroup = ImGui.BeginGroup ImGui_BeginPopup = ImGui.BeginPopup ImGui_ButtonBehavior = ImGui.ButtonBehavior ImGui_ButtonEx = ImGui.ButtonEx ImGui_CalcItemSize = ImGui.CalcItemSize ImGui_CalcItemWidth = ImGui.CalcItemWidth ImGui_CalcTextSize = ImGui.CalcTextSize ImGui_CalcTextSizeEx = ImGui.CalcTextSizeEx ImGui_CalcTextSizeXY = ImGui.CalcTextSizeXY ImGui_ClearActiveID = ImGui.ClearActiveID ImGui_ColorButton = ImGui.ColorButton ImGui_ColorConvertFloat4ToU32 = ImGui.ColorConvertFloat4ToU32 ImGui_ColorConvertHSVtoRGB = ImGui.ColorConvertHSVtoRGB ImGui_ColorConvertRGBtoHSV = ImGui.ColorConvertRGBtoHSV ImGui_ColorEdit4 = ImGui.ColorEdit4 ImGui_ColorPicker4 = ImGui.ColorPicker4 ImGui_DataTypeApplyFromText = ImGui.DataTypeApplyFromText ImGui_DataTypeCompare = ImGui.DataTypeCompare ImGui_DataTypeGetInfo = ImGui.DataTypeGetInfo ImGui_DragBehaviorT = ImGui.DragBehaviorT ImGui_DragScalar = ImGui.DragScalar ImGui_EndChild = ImGui.EndChild ImGui_EndDisabled = ImGui.EndDisabled ImGui_EndGroup = ImGui.EndGroup ImGui_EndPopup = ImGui.EndPopup ImGui_FindRenderedTextEnd = ImGui.FindRenderedTextEnd ImGui_FindWindowByName = ImGui.FindWindowByName ImGui_FocusWindow = ImGui.FocusWindow ImGui_GetColorU32 = ImGui.GetColorU32 ImGui_GetContentRegionAvail = ImGui.GetContentRegionAvail ImGui_GetCurrentContext = ImGui.GetCurrentContext ImGui_GetCurrentWindow = ImGui.GetCurrentWindow ImGui_GetFrameHeight = ImGui.GetFrameHeight ImGui_GetInputTextState = ImGui.GetInputTextState ImGui_GetKeyData = ImGui.GetKeyData ImGui_GetNavTweakPressedAmount = ImGui.GetNavTweakPressedAmount ImGui_GetTextLineHeightWithSpacing = ImGui.GetTextLineHeightWithSpacing ImGui_GetWindowScrollbarID = ImGui.GetWindowScrollbarID ImGui_InputScalar = ImGui.InputScalar ImGui_InputScalarN = ImGui.InputScalarN ImGui_InputText = ImGui.InputText ImGui_InputTextEx = ImGui.InputTextEx ImGui_InvisibleButton = ImGui.InvisibleButton ImGui_IsItemActive = ImGui.IsItemActive ImGui_IsItemHovered = ImGui.IsItemHovered ImGui_IsKeyDown = ImGui.IsKeyDown ImGui_IsKeyPressed = ImGui.IsKeyPressed ImGui_IsMouseClicked = ImGui.IsMouseClicked ImGui_IsMouseClickedEx = ImGui.IsMouseClickedEx ImGui_IsMouseDragPastThreshold = ImGui.IsMouseDragPastThreshold ImGui_IsMouseDragging = ImGui.IsMouseDragging ImGui_IsMouseReleased = ImGui.IsMouseReleased ImGui_IsPopupOpen = ImGui.IsPopupOpen ImGui_KeepAliveID = ImGui.KeepAliveID ImGui_LogRenderedText = ImGui.LogRenderedText ImGui_LogSetNextTextDecoration = ImGui.LogSetNextTextDecoration ImGui_MarkItemEdited = ImGui.MarkItemEdited ImGui_MultiSelectAddSetAll = ImGui.MultiSelectAddSetAll ImGui_MultiSelectItemFooter = ImGui.MultiSelectItemFooter ImGui_MultiSelectItemHeader = ImGui.MultiSelectItemHeader ImGui_NavMoveRequestButNoResultYet = ImGui.NavMoveRequestButNoResultYet ImGui_NavMoveRequestCancel = ImGui.NavMoveRequestCancel ImGui_OpenPopup = ImGui.OpenPopup ImGui_OpenPopupOnItemClick = ImGui.OpenPopupOnItemClick ImGui_PlotEx = ImGui.PlotEx ImGui_PopClipRect = ImGui.PopClipRect ImGui_PopID = ImGui.PopID ImGui_PopItemFlag = ImGui.PopItemFlag ImGui_PopItemWidth = ImGui.PopItemWidth ImGui_PopStyleColor = ImGui.PopStyleColor ImGui_PopStyleVar = ImGui.PopStyleVar ImGui_PushClipRect = ImGui.PushClipRect ImGui_PushID = ImGui.PushID ImGui_PushItemFlag = ImGui.PushItemFlag ImGui_PushMultiItemsWidths = ImGui.PushMultiItemsWidths ImGui_PushOverrideID = ImGui.PushOverrideID ImGui_PushStyleColor = ImGui.PushStyleColor ImGui_PushStyleVar = ImGui.PushStyleVar ImGui_PushStyleVarX = ImGui.PushStyleVarX ImGui_RadioButtonEx = ImGui.RadioButtonEx ImGui_RenderArrow = ImGui.RenderArrow ImGui_RenderArrowPointingAt = ImGui.RenderArrowPointingAt ImGui_RenderBullet = ImGui.RenderBullet ImGui_RenderColorRectWithAlphaCheckerboard = ImGui.RenderColorRectWithAlphaCheckerboard ImGui_RenderFrame = ImGui.RenderFrame ImGui_RenderFrameBorder = ImGui.RenderFrameBorder ImGui_RenderNavCursor = ImGui.RenderNavCursor ImGui_RenderText = ImGui.RenderText ImGui_RenderTextClipped = ImGui.RenderTextClipped ImGui_RenderTextEllipsis = ImGui.RenderTextEllipsis ImGui_RoundScalarWithFormatT = ImGui.RoundScalarWithFormatT ImGui_SameLine = ImGui.SameLine ImGui_ScaleRatioFromValueT = ImGui.ScaleRatioFromValueT ImGui_ScaleValueFromRatioT = ImGui.ScaleValueFromRatioT ImGui_Selectable = ImGui.Selectable ImGui_Separator = ImGui.Separator ImGui_SetActiveID = ImGui.SetActiveID ImGui_SetClipboardText = ImGui.SetClipboardText ImGui_SetCursorScreenPos = ImGui.SetCursorScreenPos ImGui_SetFocusID = ImGui.SetFocusID ImGui_SetKeyOwner = ImGui.SetKeyOwner ImGui_SetNavCursorVisibleAfterMove = ImGui.SetNavCursorVisibleAfterMove ImGui_SetNavID = ImGui.SetNavID ImGui_SetNextItemColorMarker = ImGui.SetNextItemColorMarker ImGui_SetNextItemWidth = ImGui.SetNextItemWidth ImGui_SetNextWindowPos = ImGui.SetNextWindowPos ImGui_SetScrollY = ImGui.SetScrollY ImGui_SetTooltip = ImGui.SetTooltip ImGui_Shortcut = ImGui.Shortcut ImGui_SliderBehaviorT = ImGui.SliderBehaviorT ImGui_SliderScalar = ImGui.SliderScalar ImGui_SliderScalarN = ImGui.SliderScalarN ImGui_TabBarCalcTabID = ImGui.TabBarCalcTabID ImGui_TabBarFindTabByID = ImGui.TabBarFindTabByID ImGui_TabBarGetTabOrder = ImGui.TabBarGetTabOrder ImGui_TabBarQueueFocus = ImGui.TabBarQueueFocus ImGui_TabBarScrollClamp = ImGui.TabBarScrollClamp ImGui_TabItemCalcSize = ImGui.TabItemCalcSize ImGui_TabItemEx = ImGui.TabItemEx ImGui_TablePopBackgroundChannel = ImGui.TablePopBackgroundChannel ImGui_Text = ImGui.Text ImGui_TextEx = ImGui.TextEx ImGui__ByteArrayToString = ImGui._ByteArrayToString ImGui__CalcItemSizeXY = ImGui._CalcItemSizeXY end end; __BIND[#__BIND]() +return function() +local ImGui_AcceptDragDropPayload, ImGui_AlignTextToFramePadding, ImGui_BeginChild, ImGui_BeginCombo, ImGui_BeginPopupMenuEx, ImGui_CalcClipRectVisibleItemsY, ImGui_TestKeyOwner, ImGui_TextV +__BIND[#__BIND + 1] = function() if ImGui then ImGui_AcceptDragDropPayload = ImGui.AcceptDragDropPayload ImGui_AlignTextToFramePadding = ImGui.AlignTextToFramePadding ImGui_BeginChild = ImGui.BeginChild ImGui_BeginCombo = ImGui.BeginCombo ImGui_BeginPopupMenuEx = ImGui.BeginPopupMenuEx ImGui_CalcClipRectVisibleItemsY = ImGui.CalcClipRectVisibleItemsY ImGui_TestKeyOwner = ImGui.TestKeyOwner ImGui_TextV = ImGui.TextV end end; __BIND[#__BIND]() --- Dear ImGui WIP -- (widgets code) @@ -65165,7 +65789,7 @@ function ImGui.TextEx(text, text_end, flags) line_end = text_end end if bit32.band(flags, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) == 0 then - local line_size = ImGui.CalcTextSizeEx(text, line, line_end) + local line_size = ImGui_CalcTextSizeEx(text, line, line_end) text_size.x = ImMax(text_size.x, line_size.x) end line = line_end + 1 @@ -65188,9 +65812,9 @@ function ImGui.TextEx(text, text_end, flags) line_end = text_end end - local line_size = ImGui.CalcTextSizeEx(text, line, line_end) + local line_size = ImGui_CalcTextSizeEx(text, line, line_end) text_size.x = ImMax(text_size.x, line_size.x) - ImGui.RenderText(pos, text, line, line_end, false) + ImGui_RenderText(pos, text, line, line_end, false) line = line_end + 1 line_rect.Min.y = line_rect.Min.y + line_height line_rect.Max.y = line_rect.Max.y + line_height @@ -65205,7 +65829,7 @@ function ImGui.TextEx(text, text_end, flags) line_end = text_end end if bit32.band(flags, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) == 0 then - local line_size = ImGui.CalcTextSizeEx(text, line, line_end) + local line_size = ImGui_CalcTextSizeEx(text, line, line_end) text_size.x = ImMax(text_size.x, line_size.x) end line = line_end + 1 @@ -65224,7 +65848,7 @@ end --- @param text string --- @param text_end? int function ImGui.TextUnformatted(text, text_end) - ImGui.TextEx(text, text_end, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) + ImGui_TextEx(text, text_end, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) end --- @param fmt string @@ -65238,7 +65862,7 @@ function ImGui.TextV(fmt, ...) end local text = ImFormatString(fmt, ...) - ImGui.TextEx(text, nil, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) + ImGui_TextEx(text, nil, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) end --- @param fmt string @@ -65252,9 +65876,9 @@ function ImGui.Text(fmt, ...) if window.SkipItems then return end - ImGui.TextEx(ImFormatString(fmt, ...), nil, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) + ImGui_TextEx(ImFormatString(fmt, ...), nil, 1 --[[ImGuiTextFlags.NoWidthForLargeClippedText]]) else - ImGui.TextEx(fmt) + ImGui_TextEx(fmt) end end @@ -65262,9 +65886,9 @@ end --- @param fmt string --- @param ... any function ImGui.TextColored(col, fmt, ...) - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], col) - ImGui.TextV(fmt, ...) - ImGui.PopStyleColor() + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], col) + ImGui_TextV(fmt, ...) + ImGui_PopStyleColor() end --- @param fmt string @@ -65272,9 +65896,9 @@ end @native function ImGui.TextDisabled(fmt, ...) local g = GImGui - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) - ImGui.TextV(fmt, ...) - ImGui.PopStyleColor() + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) + ImGui_TextV(fmt, ...) + ImGui_PopStyleColor() end --- @param fmt string @@ -65286,7 +65910,7 @@ function ImGui.TextWrapped(fmt, ...) if need_backup then ImGui.PushTextWrapPos(0.0) end - ImGui.TextV(fmt, ...) + ImGui_TextV(fmt, ...) if need_backup then ImGui.PopTextWrapPos() end @@ -65300,15 +65924,15 @@ end --- @param fmt string --- @param ... any function ImGui.TextAligned(align_x, size_x, fmt, ...) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end local text = ImFormatString(fmt, ...) local text_end = #text + 1 - local text_size = ImGui.CalcTextSize(text, text_end) - size_x = ImGui._CalcItemSizeXY(size_x, 0.0, 0.0, text_size.y) + local text_size = ImGui_CalcTextSize(text, text_end) + size_x = ImGui__CalcItemSizeXY(size_x, 0.0, 0.0, text_size.y) local pos = ImVec2(window.DC.CursorPos.x, window.DC.CursorPos.y + window.DC.CurrLineTextBaseOffset) local pos_max = ImVec2(pos.x + size_x, window.ClipRect.Max.y) @@ -65318,7 +65942,7 @@ function ImGui.TextAligned(align_x, size_x, fmt, ...) if align_x > 0.0 and text_size.x < size_x then pos.x = pos.x + ImTrunc((size_x - text_size.x) * align_x) end - ImGui.RenderTextEllipsis(window.DrawList, pos, pos_max, pos_max.x, text, text_end, text_size) + ImGui_RenderTextEllipsis(window.DrawList, pos, pos_max, pos_max.x, text, text_end, text_size) local backup_max_pos = ImVec2() ImVec2_Copy(backup_max_pos, window.DC.CursorMaxPos) @@ -65326,8 +65950,8 @@ function ImGui.TextAligned(align_x, size_x, fmt, ...) ImGui.ItemAdd(ImRect(pos, pos + size), 0) window.DC.CursorMaxPos.x = backup_max_pos.x -- Cancel out extending content to 'size' to use 'text_size' allowing auto-resize to function with align_x > 0.0f - if size_x < text_size.x and ImGui.IsItemHovered(bit32.bor(2048 --[[ImGuiHoveredFlags.NoNavOverride]], 1024 --[[ImGuiHoveredFlags.AllowWhenDisabled]], 4096 --[[ImGuiHoveredFlags.ForTooltip]])) then - ImGui.SetTooltip("%.*s", text_end - 1, text) + if size_x < text_size.x and ImGui_IsItemHovered(bit32.bor(2048 --[[ImGuiHoveredFlags.NoNavOverride]], 1024 --[[ImGuiHoveredFlags.AllowWhenDisabled]], 4096 --[[ImGuiHoveredFlags.ForTooltip]])) then + ImGui_SetTooltip("%.*s", text_end - 1, text) end end @@ -65335,35 +65959,44 @@ end --- @param label string --- @param fmt string --- @param ... any +-- [Luau] scratch for LabelText(): only read by its callees (ItemAdd() copies total_bb), never escape +local LabelText_value_size, LabelText_value_bb, LabelText_total_bb, LabelText_pos = ImVec2(), ImRect(), ImRect(), ImVec2() function ImGui.LabelText(label, fmt, ...) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end local g = GImGui local style = g.Style - local w = ImGui.CalcItemWidth() + local w = ImGui_CalcItemWidth() local value_text = ImFormatString(fmt, ...) local value_text_end = #value_text + 1 - local value_size = ImGui.CalcTextSize(value_text, value_text_end, false) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local value_size = LabelText_value_size + value_size.x, value_size.y = ImGui_CalcTextSizeXY(value_text, 1, value_text_end, false) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size - local pos = ImVec2() - ImVec2_Copy(pos, window.DC.CursorPos) - local value_bb = ImRect(pos, pos + ImVec2(w, value_size.y + style.FramePadding.y * 2)) - local total_bb = ImRect(pos, pos + ImVec2(w + ((label_size.x > 0.0) and (style.ItemInnerSpacing.x + label_size.x) or 0.0), ImMax(value_size.y, label_size.y) + style.FramePadding.y * 2)) + local pos_x, pos_y = window.DC.CursorPos.x, window.DC.CursorPos.y -- [Luau] scalar pos + local value_bb = LabelText_value_bb + value_bb.Min.x, value_bb.Min.y, value_bb.Max.x, value_bb.Max.y = pos_x, pos_y, pos_x + w, pos_y + (value_size.y + style.FramePadding.y * 2) + local total_bb = LabelText_total_bb + total_bb.Min.x, total_bb.Min.y = pos_x, pos_y + total_bb.Max.x = pos_x + (w + ((label_size_x > 0.0) and (style.ItemInnerSpacing.x + label_size_x) or 0.0)) + total_bb.Max.y = pos_y + (ImMax(value_size.y, label_size_y) + style.FramePadding.y * 2) ImGui.ItemSize(total_bb, style.FramePadding.y) if not ImGui.ItemAdd(total_bb, 0) then return end -- Render - ImGui.RenderTextClipped(value_bb.Min + style.FramePadding, value_bb.Max, value_text, value_text_end, value_size, ImVec2(0.0, 0.0)) - if label_size.x > 0.0 then - ImGui.RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label, 1, label_end, false) + local text_pos = LabelText_pos + text_pos.x, text_pos.y = value_bb.Min.x + style.FramePadding.x, value_bb.Min.y + style.FramePadding.y + ImGui_RenderTextClipped(text_pos, value_bb.Max, value_text, value_text_end, value_size, LAYOUT_ZERO_SIZE) + if label_size_x > 0.0 then + text_pos.x, text_pos.y = value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y + ImGui_RenderText(text_pos, label, 1, label_end, false) end end @@ -65373,7 +66006,7 @@ end local BulletText_bb, BulletText_pos, BulletText_size = ImRect(), ImVec2(), ImVec2() -- [Luau] scratch, only read by callees function ImGui.BulletText(fmt, ...) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -65383,7 +66016,7 @@ function ImGui.BulletText(fmt, ...) local text = ImFormatString(fmt, ...) local text_end = #text + 1 - local label_size_x, label_size_y = ImGui.CalcTextSizeXY(text, 1, text_end, false) -- [Luau] scalar label_size/total_size + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(text, 1, text_end, false) -- [Luau] scalar label_size/total_size local total_size_x = g.FontSize + ((label_size_x > 0.0) and (label_size_x + style.FramePadding.x * 2) or 0.0) -- Empty text doesn't add padding -- [Luau] scalar pos, no temporary ImVec2 local pos_x, pos_y = window.DC.CursorPos.x, window.DC.CursorPos.y + window.DC.CurrLineTextBaseOffset @@ -65397,12 +66030,12 @@ function ImGui.BulletText(fmt, ...) end -- Render - local text_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) + local text_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) local p = BulletText_pos p.x, p.y = bb.Min.x + (style.FramePadding.x + g.FontSize * 0.5), bb.Min.y + g.FontSize * 0.5 - ImGui.RenderBullet(window.DrawList, p, text_col) + ImGui_RenderBullet(window.DrawList, p, text_col) p.x, p.y = bb.Min.x + (g.FontSize + style.FramePadding.x * 2), bb.Min.y + 0.0 - ImGui.RenderText(p, text, 1, text_end, false) + ImGui_RenderText(p, text, 1, text_end, false) end -- [Port] va_list variants: identical to the varargs versions in Lua @@ -65424,13 +66057,13 @@ ImGui.BulletTextV = ImGui.BulletText -- [Port] Lua can't tell int from float: integers without float_format print as %d, otherwise %.3f function ImGui.Value(prefix, v, float_format) if type(v) == "boolean" then - ImGui.Text("%s: %s", prefix, v and "true" or "false") + ImGui_Text("%s: %s", prefix, v and "true" or "false") elseif float_format then - ImGui.Text("%s: " .. float_format, prefix, v) + ImGui_Text("%s: " .. float_format, prefix, v) elseif math.floor(v) == v then - ImGui.Text("%s: %d", prefix, v) + ImGui_Text("%s: %d", prefix, v) else - ImGui.Text("%s: %.3f", prefix, v) + ImGui_Text("%s: %.3f", prefix, v) end end @@ -65565,14 +66198,14 @@ function ImGui.ButtonBehavior(bb, id, flags) -- Special mode for Drag and Drop used by openables (tree nodes, tabs etc.) -- where holding the button pressed for a long time while drag a payload item triggers the button. if g.DragDropActive then - if (bit32.band(flags, 512 --[[ImGuiButtonFlags.PressedOnDragDropHold]]) ~= 0) and (bit32.band(g.DragDropSourceFlags, 4 --[[ImGuiDragDropFlags.SourceNoHoldToOpenOthers]]) == 0) and ImGui.IsItemHovered(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]]) then + if (bit32.band(flags, 512 --[[ImGuiButtonFlags.PressedOnDragDropHold]]) ~= 0) and (bit32.band(g.DragDropSourceFlags, 4 --[[ImGuiDragDropFlags.SourceNoHoldToOpenOthers]]) == 0) and ImGui_IsItemHovered(128 --[[ImGuiHoveredFlags.AllowWhenBlockedByActiveItem]]) then hovered = true ImGui.SetHoveredID(id) if (g.HoveredIdTimer - g.IO.DeltaTime <= DRAGDROP_HOLD_TO_OPEN_TIMER) and (g.HoveredIdTimer >= DRAGDROP_HOLD_TO_OPEN_TIMER) then pressed = true g.DragDropHoldJustPressedId = id - ImGui.FocusWindow(window) + ImGui_FocusWindow(window) end end @@ -65597,8 +66230,8 @@ function ImGui.ButtonBehavior(bb, id, flags) local mouse_button_released = -1 for button = 0, 2 do if bit32.band(flags, bit32.lshift(1 --[[ImGuiButtonFlags.MouseButtonLeft]], button)) ~= 0 then -- Handle ImGuiButtonFlags.MouseButtonRight and ImGuiButtonFlags.MouseButtonMiddle here. - if (ImGui.IsMouseClickedEx(button, 0 --[[ImGuiInputFlags.None]], test_owner_id) and mouse_button_clicked == -1) then mouse_button_clicked = button end - if (ImGui.IsMouseReleased(button, test_owner_id) and mouse_button_released == -1) then mouse_button_released = button end + if (ImGui_IsMouseClickedEx(button, 0 --[[ImGuiInputFlags.None]], test_owner_id) and mouse_button_clicked == -1) then mouse_button_clicked = button end + if (ImGui_IsMouseReleased(button, test_owner_id) and mouse_button_released == -1) then mouse_button_released = button end end end @@ -65609,18 +66242,18 @@ function ImGui.ButtonBehavior(bb, id, flags) --- @cast mouse_button_clicked ImGuiMouseButton if bit32.band(flags, 1048576 --[[ImGuiButtonFlags.NoSetKeyOwner]]) == 0 then - ImGui.SetKeyOwner(ImGui.MouseButtonToKey(mouse_button_clicked), id) + ImGui_SetKeyOwner(ImGui.MouseButtonToKey(mouse_button_clicked), id) end if bit32.band(flags, bit32.bor(32 --[[ImGuiButtonFlags.PressedOnClickRelease]], 64 --[[ImGuiButtonFlags.PressedOnClickReleaseAnywhere]])) ~= 0 then - ImGui.SetActiveID(id, window) + ImGui_SetActiveID(id, window) g.ActiveIdMouseButton = mouse_button_clicked if bit32.band(flags, 262144 --[[ImGuiButtonFlags.NoNavFocus]]) == 0 then - ImGui.SetFocusID(id, window) - ImGui.FocusWindow(window) + ImGui_SetFocusID(id, window) + ImGui_FocusWindow(window) elseif bit32.band(flags, 4194304 --[[ImGuiButtonFlags.NoFocus]]) == 0 then - ImGui.FocusWindow(window, 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) -- Still need to focus and bring to front, but try to avoid losing NavId when navigating a child + ImGui_FocusWindow(window, 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) -- Still need to focus and bring to front, but try to avoid losing NavId when navigating a child end end @@ -65628,18 +66261,18 @@ function ImGui.ButtonBehavior(bb, id, flags) pressed = true if bit32.band(flags, 131072 --[[ImGuiButtonFlags.NoHoldingActiveId]]) ~= 0 then - ImGui.ClearActiveID() + ImGui_ClearActiveID() else - ImGui.SetActiveID(id, window) -- Hold on ID + ImGui_SetActiveID(id, window) -- Hold on ID end g.ActiveIdMouseButton = mouse_button_clicked if bit32.band(flags, 262144 --[[ImGuiButtonFlags.NoNavFocus]]) == 0 then - ImGui.SetFocusID(id, window) - ImGui.FocusWindow(window) + ImGui_SetFocusID(id, window) + ImGui_FocusWindow(window) elseif bit32.band(flags, 4194304 --[[ImGuiButtonFlags.NoFocus]]) == 0 then - ImGui.FocusWindow(window, 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) -- Still need to focus and bring to front, but try to avoid losing NavId when navigating a child + ImGui_FocusWindow(window, 1 --[[ImGuiFocusRequestFlags.RestoreFocusedChild]]) -- Still need to focus and bring to front, but try to avoid losing NavId when navigating a child end end @@ -65647,7 +66280,7 @@ function ImGui.ButtonBehavior(bb, id, flags) -- FIXME: Traditionally ImGuiButtonFlags.PressedOnRelease never took ActiveId. Adding it in 2026-03-20 since ImGuiButtonFlags.NoHoldingActiveId can always be added. -- We don't yet perform an explicit ClearActiveID() to reduce scope of change, but this possibility could be investigated. if bit32.band(flags, 131072 --[[ImGuiButtonFlags.NoHoldingActiveId]]) == 0 then - ImGui.SetActiveID(id, window) -- Hold on ID + ImGui_SetActiveID(id, window) -- Hold on ID end g.ActiveIdMouseButton = mouse_button_clicked end @@ -65662,17 +66295,17 @@ function ImGui.ButtonBehavior(bb, id, flags) end if bit32.band(flags, 262144 --[[ImGuiButtonFlags.NoNavFocus]]) == 0 then - ImGui.SetFocusID(id, window) -- FIXME: Lack of FocusWindow() call here is inconsistent with other paths. Research why. + ImGui_SetFocusID(id, window) -- FIXME: Lack of FocusWindow() call here is inconsistent with other paths. Research why. end - ImGui.ClearActiveID() + ImGui_ClearActiveID() end end -- 'Repeat' mode acts when held regardless of _PressedOn flags (see table above). -- Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings. if g.ActiveId == id and (bit32.band(item_flags, 8 --[[ImGuiItemFlags.ButtonRepeat]]) ~= 0) then - if g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0 and ImGui.IsMouseClickedEx(g.ActiveIdMouseButton, 1 --[[ImGuiInputFlags.Repeat]], test_owner_id) then + if g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0 and ImGui_IsMouseClickedEx(g.ActiveIdMouseButton, 1 --[[ImGuiInputFlags.Repeat]], test_owner_id) then pressed = true end end @@ -65696,19 +66329,19 @@ function ImGui.ButtonBehavior(bb, id, flags) local nav_activated_by_inputs = (g.NavActivatePressedId == id) if not nav_activated_by_inputs and bit32.band(item_flags, 8 --[[ImGuiItemFlags.ButtonRepeat]]) ~= 0 then -- Avoid pressing multiple keys from triggering excessive amount of repeat events - local key1 = ImGui.GetKeyData(g, 524 --[[ImGuiKey.Space]]) - local key2 = ImGui.GetKeyData(g, 525 --[[ImGuiKey.Enter]]) - local key3 = ImGui.GetKeyData(g, ImGuiKey.NavGamepadActivate) + local key1 = ImGui_GetKeyData(g, 524 --[[ImGuiKey.Space]]) + local key2 = ImGui_GetKeyData(g, 525 --[[ImGuiKey.Enter]]) + local key3 = ImGui_GetKeyData(g, ImGuiKey.NavGamepadActivate) local t1 = ImMax(ImMax(key1.DownDuration, key2.DownDuration), key3.DownDuration) nav_activated_by_inputs = ImGui.CalcTypematicRepeatAmount(t1 - g.IO.DeltaTime, t1, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0 end if nav_activated_by_code or nav_activated_by_inputs then -- Set active id so it can be queried by user via IsItemActive(), equivalent of holding the mouse button. pressed = true - ImGui.SetActiveID(id, window) + ImGui_SetActiveID(id, window) g.ActiveIdSource = g.NavInputSource if bit32.band(flags, 262144 --[[ImGuiButtonFlags.NoNavFocus]]) == 0 and bit32.band(g.NavActivateFlags, 16 --[[ImGuiActivateFlags.FromShortcut]]) == 0 then - ImGui.SetFocusID(id, window) + ImGui_SetFocusID(id, window) end if bit32.band(g.NavActivateFlags, 16 --[[ImGuiActivateFlags.FromShortcut]]) ~= 0 then g.ActiveIdFromShortcut = true @@ -65728,7 +66361,7 @@ function ImGui.ButtonBehavior(bb, id, flags) local mouse_button = g.ActiveIdMouseButton if mouse_button == -1 then -- Fallback for the rare situation were g.ActiveId was set programmatically or from another widget (e.g. #6304). - ImGui.ClearActiveID() + ImGui_ClearActiveID() elseif ImGui.IsMouseDown(mouse_button, test_owner_id) then held = true else @@ -65741,14 +66374,14 @@ function ImGui.ButtonBehavior(bb, id, flags) local is_repeating_already = (bit32.band(item_flags, 8 --[[ImGuiItemFlags.ButtonRepeat]]) ~= 0) and g.IO.MouseDownDurationPrev[mouse_button] >= g.IO.KeyRepeatDelay -- Repeat mode trumps - local is_button_avail_or_owned = ImGui.TestKeyOwner(ImGui.MouseButtonToKey(mouse_button), test_owner_id) + local is_button_avail_or_owned = ImGui_TestKeyOwner(ImGui.MouseButtonToKey(mouse_button), test_owner_id) if not is_double_click_release and not is_repeating_already and is_button_avail_or_owned then pressed = true end end - ImGui.ClearActiveID() + ImGui_ClearActiveID() end if bit32.band(flags, 262144 --[[ImGuiButtonFlags.NoNavFocus]]) == 0 and g.IO.ConfigNavCursorVisibleAuto then @@ -65759,7 +66392,7 @@ function ImGui.ButtonBehavior(bb, id, flags) if g.NavActivateDownId == id then held = true -- hovered == true not true as we are already likely hovered on direct activation. else - ImGui.ClearActiveID() + ImGui_ClearActiveID() end end @@ -65788,7 +66421,7 @@ function ImGui.ButtonEx(label, size_arg, flags) if size_arg == nil then size_arg = LAYOUT_ZERO_SIZE end -- [Luau] shared read-only: CalcItemSize() only reads it if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -65796,9 +66429,9 @@ function ImGui.ButtonEx(label, size_arg, flags) local g = GImGui local style = g.Style local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) + local label_end = ImGui_FindRenderedTextEnd(label) local label_size = ButtonEx_label_size -- [Luau] scratch: only read below (RenderTextClipped text_size_if_known) - label_size.x, label_size.y = ImGui.CalcTextSizeXY(label, 1, label_end, false) + label_size.x, label_size.y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar pos, no temporary ImVec2 local pos_x, pos_y = window.DC.CursorPos.x, window.DC.CursorPos.y @@ -65807,7 +66440,7 @@ function ImGui.ButtonEx(label, size_arg, flags) pos_y = pos_y + window.DC.CurrLineTextBaseOffset - frame_padding.y end local size = ButtonEx_size -- [Luau] scratch + scalar CalcItemSize(): ItemSize() only reads it - size.x, size.y = ImGui._CalcItemSizeXY(size_arg.x, size_arg.y, label_size.x + frame_padding.x * 2.0, label_size.y + frame_padding.y * 2.0) + size.x, size.y = ImGui__CalcItemSizeXY(size_arg.x, size_arg.y, label_size.x + frame_padding.x * 2.0, label_size.y + frame_padding.y * 2.0) local bb = ButtonEx_bb -- [Luau] scratch: ItemAdd() copies it, ButtonBehavior()/Render*() only read it bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = pos_x, pos_y, pos_x + size.x, pos_y + size.y @@ -65816,28 +66449,28 @@ function ImGui.ButtonEx(label, size_arg, flags) return false end - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id, flags) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id, flags) -- Render local col if held and hovered then - col = ImGui.GetColorU32(24 --[[ImGuiCol.ButtonActive]]) + col = ImGui_GetColorU32(24 --[[ImGuiCol.ButtonActive]]) elseif hovered then - col = ImGui.GetColorU32(23 --[[ImGuiCol.ButtonHovered]]) + col = ImGui_GetColorU32(23 --[[ImGuiCol.ButtonHovered]]) else - col = ImGui.GetColorU32(22 --[[ImGuiCol.Button]]) + col = ImGui_GetColorU32(22 --[[ImGuiCol.Button]]) end - ImGui.RenderNavCursor(bb, id) - ImGui.RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding) + ImGui_RenderNavCursor(bb, id) + ImGui_RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding) if g.LogEnabled then - ImGui.LogSetNextTextDecoration("[", "]") + ImGui_LogSetNextTextDecoration("[", "]") end local text_min, text_max = ButtonEx_text_min, ButtonEx_text_max -- [Luau] scratch: RenderTextClipped() only reads them text_min.x = bb.Min.x + frame_padding.x; text_min.y = bb.Min.y + frame_padding.y text_max.x = bb.Max.x - frame_padding.x; text_max.y = bb.Max.y - frame_padding.y - ImGui.RenderTextClipped(text_min, text_max, label, label_end, label_size, style.ButtonTextAlign, bb) + ImGui_RenderTextClipped(text_min, text_max, label, label_end, label_size, style.ButtonTextAlign, bb) -- Automatically close popups --if (pressed && !(flags & ImGuiButtonFlags.DontClosePopups) && (window->Flags & ImGuiWindowFlags.Popup)) @@ -65852,7 +66485,7 @@ end --- @return bool @native function ImGui.Button(label, size_arg) - return ImGui.ButtonEx(label, size_arg, 0 --[[ImGuiButtonFlags.None]]) + return ImGui_ButtonEx(label, size_arg, 0 --[[ImGuiButtonFlags.None]]) end -- Small buttons fits within text without additional vertical spacing. @@ -65862,7 +66495,7 @@ function ImGui.SmallButton(label) local g = GImGui local backup_padding_y = g.Style.FramePadding.y g.Style.FramePadding.y = 0.0 - local pressed = ImGui.ButtonEx(label, ImVec2(0, 0), 32768 --[[ImGuiButtonFlags.AlignTextBaseLine]]) + local pressed = ImGui_ButtonEx(label, LAYOUT_ZERO_SIZE, 32768 --[[ImGuiButtonFlags.AlignTextBaseLine]]) -- [Luau] shared read-only ImVec2(0, 0) g.Style.FramePadding.y = backup_padding_y return pressed end @@ -65872,19 +66505,23 @@ end --- @param str_id string --- @param size_arg ImVec2 --- @param flags? ImGuiButtonFlags +local InvisibleButton_size, InvisibleButton_bb = ImVec2(), ImRect() -- [Luau] scratch for InvisibleButton(): only read by callees, never escape function ImGui.InvisibleButton(str_id, size_arg, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end -- Ensure zero-size fits to contents - local size = ImVec2(ImGui._CalcItemSizeXY(size_arg.x ~= 0.0 and size_arg.x or -1.1754943508223e-38 --[[FLT_MIN]], size_arg.y ~= 0.0 and size_arg.y or -1.1754943508223e-38 --[[FLT_MIN]], 0.0, 0.0)) + local size = InvisibleButton_size + size.x, size.y = ImGui__CalcItemSizeXY(size_arg.x ~= 0.0 and size_arg.x or -1.1754943508223e-38 --[[FLT_MIN]], size_arg.y ~= 0.0 and size_arg.y or -1.1754943508223e-38 --[[FLT_MIN]], 0.0, 0.0) local id = window:GetID(str_id) - local bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + size) + local cursor = window.DC.CursorPos + local bb = InvisibleButton_bb + bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = cursor.x, cursor.y, cursor.x + size.x, cursor.y + size.y ImGui.ItemSize(size) local item_flags = (bit32.band(flags, 8 --[[ImGuiButtonFlags.EnableNav]]) ~= 0) and 0 --[[ImGuiItemFlags.None]] or 2 --[[ImGuiItemFlags.NoNav]] @@ -65892,8 +66529,8 @@ function ImGui.InvisibleButton(str_id, size_arg, flags) return false end - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id, flags) - ImGui.RenderNavCursor(bb, id) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id, flags) + ImGui_RenderNavCursor(bb, id) -- IMGUI_TEST_ENGINE_ITEM_INFO(id, str_id, g.LastItemData.StatusFlags) return pressed @@ -65903,31 +66540,36 @@ end --- @param dir ImGuiDir --- @param size ImVec2 --- @param flags? ImGuiButtonFlags +local ArrowButton_bb, ArrowButton_pos, ArrowButton_size = ImRect(), ImVec2(), ImVec2() -- [Luau] scratch for ArrowButton[Ex](): only read by callees, never escape function ImGui.ArrowButtonEx(str_id, dir, size, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local id = window:GetID(str_id) - local bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + size) - local default_size = ImGui.GetFrameHeight() + local cursor = window.DC.CursorPos + local bb = ArrowButton_bb + bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = cursor.x, cursor.y, cursor.x + size.x, cursor.y + size.y + local default_size = ImGui_GetFrameHeight() ImGui.ItemSize(size, (size.y >= default_size) and g.Style.FramePadding.y or -1.0) if not ImGui.ItemAdd(bb, id) then return false end - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id, flags) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id, flags) -- Render - local bg_col = ImGui.GetColorU32((held and hovered) and 24 --[[ImGuiCol.ButtonActive]] or hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]]) - local text_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) - ImGui.RenderNavCursor(bb, id) - ImGui.RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding) - ImGui.RenderArrow(window.DrawList, bb.Min + ImVec2(ImMax(0.0, (size.x - g.FontSize) * 0.5), ImMax(0.0, (size.y - g.FontSize) * 0.5)), text_col, dir) + local bg_col = ImGui_GetColorU32((held and hovered) and 24 --[[ImGuiCol.ButtonActive]] or hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]]) + local text_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) + ImGui_RenderNavCursor(bb, id) + ImGui_RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding) + local pos = ArrowButton_pos + pos.x, pos.y = bb.Min.x + ImMax(0.0, (size.x - g.FontSize) * 0.5), bb.Min.y + ImMax(0.0, (size.y - g.FontSize) * 0.5) + ImGui_RenderArrow(window.DrawList, pos, text_col, dir) -- IMGUI_TEST_ENGINE_ITEM_INFO(id, str_id, g.LastItemData.StatusFlags) return pressed @@ -65936,8 +66578,9 @@ end --- @param str_id string --- @param dir ImGuiDir function ImGui.ArrowButton(str_id, dir) - local sz = ImGui.GetFrameHeight() - return ImGui.ArrowButtonEx(str_id, dir, ImVec2(sz, sz), 0 --[[ImGuiButtonFlags.None]]) + local sz = ImGui_GetFrameHeight() + local size = ArrowButton_size; size.x = sz; size.y = sz -- [Luau] scratch, ArrowButtonEx() only reads it + return ImGui_ArrowButtonEx(str_id, dir, size, 0 --[[ImGuiButtonFlags.None]]) end -- Button to close a window @@ -65964,7 +66607,7 @@ function ImGui.CloseButton(id, pos) -- (this isn't the common behavior of buttons, but it doesn't affect the user because navigation tends to keep items visible in scrolling layer). local is_clipped = not ImGui.ItemAdd(bb_interact, id) - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id) if is_clipped then return pressed end @@ -65972,9 +66615,9 @@ function ImGui.CloseButton(id, pos) -- Render local bg_col if held then - bg_col = ImGui.GetColorU32(24 --[[ImGuiCol.ButtonActive]]) + bg_col = ImGui_GetColorU32(24 --[[ImGuiCol.ButtonActive]]) else - bg_col = ImGui.GetColorU32(23 --[[ImGuiCol.ButtonHovered]]) + bg_col = ImGui_GetColorU32(23 --[[ImGuiCol.ButtonHovered]]) end if hovered then @@ -65983,7 +66626,7 @@ function ImGui.CloseButton(id, pos) local cross_center = bb:GetCenter() local cross_extent = g.FontSize * 0.5 * 0.7071 - 1 - local cross_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) + local cross_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) local cross_thickness = 1.0 -- FIXME-DPI window.DrawList:AddLine(cross_center + ImVec2(cross_extent, cross_extent), cross_center + ImVec2(-cross_extent, -cross_extent), cross_col, cross_thickness) window.DrawList:AddLine(cross_center + ImVec2(cross_extent, -cross_extent), cross_center + ImVec2(-cross_extent, cross_extent), cross_col, cross_thickness) @@ -66116,7 +66759,7 @@ function ImGui.ScrollbarEx(bb_frame, id, axis, p_scroll_v, size_visible_v, size_ -- Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar(). ImGui.ItemAdd(bb_frame, id, nil, 2 --[[ImGuiItemFlags.NoNav]]) - local pressed, hovered, held = ImGui.ButtonBehavior(bb_hit, id, 262144 --[[ImGuiButtonFlags.NoNavFocus]]) + local pressed, hovered, held = ImGui_ButtonBehavior(bb_hit, id, 262144 --[[ImGuiButtonFlags.NoNavFocus]]) local scroll_max = ImMax(1, size_contents_v - size_visible_v) local scroll_ratio = ImSaturate(p_scroll_v / scroll_max) @@ -66161,7 +66804,7 @@ function ImGui.ScrollbarEx(bb_frame, id, axis, p_scroll_v, size_visible_v, size_ p_scroll_v = scroll_v_norm * scroll_max else -- Page by page - if ImGui.IsMouseClickedEx(0 --[[ImGuiMouseButton.Left]], 1 --[[ImGuiInputFlags.Repeat]]) and held_dir == g.ScrollbarSeekMode then + if ImGui_IsMouseClickedEx(0 --[[ImGuiMouseButton.Left]], 1 --[[ImGuiInputFlags.Repeat]]) and held_dir == g.ScrollbarSeekMode then local page_dir if g.ScrollbarSeekMode > 0.0 then page_dir = 1.0 @@ -66182,14 +66825,14 @@ function ImGui.ScrollbarEx(bb_frame, id, axis, p_scroll_v, size_visible_v, size_ end -- Render - local bg_col = ImGui.GetColorU32(14 --[[ImGuiCol.ScrollbarBg]]) + local bg_col = ImGui_GetColorU32(14 --[[ImGuiCol.ScrollbarBg]]) local grab_col if held then - grab_col = ImGui.GetColorU32(17 --[[ImGuiCol.ScrollbarGrabActive]], alpha) + grab_col = ImGui_GetColorU32(17 --[[ImGuiCol.ScrollbarGrabActive]], alpha) elseif hovered then - grab_col = ImGui.GetColorU32(16 --[[ImGuiCol.ScrollbarGrabHovered]], alpha) + grab_col = ImGui_GetColorU32(16 --[[ImGuiCol.ScrollbarGrabHovered]], alpha) else - grab_col = ImGui.GetColorU32(15 --[[ImGuiCol.ScrollbarGrab]], alpha) + grab_col = ImGui_GetColorU32(15 --[[ImGuiCol.ScrollbarGrab]], alpha) end window.DrawList:AddRectFilled(bb_frame.Min, bb_frame.Max, bg_col, window.WindowRounding, draw_rounding_flags) local grab_rect @@ -66210,7 +66853,7 @@ end function ImGui.Scrollbar(axis) local g = GImGui local window = g.CurrentWindow - local id = ImGui.GetWindowScrollbarID(window, axis) + local id = ImGui_GetWindowScrollbarID(window, axis) -- Calculate scrollbar bounding box local bb = ImGui.GetWindowScrollbarRect(window, axis) @@ -66238,7 +66881,7 @@ function ImGui.ImageWithBg(tex_ref, image_size, uv0, uv1, bg_col, tint_col) if bg_col == nil then bg_col = ImVec4(0, 0, 0, 0) end if tint_col == nil then tint_col = ImVec4(1, 1, 1, 1) end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66254,15 +66897,15 @@ function ImGui.ImageWithBg(tex_ref, image_size, uv0, uv1, bg_col, tint_col) -- Render local rounding = g.Style.ImageRounding if bg_col.w > 0.0 then - window.DrawList:AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui.GetColorU32(bg_col), rounding) + window.DrawList:AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui_GetColorU32(bg_col), rounding) end if rounding > 0.0 then - window.DrawList:AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui.GetColorU32(tint_col), rounding) + window.DrawList:AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui_GetColorU32(tint_col), rounding) else - window.DrawList:AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui.GetColorU32(tint_col)) + window.DrawList:AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui_GetColorU32(tint_col)) end if g.Style.ImageBorderSize > 0.0 then - window.DrawList:AddRect(bb.Min, bb.Max, ImGui.GetColorU32(5 --[[ImGuiCol.Border]]), rounding, g.Style.ImageBorderSize, 0 --[[ImDrawFlags.None]]) + window.DrawList:AddRect(bb.Min, bb.Max, ImGui_GetColorU32(5 --[[ImGuiCol.Border]]), rounding, g.Style.ImageBorderSize, 0 --[[ImDrawFlags.None]]) end end @@ -66285,7 +66928,7 @@ end function ImGui.ImageButtonEx(id, tex_ref, image_size, uv0, uv1, bg_col, tint_col, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -66298,20 +66941,20 @@ function ImGui.ImageButtonEx(id, tex_ref, image_size, uv0, uv1, bg_col, tint_col return false end - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id, flags) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id, flags) -- Render - local col = ImGui.GetColorU32((held and hovered) and 24 --[[ImGuiCol.ButtonActive]] or hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]]) - ImGui.RenderNavCursor(bb, id) - ImGui.RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding) + local col = ImGui_GetColorU32((held and hovered) and 24 --[[ImGuiCol.ButtonActive]] or hovered and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]]) + ImGui_RenderNavCursor(bb, id) + ImGui_RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding) if bg_col.w > 0.0 then - window.DrawList:AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui.GetColorU32(bg_col)) + window.DrawList:AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui_GetColorU32(bg_col)) end local image_rounding = ImMax(g.Style.FrameRounding - ImMax(padding.x, padding.y), g.Style.ImageRounding) if image_rounding > 0.0 then - window.DrawList:AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui.GetColorU32(tint_col), image_rounding) + window.DrawList:AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui_GetColorU32(tint_col), image_rounding) else - window.DrawList:AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui.GetColorU32(tint_col)) + window.DrawList:AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui_GetColorU32(tint_col)) end return pressed @@ -66340,11 +66983,11 @@ end --- @param v bool --- @return bool is_pressed --- @return bool is_checked # The updated `v` passed in -local Checkbox_total_bb, Checkbox_check_bb, Checkbox_label_pos = ImRect(), ImRect(), ImVec2() -- [Luau] scratch, only read by callees +local Checkbox_total_bb, Checkbox_check_bb, Checkbox_label_pos, Checkbox_mark_pos = ImRect(), ImRect(), ImVec2(), ImVec2() -- [Luau] scratch, only read by callees @native function ImGui.Checkbox(label, v) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false, v end @@ -66352,8 +66995,8 @@ function ImGui.Checkbox(label, v) local g = GImGui local style = g.Style local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size_x, label_size_y = ImGui.CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size local square_sz = g.FontSize + style.FramePadding.y * 2.0 -- [Luau] inline GetFrameHeight() local pos_x, pos_y = window.DC.CursorPos.x, window.DC.CursorPos.y -- [Luau] scalar pos, no temporary ImVec2 @@ -66379,14 +67022,14 @@ function ImGui.Checkbox(label, v) -- Range-Selection/Multi-selection support (header) local checked = v if is_multi_select then - checked = ImGui.MultiSelectItemHeader(id, checked, nil) + checked = ImGui_MultiSelectItemHeader(id, checked, nil) end - local pressed, hovered, held = ImGui.ButtonBehavior(total_bb, id) + local pressed, hovered, held = ImGui_ButtonBehavior(total_bb, id) -- Range-Selection/Multi-selection support (footer) if is_multi_select then - checked, pressed = ImGui.MultiSelectItemFooter(id, checked, pressed, 1048576 --[[ImGuiMultiSelectFlags.CheckboxMode_]]) + checked, pressed = ImGui_MultiSelectItemFooter(id, checked, pressed, 1048576 --[[ImGuiMultiSelectFlags.CheckboxMode_]]) elseif pressed then checked = not checked end @@ -66394,18 +67037,18 @@ function ImGui.Checkbox(label, v) if v ~= checked then v = checked pressed = true -- return value - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end local check_bb = Checkbox_check_bb check_bb.Min.x, check_bb.Min.y, check_bb.Max.x, check_bb.Max.y = pos_x, pos_y, pos_x + square_sz, pos_y + square_sz local mixed_value = (bit32.band(g.LastItemData.ItemFlags, 4096 --[[ImGuiItemFlags.MixedValue]]) ~= 0) if is_visible then - ImGui.RenderNavCursor(total_bb, id) + ImGui_RenderNavCursor(total_bb, id) - local bg_col = ImGui.GetColorU32((held and hovered) and 9 --[[ImGuiCol.FrameBgActive]] or (hovered and 8 --[[ImGuiCol.FrameBgHovered]] or ((mixed_value or checked) and 19 --[[ImGuiCol.CheckboxSelectedBg]] or 7 --[[ImGuiCol.FrameBg]]))) - local check_col = ImGui.GetColorU32(18 --[[ImGuiCol.CheckMark]]) - ImGui.RenderFrame(check_bb.Min, check_bb.Max, bg_col, true, style.FrameRounding) + local bg_col = ImGui_GetColorU32((held and hovered) and 9 --[[ImGuiCol.FrameBgActive]] or (hovered and 8 --[[ImGuiCol.FrameBgHovered]] or ((mixed_value or checked) and 19 --[[ImGuiCol.CheckboxSelectedBg]] or 7 --[[ImGuiCol.FrameBg]]))) + local check_col = ImGui_GetColorU32(18 --[[ImGuiCol.CheckMark]]) + ImGui_RenderFrame(check_bb.Min, check_bb.Max, bg_col, true, style.FrameRounding) if mixed_value then -- Undocumented tristate/mixed/indeterminate checkbox (#2644) @@ -66415,18 +67058,20 @@ function ImGui.Checkbox(label, v) window.DrawList:AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding) elseif v then local pad = ImMax(1.0, IM_TRUNC(square_sz / 6.0)) - ImGui.RenderCheckMark(window.DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0) + local mark_pos = Checkbox_mark_pos -- [Luau] check_bb.Min + ImVec2(pad, pad) into scratch + mark_pos.x, mark_pos.y = check_bb.Min.x + pad, check_bb.Min.y + pad + ImGui.RenderCheckMark(window.DrawList, mark_pos, check_col, square_sz - pad * 2.0) end end if g.LogEnabled then - ImGui.LogRenderedText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), mixed_value and "[~]" or (v and "[x]" or "[ ]")) -- label_pos + ImGui_LogRenderedText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), mixed_value and "[~]" or (v and "[x]" or "[ ]")) -- label_pos end if is_visible and label_size_x > 0.0 then local label_pos = Checkbox_label_pos label_pos.x, label_pos.y = check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y - ImGui.RenderText(label_pos, label, 1, label_end, false) + ImGui_RenderText(label_pos, label, 1, label_end, false) end -- IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)) @@ -66464,8 +67109,10 @@ ImGui.CheckboxFlagsT = ImGui.CheckboxFlags --- @param label string --- @param active bool --- @return bool is_pressed +-- [Luau] scratch for RadioButtonEx(): only read by its callees (ItemAdd() copies total_bb), never escape +local RadioButton_total_bb, RadioButton_center, RadioButton_label_pos = ImRect(), ImVec2(), ImVec2() function ImGui.RadioButtonEx(label, active) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -66473,55 +67120,57 @@ function ImGui.RadioButtonEx(label, active) local g = GImGui local style = g.Style local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size local square_sz = g.FontSize + style.FramePadding.y * 2.0 -- [Luau] inline GetFrameHeight() local pos_x, pos_y = window.DC.CursorPos.x, window.DC.CursorPos.y -- [Luau] scalar pos, no temporary ImVec2 - local check_bb = ImRect(pos_x, pos_y, pos_x + square_sz, pos_y + square_sz) - local total_bb = ImRect(pos_x, pos_y, pos_x + (square_sz + (label_size.x > 0.0 and style.ItemInnerSpacing.x + label_size.x or 0.0)), pos_y + (label_size.y + style.FramePadding.y * 2.0)) + local check_bb_min_x, check_bb_min_y, check_bb_max_x, check_bb_max_y = pos_x, pos_y, pos_x + square_sz, pos_y + square_sz -- [Luau] scalar check_bb + local total_bb = RadioButton_total_bb + total_bb.Min.x, total_bb.Min.y, total_bb.Max.x, total_bb.Max.y = pos_x, pos_y, pos_x + (square_sz + (label_size_x > 0.0 and style.ItemInnerSpacing.x + label_size_x or 0.0)), pos_y + (label_size_y + style.FramePadding.y * 2.0) ImGui.ItemSize(total_bb, style.FramePadding.y) if not ImGui.ItemAdd(total_bb, id) then return false end - local center = check_bb:GetCenter() - center.x = IM_ROUND(center.x) - center.y = IM_ROUND(center.y) + local center = RadioButton_center -- [Luau] check_bb:GetCenter() into scratch + center.x = IM_ROUND((check_bb_min_x + check_bb_max_x) * 0.5) + center.y = IM_ROUND((check_bb_min_y + check_bb_max_y) * 0.5) local radius = (square_sz - 1.0) * 0.5 - local pressed, hovered, held = ImGui.ButtonBehavior(total_bb, id) + local pressed, hovered, held = ImGui_ButtonBehavior(total_bb, id) if (pressed) then - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end - ImGui.RenderNavCursor(total_bb, id) + ImGui_RenderNavCursor(total_bb, id) local num_segment = window.DrawList:_CalcCircleAutoSegmentCount(radius) local col if held and hovered then - col = ImGui.GetColorU32(9 --[[ImGuiCol.FrameBgActive]]) + col = ImGui_GetColorU32(9 --[[ImGuiCol.FrameBgActive]]) else if hovered then - col = ImGui.GetColorU32(8 --[[ImGuiCol.FrameBgHovered]]) + col = ImGui_GetColorU32(8 --[[ImGuiCol.FrameBgHovered]]) else - col = ImGui.GetColorU32(7 --[[ImGuiCol.FrameBg]]) + col = ImGui_GetColorU32(7 --[[ImGuiCol.FrameBg]]) end end window.DrawList:AddCircleFilled(center, radius, col, num_segment) if active then local pad = ImMax(1.0, IM_TRUNC(square_sz / 6.0)) - window.DrawList:AddCircleFilled(center, radius - pad, ImGui.GetColorU32(18 --[[ImGuiCol.CheckMark]])) + window.DrawList:AddCircleFilled(center, radius - pad, ImGui_GetColorU32(18 --[[ImGuiCol.CheckMark]])) end if style.FrameBorderSize > 0.0 then - window.DrawList:AddCircle(center + ImVec2(1, 1), radius, ImGui.GetColorU32(6 --[[ImGuiCol.BorderShadow]]), num_segment, style.FrameBorderSize) - window.DrawList:AddCircle(center, radius, ImGui.GetColorU32(5 --[[ImGuiCol.Border]]), num_segment, style.FrameBorderSize) + window.DrawList:AddCircle(center + ImVec2(1, 1), radius, ImGui_GetColorU32(6 --[[ImGuiCol.BorderShadow]]), num_segment, style.FrameBorderSize) + window.DrawList:AddCircle(center, radius, ImGui_GetColorU32(5 --[[ImGuiCol.Border]]), num_segment, style.FrameBorderSize) end - local label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y) + local label_pos = RadioButton_label_pos + label_pos.x, label_pos.y = check_bb_max_x + style.ItemInnerSpacing.x, check_bb_min_y + style.FramePadding.y if g.LogEnabled then - ImGui.LogRenderedText(label_pos, active and "(x)" or "( )") + ImGui_LogRenderedText(label_pos, active and "(x)" or "( )") end - if label_size.x > 0.0 then - ImGui.RenderText(label_pos, label, 1, label_end, false) + if label_size_x > 0.0 then + ImGui_RenderText(label_pos, label, 1, label_end, false) end return pressed @@ -66534,7 +67183,7 @@ end --- @return bool is_pressed --- @return any v # Updated v function ImGui.RadioButton(label, v, v_button) - local pressed = ImGui.RadioButtonEx(label, rawequal(v, v_button)) + local pressed = ImGui_RadioButtonEx(label, rawequal(v, v_button)) if pressed then v = v_button end @@ -66545,10 +67194,12 @@ end --- @param fraction float --- @param size_arg? ImVec2 --- @param overlay? string +local ProgressBar_size_arg_default = ImVec2(-FLT_MIN, 0) -- [Luau] shared read-only default (CalcItemSize() only reads it) +local ProgressBar_size, ProgressBar_overlay_pos, ProgressBar_overlay_align = ImVec2(), ImVec2(), ImVec2(0.0, 0.5) -- [Luau] scratch / shared read-only, only read by RenderTextClipped() function ImGui.ProgressBar(fraction, size_arg, overlay) - if size_arg == nil then size_arg = ImVec2(-1.1754943508223e-38 --[[FLT_MIN]], 0) end + if size_arg == nil then size_arg = ProgressBar_size_arg_default end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66556,10 +67207,10 @@ function ImGui.ProgressBar(fraction, size_arg, overlay) local g = GImGui local style = g.Style - local pos = ImVec2() - ImVec2_Copy(pos, window.DC.CursorPos) - local size = ImGui.CalcItemSize(size_arg, ImGui.CalcItemWidth(), g.FontSize + style.FramePadding.y * 2.0) - local bb = ImRect(pos, pos + size) + local pos = window.DC.CursorPos -- [Luau] only read before ItemSize() moves the cursor + local size_x, size_y = ImGui__CalcItemSizeXY(size_arg.x, size_arg.y, ImGui_CalcItemWidth(), g.FontSize + style.FramePadding.y * 2.0) -- [Luau] scalar size + local bb = ImRect(pos.x, pos.y, pos.x + size_x, pos.y + size_y) + local size = ProgressBar_size; size.x = size_x; size.y = size_y -- [Luau] scratch, ItemSize() only reads it ImGui.ItemSize(size, style.FramePadding.y) if not ImGui.ItemAdd(bb, 0) then return @@ -66584,13 +67235,13 @@ function ImGui.ProgressBar(fraction, size_arg, overlay) end -- Render - ImGui.RenderFrame(bb.Min, bb.Max, ImGui.GetColorU32(7 --[[ImGuiCol.FrameBg]]), true, style.FrameRounding) - bb:Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)) + ImGui_RenderFrame(bb.Min, bb.Max, ImGui_GetColorU32(7 --[[ImGuiCol.FrameBg]]), true, style.FrameRounding) + bb:Expand(-style.FrameBorderSize) -- [Luau] == Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)) local fill_x0 = ImLerp(bb.Min.x, bb.Max.x, fill_n0) local fill_x1 = ImLerp(bb.Min.x, bb.Max.x, fill_n1) if fill_x0 < fill_x1 then - ImGui.RenderRectFilledInRangeH(window.DrawList, bb, ImGui.GetColorU32(46 --[[ImGuiCol.PlotHistogram]]), fill_x0, fill_x1, style.FrameRounding) + ImGui.RenderRectFilledInRangeH(window.DrawList, bb, ImGui_GetColorU32(46 --[[ImGuiCol.PlotHistogram]]), fill_x0, fill_x1, style.FrameRounding) end -- Default displaying the fraction as percentage string, but user can override it @@ -66600,16 +67251,19 @@ function ImGui.ProgressBar(fraction, size_arg, overlay) overlay = ImFormatString("%.0f%%", fraction * 100 + 0.01) end - local overlay_size = ImGui.CalcTextSize(overlay, nil) + local overlay_size = ImGui_CalcTextSize(overlay, nil) if overlay_size.x > 0.0 then local text_x = is_indeterminate and ((bb.Min.x + bb.Max.x - overlay_size.x) * 0.5) or (fill_x1 + style.ItemSpacing.x) - ImGui.RenderTextClipped(ImVec2(ImClamp(text_x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, nil, overlay_size, ImVec2(0.0, 0.5), bb) + local overlay_pos = ProgressBar_overlay_pos + overlay_pos.x, overlay_pos.y = ImClamp(text_x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y + ImGui_RenderTextClipped(overlay_pos, bb.Max, overlay, nil, overlay_size, ProgressBar_overlay_align, bb) end end end +local Bullet_bb, Bullet_pos = ImRect(), ImVec2() -- [Luau] scratch for Bullet(): only read by its callees (ItemAdd() copies bb), never escape function ImGui.Bullet() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66617,17 +67271,21 @@ function ImGui.Bullet() local g = GImGui local style = g.Style local line_height = ImMax(ImMin(window.DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), g.FontSize) - local bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + ImVec2(g.FontSize, line_height)) + local cursor = window.DC.CursorPos + local bb = Bullet_bb + bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = cursor.x, cursor.y, cursor.x + g.FontSize, cursor.y + line_height ImGui.ItemSize(bb) if not ImGui.ItemAdd(bb, 0) then - ImGui.SameLine(0, style.FramePadding.x * 2) + ImGui_SameLine(0, style.FramePadding.x * 2) return end -- Render and stay on same line - local text_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) - ImGui.RenderBullet(window.DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize * 0.5, line_height * 0.5), text_col) - ImGui.SameLine(0, style.FramePadding.x * 2.0) + local text_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) + local pos = Bullet_pos + pos.x, pos.y = bb.Min.x + (style.FramePadding.x + g.FontSize * 0.5), bb.Min.y + line_height * 0.5 + ImGui_RenderBullet(window.DrawList, pos, text_col) + ImGui_SameLine(0, style.FramePadding.x * 2.0) end -- This is provided as a convenience for being an often requested feature. @@ -66636,25 +67294,25 @@ end -- (e.g. hovered/active colors are automatically inferred from a single color). --- @param label string function ImGui.TextLink(label) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) + local label_end = ImGui_FindRenderedTextEnd(label) local pos = ImVec2(window.DC.CursorPos.x, window.DC.CursorPos.y + window.DC.CurrLineTextBaseOffset) - local size = ImGui.CalcTextSize(label, label_end, false) + local size = ImGui_CalcTextSize(label, label_end, false) local bb = ImRect(pos, pos + size) ImGui.ItemSize(size, 0.0) if not ImGui.ItemAdd(bb, id) then return false end - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id) - ImGui.RenderNavCursor(bb, id) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id) + ImGui_RenderNavCursor(bb, id) if hovered then ImGui.SetMouseCursor(7 --[[ImGuiMouseCursor.Hand]]) @@ -66667,22 +67325,22 @@ function ImGui.TextLink(label) do -- FIXME-STYLE: Read comments above. This widget is NOT written in the same style as some earlier widgets, -- as we are currently experimenting/planning a different styling system. - local h, s, v = ImGui.ColorConvertRGBtoHSV(text_colf.x, text_colf.y, text_colf.z) + local h, s, v = ImGui_ColorConvertRGBtoHSV(text_colf.x, text_colf.y, text_colf.z) if held or hovered then v = ImSaturate(v + (held and 0.4 or 0.3)) h = ImFmod(h + 0.02, 1.0) end - text_colf.x, text_colf.y, text_colf.z = ImGui.ColorConvertHSVtoRGB(h, s, v) + text_colf.x, text_colf.y, text_colf.z = ImGui_ColorConvertHSVtoRGB(h, s, v) v = ImSaturate(v - 0.20) - line_colf.x, line_colf.y, line_colf.z = ImGui.ColorConvertHSVtoRGB(h, s, v) + line_colf.x, line_colf.y, line_colf.z = ImGui_ColorConvertHSVtoRGB(h, s, v) end local line_y = bb.Max.y + ImFloor(g.FontBaked.Descent * g.FontBakedScale * 0.20) - window.DrawList:AddLineH(bb.Min.x, bb.Max.x, line_y, ImGui.GetColorU32(line_colf), 1.0 * ImTrunc(g.Style._MainScale)) -- FIXME-TEXT: Underline mode -- FIXME-DPI + window.DrawList:AddLineH(bb.Min.x, bb.Max.x, line_y, ImGui_GetColorU32(line_colf), 1.0 * ImTrunc(g.Style._MainScale)) -- FIXME-TEXT: Underline mode -- FIXME-DPI - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImGui.GetColorU32(text_colf)) - ImGui.RenderText(bb.Min, label, 1, label_end, false) - ImGui.PopStyleColor() + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImGui_GetColorU32(text_colf)) + ImGui_RenderText(bb.Min, label, 1, label_end, false) + ImGui_PopStyleColor() -- IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags) return pressed @@ -66704,9 +67362,9 @@ function ImGui.TextLinkOpenURL(label, url) if ImGui.BeginPopupContextItem() then if ImGui.MenuItem(ImGui.LocalizeGetMsg(12 --[[ImGuiLocKey.CopyLink]])) then - ImGui.SetClipboardText(url) + ImGui_SetClipboardText(url) end - ImGui.EndPopup() + ImGui_EndPopup() end return pressed @@ -66724,9 +67382,10 @@ end ------------------------------------------------------------------------------- local LayoutHelpers_size = ImVec2() -- [Luau] scratch for ItemSize() arguments +local LayoutHelpers_bb = ImRect() -- [Luau] scratch for ItemAdd() arguments (ItemAdd() copies it) function ImGui.Spacing() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66735,19 +67394,20 @@ end --- @param size ImVec2 function ImGui.Dummy(size) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end local cursor = window.DC.CursorPos - local bb = ImRect(cursor.x, cursor.y, cursor.x + size.x, cursor.y + size.y) -- [Luau] no temporary ImVec2 + local bb = LayoutHelpers_bb -- [Luau] scratch, no temporary ImVec2 + bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = cursor.x, cursor.y, cursor.x + size.x, cursor.y + size.y ImGui.ItemSize(size) ImGui.ItemAdd(bb, 0) end function ImGui.NewLine() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66758,16 +67418,17 @@ function ImGui.NewLine() window.DC.IsSameLine = false if window.DC.CurrLineSize.y > 0.0 then -- In the event that we are on a line with items that is smaller that FontSize high, we will preserve its height. - ImGui.ItemSize(ImVec2(0, 0)) + ImGui.ItemSize(LAYOUT_ZERO_SIZE) else - ImGui.ItemSize(ImVec2(0.0, g.FontSize)) + local size = LayoutHelpers_size; size.x = 0.0; size.y = g.FontSize -- [Luau] scratch + ImGui.ItemSize(size) end window.DC.LayoutType = backup_layout_type end function ImGui.AlignTextToFramePadding() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66782,10 +67443,11 @@ end -- Note how thickness == 1.0f is handled specifically as not moving CursorPos by 'thickness', but other values are. --- @param flags ImGuiSeparatorFlags --- @param thickness float +local SeparatorEx_bb = ImRect() -- [Luau] scratch for SeparatorEx(): only read by its callees (ItemAdd() copies it), never escapes function ImGui.SeparatorEx(flags, thickness) if thickness == nil then thickness = 1.0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66798,7 +67460,8 @@ function ImGui.SeparatorEx(flags, thickness) -- Vertical separator, for menu bars (use current line height). local y1 = window.DC.CursorPos.y local y2 = window.DC.CursorPos.y + window.DC.CurrLineSize.y - local bb = ImRect(window.DC.CursorPos.x, y1, window.DC.CursorPos.x + thickness, y2) -- [Luau] no temporary ImVec2 + local bb = SeparatorEx_bb -- [Luau] scratch, no temporary ImVec2 + bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = window.DC.CursorPos.x, y1, window.DC.CursorPos.x + thickness, y2 local item_size = LayoutHelpers_size; item_size.x = thickness; item_size.y = 0.0 ImGui.ItemSize(item_size) if not ImGui.ItemAdd(bb, 0) then @@ -66806,7 +67469,7 @@ function ImGui.SeparatorEx(flags, thickness) end -- Draw - window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui.GetColorU32(28 --[[ImGuiCol.Separator]])) + window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui_GetColorU32(28 --[[ImGuiCol.Separator]])) if g.LogEnabled then ImGui.LogText(" |") end @@ -66832,15 +67495,16 @@ function ImGui.SeparatorEx(flags, thickness) -- This was mostly chosen to allow backward compatibility with user's code assuming zero-height when calculating height for layout (e.g. bottom alignment of a status bar). -- In order to handle scaling we need to scale separator thickness and it would not makes sense to have a disparity depending on height. ----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. - local bb = ImRect(x1, window.DC.CursorPos.y, x2, window.DC.CursorPos.y + thickness) -- [Luau] no temporary ImVec2 + local bb = SeparatorEx_bb -- [Luau] scratch, no temporary ImVec2 + bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = x1, window.DC.CursorPos.y, x2, window.DC.CursorPos.y + thickness local item_size = LayoutHelpers_size; item_size.x = 0.0; item_size.y = thickness ImGui.ItemSize(item_size) if ImGui.ItemAdd(bb, 0) then -- Draw - window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui.GetColorU32(28 --[[ImGuiCol.Separator]])) + window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui_GetColorU32(28 --[[ImGuiCol.Separator]])) if g.LogEnabled then - ImGui.LogRenderedText(bb.Min, "--------------------------------\n") + ImGui_LogRenderedText(bb.Min, "--------------------------------\n") end end @@ -66883,7 +67547,7 @@ function ImGui.SeparatorTextEx(id, label, label_end, extra_w) local window = g.CurrentWindow local style = g.Style - local label_size = ImGui.CalcTextSize(label, label_end, false) + local label_size = ImGui_CalcTextSize(label, label_end, false) local pos = ImVec2(window.DC.CursorPos.x, window.DC.CursorPos.y) local padding = style.SeparatorTextPadding @@ -66908,7 +67572,7 @@ function ImGui.SeparatorTextEx(id, label, label_end, extra_w) -- This allows using SameLine() to position something in the 'extra_w' window.DC.CursorPosPrevLine.x = label_pos.x + label_size.x - local separator_col = ImGui.GetColorU32(28 --[[ImGuiCol.Separator]]) + local separator_col = ImGui_GetColorU32(28 --[[ImGuiCol.Separator]]) if label_size.x > 0.0 then local sep1_x2 = label_pos.x - style.ItemSpacing.x @@ -66923,10 +67587,10 @@ function ImGui.SeparatorTextEx(id, label, label_end, extra_w) end if g.LogEnabled then - ImGui.LogSetNextTextDecoration("---", nil) + ImGui_LogSetNextTextDecoration("---", nil) end - ImGui.RenderTextEllipsis(window.DrawList, label_pos, ImVec2(bb.Max.x, bb.Max.y + style.ItemSpacing.y), bb.Max.x, label, label_end, label_size) + ImGui_RenderTextEllipsis(window.DrawList, label_pos, ImVec2(bb.Max.x, bb.Max.y + style.ItemSpacing.y), bb.Max.x, label, label_end, label_size) else if g.LogEnabled then ImGui.LogText("---") @@ -66940,7 +67604,7 @@ end --- @param label string function ImGui.SeparatorText(label) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return end @@ -66951,7 +67615,7 @@ function ImGui.SeparatorText(label) -- - because of this we probably can't turn 'string label' into 'string 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. - ImGui.SeparatorTextEx(0, label, ImGui.FindRenderedTextEnd(label), 0.0) + ImGui.SeparatorTextEx(0, label, ImGui_FindRenderedTextEnd(label), 0.0) end ------------------------------------------------------------------------------- @@ -66979,11 +67643,13 @@ end --- @param label string --- @param preview_value? string --- @param flags? ImGuiComboFlags +-- [Luau] scratch for BeginCombo(): only read by its callees (ItemAdd() copies them), never escape +local BeginCombo_bb, BeginCombo_total_bb, BeginCombo_p0, BeginCombo_p1 = ImRect(), ImRect(), ImVec2(), ImVec2() function ImGui.BeginCombo(label, preview_value, flags) if flags == nil then flags = 0 end local g = GImGui - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() local backup_next_window_data_flags = g.NextWindowData.HasFlags g.NextWindowData:ClearFlags() -- We behave like Begin() and need to consume those values @@ -67002,15 +67668,15 @@ function ImGui.BeginCombo(label, preview_value, flags) if (bit32.band(flags, 32 --[[ImGuiComboFlags.NoArrowButton]]) ~= 0) then arrow_size = 0.0 else - arrow_size = ImGui.GetFrameHeight() + arrow_size = ImGui_GetFrameHeight() end - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size local preview_width if ((bit32.band(flags, 128 --[[ImGuiComboFlags.WidthFitPreview]]) ~= 0) and (preview_value ~= nil)) then - preview_width = ImGui.CalcTextSize(preview_value, nil, false).x + preview_width = ImGui_CalcTextSize(preview_value, nil, false).x else preview_width = 0.0 end @@ -67021,12 +67687,15 @@ function ImGui.BeginCombo(label, preview_value, flags) elseif bit32.band(flags, 128 --[[ImGuiComboFlags.WidthFitPreview]]) ~= 0 then w = arrow_size + preview_width + style.FramePadding.x * 2.0 else - w = ImGui.CalcItemWidth() + w = ImGui_CalcItemWidth() end - local bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0)) - local label_offset = (label_size.x > 0.0) and (style.ItemInnerSpacing.x + label_size.x) or 0.0 - local total_bb = ImRect(bb.Min, bb.Max + ImVec2(label_offset, 0.0)) + local cursor = window.DC.CursorPos + local bb = BeginCombo_bb + bb.Min.x, bb.Min.y, bb.Max.x, bb.Max.y = cursor.x, cursor.y, cursor.x + w, cursor.y + (label_size_y + style.FramePadding.y * 2.0) + local label_offset = (label_size_x > 0.0) and (style.ItemInnerSpacing.x + label_size_x) or 0.0 + local total_bb = BeginCombo_total_bb + total_bb.Min.x, total_bb.Min.y, total_bb.Max.x, total_bb.Max.y = bb.Min.x, bb.Min.y, bb.Max.x + label_offset, bb.Max.y + 0.0 ImGui.ItemSize(total_bb, style.FramePadding.y) if not ImGui.ItemAdd(total_bb, id, bb) then @@ -67034,54 +67703,66 @@ function ImGui.BeginCombo(label, preview_value, flags) end -- Open on click - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id) local popup_id = ImHashStr("##ComboPopup", nil, id) - local popup_open = ImGui.IsPopupOpen(popup_id, 0 --[[ImGuiPopupFlags.None]]) + local popup_open = ImGui_IsPopupOpen(popup_id, 0 --[[ImGuiPopupFlags.None]]) if pressed and not popup_open then ImGui.OpenPopupEx(popup_id, 0 --[[ImGuiPopupFlags.None]]) popup_open = true end -- Render shape - local frame_col = ImGui.GetColorU32(hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]]) + local frame_col = ImGui_GetColorU32(hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]]) local value_x2 = ImMax(bb.Min.x, bb.Max.x - arrow_size) - ImGui.RenderNavCursor(bb, id) + ImGui_RenderNavCursor(bb, id) if bit32.band(flags, 64 --[[ImGuiComboFlags.NoPreview]]) == 0 then - window.DrawList:AddRectFilled(bb.Min, ImVec2(value_x2, bb.Max.y), frame_col, style.FrameRounding, (bit32.band(flags, 32 --[[ImGuiComboFlags.NoArrowButton]]) ~= 0) and 240 --[[ImDrawFlags.RoundAll]] or 80 --[[ImDrawFlags.RoundLeft]]) + local p1 = BeginCombo_p1 + p1.x, p1.y = value_x2, bb.Max.y + window.DrawList:AddRectFilled(bb.Min, p1, frame_col, style.FrameRounding, (bit32.band(flags, 32 --[[ImGuiComboFlags.NoArrowButton]]) ~= 0) and 240 --[[ImDrawFlags.RoundAll]] or 80 --[[ImDrawFlags.RoundLeft]]) end if bit32.band(flags, 32 --[[ImGuiComboFlags.NoArrowButton]]) == 0 then - local bg_col = ImGui.GetColorU32((popup_open or hovered) and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]]) - local text_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) + local bg_col = ImGui_GetColorU32((popup_open or hovered) and 23 --[[ImGuiCol.ButtonHovered]] or 22 --[[ImGuiCol.Button]]) + local text_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) - window.DrawList:AddRectFilled(ImVec2(value_x2, bb.Min.y), bb.Max, bg_col, style.FrameRounding, (w <= arrow_size) and 240 --[[ImDrawFlags.RoundAll]] or 160 --[[ImDrawFlags.RoundRight]]) + local p0 = BeginCombo_p0 + p0.x, p0.y = value_x2, bb.Min.y + window.DrawList:AddRectFilled(p0, bb.Max, bg_col, style.FrameRounding, (w <= arrow_size) and 240 --[[ImDrawFlags.RoundAll]] or 160 --[[ImDrawFlags.RoundRight]]) if value_x2 + arrow_size - style.FramePadding.x <= bb.Max.x then - ImGui.RenderArrow(window.DrawList, ImVec2(value_x2 + style.FramePadding.y, bb.Min.y + style.FramePadding.y), text_col, 3 --[[ImGuiDir.Down]], 1.0) + p0.x, p0.y = value_x2 + style.FramePadding.y, bb.Min.y + style.FramePadding.y + ImGui_RenderArrow(window.DrawList, p0, text_col, 3 --[[ImGuiDir.Down]], 1.0) end end - ImGui.RenderFrameBorder(bb.Min, bb.Max, style.FrameRounding) + ImGui_RenderFrameBorder(bb.Min, bb.Max, style.FrameRounding) -- Store geometry for BeginComboPreview() - only necessary when visible. + -- [Luau] written in place (C++ assigns the struct) + local preview_rect = g.ComboPreviewData.PreviewRect if bit32.band(flags, 64 --[[ImGuiComboFlags.NoPreview]]) ~= 0 then - g.ComboPreviewData.PreviewRect = ImRect() + preview_rect.Min.x, preview_rect.Min.y, preview_rect.Max.x, preview_rect.Max.y = 0, 0, 0, 0 else - g.ComboPreviewData.PreviewRect = ImRect(bb.Min.x, bb.Min.y, value_x2, bb.Max.y) + preview_rect.Min.x, preview_rect.Min.y, preview_rect.Max.x, preview_rect.Max.y = bb.Min.x, bb.Min.y, value_x2, bb.Max.y end -- Render preview and label if preview_value ~= nil and bit32.band(flags, 64 --[[ImGuiComboFlags.NoPreview]]) == 0 then if g.LogEnabled then - ImGui.LogSetNextTextDecoration("{", "}") + ImGui_LogSetNextTextDecoration("{", "}") end - ImGui.RenderTextClipped(bb.Min + style.FramePadding, ImVec2(value_x2, bb.Max.y), preview_value, nil, nil) + local p0, p1 = BeginCombo_p0, BeginCombo_p1 + p0.x, p0.y = bb.Min.x + style.FramePadding.x, bb.Min.y + style.FramePadding.y + p1.x, p1.y = value_x2, bb.Max.y + ImGui_RenderTextClipped(p0, p1, preview_value, nil, nil) end - if label_size.x > 0 then - ImGui.RenderText(ImVec2(bb.Max.x + style.ItemInnerSpacing.x, bb.Min.y + style.FramePadding.y), label, 1, label_end, false) + if label_size_x > 0 then + local p0 = BeginCombo_p0 + p0.x, p0.y = bb.Max.x + style.ItemInnerSpacing.x, bb.Min.y + style.FramePadding.y + ImGui_RenderText(p0, label, 1, label_end, false) end if not popup_open then @@ -67097,7 +67778,7 @@ end --- @param flags ImGuiComboFlags function ImGui.BeginComboPopup(popup_id, bb, flags) local g = GImGui - if not ImGui.IsPopupOpen(popup_id, 0 --[[ImGuiPopupFlags.None]]) then + if not ImGui_IsPopupOpen(popup_id, 0 --[[ImGuiPopupFlags.None]]) then g.NextWindowData:ClearFlags() return false end @@ -67136,7 +67817,7 @@ function ImGui.BeginComboPopup(popup_id, bb, flags) -- Set position given a custom constraint (peak into expected window size so we can position it) -- FIXME: This might be easier to express with an hypothetical SetNextWindowPosConstraints() function? -- FIXME: This might be moved to Begin() or at least around the same spot where Tooltips and other Popups are calling FindBestWindowPosForPopupEx()? - local popup_window = ImGui.FindWindowByName(name) + local popup_window = ImGui_FindWindowByName(name) if popup_window then if popup_window.WasActive then -- Always override 'AutoPosLastDirection' to not leave a chance for a past value to affect us. @@ -67145,17 +67826,17 @@ function ImGui.BeginComboPopup(popup_id, bb, flags) local r_outer = ImGui.GetPopupAllowedExtentRect(popup_window) local pos pos, popup_window.AutoPosLastDirection = ImGui.FindBestWindowPosForPopupEx(bb:GetBL(), size_expected, popup_window.AutoPosLastDirection, r_outer, bb, 1 --[[ImGuiPopupPositionPolicy.ComboBox]]) - ImGui.SetNextWindowPos(pos) + ImGui_SetNextWindowPos(pos) end end -- We don't use BeginPopupEx() solely because we have a custom name string, which we could make an argument to BeginPopupEx() local window_flags = bit32.bor(64 --[[ImGuiWindowFlags.AlwaysAutoResize]], 67108864 --[[ImGuiWindowFlags.Popup]], 1 --[[ImGuiWindowFlags.NoTitleBar]], 2 --[[ImGuiWindowFlags.NoResize]], 256 --[[ImGuiWindowFlags.NoSavedSettings]], 4 --[[ImGuiWindowFlags.NoMove]]) - ImGui.PushStyleVarX(2 --[[ImGuiStyleVar.WindowPadding]], g.Style.FramePadding.x) -- Horizontally align ourselves with the framed text + ImGui_PushStyleVarX(2 --[[ImGuiStyleVar.WindowPadding]], g.Style.FramePadding.x) -- Horizontally align ourselves with the framed text local _, ret = ImGui.Begin(name, nil, window_flags) - ImGui.PopStyleVar() + ImGui_PopStyleVar() if not ret then - ImGui.EndPopup() + ImGui_EndPopup() if not g.IO.ConfigDebugBeginReturnValueOnce and not g.IO.ConfigDebugBeginReturnValueLoop then -- Begin may only return false with those debug tools activated. assert(false) -- This should never happen as we tested for IsPopupOpen() above @@ -67179,7 +67860,7 @@ function ImGui.EndCombo() IM_ASSERT_USER_ERROR_RET(false, "Calling EndCombo() in wrong window!") end - ImGui.EndPopup() + ImGui_EndPopup() end -- Submit preview contents for BeginCombo()/EndCombo(), to display contents that's more than just a text label. @@ -67224,7 +67905,7 @@ function ImGui.BeginComboPreview() window.DC.LayoutType = 0 --[[ImGuiLayoutType.Horizontal]] window.DC.IsSameLine = false - ImGui.PushClipRect(preview_data.PreviewRect.Min, preview_data.PreviewRect.Max, true) + ImGui_PushClipRect(preview_data.PreviewRect.Min, preview_data.PreviewRect.Max, true) return true end @@ -67244,7 +67925,7 @@ function ImGui.EndComboPreview() end end - ImGui.PopClipRect() + ImGui_PopClipRect() ImVec2_Copy(window.DC.CursorPos, preview_data.BackupCursorPos) ImVec2_Copy(window.DC.CursorMaxPos, ImMax(window.DC.CursorMaxPos, preview_data.BackupCursorMaxPos)) -- No need to do the same with IdealMaxPos @@ -67324,7 +68005,7 @@ function ImGui.Combo(label, current_item, a, b, c, d) ImGui.SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(3.4028234663853e+38 --[[FLT_MAX]], CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))) end - if not ImGui.BeginCombo(label, preview_value, 0 --[[ImGuiComboFlags.None]]) then + if not ImGui_BeginCombo(label, preview_value, 0 --[[ImGuiComboFlags.None]]) then return current_item, false end @@ -67340,22 +68021,22 @@ function ImGui.Combo(label, current_item, a, b, c, d) item_text = "*Unknown item*" end - ImGui.PushID(i) + ImGui_PushID(i) local item_selected = (i == current_item) - if ImGui.Selectable(item_text, item_selected) and current_item ~= i then + if ImGui_Selectable(item_text, item_selected) and current_item ~= i then value_changed = true current_item = i end if item_selected then ImGui.SetItemDefaultFocus() end - ImGui.PopID() + ImGui_PopID() end end ImGui.EndCombo() if value_changed then - ImGui.MarkItemEdited(g.LastItemData.ID) + ImGui_MarkItemEdited(g.LastItemData.ID) end return current_item, value_changed @@ -67556,7 +68237,7 @@ local ImParseFormatSanitizeForScanning --- @param data_when_empty? number function ImGui.DataTypeApplyFromText(buf, data_type, data, format, data_when_empty) -- Copy the value so we can compare at the end of the function if it changed at all. - local type_info = ImGui.DataTypeGetInfo(data_type) + local type_info = ImGui_DataTypeGetInfo(data_type) local data_backup = data local p = 1 @@ -67676,7 +68357,7 @@ end --- @param data number function ImGui.DataTypeIsZero(data_type, data) local g = GImGui - return ImGui.DataTypeCompare(data_type, data, g.DataTypeZeroValue) == 0 + return ImGui_DataTypeCompare(data_type, data, g.DataTypeZeroValue) == 0 end local GetMinimumStepAtDecimalPrecision do @@ -67939,15 +68620,15 @@ function ImGui.TempInputText(bb, id, label, buf, buf_size, flags, callback, user local is_deactivated = (g.InputTextDeactivatedState.ID == id) local is_active = (g.TempInputId == id) if (not is_active and not is_deactivated) then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end local backup_pos = ImVec2() ImVec2_Copy(backup_pos, window.DC.CursorPos) ImVec2_Copy(window.DC.CursorPos, bb.Min) g.LastItemData.ItemFlags = bit32.bor(g.LastItemData.ItemFlags, 32 --[[ImGuiItemFlags.AllowDuplicateId]]) -- Using ImGuiInputTextFlags.MergedItem above will skip ItemAdd() so we poke here. - local value_changed = ImGui.InputTextEx(label, nil, buf, buf_size, bb:GetSize(), bit32.bor(flags, 134217728 --[[ImGuiInputTextFlags.TempInput]], 4096 --[[ImGuiInputTextFlags.AutoSelectAll]]), callback, user_data) - ImGui.KeepAliveID(id) -- Not done because of ImGuiInputTextFlags.TempInput + local value_changed = ImGui_InputTextEx(label, nil, buf, buf_size, bb:GetSize(), bit32.bor(flags, 134217728 --[[ImGuiInputTextFlags.TempInput]], 4096 --[[ImGuiInputTextFlags.AutoSelectAll]]), callback, user_data) + ImGui_KeepAliveID(id) -- Not done because of ImGuiInputTextFlags.TempInput if (not is_active and not is_deactivated) then -- First frame we started displaying the InputText widget, we expect it to take the active id. assert(g.ActiveId == id) @@ -67976,7 +68657,7 @@ function ImGui.TempInputScalar(bb, id, label, data_type, data, format, clamp_min -- 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 local g = GImGui - local type_info = ImGui.DataTypeGetInfo(data_type) + local type_info = ImGui_DataTypeGetInfo(data_type) local data_buf, data_buf_size = {}, 32 format = ImParseFormatTrimDecorations(format) if format == "" then @@ -67996,9 +68677,9 @@ function ImGui.TempInputScalar(bb, id, label, data_type, data, format, clamp_min local data_backup = data -- Apply new value (or operations) then clamp - data = ImGui.DataTypeApplyFromText(data_buf, data_type, data, format, nil) + data = ImGui_DataTypeApplyFromText(data_buf, data_type, data, format, nil) if clamp_min or clamp_max then - if clamp_min and clamp_max and ImGui.DataTypeCompare(data_type, clamp_min, clamp_max) > 0 then + if clamp_min and clamp_max and ImGui_DataTypeCompare(data_type, clamp_min, clamp_max) > 0 then clamp_min, clamp_max = clamp_max, clamp_min end data = ImGui.DataTypeClamp(data_type, data, clamp_min, clamp_max) @@ -68008,14 +68689,14 @@ function ImGui.TempInputScalar(bb, id, label, data_type, data, format, clamp_min g.LastItemData.ItemFlags = bit32.band(g.LastItemData.ItemFlags, bit32.bnot(65536 --[[ImGuiItemFlags.NoMarkEdited]])) local value_changed = data_backup ~= data if bit32.band(g.LastItemData.ItemFlags, 4096 --[[ImGuiItemFlags.MixedValue]]) ~= 0 then - local state = ImGui.GetInputTextState(g.LastItemData.ID) + local state = ImGui_GetInputTextState(g.LastItemData.ID) if state ~= nil then value_changed = value_changed or ((bit32.band(g.LastItemData.ItemFlags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) ~= 0) and (state.EditedThisFrame or state.ValidatedThisFrame) or state.ValidatedThisFrame) end end if value_changed then - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end return data, value_changed @@ -68030,10 +68711,11 @@ end --- @param step_fast? number --- @param format? string --- @param flags? ImGuiInputTextFlags +local InputScalar_button_size = ImVec2() -- [Luau] scratch for the step buttons' size (ButtonEx() only reads it) function ImGui.InputScalar(label, data_type, data, step, step_fast, format, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return data, false end @@ -68043,13 +68725,13 @@ function ImGui.InputScalar(label, data_type, data, step, step_fast, format, flag -- IM_ASSERT((flags & ImGuiInputTextFlags.EnterReturnsTrue) == 0) -- Not supported by InputScalar(). Please open an issue if you this would be useful to you. Otherwise use IsItemDeactivatedAfterEdit()! if format == nil then - format = ImGui.DataTypeGetInfo(data_type).PrintFmt + format = ImGui_DataTypeGetInfo(data_type).PrintFmt end local data_default = (bit32.band(g.NextItemData.HasFlags, 8 --[[ImGuiNextItemDataFlags.HasRefVal]]) ~= 0) and g.NextItemData.RefVal or g.DataTypeZeroValue local buf, buf_size = {}, 64 -- [Port] char buf[64]; IM_COUNTOF(buf) - if bit32.band(flags, 16384 --[[ImGuiInputTextFlags.DisplayEmptyRefVal]]) ~= 0 and ImGui.DataTypeCompare(data_type, data, data_default) == 0 then + if bit32.band(flags, 16384 --[[ImGuiInputTextFlags.DisplayEmptyRefVal]]) ~= 0 and ImGui_DataTypeCompare(data_type, data, data_default) == 0 then buf[1] = 0 else ImGui.DataTypeFormatString(buf, buf_size, data_type, data, format) @@ -68061,18 +68743,18 @@ function ImGui.InputScalar(label, data_type, data, step, step_fast, format, flag flags = bit32.bor(flags, 4096 --[[ImGuiInputTextFlags.AutoSelectAll]], 268435456 --[[ImGuiInputTextFlags.LocalizeDecimalPoint]]) local has_step_buttons = (step ~= nil) - local button_size = has_step_buttons and ImGui.GetFrameHeight() or 0.0 + local button_size = has_step_buttons and ImGui_GetFrameHeight() or 0.0 local ret if has_step_buttons then -- With Step Buttons - ImGui.BeginGroup() -- The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive() - ImGui.PushID(label) - ImGui.SetNextItemWidth(ImMax(1.0, ImGui.CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2)) - ret = ImGui.InputText("", buf, buf_size, flags) -- PushID(label) + "" gives us the expected ID from outside point of view + ImGui_BeginGroup() -- The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive() + ImGui_PushID(label) + ImGui_SetNextItemWidth(ImMax(1.0, ImGui_CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2)) + ret = ImGui_InputText("", buf, buf_size, flags) -- PushID(label) + "" gives us the expected ID from outside point of view -- IMGUI_TEST_ENGINE_ITEM_INFO() else -- Without Step Buttons - ret = ImGui.InputText(label, buf, buf_size, flags) + ret = ImGui_InputText(label, buf, buf_size, flags) end -- Apply @@ -68080,18 +68762,18 @@ function ImGui.InputScalar(label, data_type, data, step, step_fast, format, flag if bit32.band(g.LastItemData.ItemFlags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) ~= 0 then local input_edited = bit32.band(g.LastItemData.StatusFlags, 2048 --[[ImGuiItemStatusFlags.EditedInternal]]) ~= 0 -- We would be using 'ret' if ImGuiInputTextFlags.EnterReturnsTrue was not involved. if input_edited then - data, value_changed = ImGui.DataTypeApplyFromText(buf, data_type, data, format, bit32.band(flags, 8192 --[[ImGuiInputTextFlags.ParseEmptyRefVal]]) ~= 0 and data_default or nil) + data, value_changed = ImGui_DataTypeApplyFromText(buf, data_type, data, format, bit32.band(flags, 8192 --[[ImGuiInputTextFlags.ParseEmptyRefVal]]) ~= 0 and data_default or nil) end else -- g.LastItemData.StatusFlags &= ~ImGuiItemStatusFlags_Edited if (g.DeactivatedItemData.ID == g.LastItemData.ID) then -- g.DeactivatedItemData.HasBeenEditedBefore = false; // Will be set below by MarkItemEdited() -- if (IsItemDeactivated()) // Should be unnecessary - data, value_changed = ImGui.DataTypeApplyFromText(buf, data_type, data, format, bit32.band(flags, 8192 --[[ImGuiInputTextFlags.ParseEmptyRefVal]]) ~= 0 and data_default or nil) + data, value_changed = ImGui_DataTypeApplyFromText(buf, data_type, data, format, bit32.band(flags, 8192 --[[ImGuiInputTextFlags.ParseEmptyRefVal]]) ~= 0 and data_default or nil) end end if bit32.band(g.LastItemData.ItemFlags, 4096 --[[ImGuiItemFlags.MixedValue]]) ~= 0 then - local state = ImGui.GetInputTextState(g.LastItemData.ID) + local state = ImGui_GetInputTextState(g.LastItemData.ID) if state ~= nil then value_changed = value_changed or ((bit32.band(g.LastItemData.ItemFlags, 256 --[[ImGuiItemFlags.LiveEditOnInputScalar]]) ~= 0) and (state.EditedThisFrame or state.ValidatedThisFrame) or state.ValidatedThisFrame) end @@ -68099,44 +68781,44 @@ function ImGui.InputScalar(label, data_type, data, step, step_fast, format, flag -- Step buttons if has_step_buttons then - local backup_frame_padding = ImVec2() - ImVec2_Copy(backup_frame_padding, style.FramePadding) + local backup_frame_padding_x, backup_frame_padding_y = style.FramePadding.x, style.FramePadding.y -- [Luau] scalar backup style.FramePadding.x = style.FramePadding.y if bit32.band(flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) ~= 0 then - ImGui.BeginDisabled() + ImGui_BeginDisabled() end - ImGui.PushItemFlag(8 --[[ImGuiItemFlags.ButtonRepeat]], true) - ImGui.SameLine(0, style.ItemInnerSpacing.x) + ImGui_PushItemFlag(8 --[[ImGuiItemFlags.ButtonRepeat]], true) + ImGui_SameLine(0, style.ItemInnerSpacing.x) --- @cast step number - if ImGui.ButtonEx("-", ImVec2(button_size, button_size)) then + local step_button_size = InputScalar_button_size; step_button_size.x = button_size; step_button_size.y = button_size + if ImGui_ButtonEx("-", step_button_size) then data = ImGui.DataTypeApplyOp(data_type, 45, data, ((g.IO.KeyCtrl and step_fast) and step_fast or step)) value_changed = true ret = true end - ImGui.SameLine(0, style.ItemInnerSpacing.x) - if ImGui.ButtonEx("+", ImVec2(button_size, button_size)) then + ImGui_SameLine(0, style.ItemInnerSpacing.x) + if ImGui_ButtonEx("+", step_button_size) then data = ImGui.DataTypeApplyOp(data_type, 43, data, ((g.IO.KeyCtrl and step_fast) and step_fast or step)) value_changed = true ret = true end - ImGui.PopItemFlag() + ImGui_PopItemFlag() if bit32.band(flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) ~= 0 then - ImGui.EndDisabled() + ImGui_EndDisabled() end - local label_end = ImGui.FindRenderedTextEnd(label) + local label_end = ImGui_FindRenderedTextEnd(label) if label_end ~= 1 then - ImGui.SameLine(0, style.ItemInnerSpacing.x) - ImGui.TextEx(label, label_end) + ImGui_SameLine(0, style.ItemInnerSpacing.x) + ImGui_TextEx(label, label_end) end - ImVec2_Copy(style.FramePadding, backup_frame_padding) + ImVec2_CopyV(style.FramePadding, backup_frame_padding_x, backup_frame_padding_y) - ImGui.PopID() - ImGui.EndGroup() + ImGui_PopID() + ImGui_EndGroup() end g.LastItemData.ItemFlags = bit32.band(g.LastItemData.ItemFlags, bit32.bnot(65536 --[[ImGuiItemFlags.NoMarkEdited]])) if value_changed then - ImGui.MarkItemEdited(g.LastItemData.ID) + ImGui_MarkItemEdited(g.LastItemData.ID) end if bit32.band(flags, 64 --[[ImGuiInputTextFlags.EnterReturnsTrue]]) ~= 0 then @@ -68155,38 +68837,38 @@ end --- @param flags? ImGuiInputTextFlags function ImGui.InputScalarN(label, data_type, data, components, step, step_fast, format, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local value_changed = false - ImGui.BeginGroup() - ImGui.PushID(label) - ImGui.PushMultiItemsWidths(components, ImGui.CalcItemWidth()) + ImGui_BeginGroup() + ImGui_PushID(label) + ImGui_PushMultiItemsWidths(components, ImGui_CalcItemWidth()) for i = 1, components do - ImGui.PushID(i - 1) + ImGui_PushID(i - 1) if i > 1 then - ImGui.SameLine(0, g.Style.ItemInnerSpacing.x) + ImGui_SameLine(0, g.Style.ItemInnerSpacing.x) end local changed - data[i], changed = ImGui.InputScalar("", data_type, data[i], step, step_fast, format, flags) + data[i], changed = ImGui_InputScalar("", data_type, data[i], step, step_fast, format, flags) if changed then value_changed = true end - ImGui.PopID() - ImGui.PopItemWidth() + ImGui_PopID() + ImGui_PopItemWidth() end - ImGui.PopID() + ImGui_PopID() - local label_end = ImGui.FindRenderedTextEnd(label) + local label_end = ImGui_FindRenderedTextEnd(label) if label_end > 1 then - ImGui.SameLine(0.0, g.Style.ItemInnerSpacing.x) - ImGui.TextEx(label, label_end) + ImGui_SameLine(0.0, g.Style.ItemInnerSpacing.x) + ImGui_TextEx(label, label_end) end - ImGui.EndGroup() + ImGui_EndGroup() return value_changed end @@ -68197,27 +68879,27 @@ end function ImGui.InputFloat3(label, v, format, flags) if format == nil then format = "%.3f" end - return ImGui.InputScalarN(label, 8 --[[ImGuiDataType.Float]], v, 3, nil, nil, format, flags) + return ImGui_InputScalarN(label, 8 --[[ImGuiDataType.Float]], v, 3, nil, nil, format, flags) end function ImGui.InputFloat2(label, v, format, flags) - return ImGui.InputScalarN(label, 8 --[[ImGuiDataType.Float]], v, 2, nil, nil, format or "%.3f", flags) + return ImGui_InputScalarN(label, 8 --[[ImGuiDataType.Float]], v, 2, nil, nil, format or "%.3f", flags) end function ImGui.InputFloat4(label, v, format, flags) - return ImGui.InputScalarN(label, 8 --[[ImGuiDataType.Float]], v, 4, nil, nil, format or "%.3f", flags) + return ImGui_InputScalarN(label, 8 --[[ImGuiDataType.Float]], v, 4, nil, nil, format or "%.3f", flags) end function ImGui.InputInt2(label, v, flags) - return ImGui.InputScalarN(label, 4 --[[ImGuiDataType.S32]], v, 2, nil, nil, "%d", flags) + return ImGui_InputScalarN(label, 4 --[[ImGuiDataType.S32]], v, 2, nil, nil, "%d", flags) end function ImGui.InputInt3(label, v, flags) - return ImGui.InputScalarN(label, 4 --[[ImGuiDataType.S32]], v, 3, nil, nil, "%d", flags) + return ImGui_InputScalarN(label, 4 --[[ImGuiDataType.S32]], v, 3, nil, nil, "%d", flags) end function ImGui.InputInt4(label, v, flags) - return ImGui.InputScalarN(label, 4 --[[ImGuiDataType.S32]], v, 4, nil, nil, "%d", flags) + return ImGui_InputScalarN(label, 4 --[[ImGuiDataType.S32]], v, 4, nil, nil, "%d", flags) end --- @param label string @@ -68232,7 +68914,7 @@ function ImGui.InputInt(label, v, step, step_fast, flags) -- Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes. local format = (bit32.band(flags, 2 --[[ImGuiInputTextFlags.CharsHexadecimal]]) ~= 0) and "%08X" or "%d" - return ImGui.InputScalar(label, 4 --[[ImGuiDataType.S32]], v, (step > 0) and step or nil, (step_fast > 0) and step_fast or nil, format, flags) + return ImGui_InputScalar(label, 4 --[[ImGuiDataType.S32]], v, (step > 0) and step or nil, (step_fast > 0) and step_fast or nil, format, flags) end --- @param label string @@ -68246,7 +68928,7 @@ function ImGui.InputFloat(label, v, step, step_fast, format, flags) if step_fast == nil then step_fast = .0 end if format == nil then format = "%.3f" end - return ImGui.InputScalar(label, 8 --[[ImGuiDataType.Float]], v, (step > 0.0 and step or nil), (step_fast > 0.0 and step_fast or nil), format, flags) + return ImGui_InputScalar(label, 8 --[[ImGuiDataType.Float]], v, (step > 0.0 and step or nil), (step_fast > 0.0 and step_fast or nil), format, flags) end --- @param label string @@ -68260,7 +68942,7 @@ function ImGui.InputDouble(label, v, step, step_fast, format, flags) if step_fast == nil then step_fast = .0 end if format == nil then format = "%.6f" end - return ImGui.InputScalar(label, 9 --[[ImGuiDataType.Double]], v, (step > 0.0 and step or nil), (step_fast > 0.0 and step_fast or nil), format, flags) + return ImGui_InputScalar(label, 9 --[[ImGuiDataType.Double]], v, (step > 0.0 and step or nil), (step_fast > 0.0 and step_fast or nil), format, flags) end ------------------------------------------------------------------------------- @@ -68310,7 +68992,7 @@ function ImGui.DragBehaviorT(TYPE, SIGNEDTYPE, data_type, v, v_speed, v_min, v_m -- Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings local adjust_delta = 0.0 - if g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and ImGui.IsMousePosValid() and ImGui.IsMouseDragPastThreshold(0, g.IO.MouseDragThreshold * DRAG_MOUSE_THRESHOLD_FACTOR) then + if g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and ImGui.IsMousePosValid() and ImGui_IsMouseDragPastThreshold(0, g.IO.MouseDragThreshold * DRAG_MOUSE_THRESHOLD_FACTOR) then adjust_delta = g.IO.MouseDelta[axis] if g.IO.KeyAlt and bit32.band(flags, 2048 --[[ImGuiSliderFlags.NoSpeedTweaks]]) == 0 then adjust_delta = adjust_delta / 100.0 @@ -68331,15 +69013,15 @@ function ImGui.DragBehaviorT(TYPE, SIGNEDTYPE, data_type, v, v_speed, v_min, v_m local tweak_factor if bit32.band(flags, 2048 --[[ImGuiSliderFlags.NoSpeedTweaks]]) ~= 0 then tweak_factor = 1.0 - elseif ImGui.IsKeyDown(slow_key) then + elseif ImGui_IsKeyDown(slow_key) then tweak_factor = 1.0 / 10.0 - elseif ImGui.IsKeyDown(fast_key) then + elseif ImGui_IsKeyDown(fast_key) then tweak_factor = 10.0 else tweak_factor = 1.0 end - adjust_delta = ImGui.GetNavTweakPressedAmount(axis) * tweak_factor + adjust_delta = ImGui_GetNavTweakPressedAmount(axis) * tweak_factor v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision)) end adjust_delta = adjust_delta * v_speed @@ -68386,9 +69068,9 @@ function ImGui.DragBehaviorT(TYPE, SIGNEDTYPE, data_type, v, v_speed, v_min, v_m logarithmic_zero_epsilon = ImPow(0.1, decimal_precision) -- Convert to parametric space, apply delta, convert back - local v_old_parametric = ImGui.ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + local v_old_parametric = ImGui_ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) local v_new_parametric = v_old_parametric + g.DragCurrentAccum - v_cur = ImGui.ScaleValueFromRatioT(TYPE, SIGNEDTYPE, data_type, v_new_parametric, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + v_cur = ImGui_ScaleValueFromRatioT(TYPE, SIGNEDTYPE, data_type, v_new_parametric, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) v_old_ref_for_accum_remainder = v_old_parametric else v_cur = (TYPE)(v_cur + (SIGNEDTYPE)(g.DragCurrentAccum)) @@ -68396,14 +69078,14 @@ function ImGui.DragBehaviorT(TYPE, SIGNEDTYPE, data_type, v, v_speed, v_min, v_m -- Round to user desired precision based on format string if is_floating_point and bit32.band(flags, 64 --[[ImGuiSliderFlags.NoRoundToFormat]]) == 0 then - v_cur = ImGui.RoundScalarWithFormatT(format, data_type, v_cur) + v_cur = ImGui_RoundScalarWithFormatT(format, data_type, v_cur) end -- Preserve remainder after rounding has been applied. This also allow slow tweaking of values. g.DragCurrentAccumDirty = false if is_logarithmic then -- Convert to parametric space, apply delta, convert back - local v_new_parametric = ImGui.ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + local v_new_parametric = ImGui_ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) g.DragCurrentAccum = g.DragCurrentAccum - (v_new_parametric - v_old_ref_for_accum_remainder) else g.DragCurrentAccum = g.DragCurrentAccum - ((SIGNEDTYPE)(v_cur) - (SIGNEDTYPE)(v)) @@ -68444,12 +69126,12 @@ end local function ShortcutsForCancel(id) local g = GImGui - local is_cancel_with_keyboard = ImGui.Shortcut(526 --[[ImGuiKey.Escape]], 0 --[[ImGuiInputFlags.None]], id) + local is_cancel_with_keyboard = ImGui_Shortcut(526 --[[ImGuiKey.Escape]], 0 --[[ImGuiInputFlags.None]], id) -- [Luau] ImGuiKey_NavGamepadCancel macro inlined (io.ConfigNavSwapGamepadButtons is not ported: always FaceRight) - local is_cancel_with_gamepad = bit32.band(g.IO.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0 and bit32.band(g.IO.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0 and ImGui.Shortcut(635 --[[ImGuiKey.GamepadFaceRight]], 0 --[[ImGuiInputFlags.None]], id) - local is_cancel_with_mouse = ImGui.IsMouseReleased(1 --[[ImGuiMouseButton.Right]], id) + local is_cancel_with_gamepad = bit32.band(g.IO.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0 and bit32.band(g.IO.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0 and ImGui_Shortcut(635 --[[ImGuiKey.GamepadFaceRight]], 0 --[[ImGuiInputFlags.None]], id) + local is_cancel_with_mouse = ImGui_IsMouseReleased(1 --[[ImGuiMouseButton.Right]], id) if is_cancel_with_mouse then - ImGui.SetKeyOwner(657 --[[ImGuiKey.MouseRight]], id) + ImGui_SetKeyOwner(657 --[[ImGuiKey.MouseRight]], id) end return is_cancel_with_keyboard or is_cancel_with_gamepad or is_cancel_with_mouse end @@ -68471,15 +69153,15 @@ function ImGui.DragBehavior(id, data_type, v, v_speed, min, max, format, flags) local g = GImGui if g.ActiveId == id then if g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and not g.IO.MouseDown[0] then - ImGui.ClearActiveID() + ImGui_ClearActiveID() elseif (g.ActiveIdSource == 2 --[[ImGuiInputSource.Keyboard]] or g.ActiveIdSource == 3 --[[ImGuiInputSource.Gamepad]]) and g.NavActivatePressedId == id and not g.ActiveIdIsJustActivated then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end if ShortcutsForCancel(id) and g.ActiveId == id then -- Canceling action reverts to initial value local value_changed = (v ~= g.ActiveIdValueOnActivation) v = g.ActiveIdValueOnActivation - ImGui.ClearActiveID() + ImGui_ClearActiveID() return v, value_changed end end @@ -68491,25 +69173,25 @@ function ImGui.DragBehavior(id, data_type, v, v_speed, min, max, format, flags) end if data_type == 0 --[[ImGuiDataType.S8]] then - return ImGui.DragBehaviorT(ImS32, ImS32, 4 --[[ImGuiDataType.S32]], v, v_speed, min and min or IM_S8_MIN, max and max or IM_S8_MAX, format, flags) + return ImGui_DragBehaviorT(ImS32, ImS32, 4 --[[ImGuiDataType.S32]], v, v_speed, min and min or IM_S8_MIN, max and max or IM_S8_MAX, format, flags) elseif data_type == 1 --[[ImGuiDataType.U8]] then - return ImGui.DragBehaviorT(ImU32, ImS32, 5 --[[ImGuiDataType.U32]], v, v_speed, min and min or IM_U8_MIN, max and max or IM_U8_MAX, format, flags) + return ImGui_DragBehaviorT(ImU32, ImS32, 5 --[[ImGuiDataType.U32]], v, v_speed, min and min or IM_U8_MIN, max and max or IM_U8_MAX, format, flags) elseif data_type == 2 --[[ImGuiDataType.S16]] then - return ImGui.DragBehaviorT(ImS32, ImS32, 4 --[[ImGuiDataType.S32]], v, v_speed, min and min or IM_S16_MIN, max and max or IM_S16_MAX, format, flags) + return ImGui_DragBehaviorT(ImS32, ImS32, 4 --[[ImGuiDataType.S32]], v, v_speed, min and min or IM_S16_MIN, max and max or IM_S16_MAX, format, flags) elseif data_type == 3 --[[ImGuiDataType.U16]] then - return ImGui.DragBehaviorT(ImU32, ImS32, 5 --[[ImGuiDataType.U32]], v, v_speed, min and min or IM_U16_MIN, max and max or IM_U16_MAX, format, flags) + return ImGui_DragBehaviorT(ImU32, ImS32, 5 --[[ImGuiDataType.U32]], v, v_speed, min and min or IM_U16_MIN, max and max or IM_U16_MAX, format, flags) elseif data_type == 4 --[[ImGuiDataType.S32]] then - return ImGui.DragBehaviorT(ImS32, ImS32, data_type, v, v_speed, min and min or IM_S32_MIN, max and max or IM_S32_MAX, format, flags) + return ImGui_DragBehaviorT(ImS32, ImS32, data_type, v, v_speed, min and min or IM_S32_MIN, max and max or IM_S32_MAX, format, flags) elseif data_type == 5 --[[ImGuiDataType.U32]] then - return ImGui.DragBehaviorT(ImU32, ImS32, data_type, v, v_speed, min and min or IM_U32_MIN, max and max or IM_U32_MAX, format, flags) + return ImGui_DragBehaviorT(ImU32, ImS32, data_type, v, v_speed, min and min or IM_U32_MIN, max and max or IM_U32_MAX, format, flags) elseif data_type == 6 --[[ImGuiDataType.S64]] then - return ImGui.DragBehaviorT(ImS64, ImS64, data_type, v, v_speed, min and min or IM_S64_MIN, max and max or IM_S64_MAX, format, flags) + return ImGui_DragBehaviorT(ImS64, ImS64, data_type, v, v_speed, min and min or IM_S64_MIN, max and max or IM_S64_MAX, format, flags) elseif data_type == 7 --[[ImGuiDataType.U64]] then - return ImGui.DragBehaviorT(ImU64, ImS64, data_type, v, v_speed, min and min or IM_U64_MIN, max and max or IM_U64_MAX, format, flags) + return ImGui_DragBehaviorT(ImU64, ImS64, data_type, v, v_speed, min and min or IM_U64_MIN, max and max or IM_U64_MAX, format, flags) elseif data_type == 8 --[[ImGuiDataType.Float]] then - return ImGui.DragBehaviorT(float, float, data_type, v, v_speed, min and min or -3.4028234663853e+38 --[[FLT_MAX]], max and max or 3.4028234663853e+38 --[[FLT_MAX]], format, flags) + return ImGui_DragBehaviorT(float, float, data_type, v, v_speed, min and min or -3.4028234663853e+38 --[[FLT_MAX]], max and max or 3.4028234663853e+38 --[[FLT_MAX]], format, flags) elseif data_type == 9 --[[ImGuiDataType.Double]] then - return ImGui.DragBehaviorT(double, double, data_type, v, v_speed, min and min or -1.7976931348623e+308 --[[DBL_MAX]], max and max or 1.7976931348623e+308 --[[DBL_MAX]], format, flags) + return ImGui_DragBehaviorT(double, double, data_type, v, v_speed, min and min or -1.7976931348623e+308 --[[DBL_MAX]], max and max or 1.7976931348623e+308 --[[DBL_MAX]], format, flags) end assert(false) @@ -68525,7 +69207,7 @@ local function TempInputIsClampEnabled(flags, data_type, min, max) if bit32.band(flags, 512 --[[ImGuiSliderFlags.ClampOnInput]]) ~= 0 and (min ~= nil or max ~= nil) then local clamp_range_dir = 0 if min ~= nil and max ~= nil then - clamp_range_dir = ImGui.DataTypeCompare(data_type, min, max) + clamp_range_dir = ImGui_DataTypeCompare(data_type, min, max) end if min == nil or max == nil or clamp_range_dir < 0 then return true @@ -68568,7 +69250,7 @@ end function ImGui.DragScalar(label, data_type, data, v_speed, min, max, format, flags) if v_speed == nil then v_speed = 1.0 end if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return data, false end @@ -68576,11 +69258,11 @@ function ImGui.DragScalar(label, data_type, data, v_speed, min, max, format, fla local g = GImGui local style = g.Style local id = window:GetID(label) - local w = ImGui.CalcItemWidth() + local w = ImGui_CalcItemWidth() local color_marker = (bit32.band(g.NextItemData.HasFlags, 32 --[[ImGuiNextItemDataFlags.HasColorMarker]]) ~= 0) and g.NextItemData.ColorMarker or 0 - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size_x, label_size_y = ImGui.CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size local cursor = window.DC.CursorPos local frame_bb = SliderScalar_frame_bb -- [Luau] scratch: callees only read it frame_bb.Min.x, frame_bb.Min.y, frame_bb.Max.x, frame_bb.Max.y = cursor.x, cursor.y, cursor.x + w, cursor.y + (label_size_y + style.FramePadding.y * 2.0) @@ -68596,18 +69278,18 @@ function ImGui.DragScalar(label, data_type, data, v_speed, min, max, format, fla -- Default format string when passing NULL if format == nil then - format = ImGui.DataTypeGetInfo(data_type).PrintFmt + format = ImGui_DataTypeGetInfo(data_type).PrintFmt end local hovered = ImGui.ItemHoverable(frame_bb, id, g.LastItemData.ItemFlags) local temp_input_is_active = temp_input_allowed and ImGui.TempInputIsActive(id) if not temp_input_is_active then -- Tabbing or Ctrl+Click on Drag turns it into an InputText - local clicked = hovered and ImGui.IsMouseClickedEx(0, 0 --[[ImGuiInputFlags.None]], id) - local double_clicked = (hovered and g.IO.MouseClickedCount[0] == 2 and ImGui.TestKeyOwner(656 --[[ImGuiKey.MouseLeft]], id)) + local clicked = hovered and ImGui_IsMouseClickedEx(0, 0 --[[ImGuiInputFlags.None]], id) + local double_clicked = (hovered and g.IO.MouseClickedCount[0] == 2 and ImGui_TestKeyOwner(656 --[[ImGuiKey.MouseLeft]], id)) local make_active = (clicked or double_clicked or g.NavActivateId == id) if make_active and (clicked or double_clicked) then - ImGui.SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) + ImGui_SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) end if make_active and temp_input_allowed then if (clicked and g.IO.KeyCtrl) or double_clicked or (g.NavActivateId == id and bit32.band(g.NavActivateFlags, 1 --[[ImGuiActivateFlags.PreferInput]]) ~= 0) then @@ -68617,7 +69299,7 @@ function ImGui.DragScalar(label, data_type, data, v_speed, min, max, format, fla -- (Optional) simple click (without moving) turns Drag into an InputText if g.IO.ConfigDragClickToInputText and temp_input_allowed and not temp_input_is_active then - if g.ActiveId == id and hovered and g.IO.MouseReleased[0] and not ImGui.IsMouseDragPastThreshold(0, g.IO.MouseDragThreshold * DRAG_MOUSE_THRESHOLD_FACTOR) then + if g.ActiveId == id and hovered and g.IO.MouseReleased[0] and not ImGui_IsMouseDragPastThreshold(0, g.IO.MouseDragThreshold * DRAG_MOUSE_THRESHOLD_FACTOR) then g.NavActivateId = id g.NavActivateFlags = 1 --[[ImGuiActivateFlags.PreferInput]] temp_input_is_active = true @@ -68630,9 +69312,9 @@ function ImGui.DragScalar(label, data_type, data, v_speed, min, max, format, fla end if make_active and not temp_input_is_active then - ImGui.SetActiveID(id, window) - ImGui.SetFocusID(id, window) - ImGui.FocusWindow(window) + ImGui_SetActiveID(id, window) + ImGui_SetFocusID(id, window) + ImGui_FocusWindow(window) g.ActiveIdUsingNavDirMask = bit32.bor(bit32.lshift(1, 0 --[[ImGuiDir.Left]]), bit32.lshift(1, 1 --[[ImGuiDir.Right]])) end end @@ -68643,41 +69325,41 @@ function ImGui.DragScalar(label, data_type, data, v_speed, min, max, format, fla end -- Draw frame - local frame_col = ImGui.GetColorU32(g.ActiveId == id and 9 --[[ImGuiCol.FrameBgActive]] or hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]]) - ImGui.RenderNavCursor(frame_bb, id) - ImGui.RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding) + local frame_col = ImGui_GetColorU32(g.ActiveId == id and 9 --[[ImGuiCol.FrameBgActive]] or hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]]) + ImGui_RenderNavCursor(frame_bb, id) + ImGui_RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding) if color_marker ~= 0 and style.ColorMarkerSize > 0.0 then - ImGui.RenderColorComponentMarker(frame_bb, ImGui.GetColorU32(color_marker, nil, true), style.FrameRounding) + ImGui.RenderColorComponentMarker(frame_bb, ImGui_GetColorU32(color_marker, nil, true), style.FrameRounding) end - ImGui.RenderFrameBorder(frame_bb.Min, frame_bb.Max, g.Style.FrameRounding) + ImGui_RenderFrameBorder(frame_bb.Min, frame_bb.Max, g.Style.FrameRounding) -- Drag behavior local value_changed data, value_changed = ImGui.DragBehavior(id, data_type, data, v_speed, min, max, format, flags) if value_changed then - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end -- Display value using user-provided display format so user can add prefix/suffix/decorations to the value. local is_mixed = bit32.band(g.LastItemData.ItemFlags, 4096 --[[ImGuiItemFlags.MixedValue]]) ~= 0 local value_buf = DataTypeFormatStringCached(data_type, data, (is_mixed and g.MixedValueLabel ~= nil) and g.MixedValueLabel or format) if g.LogEnabled then - ImGui.LogSetNextTextDecoration("{", "}") + ImGui_LogSetNextTextDecoration("{", "}") end if is_mixed then - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue end - ImGui.RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, nil, nil, DRAG_TEXT_ALIGN) + ImGui_RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, nil, nil, DRAG_TEXT_ALIGN) if is_mixed then - ImGui.PopStyleColor() + ImGui_PopStyleColor() end if label_size_x > 0.0 then local label_pos = SliderScalar_label_pos label_pos.x, label_pos.y = frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y - ImGui.RenderText(label_pos, label, 1, label_end, false) + ImGui_RenderText(label_pos, label, 1, label_end, false) end return data, value_changed @@ -68697,7 +69379,7 @@ function ImGui.DragFloat(label, v, v_speed, v_min, v_max, format, flags) if format == nil then format = "%.3f" end if flags == nil then flags = 0 end - return ImGui.DragScalar(label, 8 --[[ImGuiDataType.Float]], v, v_speed, v_min, v_max, format, flags) + return ImGui_DragScalar(label, 8 --[[ImGuiDataType.Float]], v, v_speed, v_min, v_max, format, flags) end -- NB: v_speed is float to allow adjusting the drag speed with more precision @@ -68716,7 +69398,7 @@ function ImGui.DragInt(label, v, v_speed, v_min, v_max, format, flags) if format == nil then format = "%d" end if flags == nil then flags = 0 end - return ImGui.DragScalar(label, 4 --[[ImGuiDataType.S32]], v, v_speed, v_min, v_max, format, flags) + return ImGui_DragScalar(label, 4 --[[ImGuiDataType.S32]], v, v_speed, v_min, v_max, format, flags) end -- [Port] `v` is mutated in place (1-based), returns value_changed @@ -68724,39 +69406,39 @@ function ImGui.DragScalarN(label, data_type, v, components, v_speed, v_min, v_ma if v_speed == nil then v_speed = 1.0 end if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local value_changed = false - ImGui.BeginGroup() - ImGui.PushID(label) - ImGui.PushMultiItemsWidths(components, ImGui.CalcItemWidth()) + ImGui_BeginGroup() + ImGui_PushID(label) + ImGui_PushMultiItemsWidths(components, ImGui_CalcItemWidth()) for i = 1, components do - ImGui.PushID(i - 1) + ImGui_PushID(i - 1) if i > 1 then - ImGui.SameLine(0, g.Style.ItemInnerSpacing.x) + ImGui_SameLine(0, g.Style.ItemInnerSpacing.x) end if bit32.band(flags, 4096 --[[ImGuiSliderFlags.ColorMarkers]]) ~= 0 then - ImGui.SetNextItemColorMarker(GDefaultRgbaColorMarkers[i]) + ImGui_SetNextItemColorMarker(GDefaultRgbaColorMarkers[i]) end local changed - v[i], changed = ImGui.DragScalar("", data_type, v[i], v_speed, v_min, v_max, format, flags) + v[i], changed = ImGui_DragScalar("", data_type, v[i], v_speed, v_min, v_max, format, flags) value_changed = value_changed or changed - ImGui.PopID() - ImGui.PopItemWidth() + ImGui_PopID() + ImGui_PopItemWidth() end - ImGui.PopID() + ImGui_PopID() - local label_end = ImGui.FindRenderedTextEnd(label) + local label_end = ImGui_FindRenderedTextEnd(label) if label_end > 1 then - ImGui.SameLine(0, g.Style.ItemInnerSpacing.x) - ImGui.TextEx(label, label_end) + ImGui_SameLine(0, g.Style.ItemInnerSpacing.x) + ImGui_TextEx(label, label_end) end - ImGui.EndGroup() + ImGui_EndGroup() return value_changed end @@ -68782,7 +69464,7 @@ ImGui.DragInt4 = DragIntN(4) --- @return float v_current_max --- @return bool value_changed local function DragRange2(data_type, label, v_current_min, v_current_max, v_speed, v_min, v_max, format, format_max, flags) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return v_current_min, v_current_max, false end @@ -68790,29 +69472,29 @@ local function DragRange2(data_type, label, v_current_min, v_current_max, v_spee local g = GImGui local lo = (data_type == 8 --[[ImGuiDataType.Float]]) and -3.4028234663853e+38 --[[FLT_MAX]] or (-2147483648) --[[INT_MIN]] local hi = (data_type == 8 --[[ImGuiDataType.Float]]) and 3.4028234663853e+38 --[[FLT_MAX]] or 2147483647 --[[INT_MAX]] - ImGui.PushID(label) - ImGui.BeginGroup() - ImGui.PushMultiItemsWidths(2, ImGui.CalcItemWidth()) + ImGui_PushID(label) + ImGui_BeginGroup() + ImGui_PushMultiItemsWidths(2, ImGui_CalcItemWidth()) local min_min = (v_min >= v_max) and lo or v_min local min_max = (v_min >= v_max) and v_current_max or ImMin(v_max, v_current_max) local min_flags = bit32.bor(flags, (min_min == min_max) and 2097152 --[[ImGuiSliderFlags.ReadOnly]] or 0) local value_changed, changed - v_current_min, value_changed = ImGui.DragScalar("##min", data_type, v_current_min, v_speed, min_min, min_max, format, min_flags) - ImGui.PopItemWidth() - ImGui.SameLine(0, g.Style.ItemInnerSpacing.x) + v_current_min, value_changed = ImGui_DragScalar("##min", data_type, v_current_min, v_speed, min_min, min_max, format, min_flags) + ImGui_PopItemWidth() + ImGui_SameLine(0, g.Style.ItemInnerSpacing.x) local max_min = (v_min >= v_max) and v_current_min or ImMax(v_min, v_current_min) local max_max = (v_min >= v_max) and hi or v_max local max_flags = bit32.bor(flags, (max_min == max_max) and 2097152 --[[ImGuiSliderFlags.ReadOnly]] or 0) - v_current_max, changed = ImGui.DragScalar("##max", data_type, v_current_max, v_speed, max_min, max_max, format_max or format, max_flags) + v_current_max, changed = ImGui_DragScalar("##max", data_type, v_current_max, v_speed, max_min, max_max, format_max or format, max_flags) value_changed = value_changed or changed - ImGui.PopItemWidth() - ImGui.SameLine(0, g.Style.ItemInnerSpacing.x) + ImGui_PopItemWidth() + ImGui_SameLine(0, g.Style.ItemInnerSpacing.x) - ImGui.TextEx(label, ImGui.FindRenderedTextEnd(label)) - ImGui.EndGroup() - ImGui.PopID() + ImGui_TextEx(label, ImGui_FindRenderedTextEnd(label)) + ImGui_EndGroup() + ImGui_PopID() return v_current_min, v_current_max, value_changed end @@ -69061,7 +69743,7 @@ function ImGui.SliderBehaviorT(TYPE, SIGNEDTYPE, bb, id, data_type, v, v_min, v_ do local mouse_abs_pos = g.IO.MousePos[axis_k] if g.ActiveIdIsJustActivated then - local grab_t = ImGui.ScaleRatioFromValueT(data_type, v, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + local grab_t = ImGui_ScaleRatioFromValueT(data_type, v, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) if axis == 2 --[[ImGuiAxis.Y]] then grab_t = 1.0 - grab_t end @@ -69078,10 +69760,10 @@ function ImGui.SliderBehaviorT(TYPE, SIGNEDTYPE, bb, id, data_type, v, v_min, v_ set_new_value = true end elseif g.ActiveIdSource == 2 --[[ImGuiInputSource.Keyboard]] or g.ActiveIdSource == 3 --[[ImGuiInputSource.Gamepad]] then - local input_delta = (axis == 1 --[[ImGuiAxis.X]]) and ImGui.GetNavTweakPressedAmount(axis) or -ImGui.GetNavTweakPressedAmount(axis) + local input_delta = (axis == 1 --[[ImGuiAxis.X]]) and ImGui_GetNavTweakPressedAmount(axis) or -ImGui_GetNavTweakPressedAmount(axis) if input_delta ~= 0.0 then - local tweak_slow = ImGui.IsKeyDown((g.NavInputSource == 3 --[[ImGuiInputSource.Gamepad]]) and 642 --[[ImGuiKey.NavGamepadTweakSlow]] or 4096 --[[ImGuiKey.NavKeyboardTweakSlow]]) - local tweak_fast = ImGui.IsKeyDown((g.NavInputSource == 3 --[[ImGuiInputSource.Gamepad]]) and 643 --[[ImGuiKey.NavGamepadTweakFast]] or 8192 --[[ImGuiKey.NavKeyboardTweakFast]]) + local tweak_slow = ImGui_IsKeyDown((g.NavInputSource == 3 --[[ImGuiInputSource.Gamepad]]) and 642 --[[ImGuiKey.NavGamepadTweakSlow]] or 4096 --[[ImGuiKey.NavKeyboardTweakSlow]]) + local tweak_fast = ImGui_IsKeyDown((g.NavInputSource == 3 --[[ImGuiInputSource.Gamepad]]) and 643 --[[ImGuiKey.NavGamepadTweakFast]] or 8192 --[[ImGuiKey.NavKeyboardTweakFast]]) local decimal_precision = is_floating_point and ImParseFormatPrecision(format, 3) or 0 if decimal_precision > 0 then input_delta = input_delta / 100.0 -- Keyboard/Gamepad tweak speeds in % of slider bounds @@ -69105,7 +69787,7 @@ function ImGui.SliderBehaviorT(TYPE, SIGNEDTYPE, bb, id, data_type, v, v_min, v_ local delta = g.SliderCurrentAccum if g.SliderCurrentAccumDirty then - clicked_t = ImGui.ScaleRatioFromValueT(data_type, v, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + clicked_t = ImGui_ScaleRatioFromValueT(data_type, v, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) if (clicked_t >= 1.0 and delta > 0.0) or (clicked_t <= 0.0 and delta < 0.0) then -- This is to avoid applying the saturation when already past the limits set_new_value = false @@ -69116,11 +69798,11 @@ function ImGui.SliderBehaviorT(TYPE, SIGNEDTYPE, bb, id, data_type, v, v_min, v_ clicked_t = ImSaturate(clicked_t + delta) -- Calculate what our "new" clicked_t will be, and thus how far we actually moved the slider, and subtract this from the accumulator - local v_new = ImGui.ScaleValueFromRatioT(TYPE, SIGNEDTYPE, data_type, clicked_t, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + local v_new = ImGui_ScaleValueFromRatioT(TYPE, SIGNEDTYPE, data_type, clicked_t, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) if is_floating_point and bit32.band(flags, 64 --[[ImGuiSliderFlags.NoRoundToFormat]]) == 0 then - v_new = ImGui.RoundScalarWithFormatT(format, data_type, v_new) + v_new = ImGui_RoundScalarWithFormatT(format, data_type, v_new) end - local new_clicked_t = ImGui.ScaleRatioFromValueT(data_type, v_new, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + local new_clicked_t = ImGui_ScaleRatioFromValueT(data_type, v_new, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) if delta > 0 then g.SliderCurrentAccum = g.SliderCurrentAccum - ImMin(new_clicked_t - old_clicked_t, delta) @@ -69140,11 +69822,11 @@ function ImGui.SliderBehaviorT(TYPE, SIGNEDTYPE, bb, id, data_type, v, v_min, v_ end if set_new_value then - local v_new = ImGui.ScaleValueFromRatioT(TYPE, SIGNEDTYPE, data_type, clicked_t, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + local v_new = ImGui_ScaleValueFromRatioT(TYPE, SIGNEDTYPE, data_type, clicked_t, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) -- Round to user desired precision based on format string if is_floating_point and bit32.band(flags, 64 --[[ImGuiSliderFlags.NoRoundToFormat]]) == 0 then - v_new = ImGui.RoundScalarWithFormatT(format, data_type, v_new) + v_new = ImGui_RoundScalarWithFormatT(format, data_type, v_new) end -- Apply result @@ -69161,7 +69843,7 @@ function ImGui.SliderBehaviorT(TYPE, SIGNEDTYPE, bb, id, data_type, v, v_min, v_ og_min.x = bb.Min.x; og_min.y = bb.Min.y; og_max.x = bb.Min.x; og_max.y = bb.Min.y else -- Output grab position so it can be displayed by the caller - local grab_t = ImGui.ScaleRatioFromValueT(data_type, v, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) + local grab_t = ImGui_ScaleRatioFromValueT(data_type, v, v_min, v_max, logarithmic_zero_epsilon, zero_deadzone_halfsize) if axis == 2 --[[ImGuiAxis.Y]] then grab_t = 1.0 - grab_t end @@ -69201,7 +69883,7 @@ function ImGui.SliderBehavior(bb, id, data_type, v, min, max, format, flags, out local g = GImGui if g.ActiveId == id then if g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and not g.IO.MouseDown[0] then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end if g.ActiveIdSource == 2 --[[ImGuiInputSource.Keyboard]] or g.ActiveIdSource == 3 --[[ImGuiInputSource.Gamepad]] then if g.ActiveIdIsJustActivated then @@ -69209,56 +69891,56 @@ function ImGui.SliderBehavior(bb, id, data_type, v, min, max, format, flags, out g.SliderCurrentAccumDirty = false end if g.NavActivatePressedId == id and not g.ActiveIdIsJustActivated then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end end if ShortcutsForCancel(id) and g.ActiveId == id then -- Canceling action reverts to initial value local value_changed = (v ~= g.ActiveIdValueOnActivation) v = g.ActiveIdValueOnActivation - ImGui.ClearActiveID() + ImGui_ClearActiveID() return v, value_changed end end if data_type == 0 --[[ImGuiDataType.S8]] then local v32 = (ImS32)((ImS8)(v)); local r - v32, r = ImGui.SliderBehaviorT(ImS32, ImS32, bb, id, 4 --[[ImGuiDataType.S32]], v32, min, max, format, flags, out_grab_bb) + v32, r = ImGui_SliderBehaviorT(ImS32, ImS32, bb, id, 4 --[[ImGuiDataType.S32]], v32, min, max, format, flags, out_grab_bb) if r then v = (ImS8)(v32) end return v, r elseif data_type == 1 --[[ImGuiDataType.U8]] then local v32 = (ImU32)((ImU8)(v)); local r - v32, r = ImGui.SliderBehaviorT(ImU32, ImS32, bb, id, 5 --[[ImGuiDataType.U32]], v32, min, max, format, flags, out_grab_bb) + v32, r = ImGui_SliderBehaviorT(ImU32, ImS32, bb, id, 5 --[[ImGuiDataType.U32]], v32, min, max, format, flags, out_grab_bb) if r then v = (ImU8)(v32) end return v, r elseif data_type == 2 --[[ImGuiDataType.S16]] then local v32 = (ImS32)((ImS16)(v)); local r - v32, r = ImGui.SliderBehaviorT(ImS32, ImS32, bb, id, 4 --[[ImGuiDataType.S32]], v32, min, max, format, flags, out_grab_bb) + v32, r = ImGui_SliderBehaviorT(ImS32, ImS32, bb, id, 4 --[[ImGuiDataType.S32]], v32, min, max, format, flags, out_grab_bb) if r then v = (ImS16)(v32) end return v, r elseif data_type == 3 --[[ImGuiDataType.U16]] then local v32 = (ImU32)((ImU16)(v)); local r - v32, r = ImGui.SliderBehaviorT(ImU32, ImS32, bb, id, 5 --[[ImGuiDataType.U32]], v32, min, max, format, flags, out_grab_bb) + v32, r = ImGui_SliderBehaviorT(ImU32, ImS32, bb, id, 5 --[[ImGuiDataType.U32]], v32, min, max, format, flags, out_grab_bb) if r then v = (ImU16)(v32) end return v, r elseif data_type == 4 --[[ImGuiDataType.S32]] then assert(min >= math.floor(IM_S32_MIN / 2) and max <= math.floor(IM_S32_MAX / 2)) - return ImGui.SliderBehaviorT(ImS32, ImS32, bb, id, data_type, v, min, max, format, flags, out_grab_bb) + return ImGui_SliderBehaviorT(ImS32, ImS32, bb, id, data_type, v, min, max, format, flags, out_grab_bb) elseif data_type == 5 --[[ImGuiDataType.U32]] then assert(max <= math.floor(IM_U32_MAX / 2)) - return ImGui.SliderBehaviorT(ImU32, ImS32, bb, id, data_type, v, min, max, format, flags, out_grab_bb) + return ImGui_SliderBehaviorT(ImU32, ImS32, bb, id, data_type, v, min, max, format, flags, out_grab_bb) elseif data_type == 6 --[[ImGuiDataType.S64]] then assert(min >= IM_S64_MIN / 2 and max <= IM_S64_MAX / 2) - return ImGui.SliderBehaviorT(ImS64, ImS64, bb, id, data_type, v, min, max, format, flags, out_grab_bb) + return ImGui_SliderBehaviorT(ImS64, ImS64, bb, id, data_type, v, min, max, format, flags, out_grab_bb) elseif data_type == 7 --[[ImGuiDataType.U64]] then assert(max <= IM_U64_MAX / 2) - return ImGui.SliderBehaviorT(ImU64, ImS64, bb, id, data_type, v, min, max, format, flags, out_grab_bb) + return ImGui_SliderBehaviorT(ImU64, ImS64, bb, id, data_type, v, min, max, format, flags, out_grab_bb) elseif data_type == 8 --[[ImGuiDataType.Float]] then assert(min >= -3.4028234663853e+38 --[[FLT_MAX]] / 2.0 and max <= 3.4028234663853e+38 --[[FLT_MAX]] / 2.0) - return ImGui.SliderBehaviorT(float, float, bb, id, data_type, v, min, max, format, flags, out_grab_bb) + return ImGui_SliderBehaviorT(float, float, bb, id, data_type, v, min, max, format, flags, out_grab_bb) elseif data_type == 9 --[[ImGuiDataType.Double]] then assert(min >= -1.7976931348623e+308 --[[DBL_MAX]] / 2.0 and max <= 1.7976931348623e+308 --[[DBL_MAX]] / 2.0) - return ImGui.SliderBehaviorT(double, double, bb, id, data_type, v, min, max, format, flags, out_grab_bb) + return ImGui_SliderBehaviorT(double, double, bb, id, data_type, v, min, max, format, flags, out_grab_bb) end assert(false) @@ -69279,7 +69961,7 @@ end function ImGui.SliderScalar(label, data_type, data, min, max, format, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return data, false end @@ -69287,11 +69969,11 @@ function ImGui.SliderScalar(label, data_type, data, min, max, format, flags) local g = GImGui local style = g.Style local id = window:GetID(label) - local w = ImGui.CalcItemWidth() + local w = ImGui_CalcItemWidth() local color_marker = (bit32.band(g.NextItemData.HasFlags, 32 --[[ImGuiNextItemDataFlags.HasColorMarker]]) ~= 0) and g.NextItemData.ColorMarker or 0 - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size_x, label_size_y = ImGui.CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size local cursor = window.DC.CursorPos local frame_bb = SliderScalar_frame_bb -- [Luau] scratch: callees only read it frame_bb.Min.x, frame_bb.Min.y, frame_bb.Max.x, frame_bb.Max.y = cursor.x, cursor.y, cursor.x + w, cursor.y + (label_size_y + style.FramePadding.y * 2.0) @@ -69308,17 +69990,17 @@ function ImGui.SliderScalar(label, data_type, data, min, max, format, flags) -- Default format string when passing NULL if format == nil then - format = ImGui.DataTypeGetInfo(data_type).PrintFmt + format = ImGui_DataTypeGetInfo(data_type).PrintFmt end local hovered = ImGui.ItemHoverable(frame_bb, id, g.LastItemData.ItemFlags) local temp_input_is_active = temp_input_allowed and ImGui.TempInputIsActive(id) if not temp_input_is_active then -- Tabbing or Ctrl+Click on Slider turns it into an input box - local clicked = hovered and ImGui.IsMouseClickedEx(0, 0 --[[ImGuiInputFlags.None]], id) + local clicked = hovered and ImGui_IsMouseClickedEx(0, 0 --[[ImGuiInputFlags.None]], id) local make_active = clicked or g.NavActivateId == id if make_active and clicked then - ImGui.SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) + ImGui_SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) end if make_active and temp_input_allowed then if (clicked and g.IO.KeyCtrl) or (g.NavActivateId == id and bit32.band(g.NavActivateFlags, 1 --[[ImGuiActivateFlags.PreferInput]]) ~= 0) then @@ -69332,9 +70014,9 @@ function ImGui.SliderScalar(label, data_type, data, min, max, format, flags) end if make_active and not temp_input_is_active then - ImGui.SetActiveID(id, window) - ImGui.SetFocusID(id, window) - ImGui.FocusWindow(window) + ImGui_SetActiveID(id, window) + ImGui_SetFocusID(id, window) + ImGui_FocusWindow(window) g.ActiveIdUsingNavDirMask = bit32.bor(g.ActiveIdUsingNavDirMask, bit32.lshift(1, 0 --[[ImGuiDir.Left]]), bit32.lshift(1, 1 --[[ImGuiDir.Right]])) end end @@ -69346,45 +70028,45 @@ function ImGui.SliderScalar(label, data_type, data, min, max, format, flags) end -- Draw frame - local frame_col = ImGui.GetColorU32((g.ActiveId == id) and 9 --[[ImGuiCol.FrameBgActive]] or (hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]])) - ImGui.RenderNavCursor(frame_bb, id) - ImGui.RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding) + local frame_col = ImGui_GetColorU32((g.ActiveId == id) and 9 --[[ImGuiCol.FrameBgActive]] or (hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]])) + ImGui_RenderNavCursor(frame_bb, id) + ImGui_RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding) if color_marker ~= 0 and style.ColorMarkerSize > 0.0 then - ImGui.RenderColorComponentMarker(frame_bb, ImGui.GetColorU32(color_marker, nil, true), style.FrameRounding) + ImGui.RenderColorComponentMarker(frame_bb, ImGui_GetColorU32(color_marker, nil, true), style.FrameRounding) end - ImGui.RenderFrameBorder(frame_bb.Min, frame_bb.Max, g.Style.FrameRounding) + ImGui_RenderFrameBorder(frame_bb.Min, frame_bb.Max, g.Style.FrameRounding) -- Slider behavior local grab_bb = SliderScalar_grab_bb -- [Luau] scratch: fully written by SliderBehavior(), only read below local value_changed data, value_changed = ImGui.SliderBehavior(frame_bb, id, data_type, data, min, max, format, flags, grab_bb) if value_changed then - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end -- Render grab if grab_bb.Max.x > grab_bb.Min.x then - window.DrawList:AddRectFilled(grab_bb.Min, grab_bb.Max, ImGui.GetColorU32((g.ActiveId == id) and 21 --[[ImGuiCol.SliderGrabActive]] or 20 --[[ImGuiCol.SliderGrab]]), style.GrabRounding) + window.DrawList:AddRectFilled(grab_bb.Min, grab_bb.Max, ImGui_GetColorU32((g.ActiveId == id) and 21 --[[ImGuiCol.SliderGrabActive]] or 20 --[[ImGuiCol.SliderGrab]]), style.GrabRounding) end -- Display value using user-provided display format so user can add prefix/suffix/decorations to the value. local is_mixed = bit32.band(g.LastItemData.ItemFlags, 4096 --[[ImGuiItemFlags.MixedValue]]) ~= 0 local value_buf = DataTypeFormatStringCached(data_type, data, (is_mixed and g.MixedValueLabel ~= nil) and g.MixedValueLabel or format) if g.LogEnabled then - ImGui.LogSetNextTextDecoration("{", "}") + ImGui_LogSetNextTextDecoration("{", "}") end if is_mixed then - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue end - ImGui.RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, nil, nil, DRAG_TEXT_ALIGN) + ImGui_RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, nil, nil, DRAG_TEXT_ALIGN) if is_mixed then - ImGui.PopStyleColor() + ImGui_PopStyleColor() end if label_size_x > 0.0 then local label_pos = SliderScalar_label_pos label_pos.x, label_pos.y = frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y - ImGui.RenderText(label_pos, label, 1, label_end, false) + ImGui_RenderText(label_pos, label, 1, label_end, false) end -- IMGUI_TEST_ENGINE_ITEM_INFO() @@ -69403,40 +70085,40 @@ end function ImGui.SliderScalarN(label, data_type, v, components, v_min, v_max, format, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local value_changed = false - ImGui.BeginGroup() - ImGui.PushID(label) - ImGui.PushMultiItemsWidths(components, ImGui.CalcItemWidth()) + ImGui_BeginGroup() + ImGui_PushID(label) + ImGui_PushMultiItemsWidths(components, ImGui_CalcItemWidth()) for i = 1, components do - ImGui.PushID(i - 1) + ImGui_PushID(i - 1) if i > 1 then - ImGui.SameLine(0, g.Style.ItemInnerSpacing.x) + ImGui_SameLine(0, g.Style.ItemInnerSpacing.x) end if bit32.band(flags, 4096 --[[ImGuiSliderFlags.ColorMarkers]]) ~= 0 then - ImGui.SetNextItemColorMarker(GDefaultRgbaColorMarkers[i]) + ImGui_SetNextItemColorMarker(GDefaultRgbaColorMarkers[i]) end local changed - v[i], changed = ImGui.SliderScalar("", data_type, v[i], v_min, v_max, format, flags) + v[i], changed = ImGui_SliderScalar("", data_type, v[i], v_min, v_max, format, flags) value_changed = value_changed or changed - ImGui.PopID() - ImGui.PopItemWidth() + ImGui_PopID() + ImGui_PopItemWidth() end - ImGui.PopID() + ImGui_PopID() - local label_end = ImGui.FindRenderedTextEnd(label) + local label_end = ImGui_FindRenderedTextEnd(label) if label_end > 1 then - ImGui.SameLine(0, g.Style.ItemInnerSpacing.x) - ImGui.TextEx(label, label_end) + ImGui_SameLine(0, g.Style.ItemInnerSpacing.x) + ImGui_TextEx(label, label_end) end - ImGui.EndGroup() + ImGui_EndGroup() return value_changed end @@ -69447,7 +70129,7 @@ end --- @param format? string --- @param flags? ImGuiSliderFlags function ImGui.SliderFloat2(label, v, v_min, v_max, format, flags) - return ImGui.SliderScalarN(label, 8 --[[ImGuiDataType.Float]], v, 2, v_min, v_max, format, flags) + return ImGui_SliderScalarN(label, 8 --[[ImGuiDataType.Float]], v, 2, v_min, v_max, format, flags) end --- @param label string @@ -69457,7 +70139,7 @@ end --- @param format? string --- @param flags? ImGuiSliderFlags function ImGui.SliderFloat3(label, v, v_min, v_max, format, flags) - return ImGui.SliderScalarN(label, 8 --[[ImGuiDataType.Float]], v, 3, v_min, v_max, format, flags) + return ImGui_SliderScalarN(label, 8 --[[ImGuiDataType.Float]], v, 3, v_min, v_max, format, flags) end --- @param label string @@ -69467,7 +70149,7 @@ end --- @param format? string --- @param flags? ImGuiSliderFlags function ImGui.SliderFloat4(label, v, v_min, v_max, format, flags) - return ImGui.SliderScalarN(label, 8 --[[ImGuiDataType.Float]], v, 4, v_min, v_max, format, flags) + return ImGui_SliderScalarN(label, 8 --[[ImGuiDataType.Float]], v, 4, v_min, v_max, format, flags) end --- @param label string @@ -69481,7 +70163,7 @@ function ImGui.SliderFloat(label, v, v_min, v_max, format, flags) if format == nil then format = "%.3f" end if flags == nil then flags = 0 end - return ImGui.SliderScalar(label, 8 --[[ImGuiDataType.Float]], v, v_min, v_max, format, flags) + return ImGui_SliderScalar(label, 8 --[[ImGuiDataType.Float]], v, v_min, v_max, format, flags) end --- @param label string @@ -69517,19 +70199,19 @@ function ImGui.SliderInt(label, v, v_min, v_max, format, flags) if format == nil then format = "%d" end if flags == nil then flags = 0 end - return ImGui.SliderScalar(label, 4 --[[ImGuiDataType.S32]], v, v_min, v_max, format, flags) + return ImGui_SliderScalar(label, 4 --[[ImGuiDataType.S32]], v, v_min, v_max, format, flags) end function ImGui.SliderInt2(label, v, v_min, v_max, format, flags) - return ImGui.SliderScalarN(label, 4 --[[ImGuiDataType.S32]], v, 2, v_min, v_max, format or "%d", flags) + return ImGui_SliderScalarN(label, 4 --[[ImGuiDataType.S32]], v, 2, v_min, v_max, format or "%d", flags) end function ImGui.SliderInt3(label, v, v_min, v_max, format, flags) - return ImGui.SliderScalarN(label, 4 --[[ImGuiDataType.S32]], v, 3, v_min, v_max, format or "%d", flags) + return ImGui_SliderScalarN(label, 4 --[[ImGuiDataType.S32]], v, 3, v_min, v_max, format or "%d", flags) end function ImGui.SliderInt4(label, v, v_min, v_max, format, flags) - return ImGui.SliderScalarN(label, 4 --[[ImGuiDataType.S32]], v, 4, v_min, v_max, format or "%d", flags) + return ImGui_SliderScalarN(label, 4 --[[ImGuiDataType.S32]], v, 4, v_min, v_max, format or "%d", flags) end --- @param label string @@ -69542,7 +70224,7 @@ end --- @param flags? ImGuiSliderFlags function ImGui.VSliderScalar(label, size, data_type, data, min, max, format, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return data, false end @@ -69551,8 +70233,8 @@ function ImGui.VSliderScalar(label, size, data_type, data, min, max, format, fla local style = g.Style local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = ImGui_CalcTextSize(label, label_end, false) local frame_bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + size) local bb = ImRect(frame_bb.Min, ImVec2(frame_bb.Max.x + (label_size.x > 0.0 and (style.ItemInnerSpacing.x + label_size.x) or 0.0), frame_bb.Max.y)) @@ -69563,37 +70245,37 @@ function ImGui.VSliderScalar(label, size, data_type, data, min, max, format, fla -- Default format string when passing NULL if format == nil then - format = ImGui.DataTypeGetInfo(data_type).PrintFmt + format = ImGui_DataTypeGetInfo(data_type).PrintFmt end local hovered = ImGui.ItemHoverable(frame_bb, id, g.LastItemData.ItemFlags) - local clicked = hovered and ImGui.IsMouseClickedEx(0, 0 --[[ImGuiInputFlags.None]], id) + local clicked = hovered and ImGui_IsMouseClickedEx(0, 0 --[[ImGuiInputFlags.None]], id) if clicked or g.NavActivateId == id then if clicked then - ImGui.SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) + ImGui_SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) end - ImGui.SetActiveID(id, window) - ImGui.SetFocusID(id, window) - ImGui.FocusWindow(window) + ImGui_SetActiveID(id, window) + ImGui_SetFocusID(id, window) + ImGui_FocusWindow(window) g.ActiveIdUsingNavDirMask = bit32.bor(g.ActiveIdUsingNavDirMask, bit32.lshift(1, 2 --[[ImGuiDir.Up]]), bit32.lshift(1, 3 --[[ImGuiDir.Down]])) end -- Draw frame - local frame_col = ImGui.GetColorU32((g.ActiveId == id) and 9 --[[ImGuiCol.FrameBgActive]] or (hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]])) - ImGui.RenderNavCursor(frame_bb, id) - ImGui.RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding) + local frame_col = ImGui_GetColorU32((g.ActiveId == id) and 9 --[[ImGuiCol.FrameBgActive]] or (hovered and 8 --[[ImGuiCol.FrameBgHovered]] or 7 --[[ImGuiCol.FrameBg]])) + ImGui_RenderNavCursor(frame_bb, id) + ImGui_RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding) -- Slider behavior local grab_bb = ImRect() local value_changed data, value_changed = ImGui.SliderBehavior(frame_bb, id, data_type, data, min, max, format, bit32.bor(flags or 0, 1048576 --[[ImGuiSliderFlags.Vertical]]), grab_bb) if value_changed then - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end -- Render grab if grab_bb.Max.y > grab_bb.Min.y then - window.DrawList:AddRectFilled(grab_bb.Min, grab_bb.Max, ImGui.GetColorU32((g.ActiveId == id) and 21 --[[ImGuiCol.SliderGrabActive]] or 20 --[[ImGuiCol.SliderGrab]]), style.GrabRounding) + window.DrawList:AddRectFilled(grab_bb.Min, grab_bb.Max, ImGui_GetColorU32((g.ActiveId == id) and 21 --[[ImGuiCol.SliderGrabActive]] or 20 --[[ImGuiCol.SliderGrab]]), style.GrabRounding) end -- Display value using user-provided display format so user can add prefix/suffix/decorations to the value. @@ -69601,14 +70283,14 @@ function ImGui.VSliderScalar(label, size, data_type, data, min, max, format, fla local is_mixed = bit32.band(g.LastItemData.ItemFlags, 4096 --[[ImGuiItemFlags.MixedValue]]) ~= 0 local value_buf = DataTypeFormatStringCached(data_type, data, (is_mixed and g.MixedValueLabel ~= nil) and g.MixedValueLabel or format) if is_mixed then - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue end - ImGui.RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, nil, nil, ImVec2(0.5, 0.0)) + ImGui_RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, nil, nil, ImVec2(0.5, 0.0)) if is_mixed then - ImGui.PopStyleColor() + ImGui_PopStyleColor() end if label_size.x > 0.0 then - ImGui.RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label, 1, label_end, false) + ImGui_RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label, 1, label_end, false) end -- IMGUI_TEST_ENGINE_ITEM_INFO() @@ -69662,7 +70344,7 @@ function ImGui.InputText(label, buf, buf_size, flags, callback, user_data) if flags == nil then flags = 0 end assert(bit32.band(flags, 67108864 --[[ImGuiInputTextFlags.Multiline]]) == 0) -- call InputTextMultiline() - return ImGui.InputTextEx(label, nil, buf, buf_size, ImVec2(0, 0), flags, callback, user_data) + return ImGui_InputTextEx(label, nil, buf, buf_size, LAYOUT_ZERO_SIZE, flags, callback, user_data) -- [Luau] shared read-only ImVec2(0, 0) end -- [Luau] InputText edits a byte table in place (C++ char buf[N]). Helpers to make/read one: @@ -69676,12 +70358,12 @@ end function ImGui.TextBufferToString(buf) local n = 0 while buf[n + 1] ~= nil and buf[n + 1] ~= 0 do n = n + 1 end - return n == 0 and "" or ImGui._ByteArrayToString(buf, 1, n + 1) + return n == 0 and "" or ImGui__ByteArrayToString(buf, 1, n + 1) end --- @param size? ImVec2 function ImGui.InputTextMultiline(label, buf, buf_size, size, flags, callback, user_data) - return ImGui.InputTextEx(label, nil, buf, buf_size, size or ImVec2(0, 0), bit32.bor(flags or 0, 67108864 --[[ImGuiInputTextFlags.Multiline]]), callback, user_data) + return ImGui_InputTextEx(label, nil, buf, buf_size, size or ImVec2(0, 0), bit32.bor(flags or 0, 67108864 --[[ImGuiInputTextFlags.Multiline]]), callback, user_data) end ImStb = {} @@ -70471,7 +71153,7 @@ end function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback, callback_user_data) if type(hint) == "string" then hint = HintToBuf(hint) end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -70491,28 +71173,29 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback local is_multiline = bit32.band(flags, 67108864 --[[ImGuiInputTextFlags.Multiline]]) ~= 0 if is_multiline then -- Open group before calling GetID() because groups tracks id created within their scope (including the scrollbar) - ImGui.BeginGroup() + ImGui_BeginGroup() end local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) - local frame_size = ImGui.CalcItemSize(size_arg, ImGui.CalcItemWidth(), (is_multiline and g.FontSize * 8.0 or label_size.y) + style.FramePadding.y * 2.0) -- Arbitrary default of 8 lines high for multi-line - local total_size = ImVec2(frame_size.x + ((label_size.x > 0.0) and (style.ItemInnerSpacing.x + label_size.x) or 0.0), frame_size.y) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = ImGui_CalcTextSize(label, label_end, false) + local frame_size = ImGui_CalcItemSize(size_arg, ImGui_CalcItemWidth(), (is_multiline and g.FontSize * 8.0 or label_size.y) + style.FramePadding.y * 2.0) -- Arbitrary default of 8 lines high for multi-line + local total_size_x, total_size_y = frame_size.x + ((label_size.x > 0.0) and (style.ItemInnerSpacing.x + label_size.x) or 0.0), frame_size.y -- [Luau] scalar total_size - local frame_bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + frame_size) - local total_bb = ImRect(frame_bb.Min, frame_bb.Min + total_size) + local cursor = window.DC.CursorPos + local frame_bb = ImRect(cursor.x, cursor.y, cursor.x + frame_size.x, cursor.y + frame_size.y) -- [Luau] scalar forms: no temporary ImVec2s + local total_bb = ImRect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + total_size_x, frame_bb.Min.y + total_size_y) local draw_window = window local inner_size = ImVec2() ImVec2_Copy(inner_size, frame_size) - local item_data_backup = ImGuiLastItemData() + local item_data_backup = is_multiline and ImGuiLastItemData() or nil -- [Luau] only used by the multi-line path if is_multiline then local backup_pos = ImVec2() ImVec2_Copy(backup_pos, window.DC.CursorPos) ImGui.ItemSize(total_bb, style.FramePadding.y) local no_clip = (g.InputTextDeactivatedState.ID == id) or (g.ActiveId == id) or (id == g.NavActivateId) -- Mimic some of ItemAdd() logic + add InputTextDeactivatedState.ID check. if not ImGui.ItemAdd(total_bb, id, frame_bb, 1048576 --[[ImGuiItemFlags.Inputable]]) and not no_clip then - ImGui.EndGroup() + ImGui_EndGroup() return false end ImGuiLastItemData_Copy(item_data_backup, g.LastItemData) @@ -70530,17 +71213,17 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback end -- We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug. - ImGui.PushStyleColor(3 --[[ImGuiCol.ChildBg]], style.Colors[7 --[[ImGuiCol.FrameBg]]]) - ImGui.PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], style.FrameRounding) - ImGui.PushStyleVar(8 --[[ImGuiStyleVar.ChildBorderSize]], style.FrameBorderSize) - ImGui.PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0, 0)) -- Ensure no clip rect so mouse hover can reach FramePadding edges + ImGui_PushStyleColor(3 --[[ImGuiCol.ChildBg]], style.Colors[7 --[[ImGuiCol.FrameBg]]]) + ImGui_PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], style.FrameRounding) + ImGui_PushStyleVar(8 --[[ImGuiStyleVar.ChildBorderSize]], style.FrameBorderSize) + ImGui_PushStyleVar(2 --[[ImGuiStyleVar.WindowPadding]], ImVec2(0, 0)) -- Ensure no clip rect so mouse hover can reach FramePadding edges local child_visible = ImGui.BeginChildEx(label, id, frame_bb:GetSize(), 1 --[[ImGuiChildFlags.Borders]], 4 --[[ImGuiWindowFlags.NoMove]]) g.NavActivateId = backup_activate_id - ImGui.PopStyleVar(3) - ImGui.PopStyleColor() + ImGui_PopStyleVar(3) + ImGui_PopStyleColor() if not child_visible and not no_clip then - ImGui.EndChild() - ImGui.EndGroup() + ImGui_EndChild() + ImGui_EndGroup() return false end draw_window = g.CurrentWindow -- Child window @@ -70573,7 +71256,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback end -- We are only allowed to access the state if we are already the active widget. - local state = ImGui.GetInputTextState(id) + local state = ImGui_GetInputTextState(id) if bit32.band(g.LastItemData.ItemFlags, 2048 --[[ImGuiItemFlags.ReadOnly]]) ~= 0 then flags = bit32.bor(flags, 512 --[[ImGuiInputTextFlags.ReadOnly]]) @@ -70591,14 +71274,14 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback local is_wordwrap = bit32.band(flags, 16777216 --[[ImGuiInputTextFlags.WordWrap]]) ~= 0 local wrap_width = 0.0 if is_wordwrap then - wrap_width = ImMax(1.0, ImGui.GetContentRegionAvail().x + (draw_window.ScrollbarY and 0.0 or -g.Style.ScrollbarSize)) + wrap_width = ImMax(1.0, ImGui_GetContentRegionAvail().x + (draw_window.ScrollbarY and 0.0 or -g.Style.ScrollbarSize)) end local user_clicked = hovered and io.MouseClicked[0] local input_requested_by_nav = (g.ActiveId ~= id) and (g.NavActivateId == id) and ((bit32.band(g.NavActivateFlags, 1 --[[ImGuiActivateFlags.PreferInput]]) ~= 0) or (g.NavInputSource == 2 --[[ImGuiInputSource.Keyboard]])) local input_requested_by_reactivate = (g.InputTextReactivateId == id) -- for io.ConfigInputTextEnterKeepActive local input_requested_by_user = (user_clicked) or (g.ActiveId == 0 and bit32.band(flags, 134217728 --[[ImGuiInputTextFlags.TempInput]]) ~= 0 and g.InputTextDeactivatedState.ID ~= id) - local scrollbar_id = (is_multiline and state ~= nil) and ImGui.GetWindowScrollbarID(draw_window, 2 --[[ImGuiAxis.Y]]) or 0 + local scrollbar_id = (is_multiline and state ~= nil) and ImGui_GetWindowScrollbarID(draw_window, 2 --[[ImGuiAxis.Y]]) or 0 local user_scroll_finish = is_multiline and state ~= nil and g.ActiveId == 0 and g.ActiveIdPreviousFrame == scrollbar_id local user_scroll_active = is_multiline and state ~= nil and g.ActiveId == scrollbar_id local clear_active_id = false @@ -70660,7 +71343,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- Find initial scroll position for right alignment ImVec2_Copy(state.Scroll, ImVec2(0.0, 0.0)) if bit32.band(flags, 131072 --[[ImGuiInputTextFlags.ElideLeft]]) ~= 0 then - state.Scroll.x = state.Scroll.x + ImMax(0.0, ImGui.CalcTextSize(table.concat(buf)).x - frame_size.x + style.FramePadding.x * 2.0) -- [Port] FIXME: no table.concat here + state.Scroll.x = state.Scroll.x + ImMax(0.0, ImGui_CalcTextSize(table.concat(buf)).x - frame_size.x + style.FramePadding.x * 2.0) -- [Port] FIXME: no table.concat here end -- Recycle existing cursor/selection/undo stack but clamp position @@ -70690,11 +71373,11 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback if init_make_active and g.ActiveId ~= id then assert(state ~= nil and state.ID == id) - ImGui.SetActiveID(id, window) - ImGui.SetFocusID(id, window) - ImGui.FocusWindow(window) + ImGui_SetActiveID(id, window) + ImGui_SetFocusID(id, window) + ImGui_FocusWindow(window) if input_requested_by_nav then - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() end end if g.ActiveId == id then @@ -70702,24 +71385,24 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- FIXME: The reason we don't use Shortcut() is we would need a routing flag to specify multiple mods, or to all mods combination into individual shortcuts. local always_owned_keys = { 513 --[[ImGuiKey.LeftArrow]], 514 --[[ImGuiKey.RightArrow]], 522 --[[ImGuiKey.Delete]], 523 --[[ImGuiKey.Backspace]], 519 --[[ImGuiKey.Home]], 520 --[[ImGuiKey.End]] } for _, key in ipairs(always_owned_keys) do - ImGui.SetKeyOwner(key, id) + ImGui_SetKeyOwner(key, id) end if user_clicked then - ImGui.SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) + ImGui_SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], id) end g.ActiveIdUsingNavDirMask = bit32.bor(g.ActiveIdUsingNavDirMask, bit32.lshift(1, 0 --[[ImGuiDir.Left]]), bit32.lshift(1, 1 --[[ImGuiDir.Right]])) if is_multiline or (bit32.band(flags, 524288 --[[ImGuiInputTextFlags.CallbackHistory]]) ~= 0) then g.ActiveIdUsingNavDirMask = bit32.bor(g.ActiveIdUsingNavDirMask, bit32.lshift(1, 2 --[[ImGuiDir.Up]]), bit32.lshift(1, 3 --[[ImGuiDir.Down]])) - ImGui.SetKeyOwner(515 --[[ImGuiKey.UpArrow]], id) - ImGui.SetKeyOwner(516 --[[ImGuiKey.DownArrow]], id) + ImGui_SetKeyOwner(515 --[[ImGuiKey.UpArrow]], id) + ImGui_SetKeyOwner(516 --[[ImGuiKey.DownArrow]], id) end if is_multiline then - ImGui.SetKeyOwner(517 --[[ImGuiKey.PageUp]], id) - ImGui.SetKeyOwner(518 --[[ImGuiKey.PageDown]], id) + ImGui_SetKeyOwner(517 --[[ImGuiKey.PageUp]], id) + ImGui_SetKeyOwner(518 --[[ImGuiKey.PageDown]], id) end -- FIXME: May be a problem to always steal Alt on OSX, would ideally still allow an uninterrupted Alt down-up to toggle menu if is_osx then - ImGui.SetKeyOwner(16384 --[[ImGuiMod_Alt]], id) + ImGui_SetKeyOwner(16384 --[[ImGuiMod_Alt]], id) end -- Expose scroll in a manner that is agnostic to us using a child window @@ -70744,7 +71427,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function) if g.ActiveId == id and state == nil then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end -- Release focus when we click outside @@ -70851,7 +71534,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- We expect backends to emit a Tab key but some also emit a Tab character which we ignore (#2467, #1336) -- (For Tab and Enter: Win32/SFML/Allegro are sending both keys and chars, GLFW and SDL are only sending keys. For Space they all send all threes) if bit32.band(flags, 32 --[[ImGuiInputTextFlags.AllowTabInput]]) ~= 0 and not is_readonly then - if ImGui.Shortcut(512 --[[ImGuiKey.Tab]], 1 --[[ImGuiInputFlags.Repeat]], id) then + if ImGui_Shortcut(512 --[[ImGuiKey.Tab]], 1 --[[ImGuiInputFlags.Repeat]], id) then local c = 9 -- Insert TAB local ret2 c, ret2 = InputTextFilterCharacter(g, state, c, callback, callback_user_data) @@ -70909,50 +71592,50 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- Using Shortcut() with ImGuiInputFlags.RouteFocused (default policy) to allow routing operations for other code (e.g. calling window trying to use Ctrl+A and Ctrl+B: former would be handled by InputText) -- Otherwise we could simply assume that we own the keys as we are active. local f_repeat = 1 --[[ImGuiInputFlags.Repeat]] - local is_cut = (ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 569 --[[ImGuiKey.X]]), f_repeat, id) or ImGui.Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 522 --[[ImGuiKey.Delete]]), f_repeat, id)) and not is_readonly and not is_password and (not is_multiline or state:HasSelection()) - local is_copy = (ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 548 --[[ImGuiKey.C]]), 0, id) or ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 521 --[[ImGuiKey.Insert]]), 0, id)) and not is_password and (not is_multiline or state:HasSelection()) - local is_paste = (ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 567 --[[ImGuiKey.V]]), f_repeat, id) or ImGui.Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 521 --[[ImGuiKey.Insert]]), f_repeat, id)) and not is_readonly - local is_undo = (ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 571 --[[ImGuiKey.Z]]), f_repeat, id)) and not is_readonly and is_undoable - local is_redo = (ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 570 --[[ImGuiKey.Y]]), f_repeat, id) or ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 8192 --[[ImGuiMod_Shift]], 571 --[[ImGuiKey.Z]]), f_repeat, id)) and not is_readonly and is_undoable - local is_select_all = ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 546 --[[ImGuiKey.A]]), 0, id) + local is_cut = (ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 569 --[[ImGuiKey.X]]), f_repeat, id) or ImGui_Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 522 --[[ImGuiKey.Delete]]), f_repeat, id)) and not is_readonly and not is_password and (not is_multiline or state:HasSelection()) + local is_copy = (ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 548 --[[ImGuiKey.C]]), 0, id) or ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 521 --[[ImGuiKey.Insert]]), 0, id)) and not is_password and (not is_multiline or state:HasSelection()) + local is_paste = (ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 567 --[[ImGuiKey.V]]), f_repeat, id) or ImGui_Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 521 --[[ImGuiKey.Insert]]), f_repeat, id)) and not is_readonly + local is_undo = (ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 571 --[[ImGuiKey.Z]]), f_repeat, id)) and not is_readonly and is_undoable + local is_redo = (ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 570 --[[ImGuiKey.Y]]), f_repeat, id) or ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 8192 --[[ImGuiMod_Shift]], 571 --[[ImGuiKey.Z]]), f_repeat, id)) and not is_readonly and is_undoable + local is_select_all = ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 546 --[[ImGuiKey.A]]), 0, id) -- We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful. local nav_gamepad_active = (bit32.band(io.ConfigFlags, 2 --[[ImGuiConfigFlags.NavEnableGamepad]]) ~= 0) and (bit32.band(io.BackendFlags, 1 --[[ImGuiBackendFlags.HasGamepad]]) ~= 0) - local is_enter = ImGui.Shortcut(525 --[[ImGuiKey.Enter]], f_repeat, id) or ImGui.Shortcut(627 --[[ImGuiKey.KeypadEnter]], f_repeat, id) - local is_ctrl_enter = ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 525 --[[ImGuiKey.Enter]]), f_repeat, id) or ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 627 --[[ImGuiKey.KeypadEnter]]), f_repeat, id) - local is_shift_enter = ImGui.Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 525 --[[ImGuiKey.Enter]]), f_repeat, id) or ImGui.Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 627 --[[ImGuiKey.KeypadEnter]]), f_repeat, id) - local is_gamepad_validate = nav_gamepad_active and ImGui.IsKeyPressed(ImGuiKey.NavGamepadActivate, false) - local is_cancel = ImGui.Shortcut(526 --[[ImGuiKey.Escape]], f_repeat, id) or (nav_gamepad_active and ImGui.Shortcut(ImGuiKey.NavGamepadCancel, f_repeat, id)) + local is_enter = ImGui_Shortcut(525 --[[ImGuiKey.Enter]], f_repeat, id) or ImGui_Shortcut(627 --[[ImGuiKey.KeypadEnter]], f_repeat, id) + local is_ctrl_enter = ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 525 --[[ImGuiKey.Enter]]), f_repeat, id) or ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 627 --[[ImGuiKey.KeypadEnter]]), f_repeat, id) + local is_shift_enter = ImGui_Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 525 --[[ImGuiKey.Enter]]), f_repeat, id) or ImGui_Shortcut(bit32.bor(8192 --[[ImGuiMod_Shift]], 627 --[[ImGuiKey.KeypadEnter]]), f_repeat, id) + local is_gamepad_validate = nav_gamepad_active and ImGui_IsKeyPressed(ImGuiKey.NavGamepadActivate, false) + local is_cancel = ImGui_Shortcut(526 --[[ImGuiKey.Escape]], f_repeat, id) or (nav_gamepad_active and ImGui_Shortcut(ImGuiKey.NavGamepadCancel, f_repeat, id)) -- FIXME: Should use more Shortcut() and reduce IsKeyPressed()+SetKeyOwner(), but requires modifiers combination to be taken account of. -- FIXME-OSX: Missing support for Alt(option)+Right/Left = go to end of line, or next line if already in end of line. - if ImGui.IsKeyPressed(513 --[[ImGuiKey.LeftArrow]]) then + if ImGui_IsKeyPressed(513 --[[ImGuiKey.LeftArrow]]) then state:OnKeyPressed(bit32.bor(is_startend_key_down and 2097156 --[[STB_TEXTEDIT_K_LINESTART]] or (is_wordmove_key_down and 2097164 --[[STB_TEXTEDIT_K_WORDLEFT]] or 2097152 --[[STB_TEXTEDIT_K_LEFT]]), k_mask)) - elseif ImGui.IsKeyPressed(514 --[[ImGuiKey.RightArrow]]) then + elseif ImGui_IsKeyPressed(514 --[[ImGuiKey.RightArrow]]) then state:OnKeyPressed(bit32.bor(is_startend_key_down and 2097157 --[[STB_TEXTEDIT_K_LINEEND]] or (is_wordmove_key_down and 2097165 --[[STB_TEXTEDIT_K_WORDRIGHT]] or 2097153 --[[STB_TEXTEDIT_K_RIGHT]]), k_mask)) - elseif ImGui.IsKeyPressed(515 --[[ImGuiKey.UpArrow]]) and is_multiline then + elseif ImGui_IsKeyPressed(515 --[[ImGuiKey.UpArrow]]) and is_multiline then if io.KeyCtrl then - ImGui.SetScrollY(draw_window, ImMax(draw_window.Scroll.y - g.FontSize, 0.0)) + ImGui_SetScrollY(draw_window, ImMax(draw_window.Scroll.y - g.FontSize, 0.0)) else state:OnKeyPressed(bit32.bor(is_startend_key_down and 2097158 --[[STB_TEXTEDIT_K_TEXTSTART]] or 2097154 --[[STB_TEXTEDIT_K_UP]], k_mask)) end - elseif ImGui.IsKeyPressed(516 --[[ImGuiKey.DownArrow]]) and is_multiline then + elseif ImGui_IsKeyPressed(516 --[[ImGuiKey.DownArrow]]) and is_multiline then if io.KeyCtrl then - ImGui.SetScrollY(draw_window, ImMin(draw_window.Scroll.y + g.FontSize, ImGui.GetScrollMaxY())) + ImGui_SetScrollY(draw_window, ImMin(draw_window.Scroll.y + g.FontSize, ImGui.GetScrollMaxY())) else state:OnKeyPressed(bit32.bor(is_startend_key_down and 2097159 --[[STB_TEXTEDIT_K_TEXTEND]] or 2097155 --[[STB_TEXTEDIT_K_DOWN]], k_mask)) end - elseif ImGui.IsKeyPressed(517 --[[ImGuiKey.PageUp]]) and is_multiline then + elseif ImGui_IsKeyPressed(517 --[[ImGuiKey.PageUp]]) and is_multiline then state:OnKeyPressed(bit32.bor(2097166 --[[STB_TEXTEDIT_K_PGUP]], k_mask)) scroll_y = scroll_y - row_count_per_page * g.FontSize - elseif ImGui.IsKeyPressed(518 --[[ImGuiKey.PageDown]]) and is_multiline then + elseif ImGui_IsKeyPressed(518 --[[ImGuiKey.PageDown]]) and is_multiline then state:OnKeyPressed(bit32.bor(2097167 --[[STB_TEXTEDIT_K_PGDOWN]], k_mask)) scroll_y = scroll_y + row_count_per_page * g.FontSize - elseif ImGui.IsKeyPressed(519 --[[ImGuiKey.Home]]) then + elseif ImGui_IsKeyPressed(519 --[[ImGuiKey.Home]]) then state:OnKeyPressed(io.KeyCtrl and bit32.bor(2097158 --[[STB_TEXTEDIT_K_TEXTSTART]], k_mask) or bit32.bor(2097156 --[[STB_TEXTEDIT_K_LINESTART]], k_mask)) - elseif ImGui.IsKeyPressed(520 --[[ImGuiKey.End]]) then + elseif ImGui_IsKeyPressed(520 --[[ImGuiKey.End]]) then state:OnKeyPressed(io.KeyCtrl and bit32.bor(2097159 --[[STB_TEXTEDIT_K_TEXTEND]], k_mask) or bit32.bor(2097157 --[[STB_TEXTEDIT_K_LINEEND]], k_mask)) - elseif ImGui.IsKeyPressed(522 --[[ImGuiKey.Delete]]) and not is_readonly and not is_cut then + elseif ImGui_IsKeyPressed(522 --[[ImGuiKey.Delete]]) and not is_readonly and not is_cut then if not state:HasSelection() then -- OSX doesn't seem to have Super+Delete to delete until end-of-line, so we don't emulate that (as opposed to Super+Backspace) if is_wordmove_key_down then @@ -70960,7 +71643,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback end end state:OnKeyPressed(bit32.bor(2097160 --[[STB_TEXTEDIT_K_DELETE]], k_mask)) - elseif ImGui.IsKeyPressed(523 --[[ImGuiKey.Backspace]]) and not is_readonly then + elseif ImGui_IsKeyPressed(523 --[[ImGuiKey.Backspace]]) and not is_readonly then if not state:HasSelection() then if is_wordmove_key_down then state:OnKeyPressed(bit32.bor(2097164 --[[STB_TEXTEDIT_K_WORDLEFT]], 4194304 --[[STB_TEXTEDIT_K_SHIFT]])) @@ -71020,7 +71703,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback g.TempBuffer:reserve(ie - ib + 1) ImStd.memmove(g.TempBuffer.Data, 1, state.TextSrc, ib, ie - ib) g.TempBuffer.Data[ie - ib + 1] = 0 - ImGui.SetClipboardText(ImGui._ByteArrayToString(g.TempBuffer.Data, 1, ie - ib + 1)) + ImGui_SetClipboardText(ImGui__ByteArrayToString(g.TempBuffer.Data, 1, ie - ib + 1)) end if is_cut then if not state:HasSelection() then @@ -71106,13 +71789,13 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback local event_flag = 0 local event_key = 0 --[[ImGuiKey.None]] - if bit32.band(flags, 262144 --[[ImGuiInputTextFlags.CallbackCompletion]]) ~= 0 and ImGui.Shortcut(512 --[[ImGuiKey.Tab]], 0, id) then + if bit32.band(flags, 262144 --[[ImGuiInputTextFlags.CallbackCompletion]]) ~= 0 and ImGui_Shortcut(512 --[[ImGuiKey.Tab]], 0, id) then event_flag = 262144 --[[ImGuiInputTextFlags.CallbackCompletion]] event_key = 512 --[[ImGuiKey.Tab]] - elseif bit32.band(flags, 524288 --[[ImGuiInputTextFlags.CallbackHistory]]) ~= 0 and ImGui.IsKeyPressed(515 --[[ImGuiKey.UpArrow]]) then + elseif bit32.band(flags, 524288 --[[ImGuiInputTextFlags.CallbackHistory]]) ~= 0 and ImGui_IsKeyPressed(515 --[[ImGuiKey.UpArrow]]) then event_flag = 524288 --[[ImGuiInputTextFlags.CallbackHistory]] event_key = 515 --[[ImGuiKey.UpArrow]] - elseif bit32.band(flags, 524288 --[[ImGuiInputTextFlags.CallbackHistory]]) ~= 0 and ImGui.IsKeyPressed(516 --[[ImGuiKey.DownArrow]]) then + elseif bit32.band(flags, 524288 --[[ImGuiInputTextFlags.CallbackHistory]]) ~= 0 and ImGui_IsKeyPressed(516 --[[ImGuiKey.DownArrow]]) then event_flag = 524288 --[[ImGuiInputTextFlags.CallbackHistory]] event_key = 516 --[[ImGuiKey.DownArrow]] elseif bit32.band(flags, 8388608 --[[ImGuiInputTextFlags.CallbackEdit]]) ~= 0 and state.EditedThisFrame then @@ -71241,14 +71924,14 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- Otherwise request text input ahead for next frame. if g.ActiveId == id and clear_active_id then state.ID = 0 - ImGui.ClearActiveID() + ImGui_ClearActiveID() state.ID = id end -- Render frame if not is_multiline then - ImGui.RenderNavCursor(frame_bb, id) - ImGui.RenderFrame(frame_bb.Min, frame_bb.Max, ImGui.GetColorU32(7 --[[ImGuiCol.FrameBg]]), true, style.FrameRounding) + ImGui_RenderNavCursor(frame_bb, id) + ImGui_RenderFrame(frame_bb.Min, frame_bb.Max, ImGui_GetColorU32(7 --[[ImGuiCol.FrameBg]]), true, style.FrameRounding) end local draw_pos = ImVec2() @@ -71294,7 +71977,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- Calculate visibility local line_visible_n0, line_visible_n1 = 0, 1 -- [Port] 0-based like upstream if is_multiline then - line_visible_n0, line_visible_n1 = ImGui.CalcClipRectVisibleItemsY(clip_rect, draw_pos, g.FontSize) + line_visible_n0, line_visible_n1 = ImGui_CalcClipRectVisibleItemsY(clip_rect, draw_pos, g.FontSize) end -- Build line index for easy data access (makes code below simpler and faster) @@ -71325,7 +72008,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback local draw_scroll = ImVec2() -- Render text. We currently only render selection when the widget is active or while scrolling. - local text_col = ImGui.GetColorU32(is_displaying_hint and 1 --[[ImGuiCol.TextDisabled]] or 0 --[[ImGuiCol.Text]]) + local text_col = ImGui_GetColorU32(is_displaying_hint and 1 --[[ImGuiCol.TextDisabled]] or 0 --[[ImGuiCol.Text]]) if render_cursor or render_selection then -- Render text (with cursor and selection) -- This is going to be messy. We need to: @@ -71376,14 +72059,14 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback scroll_y = ImClamp(new_scroll_y, 0.0, scroll_max_y) draw_pos.y = draw_pos.y + (draw_window.Scroll.y - scroll_y) -- Manipulate cursor pos immediately avoid a frame of lag draw_window.Scroll.y = scroll_y - line_visible_n0, line_visible_n1 = ImGui.CalcClipRectVisibleItemsY(clip_rect, draw_pos, g.FontSize) + line_visible_n0, line_visible_n1 = ImGui_CalcClipRectVisibleItemsY(clip_rect, draw_pos, g.FontSize) line_visible_n1 = ImMin(line_visible_n1, line_count) end -- Draw selection draw_scroll.x = state.Scroll.x if render_selection then - local bg_color = ImGui.GetColorU32(54 --[[ImGuiCol.TextSelectedBg]], render_cursor and 1.0 or 0.6) -- FIXME: current code flow mandate that render_cursor is always true here, we are leaving the transparent one for tests. + local bg_color = ImGui_GetColorU32(54 --[[ImGuiCol.TextSelectedBg]], render_cursor and 1.0 or 0.6) -- FIXME: current code flow mandate that render_cursor is always true here, we are leaving the transparent one for tests. local bg_offy_up = is_multiline and 0.0 or -1.0 -- FIXME-DPI: those offsets should be part of the style? they don't play so well with multi-line selection. local bg_offy_dn = is_multiline and 0.0 or 2.0 local bg_eol_width = IM_TRUNC(g.FontBaked:GetCharAdvance(32) * 0.50) -- So we can see selected empty lines @@ -71403,7 +72086,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback local rect_width = 0.0 if line_selected_begin < line_selected_end then - rect_width = rect_width + ImGui.CalcTextSizeEx(buf_display, line_selected_begin, line_selected_end).x + rect_width = rect_width + ImGui_CalcTextSizeEx(buf_display, line_selected_begin, line_selected_end).x end if text_selected_begin <= p_eol and text_selected_end > p_eol and not p_eol_is_wrap then rect_width = rect_width + bg_eol_width -- So we can see selected empty lines @@ -71413,7 +72096,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback end local rect = ImRect() - rect.Min.x = draw_pos.x - draw_scroll.x + ImGui.CalcTextSizeEx(buf_display, p, line_selected_begin).x + rect.Min.x = draw_pos.x - draw_scroll.x + ImGui_CalcTextSizeEx(buf_display, p, line_selected_begin).x rect.Min.y = draw_pos.y - draw_scroll.y + line_n * g.FontSize rect.Max.x = rect.Min.x + rect_width rect.Max.y = rect.Min.y + bg_offy_dn + g.FontSize @@ -71428,7 +72111,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- Find render position for right alignment (single-line only) if g.ActiveId ~= id and bit32.band(flags, 131072 --[[ImGuiInputTextFlags.ElideLeft]]) ~= 0 and not render_cursor and not render_selection then - draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - ImGui.CalcTextSize(buf_display, nil).x - style.FramePadding.x) + draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - ImGui_CalcTextSize(buf_display, nil).x - style.FramePadding.x) end -- draw_scroll.x = state.Scroll.x -- Preserve scroll when inactive? @@ -71452,7 +72135,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback local cursor_screen_rect = ImRect(cursor_screen_pos.x, cursor_screen_pos.y - g.FontSize + 1.0, cursor_screen_pos.x + 1.0, cursor_screen_pos.y - 1.0) if cursor_is_visible and cursor_screen_rect:Overlaps(clip_rect) then - draw_window.DrawList:AddLineV(cursor_screen_rect.Min.x, cursor_screen_rect.Min.y, cursor_screen_rect.Max.y, ImGui.GetColorU32(34 --[[ImGuiCol.InputTextCursor]]), style.InputTextCursorSize, 131072 --[[ImDrawFlags.StrokeInside]]) + draw_window.DrawList:AddLineV(cursor_screen_rect.Min.x, cursor_screen_rect.Min.y, cursor_screen_rect.Max.y, ImGui_GetColorU32(34 --[[ImGuiCol.InputTextCursor]]), style.InputTextCursorSize, 131072 --[[ImDrawFlags.StrokeInside]]) end -- Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.) @@ -71467,7 +72150,7 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback ime_data.ViewportId = window.Viewport.ID -- [Port] selection for backends (stb positions are 1-based in this port) if state.Stb and state:HasSelection() then - ime_data.SelectedText = ImGui._ByteArrayToString(state.TextA.Data, ImMin(state.Stb.select_start, state.Stb.select_end), ImMax(state.Stb.select_start, state.Stb.select_end)) + ime_data.SelectedText = ImGui__ByteArrayToString(state.TextA.Data, ImMin(state.Stb.select_start, state.Stb.select_end), ImMax(state.Stb.select_start, state.Stb.select_end)) end end end @@ -71480,13 +72163,13 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- For focus requests to work on our multiline we need to ensure our child ItemAdd() call specifies the ImGuiItemFlags.Inputable (see #4761, #7870)... ImGui.Dummy(ImVec2(0.0, text_size_y + style.FramePadding.y)) g.NextItemData.ItemFlagsSet = bit32.bor(g.NextItemData.ItemFlagsSet, 1048576 --[[ImGuiItemFlags.Inputable]], 1 --[[ImGuiItemFlags.NoTabStop]]) - ImGui.EndChild() + ImGui_EndChild() item_data_backup.StatusFlags = bit32.bor(item_data_backup.StatusFlags, bit32.band(g.LastItemData.StatusFlags, 128 --[[ImGuiItemStatusFlags.HoveredWindow]])) -- ...and then we need to undo the group overriding last item data, which gets a bit messy as EndGroup() tries to forward scrollbar being active... -- FIXME: This quite messy/tricky, should attempt to get rid of the child window. - ImGui.EndGroup() - if g.LastItemData.ID == 0 or g.LastItemData.ID ~= ImGui.GetWindowScrollbarID(draw_window, 2 --[[ImGuiAxis.Y]]) then + ImGui_EndGroup() + if g.LastItemData.ID == 0 or g.LastItemData.ID ~= ImGui_GetWindowScrollbarID(draw_window, 2 --[[ImGuiAxis.Y]]) then g.LastItemData.ID = id g.LastItemData.ItemFlags = item_data_backup.ItemFlags g.LastItemData.StatusFlags = item_data_backup.StatusFlags @@ -71499,19 +72182,19 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback -- Log as text if g.LogEnabled and (not is_password or is_displaying_hint) then - ImGui.LogSetNextTextDecoration("{", "}") - ImGui.LogRenderedText(draw_pos, ImGui._ByteArrayToString(buf_display, 1, buf_display_end)) + ImGui_LogSetNextTextDecoration("{", "}") + ImGui_LogRenderedText(draw_pos, ImGui__ByteArrayToString(buf_display, 1, buf_display_end)) end if label_size.x > 0.0 then - ImGui.RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label, 1, label_end, false) + ImGui_RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label, 1, label_end, false) end if state and validated then state.ValidatedThisFrame = true end if value_changed then - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end if bit32.band(flags, 64 --[[ImGuiInputTextFlags.EnterReturnsTrue]]) ~= 0 then @@ -71532,7 +72215,7 @@ function ImGui.InputTextWithHint(label, hint, buf, buf_size, flags, callback, us if flags == nil then flags = 0 end assert(bit32.band(flags, 67108864 --[[ImGuiInputTextFlags.Multiline]]) == 0) -- call InputTextMultiline() or InputTextEx() manually if you need multi-line + hint. - return ImGui.InputTextEx(label, hint, buf, buf_size, ImVec2(0, 0), flags, callback, user_data) + return ImGui_InputTextEx(label, hint, buf, buf_size, LAYOUT_ZERO_SIZE, flags, callback, user_data) -- [Luau] shared read-only ImVec2(0, 0) end -- [Luau] stb positions/undo indices are 1-based in this port (displayed as-is) @@ -71541,39 +72224,39 @@ function ImGui.DebugNodeInputTextState(state) local g = GImGui local stb_state = state.Stb local undo_state = stb_state.undostate - ImGui.Text("ID: 0x%08X, ActiveID: 0x%08X", state.ID, g.ActiveId) + ImGui_Text("ID: 0x%08X, ActiveID: 0x%08X", state.ID, g.ActiveId) ImGui.DebugLocateItemOnHover(state.ID) local wrap_dir = "" if bit32.band(state.Flags, 16777216 --[[ImGuiInputTextFlags.WordWrap]]) ~= 0 then if state.LastMoveDirectionLR == 0 --[[ImGuiDir.Left]] then wrap_dir = " (L)" else wrap_dir = " (R)" end end - ImGui.Text("TextLen: %d, Cursor: %d%s, Selection: %d..%d", state.TextLen, stb_state.cursor, wrap_dir, stb_state.select_start, stb_state.select_end) - ImGui.Text("BufCapacity: %d, LineCount: %d", state.BufCapacity, state.LineCount) - ImGui.Text("(Internal Buffer: TextA Size: %d, Capacity: %d)", state.TextA.Size, state.TextA.Capacity) - ImGui.Text("has_preferred_x: %d (%.2f)", stb_state.has_preferred_x and 1 or 0, stb_state.preferred_x) - ImGui.Text("undo_point: %d, redo_point: %d, undo_char_point: %d, redo_char_point: %d", undo_state.undo_point, undo_state.redo_point, undo_state.undo_char_point, undo_state.redo_char_point) - if ImGui.BeginChild("undopoints", ImVec2(0.0, ImGui.GetTextLineHeight() * 10), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 8 --[[ImGuiChildFlags.ResizeY]])) then -- Visualize undo state - ImGui.PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) + ImGui_Text("TextLen: %d, Cursor: %d%s, Selection: %d..%d", state.TextLen, stb_state.cursor, wrap_dir, stb_state.select_start, stb_state.select_end) + ImGui_Text("BufCapacity: %d, LineCount: %d", state.BufCapacity, state.LineCount) + ImGui_Text("(Internal Buffer: TextA Size: %d, Capacity: %d)", state.TextA.Size, state.TextA.Capacity) + ImGui_Text("has_preferred_x: %d (%.2f)", stb_state.has_preferred_x and 1 or 0, stb_state.preferred_x) + ImGui_Text("undo_point: %d, redo_point: %d, undo_char_point: %d, redo_char_point: %d", undo_state.undo_point, undo_state.redo_point, undo_state.undo_char_point, undo_state.redo_char_point) + if ImGui_BeginChild("undopoints", ImVec2(0.0, ImGui.GetTextLineHeight() * 10), bit32.bor(1 --[[ImGuiChildFlags.Borders]], 8 --[[ImGuiChildFlags.ResizeY]])) then -- Visualize undo state + ImGui_PushStyleVar(14 --[[ImGuiStyleVar.ItemSpacing]], ImVec2(0, 0)) for n = 1, 99 --[[IMSTB_TEXTEDIT_UNDOSTATECOUNT]] do local undo_rec = undo_state.undo_rec[n] local undo_rec_type = (n < undo_state.undo_point) and "u" or ((n >= undo_state.redo_point) and "r" or " ") if undo_rec_type == " " then - ImGui.BeginDisabled() + ImGui_BeginDisabled() end local buf_preview_len = (undo_rec_type ~= " " and undo_rec.char_storage ~= -1) and undo_rec.insert_length or 0 local buf_preview_str = "" if buf_preview_len > 0 then buf_preview_str = string.char(unpack(undo_state.undo_char, undo_rec.char_storage, undo_rec.char_storage + buf_preview_len - 1)) end - ImGui.Text("%s [%02d] where %03d, insert %03d, delete %03d, char_storage %03d \"%s\"", + ImGui_Text("%s [%02d] where %03d, insert %03d, delete %03d, char_storage %03d \"%s\"", undo_rec_type, n, undo_rec.where, undo_rec.insert_length, undo_rec.delete_length, undo_rec.char_storage, buf_preview_str) if undo_rec_type == " " then - ImGui.EndDisabled() + ImGui_EndDisabled() end end - ImGui.PopStyleVar() + ImGui_PopStyleVar() end - ImGui.EndChild() + ImGui_EndChild() end ------------------------------------------------------------------------------- @@ -71596,7 +72279,7 @@ end local function ColorEditRestoreH(col, H) local g = GImGui assert(g.ColorEditCurrentID ~= 0) - if g.ColorEditSavedID ~= g.ColorEditCurrentID or g.ColorEditSavedColor ~= ImGui.ColorConvertFloat4ToU32(ImVec4(col[1], col[2], col[3], 0)) then + if g.ColorEditSavedID ~= g.ColorEditCurrentID or g.ColorEditSavedColor ~= ImGui_ColorConvertFloat4ToU32(ImVec4(col[1], col[2], col[3], 0)) then return H end H = g.ColorEditSavedHue @@ -71614,7 +72297,7 @@ local function ColorEditRestoreHS(col, H, S, V) local g = GImGui assert(g.ColorEditCurrentID ~= 0) - if g.ColorEditSavedID ~= g.ColorEditCurrentID or g.ColorEditSavedColor ~= ImGui.ColorConvertFloat4ToU32(ImVec4(col[1], col[2], col[3], 0)) then + if g.ColorEditSavedID ~= g.ColorEditCurrentID or g.ColorEditSavedColor ~= ImGui_ColorConvertFloat4ToU32(ImVec4(col[1], col[2], col[3], 0)) then return H, S, V end @@ -71655,16 +72338,16 @@ local fmt_table_float = { @native function ImGui.ColorEdit4(label, col, flags) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local style = g.Style - local square_sz = ImGui.GetFrameHeight() - local label_display_end = ImGui.FindRenderedTextEnd(label) - local w_full = ImGui.CalcItemWidth() + local square_sz = ImGui_GetFrameHeight() + local label_display_end = ImGui_FindRenderedTextEnd(label) + local w_full = ImGui_CalcItemWidth() g.NextItemData:ClearFlags() -- [Luau] Fast path for a row that is entirely clipped (e.g. long lists such as Style Editor > Colors): nothing @@ -71679,17 +72362,17 @@ function ImGui.ColorEdit4(label, col, flags) local p = window.DC.CursorPos local cr = window.ClipRect if p.y + square_sz < cr.Min.y or p.y > cr.Max.y or p.x + w < cr.Min.x or p.x > cr.Max.x then - ImGui.BeginGroup() + ImGui_BeginGroup() local bb = ImRect(p.x, p.y, p.x + w, p.y + square_sz) ImGui.ItemSize(ImVec2(w, square_sz), style.FramePadding.y) ImGui.ItemAdd(bb, 0) - ImGui.EndGroup() + ImGui_EndGroup() return false end end - ImGui.BeginGroup() - ImGui.PushID(label) + ImGui_BeginGroup() + ImGui_PushID(label) local set_current_color_edit_id = (g.ColorEditCurrentID == 0) if set_current_color_edit_id then g.ColorEditCurrentID = window.IDStack:back() @@ -71733,10 +72416,10 @@ function ImGui.ColorEdit4(label, col, flags) -- Convert to the formats we need local f = { col[1], col[2], col[3], alpha and col[4] or 1.0 } if bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 and bit32.band(flags, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]]) ~= 0 then - f[1], f[2], f[3] = ImGui.ColorConvertHSVtoRGB(f[1], f[2], f[3]) + f[1], f[2], f[3] = ImGui_ColorConvertHSVtoRGB(f[1], f[2], f[3]) elseif bit32.band(flags, 268435456 --[[ImGuiColorEditFlags.InputRGB]]) ~= 0 and bit32.band(flags, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]]) ~= 0 then -- Hue is lost when converting from grayscale rgb (saturation=0). Restore it. - f[1], f[2], f[3] = ImGui.ColorConvertRGBtoHSV(f[1], f[2], f[3]) + f[1], f[2], f[3] = ImGui_ColorConvertRGBtoHSV(f[1], f[2], f[3]) f[1], f[2], f[3] = ColorEditRestoreHS(col, f[1], f[2], f[3]) end local i = { IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]), IM_F32_TO_INT8_UNBOUND(f[4]) } @@ -71754,7 +72437,7 @@ function ImGui.ColorEdit4(label, col, flags) local w_items = w_inputs - style.ItemInnerSpacing.x * (components - 1) local w_per_component = IM_TRUNC(w_items / components) local draw_color_marker = bit32.band(flags, bit32.bor(2097152 --[[ImGuiColorEditFlags.DisplayHSV]], 2048 --[[ImGuiColorEditFlags.NoColorMarkers]])) == 0 - local hide_prefix = draw_color_marker or (w_per_component <= ImGui.CalcTextSize((bit32.band(flags, 16777216 --[[ImGuiColorEditFlags.Float]]) ~= 0) and "M:0.000" or "M:000").x) + local hide_prefix = draw_color_marker or (w_per_component <= ImGui_CalcTextSize((bit32.band(flags, 16777216 --[[ImGuiColorEditFlags.Float]]) ~= 0) and "M:0.000" or "M:000").x) local fmt_idx if hide_prefix then @@ -71769,13 +72452,13 @@ function ImGui.ColorEdit4(label, col, flags) local prev_split = 0.0 for n = 1, components do if n > 1 then - ImGui.SameLine(0, style.ItemInnerSpacing.x) + ImGui_SameLine(0, style.ItemInnerSpacing.x) end local next_split = IM_TRUNC(w_items * n / components) - ImGui.SetNextItemWidth(ImMax(next_split - prev_split, 1.0)) + ImGui_SetNextItemWidth(ImMax(next_split - prev_split, 1.0)) prev_split = next_split if draw_color_marker then - ImGui.SetNextItemColorMarker(GDefaultRgbaColorMarkers[n]) + ImGui_SetNextItemColorMarker(GDefaultRgbaColorMarkers[n]) end -- FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0. @@ -71791,7 +72474,7 @@ function ImGui.ColorEdit4(label, col, flags) end if bit32.band(flags, 8 --[[ImGuiColorEditFlags.NoOptions]]) == 0 then - ImGui.OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) + ImGui_OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) end end elseif bit32.band(flags, 4194304 --[[ImGuiColorEditFlags.DisplayHex]]) ~= 0 and bit32.band(flags, 32 --[[ImGuiColorEditFlags.NoInputs]]) == 0 then @@ -71807,9 +72490,9 @@ function ImGui.ColorEdit4(label, col, flags) buf = { string.byte(str, 1, #str) } buf[#buf + 1] = 0 end - ImGui.SetNextItemWidth(w_inputs) + ImGui_SetNextItemWidth(w_inputs) - if ImGui.InputText("##Text", buf, buf_size, 8 --[[ImGuiInputTextFlags.CharsUppercase]]) then + if ImGui_InputText("##Text", buf, buf_size, 8 --[[ImGuiInputTextFlags.CharsUppercase]]) then value_changed = true local p = 1 while buf[p] == 35 or ImCharIsBlankA(buf[p]) do @@ -71828,7 +72511,7 @@ function ImGui.ColorEdit4(label, col, flags) end if bit32.band(flags, 8 --[[ImGuiColorEditFlags.NoOptions]]) == 0 then - ImGui.OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) + ImGui_OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) end end @@ -71838,40 +72521,40 @@ function ImGui.ColorEdit4(label, col, flags) ImVec2_Copy(window.DC.CursorPos, ImVec2(pos.x + button_offset_x, pos.y)) local col_v4 = ImVec4(col[1], col[2], col[3], alpha and col[4] or 1.0) - if ImGui.ColorButton("##ColorButton", col_v4, flags) then + if ImGui_ColorButton("##ColorButton", col_v4, flags) then if bit32.band(flags, 4 --[[ImGuiColorEditFlags.NoPicker]]) == 0 then -- Store current color and open a picker ImVec4_Copy(g.ColorPickerRef, col_v4) - ImGui.OpenPopup("picker") - ImGui.SetNextWindowPos(g.LastItemData.Rect:GetBL() + ImVec2(0.0, style.ItemSpacing.y)) + ImGui_OpenPopup("picker") + ImGui_SetNextWindowPos(g.LastItemData.Rect:GetBL() + ImVec2(0.0, style.ItemSpacing.y)) end end if bit32.band(flags, 8 --[[ImGuiColorEditFlags.NoOptions]]) == 0 then - ImGui.OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) + ImGui_OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) end - if ImGui.BeginPopup("picker") then + if ImGui_BeginPopup("picker") then if g.CurrentWindow.BeginCount == 1 then picker_active_window = g.CurrentWindow if label ~= "" and label_display_end > 1 then - ImGui.TextEx(label, label_display_end) + ImGui_TextEx(label, label_display_end) ImGui.Spacing() end local picker_flags_to_forward = bit32.bor(25165824 --[[ImGuiColorEditFlags.DataTypeMask_]], 100663296 --[[ImGuiColorEditFlags.PickerMask_]], 805306368 --[[ImGuiColorEditFlags.InputMask_]], 524288 --[[ImGuiColorEditFlags.HDR]], 2 --[[ImGuiColorEditFlags.NoAlpha]], 262144 --[[ImGuiColorEditFlags.AlphaBar]]) local picker_flags = bit32.bor(bit32.band(flags_untouched, picker_flags_to_forward), 7340032 --[[ImGuiColorEditFlags.DisplayMask_]], 128 --[[ImGuiColorEditFlags.NoLabel]], 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]) - ImGui.SetNextItemWidth(square_sz * 12.0) -- Use 256 + bar sizes? - value_changed = value_changed or ImGui.ColorPicker4("##picker", col, picker_flags, g.ColorPickerRef) + ImGui_SetNextItemWidth(square_sz * 12.0) -- Use 256 + bar sizes? + value_changed = value_changed or ImGui_ColorPicker4("##picker", col, picker_flags, g.ColorPickerRef) end - ImGui.EndPopup() + ImGui_EndPopup() end end if label ~= "" and label_display_end > 1 and bit32.band(flags, 128 --[[ImGuiColorEditFlags.NoLabel]]) == 0 then -- Position not necessarily next to last submitted button (e.g. if style.ColorButtonPosition == ImGuiDir_Left), -- but we need to use SameLine() to setup baseline correctly. Might want to refactor SameLine() to simplify this. - ImGui.SameLine(0.0, style.ItemInnerSpacing.x) + ImGui_SameLine(0.0, style.ItemInnerSpacing.x) window.DC.CursorPos.x = pos.x + ((bit32.band(flags, 32 --[[ImGuiColorEditFlags.NoInputs]]) ~= 0) and w_button or (w_full + style.ItemInnerSpacing.x)) - ImGui.TextEx(label, label_display_end) + ImGui_TextEx(label, label_display_end) end -- Convert back @@ -71884,12 +72567,12 @@ function ImGui.ColorEdit4(label, col, flags) if bit32.band(flags, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]]) ~= 0 and bit32.band(flags, 268435456 --[[ImGuiColorEditFlags.InputRGB]]) ~= 0 then g.ColorEditSavedHue = f[1] g.ColorEditSavedSat = f[2] - f[1], f[2], f[3] = ImGui.ColorConvertHSVtoRGB(f[1], f[2], f[3]) + f[1], f[2], f[3] = ImGui_ColorConvertHSVtoRGB(f[1], f[2], f[3]) g.ColorEditSavedID = g.ColorEditCurrentID - g.ColorEditSavedColor = ImGui.ColorConvertFloat4ToU32(ImVec4(f[1], f[2], f[3], 0)) + g.ColorEditSavedColor = ImGui_ColorConvertFloat4ToU32(ImVec4(f[1], f[2], f[3], 0)) end if bit32.band(flags, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]]) ~= 0 and bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 then - f[1], f[2], f[3] = ImGui.ColorConvertRGBtoHSV(f[1], f[2], f[3]) + f[1], f[2], f[3] = ImGui_ColorConvertRGBtoHSV(f[1], f[2], f[3]) end col[1] = f[1] @@ -71903,20 +72586,20 @@ function ImGui.ColorEdit4(label, col, flags) if set_current_color_edit_id then g.ColorEditCurrentID = 0 end - ImGui.PopID() - ImGui.EndGroup() + ImGui_PopID() + ImGui_EndGroup() -- Drag and Drop Target -- NB: The flag test is merely an optional micro-optimization, BeginDragDropTarget() does the same test. if bit32.band(g.LastItemData.StatusFlags, 1 --[[ImGuiItemStatusFlags.HoveredRect]]) ~= 0 and bit32.band(g.LastItemData.ItemFlags, 2048 --[[ImGuiItemFlags.ReadOnly]]) == 0 and bit32.band(flags, 512 --[[ImGuiColorEditFlags.NoDragDrop]]) == 0 and ImGui.BeginDragDropTarget() then local accepted_drag_drop = false - local payload = ImGui.AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F) + local payload = ImGui_AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F) if payload then local d = payload.Data col[1], col[2], col[3] = d[1], d[2], d[3] -- Preserve alpha if any value_changed = true; accepted_drag_drop = true end - payload = ImGui.AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F) + payload = ImGui_AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F) if payload then local d = payload.Data for i = 1, components do col[i] = d[i] end @@ -71925,7 +72608,7 @@ function ImGui.ColorEdit4(label, col, flags) -- Drag-drop payloads are always RGB if accepted_drag_drop and bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 then - col[1], col[2], col[3] = ImGui.ColorConvertRGBtoHSV(col[1], col[2], col[3]) + col[1], col[2], col[3] = ImGui_ColorConvertRGBtoHSV(col[1], col[2], col[3]) end ImGui.EndDragDropTarget() end @@ -71936,7 +72619,7 @@ function ImGui.ColorEdit4(label, col, flags) end if value_changed and g.LastItemData.ID ~= 0 then -- In case of ID collision, the second EndGroup() won't catch g.ActiveId - ImGui.MarkItemEdited(g.LastItemData.ID) + ImGui_MarkItemEdited(g.LastItemData.ID) end return value_changed @@ -71951,14 +72634,14 @@ function ImGui.ColorEdit3(label, col, flags) if flags == nil then flags = 0 end if flags == nil then flags = 0 end - return ImGui.ColorEdit4(label, col, bit32.bor(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]])) + return ImGui_ColorEdit4(label, col, bit32.bor(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]])) end -- [Port] `col` mutated in place, returns value_changed function ImGui.ColorPicker3(label, col, flags) if flags == nil then flags = 0 end local col4 = { col[1], col[2], col[3], 1.0 } - if not ImGui.ColorPicker4(label, col4, bit32.bor(flags or 0, 2 --[[ImGuiColorEditFlags.NoAlpha]])) then + if not ImGui_ColorPicker4(label, col4, bit32.bor(flags or 0, 2 --[[ImGuiColorEditFlags.NoAlpha]])) then return false end col[1] = col4[1]; col[2] = col4[2]; col[3] = col4[3] @@ -71985,10 +72668,10 @@ end --- @param alpha float local function RenderArrowsForVerticalBar(draw_list, pos, half_sz, bar_w, alpha) local alpha8 = IM_F32_TO_INT8_SAT(alpha) - ImGui.RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), 1 --[[ImGuiDir.Right]], IM_COL32(0, 0, 0, alpha8)) - ImGui.RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, 1 --[[ImGuiDir.Right]], IM_COL32(255, 255, 255, alpha8)) - ImGui.RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), 0 --[[ImGuiDir.Left]], IM_COL32(0, 0, 0, alpha8)) - ImGui.RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, 0 --[[ImGuiDir.Left]], IM_COL32(255, 255, 255, alpha8)) + ImGui_RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), 1 --[[ImGuiDir.Right]], IM_COL32(0, 0, 0, alpha8)) + ImGui_RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, 1 --[[ImGuiDir.Right]], IM_COL32(255, 255, 255, alpha8)) + ImGui_RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), 0 --[[ImGuiDir.Left]], IM_COL32(0, 0, 0, alpha8)) + ImGui_RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, 0 --[[ImGuiDir.Left]], IM_COL32(255, 255, 255, alpha8)) end do --[[ColorPicker4]] @@ -72004,7 +72687,7 @@ local backup_initial_col = {0, 0, 0, 0} --- @param ref_col? float[] function ImGui.ColorPicker4(label, col, flags, ref_col) if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -72014,16 +72697,16 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) local style = g.Style local io = g.IO - local width = ImGui.CalcItemWidth() + local width = ImGui_CalcItemWidth() local is_readonly = bit32.band(bit32.bor(g.NextItemData.ItemFlagsSet, g.CurrentItemFlags), 2048 --[[ImGuiItemFlags.ReadOnly]]) ~= 0 g.NextItemData:ClearFlags() - ImGui.PushID(label) + ImGui_PushID(label) local set_current_color_edit_id = (g.ColorEditCurrentID == 0) if set_current_color_edit_id then g.ColorEditCurrentID = window.IDStack:back() end - ImGui.BeginGroup() + ImGui_BeginGroup() if bit32.band(flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]]) == 0 then flags = bit32.bor(flags, 16 --[[ImGuiColorEditFlags.NoSmallPreview]]) @@ -72062,7 +72745,7 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) local alpha_bar = (bit32.band(flags, 262144 --[[ImGuiColorEditFlags.AlphaBar]]) ~= 0) and (bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) == 0) local picker_pos = ImVec2() ImVec2_Copy(picker_pos, window.DC.CursorPos) - local square_sz = ImGui.GetFrameHeight() + local square_sz = ImGui_GetFrameHeight() local bars_width = square_sz -- Arbitrary smallish width of Hue/Alpha picking bars local sv_picker_size = ImMax(bars_width * 1, width - (alpha_bar and 2 or 1) * (bars_width + style.ItemInnerSpacing.x)) -- Saturation/Value picking box local bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x @@ -72088,19 +72771,19 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) local R = col[1]; local G = col[2]; local B = col[3] if bit32.band(flags, 268435456 --[[ImGuiColorEditFlags.InputRGB]]) ~= 0 then -- Hue is lost when converting from grayscale rgb (saturation=0). Restore it. - H, S, V = ImGui.ColorConvertRGBtoHSV(R, G, B) + H, S, V = ImGui_ColorConvertRGBtoHSV(R, G, B) H, S, V = ColorEditRestoreHS(col, H, S, V) elseif bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 then - R, G, B = ImGui.ColorConvertHSVtoRGB(H, S, V) + R, G, B = ImGui_ColorConvertHSVtoRGB(H, S, V) end local value_changed = false; local value_changed_h = false; local value_changed_sv = false - ImGui.PushItemFlag(2 --[[ImGuiItemFlags.NoNav]], true) + ImGui_PushItemFlag(2 --[[ImGuiItemFlags.NoNav]], true) if bit32.band(flags, 67108864 --[[ImGuiColorEditFlags.PickerHueWheel]]) ~= 0 then -- Hue wheel + SV triangle logic - ImGui.InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size)) - if ImGui.IsItemActive() and not is_readonly then + ImGui_InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size)) + if ImGui_IsItemActive() and not is_readonly then local initial_off = g.IO.MouseClickedPos[0] - wheel_center local current_off = g.IO.MousePos - wheel_center local initial_dist2 = ImLengthSqr(initial_off) @@ -72134,12 +72817,12 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) end if bit32.band(flags, 8 --[[ImGuiColorEditFlags.NoOptions]]) == 0 then - ImGui.OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) + ImGui_OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) end elseif bit32.band(flags, 33554432 --[[ImGuiColorEditFlags.PickerHueBar]]) ~= 0 then -- SV rectangle logic - ImGui.InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size)) - if ImGui.IsItemActive() and not is_readonly then + ImGui_InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size)) + if ImGui_IsItemActive() and not is_readonly then S = ImSaturate((io.MousePos.x - picker_pos.x) / ImMax(sv_picker_size - 1, 0.0001)) V = 1.0 - ImSaturate((io.MousePos.y - picker_pos.y) / ImMax(sv_picker_size - 1, 0.0001)) H = ColorEditRestoreH(col, H) -- Greatly reduces hue jitter and reset to 0 when hue == 255 and color is rapidly modified using SV square. @@ -72148,13 +72831,13 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) end if bit32.band(flags, 8 --[[ImGuiColorEditFlags.NoOptions]]) == 0 then - ImGui.OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) + ImGui_OpenPopupOnItemClick("context", 8 --[[ImGuiPopupFlags.MouseButtonRight]]) end -- Hue bar logic - ImGui.SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y)) - ImGui.InvisibleButton("hue", ImVec2(bars_width, sv_picker_size)) - if ImGui.IsItemActive() and not is_readonly then + ImGui_SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y)) + ImGui_InvisibleButton("hue", ImVec2(bars_width, sv_picker_size)) + if ImGui_IsItemActive() and not is_readonly then H = ImSaturate((io.MousePos.y - picker_pos.y) / ImMax(sv_picker_size - 1, 0.0001)) value_changed = true value_changed_h = true @@ -72163,46 +72846,46 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) -- Alpha bar logic if alpha_bar then - ImGui.SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y)) - ImGui.InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size)) - if ImGui.IsItemActive() then + ImGui_SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y)) + ImGui_InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size)) + if ImGui_IsItemActive() then col[4] = 1.0 - ImSaturate((io.MousePos.y - picker_pos.y) / ImMax(sv_picker_size - 1, 0.0001)) value_changed = true end end - ImGui.PopItemFlag() -- ImGuiItemFlags.NoNav + ImGui_PopItemFlag() -- ImGuiItemFlags.NoNav if bit32.band(flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]]) == 0 then - ImGui.SameLine(0, style.ItemInnerSpacing.x) - ImGui.BeginGroup() + ImGui_SameLine(0, style.ItemInnerSpacing.x) + ImGui_BeginGroup() end if bit32.band(flags, 128 --[[ImGuiColorEditFlags.NoLabel]]) == 0 then - local label_display_end = ImGui.FindRenderedTextEnd(label) + local label_display_end = ImGui_FindRenderedTextEnd(label) if label ~= "" and label_display_end > 1 then if bit32.band(flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]]) ~= 0 then - ImGui.SameLine(0, style.ItemInnerSpacing.x) + ImGui_SameLine(0, style.ItemInnerSpacing.x) end - ImGui.TextEx(label, label_display_end) + ImGui_TextEx(label, label_display_end) end end if bit32.band(flags, 256 --[[ImGuiColorEditFlags.NoSidePreview]]) == 0 then - ImGui.PushItemFlag(4 --[[ImGuiItemFlags.NoNavDefaultFocus]], true) + ImGui_PushItemFlag(4 --[[ImGuiItemFlags.NoNavDefaultFocus]], true) local col_v4 = ImVec4(col[1], col[2], col[3], (bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0) and 1.0 or col[4]) if bit32.band(flags, 128 --[[ImGuiColorEditFlags.NoLabel]]) ~= 0 then - ImGui.Text("Current") + ImGui_Text("Current") end local sub_flags_to_forward = bit32.bor(805306368 --[[ImGuiColorEditFlags.InputMask_]], 524288 --[[ImGuiColorEditFlags.HDR]], 28674 --[[ImGuiColorEditFlags.AlphaMask_]], 64 --[[ImGuiColorEditFlags.NoTooltip]]) - ImGui.ColorButton("##current", col_v4, bit32.band(flags, sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2)) + ImGui_ColorButton("##current", col_v4, bit32.band(flags, sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2)) if ref_col ~= nil then - ImGui.Text("Original") + ImGui_Text("Original") local ref_col_v4 = ImVec4(ref_col[1], ref_col[2], ref_col[3], (bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0) and 1.0 or ref_col[4]) - if ImGui.ColorButton("##original", ref_col_v4, bit32.band(flags, sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2)) then + if ImGui_ColorButton("##original", ref_col_v4, bit32.band(flags, sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2)) then for i = 1, components do col[i] = ref_col[i] end @@ -72210,18 +72893,18 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) end end - ImGui.PopItemFlag() - ImGui.EndGroup() + ImGui_PopItemFlag() + ImGui_EndGroup() end -- Convert back color to RGB if value_changed_h or value_changed_sv then if bit32.band(flags, 268435456 --[[ImGuiColorEditFlags.InputRGB]]) ~= 0 then - col[1], col[2], col[3] = ImGui.ColorConvertHSVtoRGB(H, S, V) -- [Port] Lua 1-based indexing + col[1], col[2], col[3] = ImGui_ColorConvertHSVtoRGB(H, S, V) -- [Port] Lua 1-based indexing g.ColorEditSavedHue = H g.ColorEditSavedSat = S g.ColorEditSavedID = g.ColorEditCurrentID - g.ColorEditSavedColor = ImGui.ColorConvertFloat4ToU32(ImVec4(col[1], col[2], col[3], 0)) + g.ColorEditSavedColor = ImGui_ColorConvertFloat4ToU32(ImVec4(col[1], col[2], col[3], 0)) elseif bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 then col[1] = H col[2] = S @@ -72238,7 +72921,7 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) local sub_flags = bit32.bor(bit32.band(flags, sub_flags_to_forward), 4 --[[ImGuiColorEditFlags.NoPicker]]) if bit32.band(flags, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]]) ~= 0 or bit32.band(flags, 7340032 --[[ImGuiColorEditFlags.DisplayMask_]]) == 0 then - if ImGui.ColorEdit4("##rgb", col, bit32.bor(sub_flags, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]])) then + if ImGui_ColorEdit4("##rgb", col, bit32.bor(sub_flags, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]])) then -- FIXME: Hackily differentiating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget. -- For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050) value_changed_fix_hue_wrap = (g.ActiveId ~= 0 and not g.ActiveIdAllowOverlap) @@ -72247,29 +72930,29 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) end if bit32.band(flags, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]]) ~= 0 or bit32.band(flags, 7340032 --[[ImGuiColorEditFlags.DisplayMask_]]) == 0 then - if ImGui.ColorEdit4("##hsv", col, bit32.bor(sub_flags, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]])) then + if ImGui_ColorEdit4("##hsv", col, bit32.bor(sub_flags, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]])) then value_changed = true end end if bit32.band(flags, 4194304 --[[ImGuiColorEditFlags.DisplayHex]]) ~= 0 or bit32.band(flags, 7340032 --[[ImGuiColorEditFlags.DisplayMask_]]) == 0 then - if ImGui.ColorEdit4("##hex", col, bit32.bor(sub_flags, 4194304 --[[ImGuiColorEditFlags.DisplayHex]])) then + if ImGui_ColorEdit4("##hex", col, bit32.bor(sub_flags, 4194304 --[[ImGuiColorEditFlags.DisplayHex]])) then value_changed = true end end - ImGui.PopItemWidth() + ImGui_PopItemWidth() end -- Try to cancel hue wrap (after ColorEdit4 call), if any if value_changed_fix_hue_wrap and bit32.band(flags, 268435456 --[[ImGuiColorEditFlags.InputRGB]]) ~= 0 then - local new_H, new_S, new_V = ImGui.ColorConvertRGBtoHSV(col[1], col[2], col[3]) -- [Port] Lua 1-based indexing + local new_H, new_S, new_V = ImGui_ColorConvertRGBtoHSV(col[1], col[2], col[3]) -- [Port] Lua 1-based indexing if new_H <= 0 and H > 0 then if new_V <= 0 and V ~= new_V then - col[1], col[2], col[3] = ImGui.ColorConvertHSVtoRGB(H, S, (new_V <= 0) and (V * 0.5) or new_V) + col[1], col[2], col[3] = ImGui_ColorConvertHSVtoRGB(H, S, (new_V <= 0) and (V * 0.5) or new_V) elseif new_S <= 0 then - col[1], col[2], col[3] = ImGui.ColorConvertHSVtoRGB(H, (new_S <= 0) and (S * 0.5) or new_S, new_V) + col[1], col[2], col[3] = ImGui_ColorConvertHSVtoRGB(H, (new_S <= 0) and (S * 0.5) or new_S, new_V) end end end @@ -72279,13 +72962,13 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) R = col[1] G = col[2] B = col[3] - H, S, V = ImGui.ColorConvertRGBtoHSV(R, G, B) + H, S, V = ImGui_ColorConvertRGBtoHSV(R, G, B) H, S, V = ColorEditRestoreHS(col, H, S, V) -- Fix local Hue as display below will use it immediately. elseif bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 then H = col[1] S = col[2] V = col[3] - R, G, B = ImGui.ColorConvertHSVtoRGB(H, S, V) + R, G, B = ImGui_ColorConvertHSVtoRGB(H, S, V) end end @@ -72296,9 +72979,9 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) local col_hues = { IM_COL32(255, 0, 0, style_alpha8), IM_COL32(255, 255, 0, style_alpha8), IM_COL32(0, 255, 0, style_alpha8), IM_COL32(0, 255, 255, style_alpha8), IM_COL32(0, 0, 255, style_alpha8), IM_COL32(255, 0, 255, style_alpha8), IM_COL32(255, 0, 0, style_alpha8) } local hue_color_f = ImVec4(1, 1, 1, style.Alpha) - hue_color_f.x, hue_color_f.y, hue_color_f.z = ImGui.ColorConvertHSVtoRGB(H, 1, 1) - local hue_color32 = ImGui.ColorConvertFloat4ToU32(hue_color_f) - local user_col32_striped_of_alpha = ImGui.ColorConvertFloat4ToU32(ImVec4(R, G, B, style.Alpha)) -- Important: this is still including the main rendering/style alpha!! + hue_color_f.x, hue_color_f.y, hue_color_f.z = ImGui_ColorConvertHSVtoRGB(H, 1, 1) + local hue_color32 = ImGui_ColorConvertFloat4ToU32(hue_color_f) + local user_col32_striped_of_alpha = ImGui_ColorConvertFloat4ToU32(ImVec4(R, G, B, style.Alpha)) -- Important: this is still including the main rendering/style alpha!! local sv_cursor_pos = ImVec2() @@ -72358,7 +73041,7 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) -- Render SV Square draw_list:AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), col_white, hue_color32, hue_color32, col_white) draw_list:AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0, 0, col_black, col_black) - ImGui.RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0.0) + ImGui_RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0.0) sv_cursor_pos.x = ImClamp(IM_ROUND(picker_pos.x + ImSaturate(S) * sv_picker_size), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2) -- Sneakily prevent the circle to stick out too much sv_cursor_pos.y = ImClamp(IM_ROUND(picker_pos.y + ImSaturate(1 - V) * sv_picker_size), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2) @@ -72369,7 +73052,7 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) end local bar0_line_y = IM_ROUND(picker_pos.y + H * sv_picker_size) - ImGui.RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0) + ImGui_RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0) RenderArrowsForVerticalBar(draw_list, ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0, style.Alpha) end @@ -72384,15 +73067,15 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) if alpha_bar then local alpha = ImSaturate(col[4]) local bar1_bb = ImRect(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size) - ImGui.RenderColorRectWithAlphaCheckerboard(draw_list, bar1_bb.Min, bar1_bb.Max, IM_COL32(0, 0, 0, 0), style.Alpha, bar1_bb:GetWidth() / 2.0, ImVec2(0.0, 0.0)) + ImGui_RenderColorRectWithAlphaCheckerboard(draw_list, bar1_bb.Min, bar1_bb.Max, IM_COL32(0, 0, 0, 0), style.Alpha, bar1_bb:GetWidth() / 2.0, ImVec2(0.0, 0.0)) draw_list:AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, user_col32_striped_of_alpha, user_col32_striped_of_alpha, bit32.band(user_col32_striped_of_alpha, bit32.bnot(4278190080 --[[IM_COL32_A_MASK]])), bit32.band(user_col32_striped_of_alpha, bit32.bnot(4278190080 --[[IM_COL32_A_MASK]]))) local bar1_line_y = IM_ROUND(picker_pos.y + (1.0 - alpha) * sv_picker_size) - ImGui.RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0) + ImGui_RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0) RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0, style.Alpha) end - ImGui.EndGroup() + ImGui_EndGroup() if value_changed then for i = 1, components do @@ -72406,14 +73089,14 @@ function ImGui.ColorPicker4(label, col, flags, ref_col) end if value_changed and g.LastItemData.ID ~= 0 then -- In case of ID collision, the second EndGroup() won't catch g.ActiveId - ImGui.MarkItemEdited(g.LastItemData.ID) + ImGui_MarkItemEdited(g.LastItemData.ID) end if set_current_color_edit_id then g.ColorEditCurrentID = 0 end - ImGui.PopID() + ImGui_PopID() return value_changed end @@ -72433,14 +73116,14 @@ function ImGui.ColorButton(desc_id, col, flags, size_arg) if flags == nil then flags = 0 end if size_arg == nil then size_arg = ImVec2(0, 0) end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local id = window:GetID(desc_id) - local default_size = ImGui.GetFrameHeight() + local default_size = ImGui_GetFrameHeight() local size = ImVec2(size_arg.x == 0.0 and default_size or size_arg.x, size_arg.y == 0.0 and default_size or size_arg.y) local bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + size) ImGui.ItemSize(bb, (size.y >= default_size) and g.Style.FramePadding.y or 0.0) @@ -72448,7 +73131,7 @@ function ImGui.ColorButton(desc_id, col, flags, size_arg) return false end - local pressed, hovered, _ = ImGui.ButtonBehavior(bb, id) + local pressed, hovered, _ = ImGui_ButtonBehavior(bb, id) if bit32.band(flags, bit32.bor(2 --[[ImGuiColorEditFlags.NoAlpha]], 4096 --[[ImGuiColorEditFlags.AlphaOpaque]])) ~= 0 then flags = bit32.band(flags, bit32.bnot(bit32.bor(8192 --[[ImGuiColorEditFlags.AlphaNoBg]], 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]))) @@ -72456,7 +73139,7 @@ function ImGui.ColorButton(desc_id, col, flags, size_arg) local col_rgb = ImVec4(col.x, col.y, col.z, col.w) if bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 then - col_rgb.x, col_rgb.y, col_rgb.z = ImGui.ColorConvertHSVtoRGB(col_rgb.x, col_rgb.y, col_rgb.z) + col_rgb.x, col_rgb.y, col_rgb.z = ImGui_ColorConvertHSVtoRGB(col_rgb.x, col_rgb.y, col_rgb.z) end local col_rgb_without_alpha = ImVec4(col_rgb.x, col_rgb.y, col_rgb.z, 1.0) @@ -72469,38 +73152,38 @@ function ImGui.ColorButton(desc_id, col, flags, size_arg) g.Style.Alpha = g.DisabledAlphaBackup -- Cancel out effect of BeginDisabled() for color swatches. end if is_mixed then - window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui.GetColorU32(7 --[[ImGuiCol.FrameBg]]), rounding) - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue + window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui_GetColorU32(7 --[[ImGuiCol.FrameBg]]), rounding) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], g.Style.Colors[1 --[[ImGuiCol.TextDisabled]]]) -- ImGuiCol_TextMixedValue if g.MixedValueLabel ~= nil then - ImGui.RenderTextClipped(ImVec2(bb.Min.x, bb.Min.y + g.Style.FramePadding.y), bb.Max, g.MixedValueLabel, nil, nil, ImVec2(0.5, 0.0)) + ImGui_RenderTextClipped(ImVec2(bb.Min.x, bb.Min.y + g.Style.FramePadding.y), bb.Max, g.MixedValueLabel, nil, nil, ImVec2(0.5, 0.0)) end - ImGui.PopStyleColor() + ImGui_PopStyleColor() elseif bit32.band(flags, 16384 --[[ImGuiColorEditFlags.AlphaPreviewHalf]]) ~= 0 and col_rgb.w < 1.0 then local mid_x = IM_ROUND((bb.Min.x + bb.Max.x) * 0.5) if bit32.band(flags, 8192 --[[ImGuiColorEditFlags.AlphaNoBg]]) == 0 then - ImGui.RenderColorRectWithAlphaCheckerboard(window.DrawList, ImVec2(bb.Min.x + grid_step, bb.Min.y), bb.Max, ImGui.ColorConvertFloat4ToU32(col_rgb), g.Style.Alpha, grid_step, ImVec2(-grid_step, 0.0), rounding, 160 --[[ImDrawFlags.RoundRight]]) + ImGui_RenderColorRectWithAlphaCheckerboard(window.DrawList, ImVec2(bb.Min.x + grid_step, bb.Min.y), bb.Max, ImGui_ColorConvertFloat4ToU32(col_rgb), g.Style.Alpha, grid_step, ImVec2(-grid_step, 0.0), rounding, 160 --[[ImDrawFlags.RoundRight]]) else - window.DrawList:AddRectFilled(ImVec2(bb.Min.x + grid_step, bb.Min.y), bb.Max, ImGui.GetColorU32(col_rgb), rounding, 160 --[[ImDrawFlags.RoundRight]]) + window.DrawList:AddRectFilled(ImVec2(bb.Min.x + grid_step, bb.Min.y), bb.Max, ImGui_GetColorU32(col_rgb), rounding, 160 --[[ImDrawFlags.RoundRight]]) end - window.DrawList:AddRectFilled(bb.Min, ImVec2(mid_x, bb.Max.y), ImGui.GetColorU32(col_rgb_without_alpha), rounding, 80 --[[ImDrawFlags.RoundLeft]]) + window.DrawList:AddRectFilled(bb.Min, ImVec2(mid_x, bb.Max.y), ImGui_GetColorU32(col_rgb_without_alpha), rounding, 80 --[[ImDrawFlags.RoundLeft]]) else -- Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha local col_source = (bit32.band(flags, 4096 --[[ImGuiColorEditFlags.AlphaOpaque]]) ~= 0) and col_rgb_without_alpha or col_rgb if col_source.w < 1.0 and bit32.band(flags, 8192 --[[ImGuiColorEditFlags.AlphaNoBg]]) == 0 then - ImGui.RenderColorRectWithAlphaCheckerboard(window.DrawList, bb.Min, bb.Max, ImGui.ColorConvertFloat4ToU32(col_source), g.Style.Alpha, grid_step, ImVec2(0.0, 0.0), rounding) + ImGui_RenderColorRectWithAlphaCheckerboard(window.DrawList, bb.Min, bb.Max, ImGui_ColorConvertFloat4ToU32(col_source), g.Style.Alpha, grid_step, ImVec2(0.0, 0.0), rounding) else - window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui.GetColorU32(col_source), rounding) + window.DrawList:AddRectFilled(bb.Min, bb.Max, ImGui_GetColorU32(col_source), rounding) end end if g.DisabledStackSize > 0 then g.Style.Alpha = backup_alpha end - ImGui.RenderNavCursor(bb, id) + ImGui_RenderNavCursor(bb, id) if bit32.band(flags, 1024 --[[ImGuiColorEditFlags.NoBorder]]) == 0 then if g.Style.FrameBorderSize > 0.0 then - ImGui.RenderFrameBorder(bb.Min, bb.Max, rounding) + ImGui_RenderFrameBorder(bb.Min, bb.Max, rounding) else - window.DrawList:AddRect(bb.Min, bb.Max, ImGui.GetColorU32(7 --[[ImGuiCol.FrameBg]]), rounding, 1.0 * ImTrunc(g.Style._MainScale)) -- Color buttons are often in need of some sort of border -- FIXME-DPI + window.DrawList:AddRect(bb.Min, bb.Max, ImGui_GetColorU32(7 --[[ImGuiCol.FrameBg]]), rounding, 1.0 * ImTrunc(g.Style._MainScale)) -- Color buttons are often in need of some sort of border -- FIXME-DPI end end @@ -72513,16 +73196,16 @@ function ImGui.ColorButton(desc_id, col, flags, size_arg) else ImGui.SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, { col_rgb.x, col_rgb.y, col_rgb.z, col_rgb.w }, 4, 2 --[[ImGuiCond.Once]]) end - ImGui.PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], false) - ImGui.ColorButton(desc_id, col, flags) - ImGui.PopItemFlag() - ImGui.SameLine() - ImGui.TextEx("Color") + ImGui_PushItemFlag(4096 --[[ImGuiItemFlags.MixedValue]], false) + ImGui_ColorButton(desc_id, col, flags) + ImGui_PopItemFlag() + ImGui_SameLine() + ImGui_TextEx("Color") ImGui.EndDragDropSource() end -- Tooltip - if bit32.band(flags, 64 --[[ImGuiColorEditFlags.NoTooltip]]) == 0 and hovered and ImGui.IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then + if bit32.band(flags, 64 --[[ImGuiColorEditFlags.NoTooltip]]) == 0 and hovered and ImGui_IsItemHovered(4096 --[[ImGuiHoveredFlags.ForTooltip]]) then ImGui.ColorTooltip(desc_id, col, bit32.band(flags, bit32.bor(805306368 --[[ImGuiColorEditFlags.InputMask_]], 28674 --[[ImGuiColorEditFlags.AlphaMask_]]))) end @@ -72540,11 +73223,11 @@ function ImGui.ColorTooltip(text, col, flags) return end - local text_end = text and ImGui.FindRenderedTextEnd(text, nil) or 1 + local text_end = text and ImGui_FindRenderedTextEnd(text, nil) or 1 if text_end > 1 then --- @cast text string - ImGui.TextEx(text, text_end) - ImGui.Separator() + ImGui_TextEx(text, text_end) + ImGui_Separator() end local sz = ImVec2(g.FontSize * 3 + g.Style.FramePadding.y * 2, g.FontSize * 3 + g.Style.FramePadding.y * 2) @@ -72555,20 +73238,20 @@ function ImGui.ColorTooltip(text, col, flags) local ca = (bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0) and 255 or IM_F32_TO_INT8_SAT(col.w) local flags_to_forward = bit32.bor(805306368 --[[ImGuiColorEditFlags.InputMask_]], 28674 --[[ImGuiColorEditFlags.AlphaMask_]]) - ImGui.ColorButton("##preview", cf, bit32.bor(bit32.band(flags, flags_to_forward), 64 --[[ImGuiColorEditFlags.NoTooltip]]), sz) - ImGui.SameLine() + ImGui_ColorButton("##preview", cf, bit32.bor(bit32.band(flags, flags_to_forward), 64 --[[ImGuiColorEditFlags.NoTooltip]]), sz) + ImGui_SameLine() if bit32.band(flags, 268435456 --[[ImGuiColorEditFlags.InputRGB]]) ~= 0 or bit32.band(flags, 805306368 --[[ImGuiColorEditFlags.InputMask_]]) == 0 then if bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0 then - ImGui.Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col.x, col.y, col.z) + ImGui_Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col.x, col.y, col.z) else - ImGui.Text("#%02X%02X%02X%02X\nR:%d, G:%d, B:%d, A:%d\n(%.3f, %.3f, %.3f, %.3f)", cr, cg, cb, ca, cr, cg, cb, ca, col.x, col.y, col.z, col.w) + ImGui_Text("#%02X%02X%02X%02X\nR:%d, G:%d, B:%d, A:%d\n(%.3f, %.3f, %.3f, %.3f)", cr, cg, cb, ca, cr, cg, cb, ca, col.x, col.y, col.z, col.w) end elseif bit32.band(flags, 536870912 --[[ImGuiColorEditFlags.InputHSV]]) ~= 0 then if bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0 then - ImGui.Text("H: %.3f, S: %.3f, V: %.3f", col.x, col.y, col.z) + ImGui_Text("H: %.3f, S: %.3f, V: %.3f", col.x, col.y, col.z) else - ImGui.Text("H: %.3f, S: %.3f, V: %.3f, A: %.3f", col.x, col.y, col.z, col.w) + ImGui_Text("H: %.3f, S: %.3f, V: %.3f, A: %.3f", col.x, col.y, col.z, col.w) end end @@ -72581,74 +73264,74 @@ function ImGui.ColorEditOptionsPopup(col, flags) local allow_opt_inputs = bit32.band(flags, 7340032 --[[ImGuiColorEditFlags.DisplayMask_]]) == 0 local allow_opt_datatype = bit32.band(flags, 25165824 --[[ImGuiColorEditFlags.DataTypeMask_]]) == 0 - if (not allow_opt_inputs and not allow_opt_datatype) or not ImGui.BeginPopup("context") then + if (not allow_opt_inputs and not allow_opt_datatype) or not ImGui_BeginPopup("context") then return end local g = GImGui - ImGui.PushItemFlag(65536 --[[ImGuiItemFlags.NoMarkEdited]], true) + ImGui_PushItemFlag(65536 --[[ImGuiItemFlags.NoMarkEdited]], true) local opts = g.IO.ConfigColorEditFlags if allow_opt_inputs then - if ImGui.RadioButtonEx("RGB", bit32.band(opts, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]]) ~= 0) then + if ImGui_RadioButtonEx("RGB", bit32.band(opts, 1048576 --[[ImGuiColorEditFlags.DisplayRGB]]) ~= 0) then opts = bit32.bor(bit32.band(opts, bit32.bnot(7340032 --[[ImGuiColorEditFlags.DisplayMask_]])), 1048576 --[[ImGuiColorEditFlags.DisplayRGB]]) end - if ImGui.RadioButtonEx("HSV", bit32.band(opts, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]]) ~= 0) then + if ImGui_RadioButtonEx("HSV", bit32.band(opts, 2097152 --[[ImGuiColorEditFlags.DisplayHSV]]) ~= 0) then opts = bit32.bor(bit32.band(opts, bit32.bnot(7340032 --[[ImGuiColorEditFlags.DisplayMask_]])), 2097152 --[[ImGuiColorEditFlags.DisplayHSV]]) end - if ImGui.RadioButtonEx("Hex", bit32.band(opts, 4194304 --[[ImGuiColorEditFlags.DisplayHex]]) ~= 0) then + if ImGui_RadioButtonEx("Hex", bit32.band(opts, 4194304 --[[ImGuiColorEditFlags.DisplayHex]]) ~= 0) then opts = bit32.bor(bit32.band(opts, bit32.bnot(7340032 --[[ImGuiColorEditFlags.DisplayMask_]])), 4194304 --[[ImGuiColorEditFlags.DisplayHex]]) end end if allow_opt_datatype then - if allow_opt_inputs then ImGui.Separator() end - if ImGui.RadioButtonEx("0..255", bit32.band(opts, 8388608 --[[ImGuiColorEditFlags.Uint8]]) ~= 0) then + if allow_opt_inputs then ImGui_Separator() end + if ImGui_RadioButtonEx("0..255", bit32.band(opts, 8388608 --[[ImGuiColorEditFlags.Uint8]]) ~= 0) then opts = bit32.bor(bit32.band(opts, bit32.bnot(25165824 --[[ImGuiColorEditFlags.DataTypeMask_]])), 8388608 --[[ImGuiColorEditFlags.Uint8]]) end - if ImGui.RadioButtonEx("0.00..1.00", bit32.band(opts, 16777216 --[[ImGuiColorEditFlags.Float]]) ~= 0) then + if ImGui_RadioButtonEx("0.00..1.00", bit32.band(opts, 16777216 --[[ImGuiColorEditFlags.Float]]) ~= 0) then opts = bit32.bor(bit32.band(opts, bit32.bnot(25165824 --[[ImGuiColorEditFlags.DataTypeMask_]])), 16777216 --[[ImGuiColorEditFlags.Float]]) end end if allow_opt_inputs or allow_opt_datatype then - ImGui.Separator() + ImGui_Separator() end if ImGui.Button("Copy as..", ImVec2(-1, 0)) then - ImGui.OpenPopup("Copy") + ImGui_OpenPopup("Copy") end - if ImGui.BeginPopup("Copy") then + if ImGui_BeginPopup("Copy") then local cr = IM_F32_TO_INT8_SAT(col[1]) local cg = IM_F32_TO_INT8_SAT(col[2]) local cb = IM_F32_TO_INT8_SAT(col[3]) local ca = (bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0) and 255 or IM_F32_TO_INT8_SAT(col[4]) local buf1 = ImFormatString("(%.3ff, %.3ff, %.3ff, %.3ff)", col[1], col[2], col[3], (bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0) and 1.0 or col[4]) - if ImGui.Selectable(buf1) then - ImGui.SetClipboardText(buf1) + if ImGui_Selectable(buf1) then + ImGui_SetClipboardText(buf1) end local buf2 = ImFormatString("(%d,%d,%d,%d)", cr, cg, cb, ca) - if ImGui.Selectable(buf2) then - ImGui.SetClipboardText(buf2) + if ImGui_Selectable(buf2) then + ImGui_SetClipboardText(buf2) end local buf3 = ImFormatString("#%02X%02X%02X", cr, cg, cb) - if ImGui.Selectable(buf3) then - ImGui.SetClipboardText(buf3) + if ImGui_Selectable(buf3) then + ImGui_SetClipboardText(buf3) end if bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) == 0 then local buf4 = ImFormatString("#%02X%02X%02X%02X", cr, cg, cb, ca) - if ImGui.Selectable(buf4) then - ImGui.SetClipboardText(buf4) + if ImGui_Selectable(buf4) then + ImGui_SetClipboardText(buf4) end end - ImGui.EndPopup() + ImGui_EndPopup() end g.IO.ConfigColorEditFlags = opts - ImGui.PopItemFlag() - ImGui.EndPopup() + ImGui_PopItemFlag() + ImGui_EndPopup() end --- @param ref_col float[] @@ -72657,21 +73340,21 @@ function ImGui.ColorPickerOptionsPopup(ref_col, flags) local allow_opt_picker = bit32.band(flags, 100663296 --[[ImGuiColorEditFlags.PickerMask_]]) == 0 local allow_opt_alpha_bar = (bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) == 0) and (bit32.band(flags, 262144 --[[ImGuiColorEditFlags.AlphaBar]]) == 0) - if (not allow_opt_picker and not allow_opt_alpha_bar) or not ImGui.BeginPopup("context") then + if (not allow_opt_picker and not allow_opt_alpha_bar) or not ImGui_BeginPopup("context") then return end local g = GImGui - ImGui.PushItemFlag(65536 --[[ImGuiItemFlags.NoMarkEdited]], true) + ImGui_PushItemFlag(65536 --[[ImGuiItemFlags.NoMarkEdited]], true) if allow_opt_picker then - local picker_size = ImVec2(g.FontSize * 8, ImMax(g.FontSize * 8 - (ImGui.GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0)) -- FIXME: Picker size copied from main picker function + local picker_size = ImVec2(g.FontSize * 8, ImMax(g.FontSize * 8 - (ImGui_GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0)) -- FIXME: Picker size copied from main picker function ImGui.PushItemWidth(picker_size.x) for picker_type = 0, 1 do -- Draw small/thumbnail version of each picker type (over an invisible button for selection) if picker_type > 0 then - ImGui.Separator() + ImGui_Separator() end - ImGui.PushID(picker_type) + ImGui_PushID(picker_type) local picker_flags = bit32.bor(32 --[[ImGuiColorEditFlags.NoInputs]], 8 --[[ImGuiColorEditFlags.NoOptions]], 128 --[[ImGuiColorEditFlags.NoLabel]], 256 --[[ImGuiColorEditFlags.NoSidePreview]], bit32.band(flags, 2 --[[ImGuiColorEditFlags.NoAlpha]])) if picker_type == 0 then picker_flags = bit32.bor(picker_flags, 33554432 --[[ImGuiColorEditFlags.PickerHueBar]]) @@ -72680,27 +73363,27 @@ function ImGui.ColorPickerOptionsPopup(ref_col, flags) picker_flags = bit32.bor(picker_flags, 67108864 --[[ImGuiColorEditFlags.PickerHueWheel]]) end local backup_pos = ImGui.GetCursorScreenPos() - if ImGui.Selectable("##selectable", false, 0, picker_size) then -- By default, Selectable() is closing popup + if ImGui_Selectable("##selectable", false, 0, picker_size) then -- By default, Selectable() is closing popup g.IO.ConfigColorEditFlags = bit32.bor(bit32.band(g.IO.ConfigColorEditFlags, bit32.bnot(100663296 --[[ImGuiColorEditFlags.PickerMask_]])), bit32.band(picker_flags, 100663296 --[[ImGuiColorEditFlags.PickerMask_]])) end - ImGui.SetCursorScreenPos(backup_pos) + ImGui_SetCursorScreenPos(backup_pos) local previewing_ref_col = ImVec4() for i = 1, (bit32.band(picker_flags, 2 --[[ImGuiColorEditFlags.NoAlpha]]) ~= 0 and 3 or 4) do previewing_ref_col[i] = ref_col[i] end - ImGui.ColorPicker4("##previewing_picker", previewing_ref_col, picker_flags) - ImGui.PopID() + ImGui_ColorPicker4("##previewing_picker", previewing_ref_col, picker_flags) + ImGui_PopID() end - ImGui.PopItemWidth() + ImGui_PopItemWidth() end if allow_opt_alpha_bar then if allow_opt_picker then - ImGui.Separator() + ImGui_Separator() end _, g.IO.ConfigColorEditFlags = ImGui.CheckboxFlags("Alpha Bar", g.IO.ConfigColorEditFlags, 262144 --[[ImGuiColorEditFlags.AlphaBar]]) end - ImGui.PopItemFlag() - ImGui.EndPopup() + ImGui_PopItemFlag() + ImGui_EndPopup() end ------------------------------------------------------------------------------- @@ -72742,7 +73425,7 @@ function ImGui.TreeNode(label, fmt, ...) if fmt ~= nil then return ImGui.TreeNodeEx(label, 0, fmt, ...) end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -72762,7 +73445,7 @@ function ImGui.TreeNodeEx(label, flags, fmt, ...) if fmt ~= nil then return ImGui.TreeNodeExV(label, flags, fmt, ...) end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -72772,7 +73455,7 @@ end --- @param str_id string|ImGuiID function ImGui.TreeNodeExV(str_id, flags, fmt, ...) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -72877,7 +73560,7 @@ local function TreeNode_tmp_pos(x, y) local v = TreeNode_tmp; v.x = x; v.y = y; @native function ImGui.TreeNodeBehavior(id, flags, label, label_end) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -72897,10 +73580,10 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) end if label_end == nil then - label_end = ImGui.FindRenderedTextEnd(label) + label_end = ImGui_FindRenderedTextEnd(label) end local label_size = TreeNode_label_size -- [Luau] scratch: only read below (RenderTextClipped text_size_if_known) - label_size.x, label_size.y = ImGui.CalcTextSizeXY(label, 1, label_end, false) + label_size.x, label_size.y = ImGui_CalcTextSizeXY(label, 1, label_end, false) local text_offset_x = g.FontSize + (display_frame and (padding_x * 3) or (padding_x * 2)) -- Collapsing arrow width + Spacing local text_offset_y = use_frame_padding and ImMax(style.FramePadding.y, window.DC.CurrLineTextBaseOffset) or window.DC.CurrLineTextBaseOffset -- Latch before ItemSize changes it @@ -72964,7 +73647,7 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) if bit32.band(flags, 8 --[[ImGuiTreeNodeFlags.NoTreePushOnOpen]]) == 0 then store_tree_node_stack_data = draw_tree_lines if bit32.band(flags, 131072 --[[ImGuiTreeNodeFlags.NavLeftJumpsToParent]]) ~= 0 and not g.NavIdIsAlive then - if g.NavMoveDir == 0 --[[ImGuiDir.Left]] and g.NavWindow == window and ImGui.NavMoveRequestButNoResultYet() then + if g.NavMoveDir == 0 --[[ImGuiDir.Left]] and g.NavWindow == window and ImGui_NavMoveRequestButNoResultYet() then store_tree_node_stack_data = true end end @@ -73041,7 +73724,7 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) -- Multi-selection support (header) if is_multi_select then -- Handle multi-select + alter button flags for it - selected, button_flags = ImGui.MultiSelectItemHeader(id, selected, button_flags) + selected, button_flags = ImGui_MultiSelectItemHeader(id, selected, button_flags) if is_mouse_x_over_arrow then button_flags = bit32.band(bit32.bor(button_flags, 16 --[[ImGuiButtonFlags.PressedOnClick]]), bit32.bnot(32 --[[ImGuiButtonFlags.PressedOnClickRelease]])) end @@ -73051,7 +73734,7 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) end end - local pressed, hovered, held = ImGui.ButtonBehavior(interact_bb, id, button_flags) + local pressed, hovered, held = ImGui_ButtonBehavior(interact_bb, id, button_flags) local toggled = false if not is_leaf then if pressed and g.DragDropHoldJustPressedId ~= id then @@ -73076,12 +73759,12 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) if g.NavId == id and g.NavMoveDir == 0 --[[ImGuiDir.Left]] and is_open then toggled = true ImGui.NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) - ImGui.NavMoveRequestCancel() + ImGui_NavMoveRequestCancel() end if g.NavId == id and g.NavMoveDir == 1 --[[ImGuiDir.Right]] and not is_open then -- If there's something upcoming on the line we may want to give it the priority? toggled = true ImGui.NavClearPreferredPosForAxis(1 --[[ImGuiAxis.X]]) - ImGui.NavMoveRequestCancel() + ImGui_NavMoveRequestCancel() end if toggled then @@ -73094,9 +73777,9 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) -- Multi-selection support (footer) if is_multi_select then local pressed_copy = pressed and not toggled - selected, pressed_copy = ImGui.MultiSelectItemFooter(id, selected, pressed_copy) + selected, pressed_copy = ImGui_MultiSelectItemFooter(id, selected, pressed_copy) if pressed then - ImGui.SetNavID(id, window.DC.NavLayerCurrent, g.CurrentFocusScopeId, interact_bb) + ImGui_SetNavID(id, window.DC.NavLayerCurrent, g.CurrentFocusScopeId, interact_bb) end end @@ -73106,23 +73789,23 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) -- Render do - local text_col = ImGui.GetColorU32(0 --[[ImGuiCol.Text]]) + local text_col = ImGui_GetColorU32(0 --[[ImGuiCol.Text]]) local nav_render_cursor_flags = 2 --[[ImGuiNavRenderCursorFlags.Compact]] if is_multi_select then nav_render_cursor_flags = bit32.bor(nav_render_cursor_flags, 4 --[[ImGuiNavRenderCursorFlags.AlwaysDraw]]) -- Always show the nav rectangle end if display_frame then -- Framed type - local bg_col = ImGui.GetColorU32((held and hovered) and 27 --[[ImGuiCol.HeaderActive]] or (hovered and 26 --[[ImGuiCol.HeaderHovered]] or 25 --[[ImGuiCol.Header]])) - ImGui.RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding) - ImGui.RenderNavCursor(frame_bb, id, nav_render_cursor_flags) + local bg_col = ImGui_GetColorU32((held and hovered) and 27 --[[ImGuiCol.HeaderActive]] or (hovered and 26 --[[ImGuiCol.HeaderHovered]] or 25 --[[ImGuiCol.Header]])) + ImGui_RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding) + ImGui_RenderNavCursor(frame_bb, id, nav_render_cursor_flags) if span_all_columns and not span_all_columns_label then - ImGui.TablePopBackgroundChannel() + ImGui_TablePopBackgroundChannel() end if bit32.band(flags, 512 --[[ImGuiTreeNodeFlags.Bullet]]) ~= 0 then - ImGui.RenderBullet(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x * 0.60, text_pos.y + g.FontSize * 0.5), text_col) + ImGui_RenderBullet(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x * 0.60, text_pos.y + g.FontSize * 0.5), text_col) elseif not is_leaf then - ImGui.RenderArrow(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x + padding_x, text_pos.y), text_col, is_open and ((bit32.band(flags, 536870912 --[[ImGuiTreeNodeFlags.UpsideDownArrow]]) ~= 0) and 2 --[[ImGuiDir.Up]] or 3 --[[ImGuiDir.Down]]) or 1 --[[ImGuiDir.Right]], 1.0) + ImGui_RenderArrow(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x + padding_x, text_pos.y), text_col, is_open and ((bit32.band(flags, 536870912 --[[ImGuiTreeNodeFlags.UpsideDownArrow]]) ~= 0) and 2 --[[ImGuiDir.Up]] or 3 --[[ImGuiDir.Down]]) or 1 --[[ImGuiDir.Right]], 1.0) else -- Leaf without bullet, left-adjusted text text_pos.x = text_pos.x - (text_offset_x - padding_x) end @@ -73130,25 +73813,25 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) frame_bb.Max.x = frame_bb.Max.x - (g.FontSize + style.FramePadding.x) end if g.LogEnabled then - ImGui.LogSetNextTextDecoration("###", "###") + ImGui_LogSetNextTextDecoration("###", "###") end else -- Unframed typed for tree nodes if hovered or selected then - local bg_col = ImGui.GetColorU32((held and hovered) and 27 --[[ImGuiCol.HeaderActive]] or (hovered and 26 --[[ImGuiCol.HeaderHovered]] or 25 --[[ImGuiCol.Header]])) - ImGui.RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false, 0.0) + local bg_col = ImGui_GetColorU32((held and hovered) and 27 --[[ImGuiCol.HeaderActive]] or (hovered and 26 --[[ImGuiCol.HeaderHovered]] or 25 --[[ImGuiCol.Header]])) + ImGui_RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false, 0.0) end - ImGui.RenderNavCursor(frame_bb, id, nav_render_cursor_flags, 0.0) + ImGui_RenderNavCursor(frame_bb, id, nav_render_cursor_flags, 0.0) if span_all_columns and not span_all_columns_label then - ImGui.TablePopBackgroundChannel() + ImGui_TablePopBackgroundChannel() end if bit32.band(flags, 512 --[[ImGuiTreeNodeFlags.Bullet]]) ~= 0 then - ImGui.RenderBullet(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x * 0.5, text_pos.y + g.FontSize * 0.5), text_col) + ImGui_RenderBullet(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x * 0.5, text_pos.y + g.FontSize * 0.5), text_col) elseif not is_leaf then - ImGui.RenderArrow(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x + padding_x, text_pos.y + g.FontSize * 0.15), text_col, is_open and ((bit32.band(flags, 536870912 --[[ImGuiTreeNodeFlags.UpsideDownArrow]]) ~= 0) and 2 --[[ImGuiDir.Up]] or 3 --[[ImGuiDir.Down]]) or 1 --[[ImGuiDir.Right]], 0.70) + ImGui_RenderArrow(window.DrawList, TreeNode_tmp_pos(text_pos.x - text_offset_x + padding_x, text_pos.y + g.FontSize * 0.15), text_col, is_open and ((bit32.band(flags, 536870912 --[[ImGuiTreeNodeFlags.UpsideDownArrow]]) ~= 0) and 2 --[[ImGuiDir.Up]] or 3 --[[ImGuiDir.Down]]) or 1 --[[ImGuiDir.Right]], 0.70) end if g.LogEnabled then - ImGui.LogSetNextTextDecoration(">", nil) + ImGui_LogSetNextTextDecoration(">", nil) end end @@ -73158,13 +73841,13 @@ function ImGui.TreeNodeBehavior(id, flags, label, label_end) -- Label if display_frame then - ImGui.RenderTextClipped(text_pos, frame_bb.Max, label, label_end, label_size) + ImGui_RenderTextClipped(text_pos, frame_bb.Max, label, label_end, label_size) else - ImGui.RenderText(text_pos, label, 1, label_end, false) + ImGui_RenderText(text_pos, label, 1, label_end, false) end if span_all_columns_label then - ImGui.TablePopBackgroundChannel() + ImGui_TablePopBackgroundChannel() end end @@ -73206,12 +73889,12 @@ function ImGui.TreeNodeDrawLineToChildNode(target_pos) if x1 < x2 then window.DrawList:PathLineTo(ImVec2(x2, y)) end - window.DrawList:PathStroke(ImGui.GetColorU32(55 --[[ImGuiCol.TreeLines]]), g.Style.TreeLinesSize) + window.DrawList:PathStroke(ImGui_GetColorU32(55 --[[ImGuiCol.TreeLines]]), g.Style.TreeLinesSize) else -- We use AddLine() instead of AddLineH() as we provide coordinates for line center, -- in order to make the code use same coordinates for both rounded and non-rounded version. (FIXME-OPT) x1 = x1 + half_size -- Avoid overdraw - window.DrawList:AddLine(ImVec2(x1, y), ImVec2(x2, y), ImGui.GetColorU32(55 --[[ImGuiCol.TreeLines]]), g.Style.TreeLinesSize) + window.DrawList:AddLine(ImVec2(x1, y), ImVec2(x2, y), ImGui_GetColorU32(55 --[[ImGuiCol.TreeLines]]), g.Style.TreeLinesSize) end end @@ -73242,7 +73925,7 @@ function ImGui.TreeNodeDrawLineToTreePop(data) end -- We use AddLine() instead of AddLineV() as we provide coordinates for line center (FIXME-OPT) - window.DrawList:AddLine(ImVec2(x, y1), ImVec2(x, y2), ImGui.GetColorU32(55 --[[ImGuiCol.TreeLines]]), g.Style.TreeLinesSize) + window.DrawList:AddLine(ImVec2(x, y1), ImVec2(x, y2), ImGui_GetColorU32(55 --[[ImGuiCol.TreeLines]]), g.Style.TreeLinesSize) if data.DrawLinesTableColumn ~= -1 then ImGui.TablePopColumnChannel() end @@ -73250,10 +73933,10 @@ end --- @param str_id string|ImGuiID function ImGui.TreePush(str_id) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() ImGui.Indent() window.DC.TreeDepth = window.DC.TreeDepth + 1 - ImGui.PushID(str_id) + ImGui_PushID(str_id) end --- @param id ImGuiID @@ -73263,7 +73946,7 @@ function ImGui.TreePushOverrideID(id) local window = g.CurrentWindow ImGui.Indent() window.DC.TreeDepth = window.DC.TreeDepth + 1 - ImGui.PushOverrideID(id) + ImGui_PushOverrideID(id) end @native @@ -73281,7 +73964,7 @@ function ImGui.TreePop() -- Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags.NavLeftJumpsToParent is enabled) if bit32.band(data.TreeFlags, 131072 --[[ImGuiTreeNodeFlags.NavLeftJumpsToParent]]) ~= 0 then - if g.NavIdIsAlive and g.NavMoveDir == 0 --[[ImGuiDir.Left]] and g.NavWindow == window and ImGui.NavMoveRequestButNoResultYet() then + if g.NavIdIsAlive and g.NavMoveDir == 0 --[[ImGuiDir.Left]] and g.NavWindow == window and ImGui_NavMoveRequestButNoResultYet() then ImGui.NavMoveRequestResolveWithPastTreeNode(g.NavMoveResultLocal, data) end end @@ -73297,7 +73980,7 @@ function ImGui.TreePop() end assert(window.IDStack.Size > 1) -- There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much. - ImGui.PopID() + ImGui_PopID() end -- Set next TreeNode/CollapsingHeader open state. @@ -73348,7 +74031,7 @@ function ImGui.CollapsingHeader(label, a, b) if type(a) == "boolean" then p_visible, flags = a, b else flags = a end if flags == nil then flags = 0 end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false, p_visible end @@ -73399,13 +74082,15 @@ end --- @param size_arg? any --- @return bool is_pressed --- @return bool is_selected # Updated `selected` +-- [Luau] scratch for Selectable(): only read by its callees (ItemAdd() copies bb), never escape +local Selectable_label_size, Selectable_size, Selectable_pos, Selectable_pos_max, Selectable_bb = ImVec2(), ImVec2(), ImVec2(), ImVec2(), ImRect() @native function ImGui.Selectable(label, selected, flags, size_arg) if selected == nil then selected = false end if flags == nil then flags = 0 end if size_arg == nil then size_arg = LAYOUT_ZERO_SIZE end -- [Luau] shared read-only default (only read below) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if (window.SkipItems) then return false, selected end @@ -73415,11 +74100,14 @@ function ImGui.Selectable(label, selected, flags, size_arg) -- Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle. local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) - local size = ImVec2((size_arg.x ~= 0.0) and size_arg.x or label_size.x, (size_arg.y ~= 0.0) and size_arg.y or label_size.y) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = Selectable_label_size + label_size.x, label_size.y = ImGui_CalcTextSizeXY(label, 1, label_end, false) + local size = Selectable_size + size.x = (size_arg.x ~= 0.0) and size_arg.x or label_size.x + size.y = (size_arg.y ~= 0.0) and size_arg.y or label_size.y - local pos = ImVec2() + local pos = Selectable_pos ImVec2_Copy(pos, window.DC.CursorPos) pos.y = pos.y + window.DC.CurrLineTextBaseOffset @@ -73436,7 +74124,8 @@ function ImGui.Selectable(label, selected, flags, size_arg) -- Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable. -- FIXME: Not part of layout so not included in clipper calculation, but ItemSize currently doesn't allow offsetting CursorPos. - local bb = ImRect(min_x, pos.y, min_x + size.x, pos.y + size.y) + local bb = Selectable_bb + bb.Min.x = min_x; bb.Min.y = pos.y; bb.Max.x = min_x + size.x; bb.Max.y = pos.y + size.y if bit32.band(flags, 67108864 --[[ImGuiSelectableFlags.NoPadWithHalfSpacing]]) == 0 then local spacing_x = span_all_columns and 0.0 or style.ItemSpacing.x local spacing_y = style.ItemSpacing.y @@ -73481,7 +74170,7 @@ function ImGui.Selectable(label, selected, flags, size_arg) local disabled_global = bit32.band(g.CurrentItemFlags, 64 --[[ImGuiItemFlags.Disabled]]) ~= 0 if disabled_item and not disabled_global then -- Only testing this as an optimization - ImGui.BeginDisabled() + ImGui_BeginDisabled() end -- FIXME: We can standardize the behavior of those two, we could also keep the fast path of override ClipRect + full push on render only, @@ -73510,15 +74199,15 @@ function ImGui.Selectable(label, selected, flags, size_arg) local was_selected = selected if is_multi_select then -- Handle multi-select + alter button flags for it - selected, button_flags = ImGui.MultiSelectItemHeader(id, selected, button_flags) + selected, button_flags = ImGui_MultiSelectItemHeader(id, selected, button_flags) end - local pressed, hovered, held = ImGui.ButtonBehavior(bb, id, button_flags) + local pressed, hovered, held = ImGui_ButtonBehavior(bb, id, button_flags) local auto_selected = false -- Multi-selection support (footer) if is_multi_select then - selected, pressed = ImGui.MultiSelectItemFooter(id, selected, pressed) + selected, pressed = ImGui_MultiSelectItemFooter(id, selected, pressed) else -- Auto-select when moved into -- - This will be more fully fleshed in the range-select branch @@ -73539,14 +74228,14 @@ function ImGui.Selectable(label, selected, flags, size_arg) -- Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with keyboard/gamepad if pressed or (hovered and bit32.band(flags, 33554432 --[[ImGuiSelectableFlags.SetNavIdOnHover]]) ~= 0) then if not g.NavHighlightItemUnderNav and g.NavWindow == window and g.NavLayer == window.DC.NavLayerCurrent then - ImGui.SetNavID(id, window.DC.NavLayerCurrent, g.CurrentFocusScopeId, ImGui.WindowRectAbsToRel(window, bb)) -- (bb == NavRect) + ImGui_SetNavID(id, window.DC.NavLayerCurrent, g.CurrentFocusScopeId, ImGui.WindowRectAbsToRel(window, bb)) -- (bb == NavRect) if g.IO.ConfigNavCursorVisibleAuto then g.NavCursorVisible = false end end end if pressed then - ImGui.MarkItemEdited(id) + ImGui_MarkItemEdited(id) end if selected ~= was_selected then @@ -73565,13 +74254,13 @@ function ImGui.Selectable(label, selected, flags, size_arg) -- Between 1.91.0 and 1.91.4 we made selected Selectable use an arbitrary lerp between _Header and _HeaderHovered. Removed that now. (#8106) local col if held and highlighted then - col = ImGui.GetColorU32(27 --[[ImGuiCol.HeaderActive]]) + col = ImGui_GetColorU32(27 --[[ImGuiCol.HeaderActive]]) elseif highlighted then - col = ImGui.GetColorU32(26 --[[ImGuiCol.HeaderHovered]]) + col = ImGui_GetColorU32(26 --[[ImGuiCol.HeaderHovered]]) else - col = ImGui.GetColorU32(25 --[[ImGuiCol.Header]]) + col = ImGui_GetColorU32(25 --[[ImGuiCol.Header]]) end - ImGui.RenderFrame(bb.Min, bb.Max, col, false, style.SelectableRounding) + ImGui_RenderFrame(bb.Min, bb.Max, col, false, style.SelectableRounding) end if g.NavId == id then @@ -73579,13 +74268,13 @@ function ImGui.Selectable(label, selected, flags, size_arg) if is_multi_select then nav_render_cursor_flags = bit32.bor(nav_render_cursor_flags, 4 --[[ImGuiNavRenderCursorFlags.AlwaysDraw]]) -- Always show the nav rectangle end - ImGui.RenderNavCursor(bb, id, nav_render_cursor_flags, style.SelectableRounding) + ImGui_RenderNavCursor(bb, id, nav_render_cursor_flags, style.SelectableRounding) end end if span_all_columns then if g.CurrentTable then - ImGui.TablePopBackgroundChannel() + ImGui_TablePopBackgroundChannel() elseif window.DC.CurrentColumns then ImGui.PopColumnsBackground() end @@ -73593,7 +74282,9 @@ function ImGui.Selectable(label, selected, flags, size_arg) -- Text stays at the submission position. Alignment/clipping extents ignore SpanAllColumns. if is_visible then - ImGui.RenderTextClipped(pos, ImVec2(ImMin(pos.x + size.x, window.WorkRect.Max.x), pos.y + size.y), label, label_end, label_size, style.SelectableTextAlign, bb) + local pos_max = Selectable_pos_max + pos_max.x = ImMin(pos.x + size.x, window.WorkRect.Max.x); pos_max.y = pos.y + size.y + ImGui_RenderTextClipped(pos, pos_max, label, label_end, label_size, style.SelectableTextAlign, bb) end -- Automatically close popups @@ -73602,7 +74293,7 @@ function ImGui.Selectable(label, selected, flags, size_arg) end if disabled_item and not disabled_global then - ImGui.EndDisabled() + ImGui_EndDisabled() end -- Selectable() always returns a pressed state! @@ -73646,8 +74337,8 @@ function ImGui.GetTypingSelectRequest(flags) clear_buffer = clear_buffer or (data.LastRequestTime + TYPING_SELECT_RESET_TIMER < g.Time) clear_buffer = clear_buffer or g.NavAnyRequest clear_buffer = clear_buffer or (g.ActiveId ~= 0 and g.NavActivateId == 0) -- Allow temporary SPACE activation to not interfere - clear_buffer = clear_buffer or ImGui.IsKeyPressed(526 --[[ImGuiKey.Escape]]) or ImGui.IsKeyPressed(525 --[[ImGuiKey.Enter]]) - clear_buffer = clear_buffer or (ImGui.IsKeyPressed(523 --[[ImGuiKey.Backspace]]) and bit32.band(flags, 1 --[[ImGuiTypingSelectFlags.AllowBackspace]]) == 0) + clear_buffer = clear_buffer or ImGui_IsKeyPressed(526 --[[ImGuiKey.Escape]]) or ImGui_IsKeyPressed(525 --[[ImGuiKey.Enter]]) + clear_buffer = clear_buffer or (ImGui_IsKeyPressed(523 --[[ImGuiKey.Backspace]]) and bit32.band(flags, 1 --[[ImGuiTypingSelectFlags.AllowBackspace]]) == 0) --if clear_buffer then IMGUI_DEBUG_LOG("GetTypingSelectRequest(): Clear SearchBuffer.\n") end if clear_buffer then data:Clear() @@ -73767,7 +74458,7 @@ function ImGui.TypingSelectFindMatch(req, items_count, get_item_name_func, user_ idx = ImGui.TypingSelectFindBestLeadingMatch(req, items_count, get_item_name_func, user_data) end if idx ~= -1 then - ImGui.SetNavCursorVisibleAfterMove() + ImGui_SetNavCursorVisibleAfterMove() end return idx end @@ -73823,9 +74514,9 @@ end --- @param data ImGuiTypingSelectState function ImGui.DebugNodeTypingSelectState(data) - ImGui.Text("SearchBuffer = \"%s\"", data.SearchBuffer) - ImGui.Text("SingleCharMode = %d, Size = %d, Lock = %d", data.Request.SingleCharMode and 1 or 0, data.Request.SingleCharSize, data.SingleCharModeLock and 1 or 0) - ImGui.Text("LastRequest = time: %.2f, frame: %d", data.LastRequestTime, data.LastRequestFrame) + ImGui_Text("SearchBuffer = \"%s\"", data.SearchBuffer) + ImGui_Text("SingleCharMode = %d, Size = %d, Lock = %d", data.Request.SingleCharMode and 1 or 0, data.Request.SingleCharSize, data.SingleCharModeLock and 1 or 0) + ImGui_Text("LastRequest = time: %.2f, frame: %d", data.LastRequestTime, data.LastRequestFrame) end ------------------------------------------------------------------------------- @@ -73863,7 +74554,7 @@ local function BoxSelectActivateDrag(bs, window) bs.IsActive = true bs.Window = window bs.IsStarting = false - ImGui.SetActiveID(bs.ID, window) + ImGui_SetActiveID(bs.ID, window) ImGui.SetActiveIdUsingAllKeyboardKeys() if bs.IsStartedFromVoid and bit32.band(bs.KeyMods, bit32.bor(4096 --[[ImGuiMod_Ctrl]], 8192 --[[ImGuiMod_Shift]])) == 0 then bs.RequestClear = true @@ -73875,7 +74566,7 @@ local function BoxSelectDeactivateDrag(bs) bs.IsActive = false; bs.IsStarting = false if g.ActiveId == bs.ID then IMGUI_DEBUG_LOG_SELECTION("[selection] BeginBoxSelect() 0X%08X: Deactivate\n", bs.ID) - ImGui.ClearActiveID() + ImGui_ClearActiveID() end bs.ID = 0 end @@ -73905,7 +74596,7 @@ local function BoxSelectScrollWithMouseDrag(bs, window, inner_r) if n == 1 then ImGui.SetScrollX(window, scroll_curr + scroll_step_i) else - ImGui.SetScrollY(window, scroll_curr + scroll_step_i) + ImGui_SetScrollY(window, scroll_curr + scroll_step_i) end bs.ScrollAccum[k] = bs.ScrollAccum[k] - scroll_step_i until true @@ -73920,7 +74611,7 @@ end function ImGui.BeginBoxSelect(scope_rect, window, box_select_id, ms_flags) local g = GImGui local bs = g.BoxSelectState - ImGui.KeepAliveID(box_select_id) + ImGui_KeepAliveID(box_select_id) if bs.ID ~= box_select_id then return false end @@ -73928,7 +74619,7 @@ function ImGui.BeginBoxSelect(scope_rect, window, box_select_id, ms_flags) -- IsStarting is set by MultiSelectItemFooter() when considering a possible box-select. We validate it here and lock geometry. bs.UnclipMode = false bs.RequestClear = false - if bs.IsStarting and ImGui.IsMouseDragPastThreshold(0) then + if bs.IsStarting and ImGui_IsMouseDragPastThreshold(0) then BoxSelectActivateDrag(bs, window) elseif (bs.IsStarting or bs.IsActive) and g.IO.MouseDown[0] == false then BoxSelectDeactivateDrag(bs) @@ -74025,8 +74716,8 @@ function ImGui.EndBoxSelect(scope_rect, ms_flags) local box_select_r = ImRect(bs.BoxSelectRectCurr.Min, bs.BoxSelectRectCurr.Max) box_select_r:ClipWith(scope_rect) local draw_window = ImGui.FindFrontMostVisibleChildWindow(window) - draw_window.DrawList:AddRectFilled(box_select_r.Min, box_select_r.Max, ImGui.GetColorU32(29 --[[ImGuiCol.SeparatorHovered]], 0.30)) -- FIXME-MULTISELECT: Styling - draw_window.DrawList:AddRect(box_select_r.Min, box_select_r.Max, ImGui.GetColorU32(59 --[[ImGuiCol.NavCursor]])) -- FIXME-MULTISELECT FIXME-DPI: Styling + draw_window.DrawList:AddRectFilled(box_select_r.Min, box_select_r.Max, ImGui_GetColorU32(29 --[[ImGuiCol.SeparatorHovered]], 0.30)) -- FIXME-MULTISELECT: Styling + draw_window.DrawList:AddRect(box_select_r.Min, box_select_r.Max, ImGui_GetColorU32(59 --[[ImGuiCol.NavCursor]])) -- FIXME-MULTISELECT FIXME-DPI: Styling -- Scroll local enable_scroll = bit32.band(ms_flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) ~= 0 and bit32.band(ms_flags, 256 --[[ImGuiMultiSelectFlags.BoxSelectNoScroll]]) == 0 @@ -74206,7 +74897,7 @@ function ImGui.BeginMultiSelect(flags, selection_size, items_count) -- - Box select also handle Escape and needs to pass an id to bypass ActiveIdUsingAllKeyboardKeys lock. if bit32.band(flags, 512 --[[ImGuiMultiSelectFlags.ClearOnEscape]]) ~= 0 then if selection_size ~= 0 or bs.IsActive then - if ImGui.Shortcut(526 --[[ImGuiKey.Escape]], 0 --[[ImGuiInputFlags.None]], bs.IsActive and bs.ID or 0) then + if ImGui_Shortcut(526 --[[ImGuiKey.Escape]], 0 --[[ImGuiInputFlags.None]], bs.IsActive and bs.ID or 0) then request_clear = true if bs.IsActive then BoxSelectDeactivateDrag(bs) @@ -74217,14 +74908,14 @@ function ImGui.BeginMultiSelect(flags, selection_size, items_count) -- Shortcut: Select all (Ctrl+A) if bit32.band(flags, 1 --[[ImGuiMultiSelectFlags.SingleSelect]]) == 0 and bit32.band(flags, 2 --[[ImGuiMultiSelectFlags.NoSelectAll]]) == 0 then - if ImGui.Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 546 --[[ImGuiKey.A]])) then + if ImGui_Shortcut(bit32.bor(4096 --[[ImGuiMod_Ctrl]], 546 --[[ImGuiKey.A]])) then request_select_all = true end end end if request_clear or request_select_all then - ImGui.MultiSelectAddSetAll(ms, request_select_all) + ImGui_MultiSelectAddSetAll(ms, request_select_all) if not request_select_all then storage.LastSelectionSize = 0 end @@ -74285,17 +74976,17 @@ function ImGui.EndMultiSelect() if bit32.band(ms.Flags, bit32.bor(64 --[[ImGuiMultiSelectFlags.BoxSelect1d]], 128 --[[ImGuiMultiSelectFlags.BoxSelect2d]])) ~= 0 then if not g.BoxSelectState.IsActive and not g.BoxSelectState.IsStarting and g.IO.MouseClickedCount[0] == 1 then BoxSelectPreStartDrag(ms.BoxSelectId, (-1) --[[ImGuiSelectionUserData_Invalid]]) - ImGui.FocusWindow(window, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) + ImGui_FocusWindow(window, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) ImGui.SetHoveredID(ms.BoxSelectId) if bit32.band(ms.Flags, 4096 --[[ImGuiMultiSelectFlags.ScopeRect]]) ~= 0 then - ImGui.SetNavID(0, 0 --[[ImGuiNavLayer.Main]], ms.FocusScopeId, ImRect(g.IO.MousePos.x, g.IO.MousePos.y, g.IO.MousePos.x, g.IO.MousePos.y)) -- Automatically switch FocusScope for initial click from void to box-select. + ImGui_SetNavID(0, 0 --[[ImGuiNavLayer.Main]], ms.FocusScopeId, ImRect(g.IO.MousePos.x, g.IO.MousePos.y, g.IO.MousePos.x, g.IO.MousePos.y)) -- Automatically switch FocusScope for initial click from void to box-select. end end end if bit32.band(ms.Flags, 1024 --[[ImGuiMultiSelectFlags.ClearOnClickVoid]]) ~= 0 then - if ImGui.IsMouseReleased(0) and ImGui.IsMouseDragPastThreshold(0) == false and g.IO.KeyMods == 0 --[[ImGuiMod_None]] then - ImGui.MultiSelectAddSetAll(ms, false) + if ImGui_IsMouseReleased(0) and ImGui_IsMouseDragPastThreshold(0) == false and g.IO.KeyMods == 0 --[[ImGuiMod_None]] then + ImGui_MultiSelectAddSetAll(ms, false) end end end @@ -74303,7 +74994,7 @@ function ImGui.EndMultiSelect() -- Courtesy nav wrapping helper flag if bit32.band(ms.Flags, 65536 --[[ImGuiMultiSelectFlags.NavWrapX]]) ~= 0 then assert(bit32.band(ms.Flags, 2048 --[[ImGuiMultiSelectFlags.ScopeWindow]]) ~= 0) -- Only supported at window scope - ImGui.NavMoveRequestTryWrapping(ImGui.GetCurrentWindow(), 4 --[[ImGuiNavMoveFlags.WrapX]]) + ImGui.NavMoveRequestTryWrapping(ImGui_GetCurrentWindow(), 4 --[[ImGuiNavMoveFlags.WrapX]]) end -- Unwind @@ -74447,7 +75138,7 @@ function ImGui.MultiSelectItemFooter(id, selected, pressed, extra_flags) local hovered = false if bit32.band(g.LastItemData.StatusFlags, 1 --[[ImGuiItemStatusFlags.HoveredRect]]) ~= 0 then - hovered = ImGui.IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]) + hovered = ImGui_IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]) end if not ms.IsFocused and not hovered then return selected, pressed @@ -74537,11 +75228,11 @@ function ImGui.MultiSelectItemFooter(id, selected, pressed, extra_flags) -- Right-click handling. -- FIXME-MULTISELECT: Maybe should be moved to Selectable()? Also see #5816, #8200, #9015 - if hovered and ImGui.IsMouseClicked(1) and bit32.band(flags, bit32.bor(8 --[[ImGuiMultiSelectFlags.NoAutoSelect]], 131072 --[[ImGuiMultiSelectFlags.NoSelectOnRightClick]])) == 0 then + if hovered and ImGui_IsMouseClicked(1) and bit32.band(flags, bit32.bor(8 --[[ImGuiMultiSelectFlags.NoAutoSelect]], 131072 --[[ImGuiMultiSelectFlags.NoSelectOnRightClick]])) == 0 then if g.ActiveId ~= 0 and g.ActiveId ~= id then - ImGui.ClearActiveID() + ImGui_ClearActiveID() end - ImGui.SetFocusID(id, window) + ImGui_SetFocusID(id, window) if not pressed and not selected then pressed = true is_ctrl = false; is_shift = false @@ -74590,7 +75281,7 @@ function ImGui.MultiSelectItemFooter(id, selected, pressed, extra_flags) request_clear = true -- With is_shift==false the RequestClear was done in BeginIO, not necessary to do again. end if request_clear then - ImGui.MultiSelectAddSetAll(ms, false) + ImGui_MultiSelectAddSetAll(ms, false) end end @@ -74680,16 +75371,16 @@ end --- @param storage ImGuiMultiSelectState function ImGui.DebugNodeMultiSelectState(storage) local is_active = (storage.LastFrameActive >= ImGui.GetFrameCount() - 2) -- Note that fully clipped early out scrolling tables will appear as inactive here. - if not is_active then ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImGui.GetStyleColorVec4(1 --[[ImGuiCol.TextDisabled]])) end + if not is_active then ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImGui.GetStyleColorVec4(1 --[[ImGuiCol.TextDisabled]])) end local open = ImGui.TreeNode(storage.ID, "MultiSelect 0x%08X in '%s'%s", storage.ID, storage.Window and storage.Window.Name or "N/A", is_active and "" or " *Inactive*") - if not is_active then ImGui.PopStyleColor() end + if not is_active then ImGui_PopStyleColor() end if not open then return end -- [Port] ImGuiSelectionUserData may be any Lua value: printed with tostring() instead of %lld (0x%llX) - ImGui.Text("RangeSrcItem = %s, RangeSelected = %d", tostring(storage.RangeSrcItem), storage.RangeSelected) - ImGui.Text("NavIdItem = %s, NavIdSelected = %d", tostring(storage.NavIdItem), storage.NavIdSelected) - ImGui.Text("LastSelectionSize = %d", storage.LastSelectionSize) -- Provided by user + ImGui_Text("RangeSrcItem = %s, RangeSelected = %d", tostring(storage.RangeSrcItem), storage.RangeSelected) + ImGui_Text("NavIdItem = %s, NavIdSelected = %d", tostring(storage.NavIdItem), storage.NavIdSelected) + ImGui_Text("LastSelectionSize = %d", storage.LastSelectionSize) -- Provided by user ImGui.TreePop() end @@ -74954,19 +75645,19 @@ end -- [Port] do (Typing-Select, Box-Select, Multi-Select) function ImGui.BeginListBox(label, size_arg) if size_arg == nil then size_arg = ImVec2(0, 0) end local g = GImGui - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local style = g.Style local id = ImGui.GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = ImGui_CalcTextSize(label, label_end, false) -- Size default to hold ~7.25 items. -- Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar. - local size = ImTrunc(ImGui.CalcItemSize(size_arg, ImGui.CalcItemWidth(), ImGui.GetTextLineHeightWithSpacing() * 7.25 + style.FramePadding.y * 2.0)) + local size = ImTrunc(ImGui_CalcItemSize(size_arg, ImGui_CalcItemWidth(), ImGui_GetTextLineHeightWithSpacing() * 7.25 + style.FramePadding.y * 2.0)) local frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)) local frame_bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + frame_size) local bb = ImRect(frame_bb.Min, frame_bb.Max + ImVec2((label_size.x > 0.0) and (style.ItemInnerSpacing.x + label_size.x) or 0.0, 0.0)) @@ -74980,15 +75671,15 @@ function ImGui.BeginListBox(label, size_arg) end -- FIXME-OPT: We could omit the BeginGroup() if label_size.x == 0.0f but would need to omit the EndGroup() as well. - ImGui.BeginGroup() + ImGui_BeginGroup() if label_size.x > 0.0 then local label_pos = ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y) - ImGui.RenderText(label_pos, label, 1, label_end, false) + ImGui_RenderText(label_pos, label, 1, label_end, false) ImVec2_Copy(window.DC.CursorMaxPos, ImMax(window.DC.CursorMaxPos, label_pos + label_size)) - ImGui.AlignTextToFramePadding() + ImGui_AlignTextToFramePadding() end - ImGui.BeginChild(id, frame_bb:GetSize(), 128 --[[ImGuiChildFlags.FrameStyle]]) + ImGui_BeginChild(id, frame_bb:GetSize(), 128 --[[ImGuiChildFlags.FrameStyle]]) return true end @@ -74997,8 +75688,8 @@ function ImGui.EndListBox() local window = g.CurrentWindow assert(bit32.band(window.Flags, 16777216 --[[ImGuiWindowFlags.ChildWindow]]) ~= 0, "Mismatched BeginListBox/EndListBox calls. Did you test the return value of BeginListBox?") - ImGui.EndChild() - ImGui.EndGroup() -- This is only required to be able to do IsItemXXX query on the whole ListBox including label + ImGui_EndChild() + ImGui_EndGroup() -- This is only required to be able to do IsItemXXX query on the whole ListBox including label end -- This is merely a helper around BeginListBox(), EndListBox(). @@ -75017,7 +75708,7 @@ function ImGui.ListBox(label, current_item, a, b, c, d) height_in_items = ImMin(items_count, 7) end local height_in_items_f = height_in_items + 0.25 - local size = ImVec2(0.0, ImTrunc(ImGui.GetTextLineHeightWithSpacing() * height_in_items_f + g.Style.FramePadding.y * 2.0)) + local size = ImVec2(0.0, ImTrunc(ImGui_GetTextLineHeightWithSpacing() * height_in_items_f + g.Style.FramePadding.y * 2.0)) if not ImGui.BeginListBox(label, size) then return current_item, false @@ -75027,7 +75718,7 @@ function ImGui.ListBox(label, current_item, a, b, c, d) -- you can create a custom version of ListBox() in your code without using the clipper. local value_changed = false local clipper = ImGuiListClipper() - clipper:Begin(items_count, ImGui.GetTextLineHeightWithSpacing()) -- We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to. + clipper:Begin(items_count, ImGui_GetTextLineHeightWithSpacing()) -- We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to. clipper:IncludeItemByIndex(current_item) while clipper:Step() do for i = clipper.DisplayStart, clipper.DisplayEnd - 1 do @@ -75036,22 +75727,22 @@ function ImGui.ListBox(label, current_item, a, b, c, d) item_text = "*Unknown item*" end - ImGui.PushID(i) + ImGui_PushID(i) local item_selected = (i == current_item) - if ImGui.Selectable(item_text, item_selected) then + if ImGui_Selectable(item_text, item_selected) then current_item = i value_changed = true end if item_selected then ImGui.SetItemDefaultFocus() end - ImGui.PopID() + ImGui_PopID() end end ImGui.EndListBox() if value_changed then - ImGui.MarkItemEdited(g.LastItemData.ID) + ImGui_MarkItemEdited(g.LastItemData.ID) end return current_item, value_changed @@ -75081,7 +75772,7 @@ end --- @return int function ImGui.PlotEx(plot_type, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, size_arg) local g = GImGui - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return -1 end @@ -75089,9 +75780,9 @@ function ImGui.PlotEx(plot_type, label, values_getter, data, values_count, value local style = g.Style local id = window:GetID(label) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) - local frame_size = ImGui.CalcItemSize(size_arg, ImGui.CalcItemWidth(), label_size.y + style.FramePadding.y * 2.0) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = ImGui_CalcTextSize(label, label_end, false) + local frame_size = ImGui_CalcItemSize(size_arg, ImGui_CalcItemWidth(), label_size.y + style.FramePadding.y * 2.0) local frame_bb = ImRect(window.DC.CursorPos, window.DC.CursorPos + frame_size) local inner_bb = ImRect(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding) @@ -75101,7 +75792,7 @@ function ImGui.PlotEx(plot_type, label, values_getter, data, values_count, value return -1 end - local _, hovered, _ = ImGui.ButtonBehavior(frame_bb, id) + local _, hovered, _ = ImGui_ButtonBehavior(frame_bb, id) -- Determine scale from values if not specified if scale_min == 3.4028234663853e+38 --[[FLT_MAX]] or scale_max == 3.4028234663853e+38 --[[FLT_MAX]] then @@ -75121,7 +75812,7 @@ function ImGui.PlotEx(plot_type, label, values_getter, data, values_count, value end end - ImGui.RenderFrame(frame_bb.Min, frame_bb.Max, ImGui.GetColorU32(7 --[[ImGuiCol.FrameBg]]), true, style.FrameRounding) + ImGui_RenderFrame(frame_bb.Min, frame_bb.Max, ImGui_GetColorU32(7 --[[ImGuiCol.FrameBg]]), true, style.FrameRounding) local values_count_min = (plot_type == 0 --[[ImGuiPlotType.Lines]]) and 2 or 1 local idx_hovered = -1 @@ -75139,9 +75830,9 @@ function ImGui.PlotEx(plot_type, label, values_getter, data, values_count, value local v0 = values_getter(data, (v_idx - 1 + values_offset) % values_count + 1) local v1 = values_getter(data, (v_idx - 1 + 1 + values_offset) % values_count + 1) if plot_type == 0 --[[ImGuiPlotType.Lines]] then - ImGui.SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx + 1, v1) + ImGui_SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx + 1, v1) elseif plot_type == 1 --[[ImGuiPlotType.Histogram]] then - ImGui.SetTooltip("%d: %8.4g", v_idx, v0) + ImGui_SetTooltip("%d: %8.4g", v_idx, v0) end idx_hovered = v_idx end @@ -75154,8 +75845,8 @@ function ImGui.PlotEx(plot_type, label, values_getter, data, values_count, value local tp0 = ImVec2(t0, 1.0 - ImSaturate((v0 - scale_min) * inv_scale)) -- Point in the normalized space of our target rectangle local histogram_zero_line_t = (scale_min * scale_max < 0.0) and (1 + scale_min * inv_scale) or (scale_min < 0.0 and 0.0 or 1.0) -- Where does the zero line stands - local col_base = ImGui.GetColorU32((plot_type == 0 --[[ImGuiPlotType.Lines]]) and 44 --[[ImGuiCol.PlotLines]] or 46 --[[ImGuiCol.PlotHistogram]]) - local col_hovered = ImGui.GetColorU32((plot_type == 0 --[[ImGuiPlotType.Lines]]) and 45 --[[ImGuiCol.PlotLinesHovered]] or 47 --[[ImGuiCol.PlotHistogramHovered]]) + local col_base = ImGui_GetColorU32((plot_type == 0 --[[ImGuiPlotType.Lines]]) and 44 --[[ImGuiCol.PlotLines]] or 46 --[[ImGuiCol.PlotHistogram]]) + local col_hovered = ImGui_GetColorU32((plot_type == 0 --[[ImGuiPlotType.Lines]]) and 45 --[[ImGuiCol.PlotLinesHovered]] or 47 --[[ImGuiCol.PlotHistogramHovered]]) for _ = 0, res_w - 1 do local t1 = t0 + t_step @@ -75189,11 +75880,11 @@ function ImGui.PlotEx(plot_type, label, values_getter, data, values_count, value -- Text overlay if overlay_text then - ImGui.RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, overlay_text, nil, nil, ImVec2(0.5, 0.0)) + ImGui_RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, overlay_text, nil, nil, ImVec2(0.5, 0.0)) end if label_size.x > 0.0 then - ImGui.RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label, 1, label_end, false) + ImGui_RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label, 1, label_end, false) end -- Return hovered index or -1 if none are hovered. @@ -75242,10 +75933,10 @@ function ImGui.PlotLines(label, values_or_getter, data, values_count, values_off if stride == nil then stride = 1 end if type(values_or_getter) == "function" then - ImGui.PlotEx(0 --[[ImGuiPlotType.Lines]], label, values_or_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) + ImGui_PlotEx(0 --[[ImGuiPlotType.Lines]], label, values_or_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) else data = ImGuiPlotArrayGetterData(values_or_getter, stride) - ImGui.PlotEx(0 --[[ImGuiPlotType.Lines]], label, Plot_ArrayGetter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) + ImGui_PlotEx(0 --[[ImGuiPlotType.Lines]], label, Plot_ArrayGetter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) end end @@ -75268,10 +75959,10 @@ function ImGui.PlotHistogram(label, values_or_getter, data, values_count, values if stride == nil then stride = 1 end if type(values_or_getter) == "function" then - ImGui.PlotEx(1 --[[ImGuiPlotType.Histogram]], label, values_or_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) + ImGui_PlotEx(1 --[[ImGuiPlotType.Histogram]], label, values_or_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) else data = ImGuiPlotArrayGetterData(values_or_getter, stride) - ImGui.PlotEx(1 --[[ImGuiPlotType.Histogram]], label, Plot_ArrayGetter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) + ImGui_PlotEx(1 --[[ImGuiPlotType.Histogram]], label, Plot_ArrayGetter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size) end end @@ -75341,7 +76032,7 @@ end -- Ideally we also want this to be responsible for claiming space out of the main window scrolling rectangle, in which case ImGuiWindowFlags.MenuBar will become unnecessary. -- Then later the same system could be used for multiple menu-bars, scrollbars, side-bars. function ImGui.BeginMenuBar() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -75350,8 +76041,8 @@ function ImGui.BeginMenuBar() end assert(not window.DC.MenuBarAppending) - ImGui.BeginGroup() -- Backup position on layer 0 // FIXME: Misleading to use a group for that backup/restore - ImGui.PushID("##MenuBar") + ImGui_BeginGroup() -- Backup position on layer 0 // FIXME: Misleading to use a group for that backup/restore + ImGui_PushID("##MenuBar") -- We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect. -- We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy. @@ -75360,7 +76051,7 @@ function ImGui.BeginMenuBar() local bar_rect = window:MenuBarRect() local clip_rect = ImRect(ImFloor(bar_rect.Min.x + border_half), ImFloor(bar_rect.Min.y + border_top), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window.WindowRounding, border_half))), ImFloor(bar_rect.Max.y)) clip_rect:ClipWith(window.OuterRectClipped) - ImGui.PushClipRect(clip_rect.Min, clip_rect.Max, false) + ImGui_PushClipRect(clip_rect.Min, clip_rect.Max, false) -- We overwrite CursorMaxPos because BeginGroup sets it to CursorPos (essentially the .EmitItem hack in EndMenuBar() would need something analogous here, maybe a BeginGroupEx() with flags). ImVec2_Copy(window.DC.CursorPos, ImVec2(bar_rect.Min.x + window.DC.MenuBarOffset.x, bar_rect.Min.y + window.DC.MenuBarOffset.y)) @@ -75369,13 +76060,13 @@ function ImGui.BeginMenuBar() window.DC.IsSameLine = false window.DC.NavLayerCurrent = 1 --[[ImGuiNavLayer.Menu]] window.DC.MenuBarAppending = true - ImGui.AlignTextToFramePadding() + ImGui_AlignTextToFramePadding() return true end function ImGui.EndMenuBar() - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -75385,7 +76076,7 @@ function ImGui.EndMenuBar() assert(window.DC.MenuBarAppending) -- Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings. - if ImGui.NavMoveRequestButNoResultYet() and (g.NavMoveDir == 0 --[[ImGuiDir.Left]] or g.NavMoveDir == 1 --[[ImGuiDir.Right]]) and bit32.band(g.NavWindow.Flags, 268435456 --[[ImGuiWindowFlags.ChildMenu]]) ~= 0 then + if ImGui_NavMoveRequestButNoResultYet() and (g.NavMoveDir == 0 --[[ImGuiDir.Left]] or g.NavMoveDir == 1 --[[ImGuiDir.Right]]) and bit32.band(g.NavWindow.Flags, 268435456 --[[ImGuiWindowFlags.ChildMenu]]) ~= 0 then -- Try to find out if the request is for one of our child menu local nav_earliest_child = g.NavWindow while nav_earliest_child.ParentWindow and bit32.band(nav_earliest_child.ParentWindow.Flags, 268435456 --[[ImGuiWindowFlags.ChildMenu]]) ~= 0 do @@ -75396,8 +76087,8 @@ function ImGui.EndMenuBar() -- This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth bothering) local layer = 1 --[[ImGuiNavLayer.Menu]] assert(bit32.band(window.DC.NavLayersActiveMaskNext, bit32.lshift(1, layer)) ~= 0) -- Sanity check (FIXME: Seems unnecessary) - ImGui.FocusWindow(window) - ImGui.SetNavID(window.NavLastIds[layer], layer, 0, window.NavRectRel[layer]) + ImGui_FocusWindow(window) + ImGui_SetNavID(window.NavLastIds[layer], layer, 0, window.NavRectRel[layer]) -- FIXME-NAV: How to deal with this when not using g.IO.ConfigNavCursorVisibleAuto? if g.NavCursorVisible then g.NavCursorVisible = false -- Hide nav cursor for the current frame so we don't see the intermediary selection. Will be set again @@ -75411,8 +76102,8 @@ function ImGui.EndMenuBar() ImGui.NavMoveRequestTryWrapping(window, 4 --[[ImGuiNavMoveFlags.WrapX]]) end - ImGui.PopClipRect() - ImGui.PopID() + ImGui_PopClipRect() + ImGui_PopID() window.DC.MenuBarOffset.x = window.DC.CursorPos.x - window.Pos.x -- Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos. -- FIXME: Extremely confusing, cleanup by (a) working on WorkRect stack system (b) not using a Group confusingly here. @@ -75421,7 +76112,7 @@ function ImGui.EndMenuBar() local restore_cursor_max_pos = ImVec2() ImVec2_Copy(restore_cursor_max_pos, group_data.BackupCursorMaxPos) window.DC.IdealMaxPos.x = ImMax(window.DC.IdealMaxPos.x, window.DC.CursorMaxPos.x - window.Scroll.x) -- Convert ideal extents for scrolling layer equivalent. - ImGui.EndGroup() -- Restore position on layer 0 // FIXME: Misleading to use a group for that backup/restore + ImGui_EndGroup() -- Restore position on layer 0 // FIXME: Misleading to use a group for that backup/restore window.DC.LayoutType = 1 --[[ImGuiLayoutType.Vertical]] window.DC.IsSameLine = false window.DC.NavLayerCurrent = 0 --[[ImGuiNavLayer.Main]] @@ -75440,7 +76131,7 @@ end function ImGui.BeginViewportSideBar(name, viewport_p, dir, axis_size, window_flags) assert(dir ~= (-1) --[[ImGuiDir.None]]) - local bar_window = ImGui.FindWindowByName(name) + local bar_window = ImGui_FindWindowByName(name) local viewport = viewport_p or ImGui.GetMainViewport() if bar_window == nil or bar_window.BeginCount == 0 then -- Calculate and set window size/position @@ -75452,7 +76143,7 @@ function ImGui.BeginViewportSideBar(name, viewport_p, dir, axis_size, window_fla end local size = avail_rect:GetSize() size[axis] = axis_size - ImGui.SetNextWindowPos(pos) + ImGui_SetNextWindowPos(pos) ImGui.SetNextWindowSize(size) -- Report our size into work area (for next frame) using actual window size @@ -75465,10 +76156,10 @@ function ImGui.BeginViewportSideBar(name, viewport_p, dir, axis_size, window_fla window_flags = bit32.bor(window_flags or 0, 1 --[[ImGuiWindowFlags.NoTitleBar]], 2 --[[ImGuiWindowFlags.NoResize]], 4 --[[ImGuiWindowFlags.NoMove]], 524288 --[[ImGuiWindowFlags.NoDocking]]) ImGui.SetNextWindowViewport(viewport.ID) - ImGui.PushStyleVar(3 --[[ImGuiStyleVar.WindowRounding]], 0.0) - ImGui.PushStyleVar(5 --[[ImGuiStyleVar.WindowMinSize]], ImVec2(0, 0)) -- Lift normal size constraint + ImGui_PushStyleVar(3 --[[ImGuiStyleVar.WindowRounding]], 0.0) + ImGui_PushStyleVar(5 --[[ImGuiStyleVar.WindowMinSize]], ImVec2(0, 0)) -- Lift normal size constraint local _, is_open = ImGui.Begin(name, nil, window_flags) - ImGui.PopStyleVar(2) + ImGui_PopStyleVar(2) return is_open end @@ -75485,7 +76176,7 @@ function ImGui.BeginMainMenuBar() -- FIXME: Consider removing support for safe area down the line... it's messy. Nowadays consoles have support for TV calibration in OS settings. g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0)) local window_flags = bit32.bor(8 --[[ImGuiWindowFlags.NoScrollbar]], 256 --[[ImGuiWindowFlags.NoSavedSettings]], 1024 --[[ImGuiWindowFlags.MenuBar]]) - local height = ImGui.GetFrameHeight() + local height = ImGui_GetFrameHeight() local is_open = ImGui.BeginViewportSideBar("##MainMenuBar", viewport, 2 --[[ImGuiDir.Up]], height, window_flags) g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0, 0.0) if not is_open then @@ -75544,7 +76235,7 @@ end --- @param icon? string --- @param enabled bool function ImGui.BeginMenuEx(label, icon, enabled) - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end @@ -75552,7 +76243,7 @@ function ImGui.BeginMenuEx(label, icon, enabled) local g = GImGui local style = g.Style local id = window:GetID(label) - local menu_is_open = ImGui.IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) + local menu_is_open = ImGui_IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) -- Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu) -- The first menu in a hierarchy isn't so hovering doesn't get across (otherwise e.g. resizing borders with ImGuiButtonFlags.FlattenChildren would react), but top-most BeginMenu() will bypass that limitation. @@ -75566,7 +76257,7 @@ function ImGui.BeginMenuEx(label, icon, enabled) -- If somehow this is ever becoming a problem we can switch to use e.g. ImGuiStorage mapping key to last frame used. if g.MenusIdSubmittedThisFrame:contains(id) then if menu_is_open then - menu_is_open = ImGui.BeginPopupMenuEx(id, label, window_flags) -- menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) + menu_is_open = ImGui_BeginPopupMenuEx(id, label, window_flags) -- menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) else g.NextWindowData:ClearFlags() -- we behave like Begin() and need to consume those values end @@ -75576,8 +76267,8 @@ function ImGui.BeginMenuEx(label, icon, enabled) -- Tag menu as used. Next time BeginMenu() with same ID is called it will append to existing menu g.MenusIdSubmittedThisFrame:push_back(id) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = ImGui_CalcTextSize(label, label_end, false) -- Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent without always being a Child window) -- This is only done for items for the menu set and not the full parent window. @@ -75592,9 +76283,9 @@ function ImGui.BeginMenuEx(label, icon, enabled) local popup_pos local pos = ImVec2() ImVec2_Copy(pos, window.DC.CursorPos) - ImGui.PushID(label) + ImGui_PushID(label) if not enabled then - ImGui.BeginDisabled() + ImGui_BeginDisabled() end local pressed @@ -75608,12 +76299,12 @@ function ImGui.BeginMenuEx(label, icon, enabled) -- Selectable extend their highlight by half ItemSpacing in each direction. -- For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin() window.DC.CursorPos.x = window.DC.CursorPos.x + IM_TRUNC(style.ItemSpacing.x * 0.5) - ImGui.PushStyleVarX(14 --[[ImGuiStyleVar.ItemSpacing]], style.ItemSpacing.x * 2.0) + ImGui_PushStyleVarX(14 --[[ImGuiStyleVar.ItemSpacing]], style.ItemSpacing.x * 2.0) local text_pos = ImVec2(window.DC.CursorPos.x + offsets.OffsetLabel, pos.y + window.DC.CurrLineTextBaseOffset) - pressed = ImGui.Selectable("", menu_is_open, selectable_flags, label_size) - ImGui.LogSetNextTextDecoration("[", "]") - ImGui.RenderText(text_pos, label, 1, label_end, false) - ImGui.PopStyleVar() + pressed = ImGui_Selectable("", menu_is_open, selectable_flags, label_size) + ImGui_LogSetNextTextDecoration("[", "]") + ImGui_RenderText(text_pos, label, 1, label_end, false) + ImGui_PopStyleVar() window.DC.CursorPos.x = window.DC.CursorPos.x + IM_TRUNC(style.ItemSpacing.x * (-1.0 + 0.5)) -- -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). popup_pos = ImVec2(pos.x - 1.0 - IM_TRUNC(style.ItemSpacing.x * 0.5), text_pos.y - style.FramePadding.y + window.MenuBarHeight) else @@ -75621,32 +76312,32 @@ function ImGui.BeginMenuEx(label, icon, enabled) -- (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f. -- Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.) local icon_w - if (icon and icon ~= "") then icon_w = ImGui.CalcTextSize(icon, nil).x else icon_w = 0.0 end + if (icon and icon ~= "") then icon_w = ImGui_CalcTextSize(icon, nil).x else icon_w = 0.0 end local checkmark_w = IM_TRUNC(g.FontSize * 1.20) local min_w = offsets:DeclColumns(icon_w, label_size.x, 0.0, checkmark_w) -- Feedback to next frame - local extra_w = ImMax(0.0, ImGui.GetContentRegionAvail().x - min_w) + local extra_w = ImMax(0.0, ImGui_GetContentRegionAvail().x - min_w) local text_pos = ImVec2(window.DC.CursorPos.x, pos.y + window.DC.CurrLineTextBaseOffset) - pressed = ImGui.Selectable("", menu_is_open, bit32.bor(selectable_flags, 16777216 --[[ImGuiSelectableFlags.SpanAvailWidth]]), ImVec2(min_w, label_size.y)) - ImGui.LogSetNextTextDecoration("", ">") - ImGui.RenderText(ImVec2(text_pos.x + offsets.OffsetLabel, text_pos.y), label, 1, label_end, false) + pressed = ImGui_Selectable("", menu_is_open, bit32.bor(selectable_flags, 16777216 --[[ImGuiSelectableFlags.SpanAvailWidth]]), ImVec2(min_w, label_size.y)) + ImGui_LogSetNextTextDecoration("", ">") + ImGui_RenderText(ImVec2(text_pos.x + offsets.OffsetLabel, text_pos.y), label, 1, label_end, false) if icon_w > 0.0 then --- @cast icon string - ImGui.RenderText(ImVec2(text_pos.x + offsets.OffsetIcon, text_pos.y), icon) + ImGui_RenderText(ImVec2(text_pos.x + offsets.OffsetIcon, text_pos.y), icon) end - ImGui.RenderArrow(window.DrawList, ImVec2(text_pos.x + offsets.OffsetMark + extra_w + g.FontSize * 0.30, text_pos.y), ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), 1 --[[ImGuiDir.Right]]) + ImGui_RenderArrow(window.DrawList, ImVec2(text_pos.x + offsets.OffsetMark + extra_w + g.FontSize * 0.30, text_pos.y), ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), 1 --[[ImGuiDir.Right]]) popup_pos = ImVec2(pos.x, text_pos.y - style.WindowPadding.y) end style.SelectableRounding = backup_rounding if not enabled then - ImGui.EndDisabled() + ImGui_EndDisabled() end -- Once dragged, release ActiveId + key ownership. This is to allow the idiom of mouse down a menu, dragging elsewhere, up on some other MenuItem(). (#8233, #9394) -- Could move logic into lower-level ImGuiButtonFlags.AutoReleaseActiveId + ImGuiButtonFlags.AutoReleaseKeyOwner? Easier once we get rid of the Selectable() middle-man here. - if g.ActiveId == id and g.HoveredId ~= id and g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and ImGui.IsMouseDragging(0) then - ImGui.ClearActiveID() - ImGui.SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) + if g.ActiveId == id and g.HoveredId ~= id and g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and ImGui_IsMouseDragging(0) then + ImGui_ClearActiveID() + ImGui_SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) end local hovered = g.HoveredId == id and enabled and not g.NavHighlightItemUnderNav @@ -75703,8 +76394,8 @@ function ImGui.BeginMenuEx(label, icon, enabled) if g.NavId == id and g.NavMoveDir == 1 --[[ImGuiDir.Right]] then -- Nav-Right to open want_open = true want_open_nav_init = true - ImGui.NavMoveRequestCancel() - ImGui.SetNavCursorVisibleAfterMove() + ImGui_NavMoveRequestCancel() + ImGui_SetNavCursorVisibleAfterMove() end else -- Menu bar @@ -75716,19 +76407,19 @@ function ImGui.BeginMenuEx(label, icon, enabled) want_open = true elseif g.NavId == id and g.NavMoveDir == 3 --[[ImGuiDir.Down]] then -- Nav-Down to open want_open = true - ImGui.NavMoveRequestCancel() + ImGui_NavMoveRequestCancel() end end if not enabled then -- explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }' want_close = true end - if want_close and ImGui.IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then + if want_close and ImGui_IsPopupOpen(id, 0 --[[ImGuiPopupFlags.None]]) then ImGui.ClosePopupToLevel(g.BeginPopupStack.Size, true) end -- IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0)) - ImGui.PopID() + ImGui_PopID() if g.ActiveId == id and want_open then g.ActiveIdNoClearOnFocusLoss = true @@ -75736,25 +76427,25 @@ function ImGui.BeginMenuEx(label, icon, enabled) if want_open and not menu_is_open and g.OpenPopupStack.Size > g.BeginPopupStack.Size then -- Don't reopen/recycle same menu level in the same frame if it is a different menu ID, first close the other menu and yield for a frame. - ImGui.OpenPopup(label) + ImGui_OpenPopup(label) elseif want_open then menu_is_open = true - ImGui.OpenPopup(label, 32 --[[ImGuiPopupFlags.NoReopen]]) -- | (want_open_nav_init ? ImGuiPopupFlags.NoReopenAlwaysNavInit : 0)) + ImGui_OpenPopup(label, 32 --[[ImGuiPopupFlags.NoReopen]]) -- | (want_open_nav_init ? ImGuiPopupFlags.NoReopenAlwaysNavInit : 0)) end if menu_is_open then local last_item_in_parent = ImGuiLastItemData() ImGuiLastItemData_Copy(last_item_in_parent, g.LastItemData) - ImGui.SetNextWindowPos(popup_pos, 1 --[[ImGuiCond.Always]]) -- Note: misleading: the value will serve as reference for FindBestWindowPosForPopup(), not actual pos. - ImGui.PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], style.PopupRounding) -- First level will use _PopupRounding, subsequent will use _ChildRounding - menu_is_open = ImGui.BeginPopupMenuEx(id, label, window_flags) -- menu_is_open may be 'false' when the popup is completely clipped (e.g. zero size display) - ImGui.PopStyleVar() + ImGui_SetNextWindowPos(popup_pos, 1 --[[ImGuiCond.Always]]) -- Note: misleading: the value will serve as reference for FindBestWindowPosForPopup(), not actual pos. + ImGui_PushStyleVar(7 --[[ImGuiStyleVar.ChildRounding]], style.PopupRounding) -- First level will use _PopupRounding, subsequent will use _ChildRounding + menu_is_open = ImGui_BeginPopupMenuEx(id, label, window_flags) -- menu_is_open may be 'false' when the popup is completely clipped (e.g. zero size display) + ImGui_PopStyleVar() if menu_is_open then -- Implement what ImGuiPopupFlags.NoReopenAlwaysNavInit would do: -- Perform an init request in the case the popup was already open (via a previous mouse hover) if want_open and want_open_nav_init and not g.NavInitRequest then - ImGui.FocusWindow(g.CurrentWindow, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) + ImGui_FocusWindow(g.CurrentWindow, 2 --[[ImGuiFocusRequestFlags.UnlessBelowModal]]) ImGui.NavInitWindow(g.CurrentWindow, false) end @@ -75788,15 +76479,15 @@ function ImGui.EndMenu() local parent_window = window.ParentWindow -- Should always be ~= nil is we passed assert. if window.BeginCount == window.BeginCountPreviousFrame then - if g.NavMoveDir == 0 --[[ImGuiDir.Left]] and ImGui.NavMoveRequestButNoResultYet() then + if g.NavMoveDir == 0 --[[ImGuiDir.Left]] and ImGui_NavMoveRequestButNoResultYet() then if g.NavWindow and g.NavWindow.RootWindowForNav == window and parent_window.DC.LayoutType == 1 --[[ImGuiLayoutType.Vertical]] then ImGui.ClosePopupToLevel(g.BeginPopupStack.Size - 1, true) - ImGui.NavMoveRequestCancel() + ImGui_NavMoveRequestCancel() end end end - ImGui.EndPopup() + ImGui_EndPopup() end --- @param label string @@ -75804,21 +76495,22 @@ end --- @param shortcut? string --- @param selected? bool --- @param enabled? bool +-- [Luau] scratch for MenuItemEx(): only read by its callees (Selectable() only reads size_arg), never escape +local MenuItem_text_pos, MenuItem_size, MenuItem_p = ImVec2(), ImVec2(), ImVec2() function ImGui.MenuItemEx(label, icon, shortcut, selected, enabled) if selected == nil then selected = false end if enabled == nil then enabled = true end - local window = ImGui.GetCurrentWindow() + local window = ImGui_GetCurrentWindow() if window.SkipItems then return false end local g = GImGui local style = g.Style - local pos = ImVec2() - ImVec2_Copy(pos, window.DC.CursorPos) - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local pos_x, pos_y = window.DC.CursorPos.x, window.DC.CursorPos.y -- [Luau] scalar pos + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size_x, label_size_y = ImGui_CalcTextSizeXY(label, 1, label_end, false) -- [Luau] scalar label_size -- See BeginMenuEx() for comments about this. local menuset_is_open = IsRootOfOpenMenuSet() @@ -75828,9 +76520,9 @@ function ImGui.MenuItemEx(label, icon, shortcut, selected, enabled) -- We've been using the equivalent of ImGuiSelectableFlags.SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73), -- but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only. - ImGui.PushID(label) + ImGui_PushID(label) if not enabled then - ImGui.BeginDisabled() + ImGui_BeginDisabled() end local pressed @@ -75844,12 +76536,14 @@ function ImGui.MenuItemEx(label, icon, shortcut, selected, enabled) -- Mimic the exact layout spacing of BeginMenu() to allow MenuItem() inside a menu bar, which is a little misleading but may be useful -- Note that in this situation: we don't render the shortcut, we render a highlight instead of the selected tick mark. window.DC.CursorPos.x = window.DC.CursorPos.x + IM_TRUNC(style.ItemSpacing.x * 0.5) - local text_pos = ImVec2(window.DC.CursorPos.x + offsets.OffsetLabel, window.DC.CursorPos.y + window.DC.CurrLineTextBaseOffset) - ImGui.PushStyleVarX(14 --[[ImGuiStyleVar.ItemSpacing]], style.ItemSpacing.x * 2.0) - pressed = ImGui.Selectable("", selected, selectable_flags, ImVec2(label_size.x, 0.0)) - ImGui.PopStyleVar() + local text_pos = MenuItem_text_pos + text_pos.x, text_pos.y = window.DC.CursorPos.x + offsets.OffsetLabel, window.DC.CursorPos.y + window.DC.CurrLineTextBaseOffset + ImGui_PushStyleVarX(14 --[[ImGuiStyleVar.ItemSpacing]], style.ItemSpacing.x * 2.0) + local size = MenuItem_size; size.x = label_size_x; size.y = 0.0 + pressed = ImGui_Selectable("", selected, selectable_flags, size) + ImGui_PopStyleVar() if bit32.band(g.LastItemData.StatusFlags, 256 --[[ImGuiItemStatusFlags.Visible]]) ~= 0 then - ImGui.RenderText(text_pos, label, 1, label_end, false) + ImGui_RenderText(text_pos, label, 1, label_end, false) end window.DC.CursorPos.x = window.DC.CursorPos.x + IM_TRUNC(style.ItemSpacing.x * (-1.0 + 0.5)) -- -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). else @@ -75858,32 +76552,38 @@ function ImGui.MenuItemEx(label, icon, shortcut, selected, enabled) -- Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.) local icon_w = 0.0 if icon and icon ~= "" then - icon_w = ImGui.CalcTextSize(icon, nil).x + icon_w = ImGui_CalcTextSize(icon, nil).x end local shortcut_w = 0.0 if shortcut and shortcut ~= "" then - shortcut_w = ImGui.CalcTextSize(shortcut, nil).x + shortcut_w = ImGui_CalcTextSize(shortcut, nil).x end local checkmark_w = IM_TRUNC(g.FontSize * 1.20) -- FIXME: Always accounted for, even in a menu with none, because 'selected' has no neutral setting. - local min_w = offsets:DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w) -- Feedback for next frame - local stretch_w = ImMax(0.0, ImGui.GetContentRegionAvail().x - min_w) - local text_pos = ImVec2(pos.x, pos.y + window.DC.CurrLineTextBaseOffset) - pressed = ImGui.Selectable("", false, bit32.bor(selectable_flags, 16777216 --[[ImGuiSelectableFlags.SpanAvailWidth]]), ImVec2(min_w, label_size.y)) + local min_w = offsets:DeclColumns(icon_w, label_size_x, shortcut_w, checkmark_w) -- Feedback for next frame + local stretch_w = ImMax(0.0, ImGui_GetContentRegionAvail().x - min_w) + local text_pos_x, text_pos_y = pos_x, pos_y + window.DC.CurrLineTextBaseOffset -- [Luau] scalar text_pos + local size = MenuItem_size; size.x = min_w; size.y = label_size_y + pressed = ImGui_Selectable("", false, bit32.bor(selectable_flags, 16777216 --[[ImGuiSelectableFlags.SpanAvailWidth]]), size) if bit32.band(g.LastItemData.StatusFlags, 256 --[[ImGuiItemStatusFlags.Visible]]) ~= 0 then - ImGui.RenderText(text_pos + ImVec2(offsets.OffsetLabel, 0.0), label, 1, label_end, false) + local p = MenuItem_p -- [Luau] text_pos + ImVec2(...) into scratch (RenderText()/RenderCheckMark() only read it) + p.x, p.y = text_pos_x + offsets.OffsetLabel, text_pos_y + 0.0 + ImGui_RenderText(p, label, 1, label_end, false) if icon_w > 0.0 then --- @cast icon string - ImGui.RenderText(text_pos + ImVec2(offsets.OffsetIcon, 0.0), icon) + p.x, p.y = text_pos_x + offsets.OffsetIcon, text_pos_y + 0.0 + ImGui_RenderText(p, icon) end if shortcut_w > 0.0 then - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], style.Colors[1 --[[ImGuiCol.TextDisabled]]]) - ImGui.LogSetNextTextDecoration("(", ")") + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], style.Colors[1 --[[ImGuiCol.TextDisabled]]]) + ImGui_LogSetNextTextDecoration("(", ")") --- @cast shortcut string - ImGui.RenderText(text_pos + ImVec2(offsets.OffsetShortcut + stretch_w, 0.0), shortcut, nil, nil, false) - ImGui.PopStyleColor() + p.x, p.y = text_pos_x + (offsets.OffsetShortcut + stretch_w), text_pos_y + 0.0 + ImGui_RenderText(p, shortcut, nil, nil, false) + ImGui_PopStyleColor() end if selected then - ImGui.RenderCheckMark(window.DrawList, text_pos + ImVec2(offsets.OffsetMark + stretch_w + g.FontSize * 0.40, g.FontSize * 0.134 * 0.5), ImGui.GetColorU32(0 --[[ImGuiCol.Text]]), g.FontSize * 0.866) + p.x, p.y = text_pos_x + (offsets.OffsetMark + stretch_w + g.FontSize * 0.40), text_pos_y + g.FontSize * 0.134 * 0.5 + ImGui.RenderCheckMark(window.DrawList, p, ImGui_GetColorU32(0 --[[ImGuiCol.Text]]), g.FontSize * 0.866) end end end @@ -75892,17 +76592,17 @@ function ImGui.MenuItemEx(label, icon, shortcut, selected, enabled) -- Once dragged, release ActiveId + key ownership. This is to allow the idiom of mouse down a menu, dragging elsewhere, up on some other MenuItem(). (#8233, #9394) -- Could move logic into lower-level ImGuiButtonFlags_AutoReleaseActiveId + ImGuiButtonFlags_AutoReleaseKeyOwner? Easier once we get rid of the Selectable() middle-man here. local id = g.LastItemData.ID - if g.ActiveId == id and g.HoveredId ~= id and g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and ImGui.IsMouseDragging(0) then - ImGui.ClearActiveID() - ImGui.SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) + if g.ActiveId == id and g.HoveredId ~= id and g.ActiveIdSource == 1 --[[ImGuiInputSource.Mouse]] and ImGui_IsMouseDragging(0) then + ImGui_ClearActiveID() + ImGui_SetKeyOwner(656 --[[ImGuiKey.MouseLeft]], 4294967295 --[[ImGuiKeyOwner_NoOwner]]) end -- IMGUI_TEST_ENGINE_ITEM_INFO() if not enabled then - ImGui.EndDisabled() + ImGui_EndDisabled() end - ImGui.PopID() + ImGui_PopID() return pressed end @@ -75938,7 +76638,7 @@ do --[[ [SECTION] Widgets: BeginTabBar, EndTabBar, etc. (was imgui_tabs.lua) ]] local MT = ImGui.GetMetatables() local GImGui -local function SyncContext() GImGui = ImGui.GetCurrentContext() end +local function SyncContext() GImGui = ImGui_GetCurrentContext() end local function ImLinearSweep(current, target, speed) if current < target then return ImMin(current + speed, target) end @@ -76130,7 +76830,7 @@ function ImGui.BeginTabBarEx(tab_bar, tab_bar_bb, flags) assert(tab_bar.ID ~= 0) if bit32.band(flags, 1048576 --[[ImGuiTabBarFlags.DockNode]]) == 0 then -- Already done - ImGui.PushOverrideID(tab_bar.ID) + ImGui_PushOverrideID(tab_bar.ID) end -- Add to stack @@ -76178,7 +76878,7 @@ function ImGui.BeginTabBarEx(tab_bar, tab_bar_bb, flags) -- Draw separator -- (it would be misleading to draw this in EndTabBar() suggesting that it may be drawn over tabs, as tab bar are appendable) - local col = ImGui.GetColorU32(bit32.band(flags, 2097152 --[[ImGuiTabBarFlags.IsFocused]]) ~= 0 and 37 --[[ImGuiCol.TabSelected]] or 40 --[[ImGuiCol.TabDimmedSelected]]) + local col = ImGui_GetColorU32(bit32.band(flags, 2097152 --[[ImGuiTabBarFlags.IsFocused]]) ~= 0 and 37 --[[ImGuiCol.TabSelected]] or 40 --[[ImGuiCol.TabDimmedSelected]]) if g.Style.TabBarBorderSize > 0.0 then local y = tab_bar.BarRect.Max.y window.DrawList:AddRectFilled(ImVec2(tab_bar.SeparatorMinX, y - g.Style.TabBarBorderSize), ImVec2(tab_bar.SeparatorMaxX, y), col) @@ -76212,7 +76912,7 @@ function ImGui.EndTabBar() tab_bar.LastTabItemIdx = -1 if bit32.band(tab_bar.Flags, 1048576 --[[ImGuiTabBarFlags.DockNode]]) == 0 then -- Already done - ImGui.PopID() + ImGui_PopID() end g.CurrentTabBarStack:pop_back() @@ -76333,7 +77033,7 @@ function ImGui.TabBarLayout(tab_bar) -- and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window. local tab_name = ImGui.TabBarGetTabName(tab_bar, tab) local has_close_button_or_unsaved_marker = bit32.band(tab.Flags, 1048576 --[[ImGuiTabItemFlags.NoCloseButton]]) == 0 or bit32.band(tab.Flags, 1 --[[ImGuiTabItemFlags.UnsavedDocument]]) ~= 0 - tab.ContentWidth = (tab.RequestedWidth >= 0.0) and tab.RequestedWidth or ImGui.TabItemCalcSize(tab_name, has_close_button_or_unsaved_marker).x + tab.ContentWidth = (tab.RequestedWidth >= 0.0) and tab.RequestedWidth or ImGui_TabItemCalcSize(tab_name, has_close_button_or_unsaved_marker).x if bit32.band(tab.Flags, 2097152 --[[ImGuiTabItemFlags.Button]]) == 0 then tab.ContentWidth = ImMax(tab.ContentWidth, g.Style.TabMinWidthBase) end @@ -76460,17 +77160,17 @@ function ImGui.TabBarLayout(tab_bar) elseif tab_bar.ScrollButtonEnabled and ImGui.IsMouseHoveringRect(tab_bar.BarRect.Min, tab_bar.BarRect.Max, true) and ImGui.IsWindowContentHoverable(g.CurrentWindow) then local wheel = g.IO.MouseWheelRequestAxisSwap and g.IO.MouseWheel or g.IO.MouseWheelH local wheel_key = g.IO.MouseWheelRequestAxisSwap and 662 --[[ImGuiKey.MouseWheelY]] or 661 --[[ImGuiKey.MouseWheelX]] - if ImGui.TestKeyOwner(wheel_key, tab_bar.ID) and wheel ~= 0.0 then + if ImGui_TestKeyOwner(wheel_key, tab_bar.ID) and wheel ~= 0.0 then local scroll_step = wheel * TabBarCalcScrollableWidth(tab_bar, sections) / 3.0 tab_bar.ScrollingTargetDistToVisibility = 0.0 - tab_bar.ScrollingTarget = ImGui.TabBarScrollClamp(tab_bar, tab_bar.ScrollingTarget - scroll_step) + tab_bar.ScrollingTarget = ImGui_TabBarScrollClamp(tab_bar, tab_bar.ScrollingTarget - scroll_step) end - ImGui.SetKeyOwner(wheel_key, tab_bar.ID) + ImGui_SetKeyOwner(wheel_key, tab_bar.ID) end -- Update scrolling - tab_bar.ScrollingAnim = ImGui.TabBarScrollClamp(tab_bar, tab_bar.ScrollingAnim) - tab_bar.ScrollingTarget = ImGui.TabBarScrollClamp(tab_bar, tab_bar.ScrollingTarget) + tab_bar.ScrollingAnim = ImGui_TabBarScrollClamp(tab_bar, tab_bar.ScrollingAnim) + tab_bar.ScrollingTarget = ImGui_TabBarScrollClamp(tab_bar, tab_bar.ScrollingTarget) if tab_bar.ScrollingAnim ~= tab_bar.ScrollingTarget then -- Scrolling speed adjust itself so we can always reach our target in 1/3 seconds. -- Teleport if we are aiming far off the visible line @@ -76496,14 +77196,14 @@ function ImGui.TabBarCalcTabID(tab_bar, label, docked_window) if docked_window ~= nil then assert(bit32.band(tab_bar.Flags, 1048576 --[[ImGuiTabBarFlags.DockNode]]) ~= 0) local id = docked_window.TabId - ImGui.KeepAliveID(id) + ImGui_KeepAliveID(id) return id end - return ImGui.GetCurrentContext().CurrentWindow:GetID(label) + return ImGui_GetCurrentContext().CurrentWindow:GetID(label) end function ImGui.TabBarCalcMaxTabWidth() - return ImGui.GetCurrentContext().FontSize * 20.0 + return ImGui_GetCurrentContext().FontSize * 20.0 end function ImGui.TabBarFindTabByID(tab_bar, tab_id) @@ -76562,8 +77262,8 @@ end -- The purpose of this call is to register tab in advance so we can control their order at the time they appear. -- Otherwise calling this is unnecessary as tabs are appending as needed by the BeginTabItem() function. function ImGui.TabBarAddTab(tab_bar, tab_flags, window) - local g = ImGui.GetCurrentContext() - assert(ImGui.TabBarFindTabByID(tab_bar, window.TabId) == nil) + local g = ImGui_GetCurrentContext() + assert(ImGui_TabBarFindTabByID(tab_bar, window.TabId) == nil) assert(g.CurrentTabBar ~= tab_bar) -- Can't work while the tab bar is active as our tab doesn't have an X offset yet, in theory we could/should test something like (tab_bar.CurrFrameVisible < g.FrameCount) but we'd need to solve why triggers the commented early-out assert in BeginTabBarEx() (probably dock node going from implicit to explicit in same frame) if not window.HasCloseButton then tab_flags = bit32.bor(tab_flags, 1048576 --[[ImGuiTabItemFlags.NoCloseButton]]) -- Set _NoCloseButton immediately because it will be used for first-frame width calculation. @@ -76579,7 +77279,7 @@ end -- The *TabId fields are already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. function ImGui.TabBarRemoveTab(tab_bar, tab_id) - local tab = ImGui.TabBarFindTabByID(tab_bar, tab_id) + local tab = ImGui_TabBarFindTabByID(tab_bar, tab_id) if tab then tab_bar.Tabs:erase(tab_bar.Tabs:find_index(tab)) end if tab_bar.VisibleTabId == tab_id then tab_bar.VisibleTabId = 0 end if tab_bar.SelectedTabId == tab_id then tab_bar.SelectedTabId = 0 end @@ -76601,7 +77301,7 @@ function ImGui.TabBarCloseTab(tab_bar, tab) end else -- Actually select before expecting closure attempt (on an UnsavedDocument tab user is expect to e.g. show a popup) - if tab_bar.VisibleTabId ~= tab.ID then ImGui.TabBarQueueFocus(tab_bar, tab) end + if tab_bar.VisibleTabId ~= tab.ID then ImGui_TabBarQueueFocus(tab_bar, tab) end end end @@ -76612,7 +77312,7 @@ end -- Note: we may scroll to tab that are not selected! e.g. using keyboard arrow keys function ImGui.TabBarScrollToTab(tab_bar, tab_id, sections) - local tab = ImGui.TabBarFindTabByID(tab_bar, tab_id) + local tab = ImGui_TabBarFindTabByID(tab_bar, tab_id) if tab == nil then return end -- Clamp attempt to scroll to leading/trailing sections items. @@ -76626,9 +77326,9 @@ function ImGui.TabBarScrollToTab(tab_bar, tab_id, sections) -- When scrolling to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar) -- Disable the margin if the scrolling section is too small for the target tab: prefer displaying a maximum of the label. - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local margin = ImClamp(tab_bar.ScrollingRectMaxX - tab_bar.ScrollingRectMinX - tab.Width, g.Style.ItemInnerSpacing.x, g.FontSize * 1.0) - local order = ImGui.TabBarGetTabOrder(tab_bar, tab) + local order = ImGui_TabBarGetTabOrder(tab_bar, tab) -- Scrolling happens only in the central section (leading/trailing sections are not scrolling) local scrollable_width = TabBarCalcScrollableWidth(tab_bar, sections) @@ -76652,7 +77352,7 @@ end function ImGui.TabBarQueueFocus(tab_bar, tab) if type(tab) == "string" then assert(bit32.band(tab_bar.Flags, 1048576 --[[ImGuiTabBarFlags.DockNode]]) == 0) -- Only supported for manual/explicit tab bars - tab_bar.NextSelectedTabId = ImGui.TabBarCalcTabID(tab_bar, tab, nil) + tab_bar.NextSelectedTabId = ImGui_TabBarCalcTabID(tab_bar, tab, nil) return end tab_bar.NextSelectedTabId = tab.ID @@ -76666,7 +77366,7 @@ function ImGui.TabBarQueueReorder(tab_bar, tab, offset) end function ImGui.TabBarQueueReorderFromMousePos(tab_bar, src_tab, mouse_pos) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() assert(tab_bar.ReorderRequestTabId == 0) if bit32.band(tab_bar.Flags, 1 --[[ImGuiTabBarFlags.Reorderable]]) == 0 then return end @@ -76676,7 +77376,7 @@ function ImGui.TabBarQueueReorderFromMousePos(tab_bar, src_tab, mouse_pos) -- Count number of contiguous tabs we are crossing over local dir = ((bar_offset + src_tab.Offset) > mouse_pos.x) and -1 or 1 - local src_idx = ImGui.TabBarGetTabOrder(tab_bar, src_tab) + local src_idx = ImGui_TabBarGetTabOrder(tab_bar, src_tab) local dst_idx = src_idx local i = src_idx while i >= 0 and i < tab_bar.Tabs.Size do @@ -76700,11 +77400,11 @@ function ImGui.TabBarQueueReorderFromMousePos(tab_bar, src_tab, mouse_pos) end function ImGui.TabBarProcessReorder(tab_bar) - local tab1 = ImGui.TabBarFindTabByID(tab_bar, tab_bar.ReorderRequestTabId) + local tab1 = ImGui_TabBarFindTabByID(tab_bar, tab_bar.ReorderRequestTabId) if tab1 == nil or bit32.band(tab1.Flags, 32 --[[ImGuiTabItemFlags.NoReorder]]) ~= 0 then return false end -- IM_ASSERT(bit32.band(tab_bar.Flags, ImGuiTabBarFlags.Reorderable) ~= 0) -- <- this may happen when using debug tools - local tab1_order = ImGui.TabBarGetTabOrder(tab_bar, tab1) + local tab1_order = ImGui_TabBarGetTabOrder(tab_bar, tab1) local tab2_order = tab1_order + tab_bar.ReorderRequestOffset if tab2_order < 0 or tab2_order >= tab_bar.Tabs.Size then return false end @@ -76723,7 +77423,7 @@ function ImGui.TabBarProcessReorder(tab_bar) end function ImGui.TabBarScrollingButtons(tab_bar) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow local arrow_button_size = ImVec2(g.FontSize - 2.0, g.FontSize + g.Style.FramePadding.y * 2.0) @@ -76736,28 +77436,28 @@ function ImGui.TabBarScrollingButtons(tab_bar) local tc = g.Style.Colors[0 --[[ImGuiCol.Text]]] local arrow_col = ImVec4(tc.x, tc.y, tc.z, tc.w * 0.5) - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], arrow_col) - ImGui.PushStyleColor(22 --[[ImGuiCol.Button]], ImVec4(0, 0, 0, 0)) - ImGui.PushItemFlag(bit32.bor(8 --[[ImGuiItemFlags.ButtonRepeat]], 2 --[[ImGuiItemFlags.NoNav]]), true) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], arrow_col) + ImGui_PushStyleColor(22 --[[ImGuiCol.Button]], ImVec4(0, 0, 0, 0)) + ImGui_PushItemFlag(bit32.bor(8 --[[ImGuiItemFlags.ButtonRepeat]], 2 --[[ImGuiItemFlags.NoNav]]), true) local backup_repeat_delay = g.IO.KeyRepeatDelay local backup_repeat_rate = g.IO.KeyRepeatRate g.IO.KeyRepeatDelay = 0.250 g.IO.KeyRepeatRate = 0.200 local x = ImMax(tab_bar.BarRect.Min.x, tab_bar.BarRect.Max.x - scrolling_buttons_width) ImVec2_CopyV(window.DC.CursorPos, x, tab_bar.BarRect.Min.y) - if ImGui.ArrowButtonEx("##<", 0 --[[ImGuiDir.Left]], arrow_button_size, 16 --[[ImGuiButtonFlags.PressedOnClick]]) then select_dir = -1 end + if ImGui_ArrowButtonEx("##<", 0 --[[ImGuiDir.Left]], arrow_button_size, 16 --[[ImGuiButtonFlags.PressedOnClick]]) then select_dir = -1 end ImVec2_CopyV(window.DC.CursorPos, x + arrow_button_size.x, tab_bar.BarRect.Min.y) - if ImGui.ArrowButtonEx("##>", 1 --[[ImGuiDir.Right]], arrow_button_size, 16 --[[ImGuiButtonFlags.PressedOnClick]]) then select_dir = 1 end - ImGui.PopItemFlag() - ImGui.PopStyleColor(2) + if ImGui_ArrowButtonEx("##>", 1 --[[ImGuiDir.Right]], arrow_button_size, 16 --[[ImGuiButtonFlags.PressedOnClick]]) then select_dir = 1 end + ImGui_PopItemFlag() + ImGui_PopStyleColor(2) g.IO.KeyRepeatRate = backup_repeat_rate g.IO.KeyRepeatDelay = backup_repeat_delay local tab_to_scroll_to = nil if select_dir ~= 0 then - local tab_item = ImGui.TabBarFindTabByID(tab_bar, tab_bar.SelectedTabId) + local tab_item = ImGui_TabBarFindTabByID(tab_bar, tab_bar.SelectedTabId) if tab_item then - local selected_order = ImGui.TabBarGetTabOrder(tab_bar, tab_item) + local selected_order = ImGui_TabBarGetTabOrder(tab_bar, tab_item) local target_order = selected_order + select_dir -- Skip tab item buttons until another tab item is found or end is reached @@ -76783,7 +77483,7 @@ function ImGui.TabBarScrollingButtons(tab_bar) end function ImGui.TabBarTabListPopupButton(tab_bar) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow -- We use g.Style.FramePadding.y to match the square ArrowButton size @@ -76793,10 +77493,10 @@ function ImGui.TabBarTabListPopupButton(tab_bar) tab_bar.BarRect.Min.x = tab_bar.BarRect.Min.x + tab_list_popup_button_width local tc = g.Style.Colors[0 --[[ImGuiCol.Text]]] - ImGui.PushStyleColor(0 --[[ImGuiCol.Text]], ImVec4(tc.x, tc.y, tc.z, tc.w * 0.5)) - ImGui.PushStyleColor(22 --[[ImGuiCol.Button]], ImVec4(0, 0, 0, 0)) - local open = ImGui.BeginCombo("##v", nil, bit32.bor(64 --[[ImGuiComboFlags.NoPreview]], 16 --[[ImGuiComboFlags.HeightLargest]])) - ImGui.PopStyleColor(2) + ImGui_PushStyleColor(0 --[[ImGuiCol.Text]], ImVec4(tc.x, tc.y, tc.z, tc.w * 0.5)) + ImGui_PushStyleColor(22 --[[ImGuiCol.Button]], ImVec4(0, 0, 0, 0)) + local open = ImGui_BeginCombo("##v", nil, bit32.bor(64 --[[ImGuiComboFlags.NoPreview]], 16 --[[ImGuiComboFlags.HeightLargest]])) + ImGui_PopStyleColor(2) local tab_to_select = nil if open then @@ -76804,7 +77504,7 @@ function ImGui.TabBarTabListPopupButton(tab_bar) local tab = tab_bar.Tabs.Data[n] if bit32.band(tab.Flags, 2097152 --[[ImGuiTabItemFlags.Button]]) == 0 then local tab_name = ImGui.TabBarGetTabName(tab_bar, tab) - if ImGui.Selectable(tab_name, tab_bar.SelectedTabId == tab.ID) then + if ImGui_Selectable(tab_name, tab_bar.SelectedTabId == tab.ID) then tab_to_select = tab end end @@ -76832,7 +77532,7 @@ end --- @return bool visible, bool? p_open function ImGui.BeginTabItem(label, p_open, flags) if flags == nil then flags = 0 end - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow if window.SkipItems then return false, p_open end @@ -76841,16 +77541,16 @@ function ImGui.BeginTabItem(label, p_open, flags) assert(bit32.band(flags, 2097152 --[[ImGuiTabItemFlags.Button]]) == 0) -- BeginTabItem() Can't be used with button flags, use TabItemButton() instead! local ret - ret, p_open = ImGui.TabItemEx(tab_bar, label, p_open, flags, nil) + ret, p_open = ImGui_TabItemEx(tab_bar, label, p_open, flags, nil) if ret and bit32.band(flags, 8 --[[ImGuiTabItemFlags.NoPushId]]) == 0 then local tab = tab_bar.Tabs.Data[tab_bar.LastTabItemIdx + 1] - ImGui.PushOverrideID(tab.ID) -- We already hashed 'label' so push into the ID stack directly instead of doing another hash through PushID(label) + ImGui_PushOverrideID(tab.ID) -- We already hashed 'label' so push into the ID stack directly instead of doing another hash through PushID(label) end return ret, p_open end function ImGui.EndTabItem() - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow if window.SkipItems then return end @@ -76859,34 +77559,34 @@ function ImGui.EndTabItem() assert(tab_bar.LastTabItemIdx >= 0) local tab = tab_bar.Tabs.Data[tab_bar.LastTabItemIdx + 1] if bit32.band(tab.Flags, 8 --[[ImGuiTabItemFlags.NoPushId]]) == 0 then - ImGui.PopID() + ImGui_PopID() end end function ImGui.TabItemButton(label, flags) if flags == nil then flags = 0 end - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow if window.SkipItems then return false end local tab_bar = g.CurrentTabBar assert(tab_bar ~= nil, "Needs to be called between BeginTabBar() and EndTabBar()!") - return (ImGui.TabItemEx(tab_bar, label, nil, bit32.bor(flags, 2097152 --[[ImGuiTabItemFlags.Button]], 32 --[[ImGuiTabItemFlags.NoReorder]]), nil)) + return (ImGui_TabItemEx(tab_bar, label, nil, bit32.bor(flags, 2097152 --[[ImGuiTabItemFlags.Button]], 32 --[[ImGuiTabItemFlags.NoReorder]]), nil)) end function ImGui.TabItemSpacing(str_id, flags, width) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local window = g.CurrentWindow if window.SkipItems then return end local tab_bar = g.CurrentTabBar assert(tab_bar ~= nil, "Needs to be called between BeginTabBar() and EndTabBar()!") - ImGui.SetNextItemWidth(width) - ImGui.TabItemEx(tab_bar, str_id, nil, bit32.bor(flags or 0, 2097152 --[[ImGuiTabItemFlags.Button]], 32 --[[ImGuiTabItemFlags.NoReorder]], 4194304 --[[ImGuiTabItemFlags.Invisible]]), nil) + ImGui_SetNextItemWidth(width) + ImGui_TabItemEx(tab_bar, str_id, nil, bit32.bor(flags or 0, 2097152 --[[ImGuiTabItemFlags.Button]], 32 --[[ImGuiTabItemFlags.NoReorder]], 4194304 --[[ImGuiTabItemFlags.Invisible]]), nil) end --- @return bool ret, bool? p_open function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) -- Layout whole tab bar if not already done - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() if tab_bar.WantLayout then local backup_next_item_data = {} for k, v in pairs(g.NextItemData) do backup_next_item_data[k] = v end @@ -76897,7 +77597,7 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) if window.SkipItems then return false, p_open end local style = g.Style - local id = ImGui.TabBarCalcTabID(tab_bar, label, docked_window) + local id = ImGui_TabBarCalcTabID(tab_bar, label, docked_window) -- If the user called us with p_open == false, we early out and don't render. -- We make a call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID. @@ -76918,7 +77618,7 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) end -- Acquire tab data - local tab = ImGui.TabBarFindTabByID(tab_bar, id) + local tab = ImGui_TabBarFindTabByID(tab_bar, id) local tab_is_new = false if tab == nil then tab = ImGuiTabItem() @@ -76927,10 +77627,10 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) tab_bar.TabsAddedNew = true tab_is_new = true end - tab_bar.LastTabItemIdx = ImGui.TabBarGetTabOrder(tab_bar, tab) + tab_bar.LastTabItemIdx = ImGui_TabBarGetTabOrder(tab_bar, tab) -- Calculate tab contents size - local size = ImGui.TabItemCalcSize(label, has_p_open or bit32.band(flags, 1 --[[ImGuiTabItemFlags.UnsavedDocument]]) ~= 0) + local size = ImGui_TabItemCalcSize(label, has_p_open or bit32.band(flags, 1 --[[ImGuiTabItemFlags.UnsavedDocument]]) ~= 0) tab.RequestedWidth = -1.0 if bit32.band(g.NextItemData.HasFlags, 1 --[[ImGuiNextItemDataFlags.HasWidth]]) ~= 0 then size.x = g.NextItemData.Width @@ -76965,11 +77665,11 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) if not is_tab_button then if tab_appearing and bit32.band(tab_bar.Flags, 2 --[[ImGuiTabBarFlags.AutoSelectNewTabs]]) ~= 0 and tab_bar.NextSelectedTabId == 0 then if not tab_bar_appearing or tab_bar.SelectedTabId == 0 then - ImGui.TabBarQueueFocus(tab_bar, tab) -- New tabs gets activated + ImGui_TabBarQueueFocus(tab_bar, tab) -- New tabs gets activated end end if bit32.band(flags, 2 --[[ImGuiTabItemFlags.SetSelected]]) ~= 0 and tab_bar.SelectedTabId ~= id then -- _SetSelected can only be passed on explicit tab bar - ImGui.TabBarQueueFocus(tab_bar, tab) + ImGui_TabBarQueueFocus(tab_bar, tab) end end @@ -77008,7 +77708,7 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) -- We don't have CPU clipping primitives to clip the CloseButton (until it becomes a texture), so need to add an extra draw call (temporary in the case of vertical animation) local want_clip_rect = is_central_section and (bb.Min.x < tab_bar.ScrollingRectMinX or bb.Max.x > tab_bar.ScrollingRectMaxX) if want_clip_rect then - ImGui.PushClipRect(ImVec2(ImClamp(bb.Min.x, tab_bar.ScrollingRectMinX, tab_bar.ScrollingRectMaxX), bb.Min.y - 1), ImVec2(tab_bar.ScrollingRectMaxX, bb.Max.y), true) + ImGui_PushClipRect(ImVec2(ImClamp(bb.Min.x, tab_bar.ScrollingRectMinX, tab_bar.ScrollingRectMaxX), bb.Min.y - 1), ImVec2(tab_bar.ScrollingRectMaxX, bb.Max.y), true) end local backup_cursor_max_pos = ImVec2(window.DC.CursorMaxPos.x, window.DC.CursorMaxPos.y) @@ -77016,7 +77716,7 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) ImVec2_Copy(window.DC.CursorMaxPos, backup_cursor_max_pos) if not ImGui.ItemAdd(bb, id) then - if want_clip_rect then ImGui.PopClipRect() end + if want_clip_rect then ImGui_PopClipRect() end ImVec2_Copy(window.DC.CursorPos, backup_main_cursor_pos) return tab_contents_visible, p_open end @@ -77030,9 +77730,9 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) if bit32.band(flags, 4194304 --[[ImGuiTabItemFlags.Invisible]]) ~= 0 then hovered, held, pressed = false, false, false else - pressed, hovered, held = ImGui.ButtonBehavior(bb, id, button_flags) + pressed, hovered, held = ImGui_ButtonBehavior(bb, id, button_flags) end - if pressed and not is_tab_button then ImGui.TabBarQueueFocus(tab_bar, tab) end + if pressed and not is_tab_button then ImGui_TabBarQueueFocus(tab_bar, tab) end -- Transfer active id window so the active id is not owned by the dock host (as StartMouseMovingWindow() -- will only do it on the drag). This allows FocusWindow() to be more conservative in how it clears active id. @@ -77043,10 +77743,10 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) -- Drag and drop a single floating window node moves it local node = docked_window and docked_window.DockNode or nil local single_floating_window_node = node and node:IsFloatingNode() and (node.Windows.Size == 1) - if held and single_floating_window_node and ImGui.IsMouseDragging(0, 0.0) then + if held and single_floating_window_node and ImGui_IsMouseDragging(0, 0.0) then -- Move ImGui.StartMouseMovingWindow(docked_window) - elseif held and not tab_appearing and ImGui.IsMouseDragging(0) then + elseif held and not tab_appearing and ImGui_IsMouseDragging(0) then -- Drag and drop: re-order tabs local drag_dir = 0 local drag_distance_from_edge_x = 0.0 @@ -77077,7 +77777,7 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) local distance_from_edge_y = ImMax(bb.Min.y - g.IO.MousePos.y, g.IO.MousePos.y - bb.Max.y) if distance_from_edge_y >= threshold_y then undocking_tab = true end if drag_distance_from_edge_x > threshold_x then - if (drag_dir < 0 and ImGui.TabBarGetTabOrder(tab_bar, tab) == 0) or (drag_dir > 0 and ImGui.TabBarGetTabOrder(tab_bar, tab) == tab_bar.Tabs.Size - 1) then + if (drag_dir < 0 and ImGui_TabBarGetTabOrder(tab_bar, tab) == 0) or (drag_dir > 0 and ImGui_TabBarGetTabOrder(tab_bar, tab) == tab_bar.Tabs.Size - 1) then undocking_tab = true end end @@ -77088,7 +77788,7 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) -- FIXME: refactor to share more code with e.g. StartMouseMovingWindow ImGui.DockContextQueueUndockWindow(g, docked_window) g.MovingWindow = docked_window - ImGui.SetActiveID(g.MovingWindow.MoveId, g.MovingWindow) + ImGui_SetActiveID(g.MovingWindow.MoveId, g.MovingWindow) ImVec2_Copy(g.ActiveIdClickOffset, g.ActiveIdClickOffset - (g.MovingWindow.Pos - bb.Min)) g.ActiveIdNoClearOnFocusLoss = true ImGui.SetActiveIdUsingAllKeyboardKeys() @@ -77104,12 +77804,12 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) if held or hovered then col_idx = 35 --[[ImGuiCol.TabHovered]] elseif tab_contents_visible then col_idx = tab_bar_focused and 37 --[[ImGuiCol.TabSelected]] or 40 --[[ImGuiCol.TabDimmedSelected]] else col_idx = tab_bar_focused and 36 --[[ImGuiCol.Tab]] or 39 --[[ImGuiCol.TabDimmed]] end - ImGui.TabItemBackground(display_draw_list, bb, flags, ImGui.GetColorU32(col_idx)) + ImGui.TabItemBackground(display_draw_list, bb, flags, ImGui_GetColorU32(col_idx)) if tab_contents_visible and bit32.band(tab_bar.Flags, 64 --[[ImGuiTabBarFlags.DrawSelectedOverline]]) ~= 0 and style.TabBarOverlineSize > 0.0 then -- Might be moved to TabItemBackground() ? local tl = ImVec2(bb.Min.x, bb.Min.y + style.TabBarOverlineSize * 0.5) local tr = ImVec2(bb.Max.x, bb.Min.y + style.TabBarOverlineSize * 0.5) - local overline_col = ImGui.GetColorU32(tab_bar_focused and 38 --[[ImGuiCol.TabSelectedOverline]] or 41 --[[ImGuiCol.TabDimmedSelectedOverline]]) + local overline_col = ImGui_GetColorU32(tab_bar_focused and 38 --[[ImGuiCol.TabSelectedOverline]] or 41 --[[ImGuiCol.TabDimmedSelectedOverline]]) if style.TabRounding > 0.0 then local rounding = style.TabRounding display_draw_list:PathArcToFast(tl + ImVec2(rounding, rounding), rounding, 7, 9) @@ -77119,12 +77819,12 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) display_draw_list:AddLine(tl, tr, overline_col, style.TabBarOverlineSize) end end - ImGui.RenderNavCursor(bb, id) + ImGui_RenderNavCursor(bb, id) -- Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget. - local hovered_unblocked = ImGui.IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]) - if tab_bar.SelectedTabId ~= tab.ID and hovered_unblocked and (ImGui.IsMouseClicked(1) or ImGui.IsMouseReleased(1)) and not is_tab_button then - ImGui.TabBarQueueFocus(tab_bar, tab) + local hovered_unblocked = ImGui_IsItemHovered(32 --[[ImGuiHoveredFlags.AllowWhenBlockedByPopup]]) + if tab_bar.SelectedTabId ~= tab.ID and hovered_unblocked and (ImGui_IsMouseClicked(1) or ImGui_IsMouseReleased(1)) and not is_tab_button then + ImGui_TabBarQueueFocus(tab_bar, tab) end if bit32.band(tab_bar.Flags, 8 --[[ImGuiTabBarFlags.NoCloseWithMiddleMouseButton]]) ~= 0 then @@ -77153,14 +77853,14 @@ function ImGui.TabItemEx(tab_bar, label, p_open, flags, docked_window) -- FIXME: We may want disabled tab to still display the tooltip? if text_clipped and g.HoveredId == id and not held then if bit32.band(tab_bar.Flags, 32 --[[ImGuiTabBarFlags.NoTooltip]]) == 0 and bit32.band(tab.Flags, 16 --[[ImGuiTabItemFlags.NoTooltip]]) == 0 then - local label_end = ImGui.FindRenderedTextEnd(label) + local label_end = ImGui_FindRenderedTextEnd(label) ImGui.SetItemTooltip("%s", string.sub(label, 1, label_end - 1)) end end end -- Restore main window position so user can draw there - if want_clip_rect then ImGui.PopClipRect() end + if want_clip_rect then ImGui_PopClipRect() end ImVec2_Copy(window.DC.CursorPos, backup_main_cursor_pos) if is_tab_button then return pressed, p_open end @@ -77171,19 +77871,19 @@ end -- To use it to need to call the function SetTabItemClosed() between BeginTabBar() and EndTabBar(). -- Tabs closed by the close button will automatically be flagged to avoid this issue. function ImGui.SetTabItemClosed(label) - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local is_within_manual_tab_bar = g.CurrentTabBar and bit32.band(g.CurrentTabBar.Flags, 1048576 --[[ImGuiTabBarFlags.DockNode]]) == 0 if is_within_manual_tab_bar then local tab_bar = g.CurrentTabBar - local tab_id = ImGui.TabBarCalcTabID(tab_bar, label, nil) - local tab = ImGui.TabBarFindTabByID(tab_bar, tab_id) + local tab_id = ImGui_TabBarCalcTabID(tab_bar, label, nil) + local tab = ImGui_TabBarFindTabByID(tab_bar, tab_id) if tab then tab.WantClose = true end -- Will be processed by next call to TabBarLayout() else - local window = ImGui.FindWindowByName(label) + local window = ImGui_FindWindowByName(label) if window and window.DockIsActive then local node = window.DockNode if node then - local tab_id = ImGui.TabBarCalcTabID(node.TabBar, label, window) + local tab_id = ImGui_TabBarCalcTabID(node.TabBar, label, window) ImGui.TabBarRemoveTab(node.TabBar, tab_id) window.DockTabWantClose = true end @@ -77195,10 +77895,10 @@ end function ImGui.TabItemCalcSize(label, has_close_button_or_unsaved_marker) if type(label) == "table" then local window = label - return ImGui.TabItemCalcSize(window.Name, window.HasCloseButton or bit32.band(window.Flags, 262144 --[[ImGuiWindowFlags.UnsavedDocument]]) ~= 0) + return ImGui_TabItemCalcSize(window.Name, window.HasCloseButton or bit32.band(window.Flags, 262144 --[[ImGuiWindowFlags.UnsavedDocument]]) ~= 0) end - local g = ImGui.GetCurrentContext() - local label_size = ImGui.CalcTextSize(label, nil, true) + local g = ImGui_GetCurrentContext() + local label_size = ImGui_CalcTextSize(label, nil, true) local size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0) if has_close_button_or_unsaved_marker then size.x = size.x + g.Style.FramePadding.x + (g.Style.ItemInnerSpacing.x + g.FontSize) -- We use Y intentionally to fit the close button circle. @@ -77210,7 +77910,7 @@ end function ImGui.TabItemBackground(draw_list, bb, flags, col) -- While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it. - local g = ImGui.GetCurrentContext() + local g = ImGui_GetCurrentContext() local width = bb:GetWidth() assert(width > 0.0) local rounding = ImMax(0.0, ImMin(bit32.band(flags, 2097152 --[[ImGuiTabItemFlags.Button]]) ~= 0 and g.Style.FrameRounding or g.Style.TabRounding, width * 0.5 - 1.0)) @@ -77222,7 +77922,7 @@ function ImGui.TabItemBackground(draw_list, bb, flags, col) draw_list:PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9) draw_list:PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12) draw_list:PathLineTo(ImVec2(bb.Max.x, y2)) - draw_list:PathStroke(ImGui.GetColorU32(5 --[[ImGuiCol.Border]]), g.Style.TabBorderSize, 393216 --[[ImDrawFlags.StrokeCenterBiased]]) -- Use _StrokeInside? + draw_list:PathStroke(ImGui_GetColorU32(5 --[[ImGuiCol.Border]]), g.Style.TabBorderSize, 393216 --[[ImDrawFlags.StrokeCenterBiased]]) -- Use _StrokeInside? end end @@ -77230,9 +77930,9 @@ end -- We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter. --- @return bool just_closed, bool text_clipped function ImGui.TabItemLabelAndCloseButton(draw_list, bb, flags, frame_padding, label, tab_id, close_button_id, is_contents_visible) - local g = ImGui.GetCurrentContext() - local label_end = ImGui.FindRenderedTextEnd(label) - local label_size = ImGui.CalcTextSize(label, label_end, false) + local g = ImGui_GetCurrentContext() + local label_end = ImGui_FindRenderedTextEnd(label) + local label_size = ImGui_CalcTextSize(label, label_end, false) if bb:GetWidth() <= 1.0 then return false, false end @@ -77267,7 +77967,7 @@ function ImGui.TabItemLabelAndCloseButton(draw_list, bb, flags, frame_padding, l local unsaved_marker_visible = bit32.band(flags, 1 --[[ImGuiTabItemFlags.UnsavedDocument]]) ~= 0 and (button_pos.x + button_sz <= bb.Max.x) and (not close_button_visible or not is_hovered) if unsaved_marker_visible then local bullet_pos = button_pos + ImVec2(button_sz, button_sz) * 0.5 - ImGui.RenderBullet(draw_list, bullet_pos, ImGui.GetColorU32(58 --[[ImGuiCol.UnsavedMarker]])) + ImGui_RenderBullet(draw_list, bullet_pos, ImGui_GetColorU32(58 --[[ImGuiCol.UnsavedMarker]])) elseif close_button_visible then local last_item_backup = ImGuiLastItemData() ImGuiLastItemData_Copy(last_item_backup, g.LastItemData) @@ -77275,7 +77975,7 @@ function ImGui.TabItemLabelAndCloseButton(draw_list, bb, flags, frame_padding, l ImGuiLastItemData_Copy(g.LastItemData, last_item_backup) -- Close with middle mouse button - if is_hovered and bit32.band(flags, 4 --[[ImGuiTabItemFlags.NoCloseWithMiddleMouseButton]]) == 0 and ImGui.IsMouseClicked(2) then + if is_hovered and bit32.band(flags, 4 --[[ImGuiTabItemFlags.NoCloseWithMiddleMouseButton]]) == 0 and ImGui_IsMouseClicked(2) then close_button_pressed = true end end @@ -77293,15 +77993,15 @@ function ImGui.TabItemLabelAndCloseButton(draw_list, bb, flags, frame_padding, l text_ellipsis_clip_bb.Max.x = text_ellipsis_clip_bb.Max.x - button_sz * 1.00 end end - ImGui.LogSetNextTextDecoration("/", "\\") - ImGui.RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, ellipsis_max_x, label, label_end, label_size) + ImGui_LogSetNextTextDecoration("/", "\\") + ImGui_RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, ellipsis_max_x, label, label_end, label_size) return close_button_pressed, text_clipped end end --[[ [SECTION] Widgets: BeginTabBar, EndTabBar, etc. (was imgui_tabs.lua) ]] return true -- [Roblox] ModuleScripts must return exactly one value -end +end end)() __FILES['imstb_rectpack.lua'] = function() --- Dear ImGui diff --git a/build/ImGuiWorker.client.luau b/build/ImGuiWorker.client.luau index 55b3c40..6be09cc 100644 --- a/build/ImGuiWorker.client.luau +++ b/build/ImGuiWorker.client.luau @@ -490,9 +490,34 @@ local function DrawTriangle(dbuf: buffer, vbuf: buffer, va: number, vb: number, if yt > yb then continue end local o = (yt * TargetWidth + x) * 4 + TargetBase if flat then - for _ = yt, yb do - BlendPixel(dbuf, o, ra, ga, ba, aa) - o += stride + -- the row path's flat spans (BlendPixel's math, per-span constants, cached per destination value) + local o1 = o + (yb - yt) * stride + if f_opaque then + for oo = o, o1, stride do writeu32(dbuf, oo, f_packed) end + continue + end + local last_d, last_v = -1, 0 + for oo = o, o1, stride do + local d = readu32(dbuf, oo) + if d == last_d then + writeu32(dbuf, oo, last_v) + elseif d < 16777216 then + writeu32(dbuf, oo, f_packed) + else + last_d = d + local dr, dg, db = band(d, 255), band(rshift(d, 8), 255), band(rshift(d, 16), 255) + if d >= 4278190080 then + last_v = floor(f_rs + dr * f_ns + 0.5) + floor(f_gs + dg * f_ns + 0.5) * 256 + + floor(f_bs + db * f_ns + 0.5) * 65536 + 4278190080 + else + local k = rshift(d, 24) * f_c1 + local oa = f_sa + k + local inv2 = 1 / oa + last_v = floor((f_rs + dr * k) * inv2 + 0.5) + floor((f_gs + dg * k) * inv2 + 0.5) * 256 + + floor((f_bs + db * k) * inv2 + 0.5) * 65536 + floor(oa * 255 + 0.5) * 16777216 + end + writeu32(dbuf, oo, last_v) + end end continue end