WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 1f54665

Browse files
committed
Menus: fixed MenuItem() label baseline when using inside a line with an offset.
Amend f8fae02
1 parent ae873b1 commit 1f54665

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Other Changes:
5151
- Textures:
5252
- Fixed a building issue when ImTextureID is defined as a struct.
5353
- Fixed displaying texture # in Metrics/Debugger window.
54+
- Menus: fixed MenuItem() label baseline when using inside a line with an offset.
5455
- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be
5556
noticeable by user but detected by sanitizers). (#9089) [@judicaelclair]
5657
- Backends:

imgui_widgets.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9434,21 +9434,22 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
94349434
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
94359435
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame
94369436
float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
9437+
ImVec2 text_pos(pos.x, pos.y + window->DC.CurrLineTextBaseOffset);
94379438
pressed = Selectable("", false, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
94389439
if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Visible)
94399440
{
9440-
RenderText(pos + ImVec2(offsets->OffsetLabel, 0.0f), label);
9441+
RenderText(text_pos + ImVec2(offsets->OffsetLabel, 0.0f), label);
94419442
if (icon_w > 0.0f)
9442-
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
9443+
RenderText(text_pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
94439444
if (shortcut_w > 0.0f)
94449445
{
94459446
PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
94469447
LogSetNextTextDecoration("(", ")");
9447-
RenderText(pos + ImVec2(offsets->OffsetShortcut + stretch_w, 0.0f), shortcut, NULL, false);
9448+
RenderText(text_pos + ImVec2(offsets->OffsetShortcut + stretch_w, 0.0f), shortcut, NULL, false);
94489449
PopStyleColor();
94499450
}
94509451
if (selected)
9451-
RenderCheckMark(window->DrawList, pos + ImVec2(offsets->OffsetMark + stretch_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(ImGuiCol_Text), g.FontSize * 0.866f);
9452+
RenderCheckMark(window->DrawList, text_pos + ImVec2(offsets->OffsetMark + stretch_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(ImGuiCol_Text), g.FontSize * 0.866f);
94529453
}
94539454
}
94549455
IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));

0 commit comments

Comments
 (0)