Skip to content

Commit ac2247f

Browse files
committed
Selectable: Removed seemingly ineffective text clipping offset in SpanAllColumns handling path + tweaks.
made max_x absolutely to reduce confusion. amend cf481e1
1 parent 1d4b5de commit ac2247f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

imgui_widgets.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,14 +5580,14 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
55805580

55815581
// Fill horizontal space.
55825582
ImVec2 window_padding = window->WindowPadding;
5583-
float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x;
5584-
float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - pos.x);
5585-
ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size_arg.y != 0.0f ? size_arg.y : size.y);
5583+
float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x + window->Pos.x : GetContentRegionMaxAbs().x;
5584+
float w_draw = ImMax(label_size.x, max_x - window_padding.x - pos.x);
5585+
ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size.y);
55865586
ImRect bb(pos, pos + size_draw);
55875587
if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth))
55885588
bb.Max.x += window_padding.x;
55895589

5590-
// Selectables are tightly packed together so we extend the box to cover spacing between selectable.
5590+
// Selectables are meant to be tightly packed together with no click-gap, so we extend the box to cover spacing between selectable.
55915591
const float spacing_x = style.ItemSpacing.x;
55925592
const float spacing_y = style.ItemSpacing.y;
55935593
const float spacing_L = IM_FLOOR(spacing_x * 0.50f);
@@ -5662,10 +5662,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
56625662
}
56635663

56645664
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns)
5665-
{
56665665
PopColumnsBackground();
5667-
bb.Max.x -= (GetContentRegionMax().x - max_x);
5668-
}
56695666

56705667
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
56715668
RenderTextClipped(bb_inner.Min, bb_inner.Max, label, NULL, &label_size, style.SelectableTextAlign, &bb);

0 commit comments

Comments
 (0)