Selectable: Removed seemingly ineffective text clipping offset in SpanAllColumns handling path + tweaks.
made max_x absolutely to reduce confusion.
amend cf481e1
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 938e94c..061feca 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -5580,14 +5580,14 @@
// Fill horizontal space.
ImVec2 window_padding = window->WindowPadding;
- float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x;
- float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - pos.x);
- 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);
+ float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x + window->Pos.x : GetContentRegionMaxAbs().x;
+ float w_draw = ImMax(label_size.x, max_x - window_padding.x - pos.x);
+ ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size.y);
ImRect bb(pos, pos + size_draw);
if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth))
bb.Max.x += window_padding.x;
- // Selectables are tightly packed together so we extend the box to cover spacing between selectable.
+ // Selectables are meant to be tightly packed together with no click-gap, so we extend the box to cover spacing between selectable.
const float spacing_x = style.ItemSpacing.x;
const float spacing_y = style.ItemSpacing.y;
const float spacing_L = IM_FLOOR(spacing_x * 0.50f);
@@ -5662,10 +5662,7 @@
}
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns)
- {
PopColumnsBackground();
- bb.Max.x -= (GetContentRegionMax().x - max_x);
- }
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
RenderTextClipped(bb_inner.Min, bb_inner.Max, label, NULL, &label_size, style.SelectableTextAlign, &bb);