Fix build against ImGui >= 1.92.8 (ImLerp cannot take ImOffsetRect)#22
Open
tonzsm wants to merge 1 commit into
Open
Fix build against ImGui >= 1.92.8 (ImLerp cannot take ImOffsetRect)#22tonzsm wants to merge 1 commit into
tonzsm wants to merge 1 commit into
Conversation
Added ImLerp overload for ImOffsetRect to support new ImGui version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Body
The new form needs a
T -> floatconversion.ImOffsetRectonly converts the other way (via itsImOffsetRect(float all)constructor), so instantiating the template fails — andImGuiToggleRenderer::UpdateState()lerps two of them:// imgui_toggle_renderer.cpp:409-410 _state.KnobInset = ImLerp(_config.Off.KnobInset, _config.On.KnobInset, _animationPercent); _state.KnobOffset = ImLerp(_config.Off.KnobOffset, _config.On.KnobOffset, _animationPercent);giving:
Pinning an older ImGui is not a way out: #20 ("Fix for ImGui 1.92.8 AddRect arg swap") already requires
Fix
This is @nitz's own fix from #21, unchanged — an exact-match
ImLerpoverload forImOffsetRectatthe end of
imgui_offset_rect.h, guarded onIMGUI_VERSION_NUM >= 19274:An exact match beats ImGui's template during overload resolution, so the two call sites above pick it up
with no other change. The result is identical to what the old template produced:
tconverts toImOffsetRect(t,t,t,t)and the existingoperator*multiplies component-wise.I added only a comment explaining why it exists and
IM_MSVC_RUNTIME_CHECKS_OFF/RESTOREto match theneighbouring operators.
#21 was closed as completed, but the fix only ever existed as a comment — so anyone cloning
mainstillhits this. This commits it.
Verification
1.92.8(IMGUI_VERSION_NUM 19280), MSVC,/std:c++17 /W4, no warnings.