Skip to content

Commit 3fbeae7

Browse files
committed
chore(ImGuiExt): tidy up
1 parent 01618f6 commit 3fbeae7

2 files changed

Lines changed: 26 additions & 28 deletions

File tree

SSV2/includes/frontend/yim_resupplier/yrv3_ui.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ local function YRV3UI()
117117
end
118118
ImGui.EndChild()
119119

120-
ImGui.SameLine()
121120
ImGui.VerticalSeparator(separatorWidth)
122-
ImGui.SameLine()
123121

124122
ImGui.SetNextWindowBgAlpha(0)
125123
ImGui.BeginChild("##yrv3_4")

SSV2/includes/lib/imgui_ext.lua

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,21 @@ end
119119
---@return string result lowercase
120120
---@return boolean changed
121121
function ImGui.SearchBar(label, stringBuffer, flags, maxWidth, bufferSize)
122-
maxWidth = maxWidth or -1
123-
bufferSize = bufferSize or math.max(#stringBuffer + 32, 256)
124-
flags = flags or ImGuiInputTextFlags.None
125-
local changed = false
122+
maxWidth = maxWidth or -1
123+
bufferSize = bufferSize or math.max(#stringBuffer + 32, 256)
124+
flags = flags or 0
126125

127126
ImGui.SetNextItemWidth(maxWidth)
128127
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, 15, 5)
129-
stringBuffer, changed = ImGui.InputTextWithHint(
128+
local out, changed = ImGui.InputTextWithHint(
130129
label,
131130
_T("GENERIC_SEARCH_HINT"),
132131
stringBuffer,
133132
bufferSize,
134133
flags
135134
)
136135
ImGui.PopStyleVar()
137-
return stringBuffer:lower(), changed
136+
return out:lower(), changed
138137
end
139138

140139
-- Returns a basic animated string
@@ -173,6 +172,18 @@ function ImGui.GetAutoTextColor(bgColor)
173172
return bgColor:IsDark() and Color.WHITE or Color.BLACK
174173
end
175174

175+
---@param idx ImGuiCol
176+
---@return Color
177+
function ImGui.GetStyleColor(idx)
178+
return Color(ImGui.GetStyleColorVec4(idx))
179+
end
180+
181+
---@param idx ImGuiCol
182+
---@return uint32_t
183+
function ImGui.GetStyleColorU32(idx)
184+
return ImGui.ColorConvertFloat4ToU32({ ImGui.GetStyleColorVec4(idx) })
185+
end
186+
176187
---@param bgColor uint32_t
177188
---@return uint32_t
178189
function ImGui.GetAutoTextColorU32(bgColor)
@@ -247,10 +258,10 @@ end
247258
-- Wrapper for `ImGui.ColorEdit3` that takes a vec3 and mutates it in place.
248259
---@param label string
249260
---@param outVector vec3
250-
---@return boolean
261+
---@return boolean clicked
251262
function ImGui.ColorEditVec3(label, outVector)
252263
if (not IsInstance(outVector, vec3)) then
253-
Notifier:ShowError("ImGui", _F("Invalid argument #2: vec3 expected, got %s instead.", type(outVector)), true)
264+
log.fwarning("Invalid argument #2: vec3 expected, got %s instead.", type(outVector))
254265
return false
255266
end
256267

@@ -289,12 +300,12 @@ end
289300

290301
---@param label string
291302
---@param outU32 uint32_t
292-
---@return uint32_t, boolean
303+
---@return uint32_t U32, boolean clicked
293304
function ImGui.ColorEditU32(label, outU32)
294305
local temp, changed = { Color(outU32):AsFloat() }, false
295306
temp, changed = ImGui.ColorEdit4(label, temp)
296307
if (changed) then
297-
return Color(temp):AsU32(), changed
308+
return ImGui.ColorConvertFloat4ToU32(temp), changed
298309
end
299310

300311
return outU32, changed
@@ -455,18 +466,6 @@ function ImGui.Selectable2(label, selected, size, align, ellipsis, shouldHighlig
455466
return clicked
456467
end
457468

458-
---@param idx ImGuiCol
459-
---@return Color
460-
function ImGui.GetStyleColor(idx)
461-
return Color(ImGui.GetStyleColorVec4(idx))
462-
end
463-
464-
---@param idx ImGuiCol
465-
---@return uint32_t
466-
function ImGui.GetStyleColorU32(idx)
467-
return ImGui.ColorConvertFloat4ToU32({ ImGui.GetStyleColorVec4(idx) })
468-
end
469-
470469
-- https://github.com/ocornut/imgui/issues/5263
471470
---@param label string
472471
---@param value float
@@ -477,10 +476,8 @@ function ImGui.ValueBar(label, value, size, flags, opts)
477476
flags = flags or ImGuiValueBarFlags.NONE
478477
size = size or vec2:zero()
479478
opts = opts or {}
480-
481-
---@type boolean
482-
local isMultiVal = flags & ImGuiValueBarFlags.MULTI_VAL ~= 0
483-
local isHotizontal = flags & ImGuiValueBarFlags.VERTICAL == 0
479+
local isMultiVal = (flags & ImGuiValueBarFlags.MULTI_VAL) ~= 0
480+
local isHotizontal = (flags & ImGuiValueBarFlags.VERTICAL) == 0
484481
local region = vec2:new(ImGui.GetContentRegionAvail())
485482

486483
if (size.x <= 0) then
@@ -607,6 +604,8 @@ end
607604
---@param thickness? float
608605
---@param color? uint32_t
609606
function ImGui.VerticalSeparator(thickness, color)
607+
ImGui.SameLine()
608+
610609
thickness = thickness or 1
611610
color = color or ImGui.GetStyleColorU32(ImGuiCol.Separator)
612611
local drawList = ImGui.GetWindowDrawList()
@@ -624,6 +623,7 @@ function ImGui.VerticalSeparator(thickness, color)
624623
)
625624

626625
ImGui.Dummy(thickness, 0)
626+
ImGui.SameLine()
627627
end
628628

629629
---@param label string

0 commit comments

Comments
 (0)