Less garbage: reuse window stack entries in Begin, scratch rects in UpdateWindowManualResize/GetResizeBorderRect
This commit is contained in:
1 parent
5029525f2a
commit
25a7387642
5 files changed
+101
-62
No files matched your search
Generated
+1
-1
@@ -1 +1 @@
|
||||
[[46, "imgui.lua"], [22651, "imgui_demo.lua"], [34508, "imgui_draw.lua"], [42845, "imgui_h.lua"], [45848, "roblox/raster.lua"], [46324, "roblox/textures.lua"], [46495, "roblox/layers.lua"], [46832, "roblox/overlays.lua"], [46913, "roblox/render.lua"], [47758, "roblox/parallel.lua"], [48157, "imgui_impl_roblox.lua"], [48658, "imgui_impl_roblox_fonts.lua"], [55061, "imgui_internal.lua"], [59027, "imgui_tables.lua"], [64119, "imgui_widgets.lua"], [76360, "imstb_rectpack.lua"], [77024, "imstb_textedit.lua"], [78566, "imstb_truetype.lua"], [81354, "imstd_minstdio.lua"]]
|
||||
[[46, "imgui.lua"], [22664, "imgui_demo.lua"], [34521, "imgui_draw.lua"], [42858, "imgui_h.lua"], [45861, "roblox/raster.lua"], [46337, "roblox/textures.lua"], [46508, "roblox/layers.lua"], [46845, "roblox/overlays.lua"], [46926, "roblox/render.lua"], [47771, "roblox/parallel.lua"], [48170, "imgui_impl_roblox.lua"], [48671, "imgui_impl_roblox_fonts.lua"], [55074, "imgui_internal.lua"], [59040, "imgui_tables.lua"], [64132, "imgui_widgets.lua"], [76373, "imstb_rectpack.lua"], [77037, "imstb_textedit.lua"], [78579, "imstb_truetype.lua"], [81367, "imstd_minstdio.lua"]]
|
||||
Generated
+33
-20
@@ -4917,26 +4917,33 @@ local ImGuiResizeBorderDef = {
|
||||
--- @param thickness float
|
||||
--- @return ImRect
|
||||
--- @nodiscard
|
||||
local function GetResizeBorderRect(window, border_n, perp_padding, thickness)
|
||||
local rect = window:Rect()
|
||||
-- [Luau] out: optional ImRect written in place (no allocation)
|
||||
local function GetResizeBorderRect(window, border_n, perp_padding, thickness, out)
|
||||
local x0, y0 = window.Pos.x, window.Pos.y
|
||||
local x1, y1 = x0 + window.Size.x, y0 + window.Size.y
|
||||
if thickness == 0.0 then
|
||||
ImVec2_CopyV(rect.Max, rect.Max.x - 1, rect.Max.y - 1)
|
||||
x1, y1 = x1 - 1, y1 - 1
|
||||
end
|
||||
local a, b, c, d
|
||||
if border_n == 0 --[[ImGuiDir.Left]] then
|
||||
return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding)
|
||||
a, b, c, d = x0 - thickness, y0 + perp_padding, x0 + thickness, y1 - perp_padding
|
||||
elseif border_n == 1 --[[ImGuiDir.Right]] then
|
||||
a, b, c, d = x1 - thickness, y0 + perp_padding, x1 + thickness, y1 - perp_padding
|
||||
elseif border_n == 2 --[[ImGuiDir.Up]] then
|
||||
a, b, c, d = x0 + perp_padding, y0 - thickness, x1 - perp_padding, y0 + thickness
|
||||
elseif border_n == 3 --[[ImGuiDir.Down]] then
|
||||
a, b, c, d = x0 + perp_padding, y1 - thickness, x1 - perp_padding, y1 + thickness
|
||||
else
|
||||
assert(false)
|
||||
a, b, c, d = 0, 0, 0, 0
|
||||
end
|
||||
if border_n == 1 --[[ImGuiDir.Right]] then
|
||||
return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding)
|
||||
if out then
|
||||
out.Min.x, out.Min.y, out.Max.x, out.Max.y = a, b, c, d
|
||||
return out
|
||||
end
|
||||
if border_n == 2 --[[ImGuiDir.Up]] then
|
||||
return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness)
|
||||
end
|
||||
if border_n == 3 --[[ImGuiDir.Down]] then
|
||||
return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness)
|
||||
end
|
||||
assert(false)
|
||||
return ImRect()
|
||||
return ImRect(a, b, c, d)
|
||||
end
|
||||
local UpdateWindowManualResize_rect = ImRect() -- [Luau] scratch grip/border rect: ItemAdd() copies, ButtonBehavior() reads
|
||||
|
||||
-- Known size hash
|
||||
-- It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
|
||||
@@ -10218,10 +10225,12 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
local corner_pos = def.CornerPosN
|
||||
local inner_dir = def.InnerDir
|
||||
|
||||
local corner = ImVec2(window.Pos.x + corner_pos.x * window.Size.x, window.Pos.y + corner_pos.y * window.Size.y)
|
||||
local corner_x, corner_y = window.Pos.x + corner_pos.x * window.Size.x, window.Pos.y + corner_pos.y * window.Size.y
|
||||
|
||||
-- Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
|
||||
local resize_rect = ImRect(corner - inner_dir * grip_hover_outer_size, corner + inner_dir * grip_hover_inner_size)
|
||||
local resize_rect = UpdateWindowManualResize_rect -- [Luau] scratch, scalar math
|
||||
resize_rect.Min.x, resize_rect.Min.y = corner_x - inner_dir.x * grip_hover_outer_size, corner_y - inner_dir.y * grip_hover_outer_size
|
||||
resize_rect.Max.x, resize_rect.Max.y = corner_x + inner_dir.x * grip_hover_inner_size, corner_y + inner_dir.y * grip_hover_inner_size
|
||||
|
||||
if resize_rect.Min.x > resize_rect.Max.x then resize_rect.Min.x, resize_rect.Max.x = resize_rect.Max.x, resize_rect.Min.x end
|
||||
if resize_rect.Min.y > resize_rect.Max.y then resize_rect.Min.y, resize_rect.Max.y = resize_rect.Max.y, resize_rect.Min.y end
|
||||
@@ -10294,7 +10303,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
axis = 2 --[[ImGuiAxis.Y]]
|
||||
end
|
||||
|
||||
local border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, g.WindowsBorderHoverPadding)
|
||||
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]]))
|
||||
@@ -10323,7 +10332,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
-- 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))
|
||||
if g.ActiveIdIsJustActivated or just_scrolled_manually_while_resizing then
|
||||
g.WindowResizeBorderExpectedRect = border_rect
|
||||
g.WindowResizeBorderExpectedRect = ImRect(border_rect.Min, border_rect.Max) -- [Luau] copy: border_rect is scratch
|
||||
g.WindowResizeRelativeMode = false
|
||||
end
|
||||
|
||||
@@ -12214,13 +12223,17 @@ function ImGui.Begin(name, open, flags)
|
||||
-- Add to stack
|
||||
g.CurrentWindow = window
|
||||
g.CurrentWindowStack:resize(g.CurrentWindowStack.Size + 1)
|
||||
g.CurrentWindowStack.Data[g.CurrentWindowStack.Size] = ImGuiWindowStackData()
|
||||
-- [Luau] reuse the slot's table left by pop_back() (C++ reuses the vector storage); every field is set below
|
||||
local window_stack_data = g.CurrentWindowStack.Data[g.CurrentWindowStack.Size]
|
||||
if type(window_stack_data) ~= "table" or window_stack_data.ParentLastItemDataBackup == nil then
|
||||
window_stack_data = ImGuiWindowStackData()
|
||||
g.CurrentWindowStack.Data[g.CurrentWindowStack.Size] = window_stack_data
|
||||
end
|
||||
window_stack_data.Window = window
|
||||
ImGuiLastItemData_Copy(window_stack_data.ParentLastItemDataBackup, g.LastItemData)
|
||||
window_stack_data.DisabledOverrideReenable = (bit32.band(flags, 33554432 --[[ImGuiWindowFlags.Tooltip]]) ~= 0) and (bit32.band(g.CurrentItemFlags, 64 --[[ImGuiItemFlags.Disabled]]) ~= 0)
|
||||
window_stack_data.DisabledOverrideReenableAlphaBackup = 0.0
|
||||
window_stack_data.StackSizesInBegin = ImGuiErrorRecoveryState()
|
||||
window_stack_data.StackSizesInBegin = window_stack_data.StackSizesInBegin or ImGuiErrorRecoveryState() -- [Luau] reused, all fields stored
|
||||
ImGui.ErrorRecoveryStoreState(window_stack_data.StackSizesInBegin)
|
||||
g.StackSizesInBeginForCurrentWindow = window_stack_data.StackSizesInBegin
|
||||
if bit32.band(flags, 268435456 --[[ImGuiWindowFlags.ChildMenu]]) ~= 0 then
|
||||
|
||||
Generated
+1
-1
@@ -1 +1 @@
|
||||
[[183, "imgui.lua"], [22788, "imgui_demo.lua"], [34645, "imgui_draw.lua"], [42982, "imgui_h.lua"], [45983, "imgui_impl_love.lua"], [46527, "imgui_internal.lua"], [50493, "imgui_tables.lua"], [55585, "imgui_widgets.lua"], [67826, "imstb_rectpack.lua"], [68490, "imstb_textedit.lua"], [70032, "imstb_truetype.lua"], [72820, "imstd_minstdio.lua"]]
|
||||
[[183, "imgui.lua"], [22801, "imgui_demo.lua"], [34658, "imgui_draw.lua"], [42995, "imgui_h.lua"], [45996, "imgui_impl_love.lua"], [46540, "imgui_internal.lua"], [50506, "imgui_tables.lua"], [55598, "imgui_widgets.lua"], [67839, "imstb_rectpack.lua"], [68503, "imstb_textedit.lua"], [70045, "imstb_truetype.lua"], [72833, "imstd_minstdio.lua"]]
|
||||
Generated
+33
-20
@@ -5054,26 +5054,33 @@ local ImGuiResizeBorderDef = {
|
||||
--- @param thickness float
|
||||
--- @return ImRect
|
||||
--- @nodiscard
|
||||
local function GetResizeBorderRect(window, border_n, perp_padding, thickness)
|
||||
local rect = window:Rect()
|
||||
-- [Luau] out: optional ImRect written in place (no allocation)
|
||||
local function GetResizeBorderRect(window, border_n, perp_padding, thickness, out)
|
||||
local x0, y0 = window.Pos.x, window.Pos.y
|
||||
local x1, y1 = x0 + window.Size.x, y0 + window.Size.y
|
||||
if thickness == 0.0 then
|
||||
ImVec2_CopyV(rect.Max, rect.Max.x - 1, rect.Max.y - 1)
|
||||
x1, y1 = x1 - 1, y1 - 1
|
||||
end
|
||||
local a, b, c, d
|
||||
if border_n == 0 --[[ImGuiDir.Left]] then
|
||||
return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding)
|
||||
a, b, c, d = x0 - thickness, y0 + perp_padding, x0 + thickness, y1 - perp_padding
|
||||
elseif border_n == 1 --[[ImGuiDir.Right]] then
|
||||
a, b, c, d = x1 - thickness, y0 + perp_padding, x1 + thickness, y1 - perp_padding
|
||||
elseif border_n == 2 --[[ImGuiDir.Up]] then
|
||||
a, b, c, d = x0 + perp_padding, y0 - thickness, x1 - perp_padding, y0 + thickness
|
||||
elseif border_n == 3 --[[ImGuiDir.Down]] then
|
||||
a, b, c, d = x0 + perp_padding, y1 - thickness, x1 - perp_padding, y1 + thickness
|
||||
else
|
||||
assert(false)
|
||||
a, b, c, d = 0, 0, 0, 0
|
||||
end
|
||||
if border_n == 1 --[[ImGuiDir.Right]] then
|
||||
return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding)
|
||||
if out then
|
||||
out.Min.x, out.Min.y, out.Max.x, out.Max.y = a, b, c, d
|
||||
return out
|
||||
end
|
||||
if border_n == 2 --[[ImGuiDir.Up]] then
|
||||
return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness)
|
||||
end
|
||||
if border_n == 3 --[[ImGuiDir.Down]] then
|
||||
return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness)
|
||||
end
|
||||
assert(false)
|
||||
return ImRect()
|
||||
return ImRect(a, b, c, d)
|
||||
end
|
||||
local UpdateWindowManualResize_rect = ImRect() -- [Luau] scratch grip/border rect: ItemAdd() copies, ButtonBehavior() reads
|
||||
|
||||
-- Known size hash
|
||||
-- It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
|
||||
@@ -10355,10 +10362,12 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
local corner_pos = def.CornerPosN
|
||||
local inner_dir = def.InnerDir
|
||||
|
||||
local corner = ImVec2(window.Pos.x + corner_pos.x * window.Size.x, window.Pos.y + corner_pos.y * window.Size.y)
|
||||
local corner_x, corner_y = window.Pos.x + corner_pos.x * window.Size.x, window.Pos.y + corner_pos.y * window.Size.y
|
||||
|
||||
-- Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
|
||||
local resize_rect = ImRect(corner - inner_dir * grip_hover_outer_size, corner + inner_dir * grip_hover_inner_size)
|
||||
local resize_rect = UpdateWindowManualResize_rect -- [Luau] scratch, scalar math
|
||||
resize_rect.Min.x, resize_rect.Min.y = corner_x - inner_dir.x * grip_hover_outer_size, corner_y - inner_dir.y * grip_hover_outer_size
|
||||
resize_rect.Max.x, resize_rect.Max.y = corner_x + inner_dir.x * grip_hover_inner_size, corner_y + inner_dir.y * grip_hover_inner_size
|
||||
|
||||
if resize_rect.Min.x > resize_rect.Max.x then resize_rect.Min.x, resize_rect.Max.x = resize_rect.Max.x, resize_rect.Min.x end
|
||||
if resize_rect.Min.y > resize_rect.Max.y then resize_rect.Min.y, resize_rect.Max.y = resize_rect.Max.y, resize_rect.Min.y end
|
||||
@@ -10431,7 +10440,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
axis = 2 --[[ImGuiAxis.Y]]
|
||||
end
|
||||
|
||||
local border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, g.WindowsBorderHoverPadding)
|
||||
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]]))
|
||||
@@ -10460,7 +10469,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
-- 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))
|
||||
if g.ActiveIdIsJustActivated or just_scrolled_manually_while_resizing then
|
||||
g.WindowResizeBorderExpectedRect = border_rect
|
||||
g.WindowResizeBorderExpectedRect = ImRect(border_rect.Min, border_rect.Max) -- [Luau] copy: border_rect is scratch
|
||||
g.WindowResizeRelativeMode = false
|
||||
end
|
||||
|
||||
@@ -12351,13 +12360,17 @@ function ImGui.Begin(name, open, flags)
|
||||
-- Add to stack
|
||||
g.CurrentWindow = window
|
||||
g.CurrentWindowStack:resize(g.CurrentWindowStack.Size + 1)
|
||||
g.CurrentWindowStack.Data[g.CurrentWindowStack.Size] = ImGuiWindowStackData()
|
||||
-- [Luau] reuse the slot's table left by pop_back() (C++ reuses the vector storage); every field is set below
|
||||
local window_stack_data = g.CurrentWindowStack.Data[g.CurrentWindowStack.Size]
|
||||
if type(window_stack_data) ~= "table" or window_stack_data.ParentLastItemDataBackup == nil then
|
||||
window_stack_data = ImGuiWindowStackData()
|
||||
g.CurrentWindowStack.Data[g.CurrentWindowStack.Size] = window_stack_data
|
||||
end
|
||||
window_stack_data.Window = window
|
||||
ImGuiLastItemData_Copy(window_stack_data.ParentLastItemDataBackup, g.LastItemData)
|
||||
window_stack_data.DisabledOverrideReenable = (bit32.band(flags, 33554432 --[[ImGuiWindowFlags.Tooltip]]) ~= 0) and (bit32.band(g.CurrentItemFlags, 64 --[[ImGuiItemFlags.Disabled]]) ~= 0)
|
||||
window_stack_data.DisabledOverrideReenableAlphaBackup = 0.0
|
||||
window_stack_data.StackSizesInBegin = ImGuiErrorRecoveryState()
|
||||
window_stack_data.StackSizesInBegin = window_stack_data.StackSizesInBegin or ImGuiErrorRecoveryState() -- [Luau] reused, all fields stored
|
||||
ImGui.ErrorRecoveryStoreState(window_stack_data.StackSizesInBegin)
|
||||
g.StackSizesInBeginForCurrentWindow = window_stack_data.StackSizesInBegin
|
||||
if bit32.band(flags, 268435456 --[[ImGuiWindowFlags.ChildMenu]]) ~= 0 then
|
||||
|
||||
@@ -4872,26 +4872,33 @@ local ImGuiResizeBorderDef = {
|
||||
--- @param thickness float
|
||||
--- @return ImRect
|
||||
--- @nodiscard
|
||||
local function GetResizeBorderRect(window, border_n, perp_padding, thickness)
|
||||
local rect = window:Rect()
|
||||
-- [Luau] out: optional ImRect written in place (no allocation)
|
||||
local function GetResizeBorderRect(window, border_n, perp_padding, thickness, out)
|
||||
local x0, y0 = window.Pos.x, window.Pos.y
|
||||
local x1, y1 = x0 + window.Size.x, y0 + window.Size.y
|
||||
if thickness == 0.0 then
|
||||
ImVec2_CopyV(rect.Max, rect.Max.x - 1, rect.Max.y - 1)
|
||||
x1, y1 = x1 - 1, y1 - 1
|
||||
end
|
||||
local a, b, c, d
|
||||
if border_n == ImGuiDir.Left then
|
||||
return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding)
|
||||
a, b, c, d = x0 - thickness, y0 + perp_padding, x0 + thickness, y1 - perp_padding
|
||||
elseif border_n == ImGuiDir.Right then
|
||||
a, b, c, d = x1 - thickness, y0 + perp_padding, x1 + thickness, y1 - perp_padding
|
||||
elseif border_n == ImGuiDir.Up then
|
||||
a, b, c, d = x0 + perp_padding, y0 - thickness, x1 - perp_padding, y0 + thickness
|
||||
elseif border_n == ImGuiDir.Down then
|
||||
a, b, c, d = x0 + perp_padding, y1 - thickness, x1 - perp_padding, y1 + thickness
|
||||
else
|
||||
IM_ASSERT(false)
|
||||
a, b, c, d = 0, 0, 0, 0
|
||||
end
|
||||
if border_n == ImGuiDir.Right then
|
||||
return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding)
|
||||
if out then
|
||||
out.Min.x, out.Min.y, out.Max.x, out.Max.y = a, b, c, d
|
||||
return out
|
||||
end
|
||||
if border_n == ImGuiDir.Up then
|
||||
return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness)
|
||||
end
|
||||
if border_n == ImGuiDir.Down then
|
||||
return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness)
|
||||
end
|
||||
IM_ASSERT(false)
|
||||
return ImRect()
|
||||
return ImRect(a, b, c, d)
|
||||
end
|
||||
local UpdateWindowManualResize_rect = ImRect() -- [Luau] scratch grip/border rect: ItemAdd() copies, ButtonBehavior() reads
|
||||
|
||||
-- Known size hash
|
||||
-- It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
|
||||
@@ -10173,10 +10180,12 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
local corner_pos = def.CornerPosN
|
||||
local inner_dir = def.InnerDir
|
||||
|
||||
local corner = ImVec2(window.Pos.x + corner_pos.x * window.Size.x, window.Pos.y + corner_pos.y * window.Size.y)
|
||||
local corner_x, corner_y = window.Pos.x + corner_pos.x * window.Size.x, window.Pos.y + corner_pos.y * window.Size.y
|
||||
|
||||
-- Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
|
||||
local resize_rect = ImRect(corner - inner_dir * grip_hover_outer_size, corner + inner_dir * grip_hover_inner_size)
|
||||
local resize_rect = UpdateWindowManualResize_rect -- [Luau] scratch, scalar math
|
||||
resize_rect.Min.x, resize_rect.Min.y = corner_x - inner_dir.x * grip_hover_outer_size, corner_y - inner_dir.y * grip_hover_outer_size
|
||||
resize_rect.Max.x, resize_rect.Max.y = corner_x + inner_dir.x * grip_hover_inner_size, corner_y + inner_dir.y * grip_hover_inner_size
|
||||
|
||||
if resize_rect.Min.x > resize_rect.Max.x then resize_rect.Min.x, resize_rect.Max.x = resize_rect.Max.x, resize_rect.Min.x end
|
||||
if resize_rect.Min.y > resize_rect.Max.y then resize_rect.Min.y, resize_rect.Max.y = resize_rect.Max.y, resize_rect.Min.y end
|
||||
@@ -10249,7 +10258,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
axis = ImGuiAxis.Y
|
||||
end
|
||||
|
||||
local border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, g.WindowsBorderHoverPadding)
|
||||
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, ImGuiItemFlags.NoNav)
|
||||
local _, hovered, held = ImGui.ButtonBehavior(border_rect, border_id, bit32.bor(ImGuiButtonFlags.FlattenChildren, ImGuiButtonFlags.NoNavFocus))
|
||||
@@ -10278,7 +10287,7 @@ local function UpdateWindowManualResize(window, resize_grip_count, resize_grip_c
|
||||
-- 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))
|
||||
if g.ActiveIdIsJustActivated or just_scrolled_manually_while_resizing then
|
||||
g.WindowResizeBorderExpectedRect = border_rect
|
||||
g.WindowResizeBorderExpectedRect = ImRect(border_rect.Min, border_rect.Max) -- [Luau] copy: border_rect is scratch
|
||||
g.WindowResizeRelativeMode = false
|
||||
end
|
||||
|
||||
@@ -12169,13 +12178,17 @@ function ImGui.Begin(name, open, flags)
|
||||
-- Add to stack
|
||||
g.CurrentWindow = window
|
||||
g.CurrentWindowStack:resize(g.CurrentWindowStack.Size + 1)
|
||||
g.CurrentWindowStack.Data[g.CurrentWindowStack.Size] = ImGuiWindowStackData()
|
||||
-- [Luau] reuse the slot's table left by pop_back() (C++ reuses the vector storage); every field is set below
|
||||
local window_stack_data = g.CurrentWindowStack.Data[g.CurrentWindowStack.Size]
|
||||
if type(window_stack_data) ~= "table" or window_stack_data.ParentLastItemDataBackup == nil then
|
||||
window_stack_data = ImGuiWindowStackData()
|
||||
g.CurrentWindowStack.Data[g.CurrentWindowStack.Size] = window_stack_data
|
||||
end
|
||||
window_stack_data.Window = window
|
||||
ImGuiLastItemData_Copy(window_stack_data.ParentLastItemDataBackup, g.LastItemData)
|
||||
window_stack_data.DisabledOverrideReenable = (bit32.band(flags, ImGuiWindowFlags.Tooltip) ~= 0) and (bit32.band(g.CurrentItemFlags, ImGuiItemFlags.Disabled) ~= 0)
|
||||
window_stack_data.DisabledOverrideReenableAlphaBackup = 0.0
|
||||
window_stack_data.StackSizesInBegin = ImGuiErrorRecoveryState()
|
||||
window_stack_data.StackSizesInBegin = window_stack_data.StackSizesInBegin or ImGuiErrorRecoveryState() -- [Luau] reused, all fields stored
|
||||
ImGui.ErrorRecoveryStoreState(window_stack_data.StackSizesInBegin)
|
||||
g.StackSizesInBeginForCurrentWindow = window_stack_data.StackSizesInBegin
|
||||
if bit32.band(flags, ImGuiWindowFlags.ChildMenu) ~= 0 then
|
||||
|
||||
Reference in new issue
Block a user