|
@@ -5899,7 +5899,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
const ImGuiStyle& style = g.Style;
|
|
|
|
|
|
- if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) // FIXME-OPT: Avoid if vertically clipped.
|
|
|
+ const bool span_all_columns = (flags & ImGuiSelectableFlags_SpanAllColumns) != 0;
|
|
|
+ if (span_all_columns && window->DC.CurrentColumns) // FIXME-OPT: Avoid if vertically clipped.
|
|
|
PushColumnsBackground();
|
|
|
|
|
|
// Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle.
|
|
@@ -5911,8 +5912,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
|
ItemSize(size, 0.0f);
|
|
|
|
|
|
// Fill horizontal space
|
|
|
- const float min_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? window->ParentWorkRect.Min.x : pos.x;
|
|
|
- const float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x;
|
|
|
+ const float min_x = span_all_columns ? window->ParentWorkRect.Min.x : pos.x;
|
|
|
+ const float max_x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x;
|
|
|
if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth))
|
|
|
size.x = ImMax(label_size.x, max_x - min_x);
|
|
|
|
|
@@ -5921,33 +5922,35 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
|
const ImVec2 text_max(min_x + size.x, pos.y + size.y);
|
|
|
|
|
|
// Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable.
|
|
|
- ImRect bb_enlarged(min_x, pos.y, text_max.x, text_max.y);
|
|
|
- const float spacing_x = style.ItemSpacing.x;
|
|
|
- const float spacing_y = style.ItemSpacing.y;
|
|
|
- const float spacing_L = IM_FLOOR(spacing_x * 0.50f);
|
|
|
- const float spacing_U = IM_FLOOR(spacing_y * 0.50f);
|
|
|
- bb_enlarged.Min.x -= spacing_L;
|
|
|
- bb_enlarged.Min.y -= spacing_U;
|
|
|
- bb_enlarged.Max.x += (spacing_x - spacing_L);
|
|
|
- bb_enlarged.Max.y += (spacing_y - spacing_U);
|
|
|
- //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb_align.Min, bb_align.Max, IM_COL32(255, 0, 0, 255)); }
|
|
|
- //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb_enlarged.Min, bb_enlarged.Max, IM_COL32(0, 255, 0, 255)); }
|
|
|
+ ImRect bb(min_x, pos.y, text_max.x, text_max.y);
|
|
|
+ if ((flags & ImGuiSelectableFlags_NoPadWithHalfSpacing) == 0)
|
|
|
+ {
|
|
|
+ const float spacing_x = style.ItemSpacing.x;
|
|
|
+ const float spacing_y = style.ItemSpacing.y;
|
|
|
+ const float spacing_L = IM_FLOOR(spacing_x * 0.50f);
|
|
|
+ const float spacing_U = IM_FLOOR(spacing_y * 0.50f);
|
|
|
+ bb.Min.x -= spacing_L;
|
|
|
+ bb.Min.y -= spacing_U;
|
|
|
+ bb.Max.x += (spacing_x - spacing_L);
|
|
|
+ bb.Max.y += (spacing_y - spacing_U);
|
|
|
+ }
|
|
|
+ //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(0, 255, 0, 255)); }
|
|
|
|
|
|
bool item_add;
|
|
|
if (flags & ImGuiSelectableFlags_Disabled)
|
|
|
{
|
|
|
ImGuiItemFlags backup_item_flags = window->DC.ItemFlags;
|
|
|
window->DC.ItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus;
|
|
|
- item_add = ItemAdd(bb_enlarged, id);
|
|
|
+ item_add = ItemAdd(bb, id);
|
|
|
window->DC.ItemFlags = backup_item_flags;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- item_add = ItemAdd(bb_enlarged, id);
|
|
|
+ item_add = ItemAdd(bb, id);
|
|
|
}
|
|
|
if (!item_add)
|
|
|
{
|
|
|
- if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns)
|
|
|
+ if (span_all_columns && window->DC.CurrentColumns)
|
|
|
PopColumnsBackground();
|
|
|
return false;
|
|
|
}
|
|
@@ -5966,7 +5969,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
|
|
|
|
const bool was_selected = selected;
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(bb_enlarged, id, &hovered, &held, button_flags);
|
|
|
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
|
|
|
|
|
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard
|
|
|
if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover)))
|
|
@@ -5993,15 +5996,15 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
|
if (hovered || selected)
|
|
|
{
|
|
|
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
|
|
- RenderFrame(bb_enlarged.Min, bb_enlarged.Max, col, false, 0.0f);
|
|
|
- RenderNavHighlight(bb_enlarged, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
|
|
+ RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
|
|
|
+ RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
|
|
}
|
|
|
|
|
|
- if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns)
|
|
|
+ if (span_all_columns && window->DC.CurrentColumns)
|
|
|
PopColumnsBackground();
|
|
|
|
|
|
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
|
|
|
- RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb_enlarged);
|
|
|
+ RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb);
|
|
|
if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();
|
|
|
|
|
|
// Automatically close popups
|
|
@@ -7749,7 +7752,7 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|
|
bool close_button_visible = false;
|
|
|
if (close_button_id != 0)
|
|
|
if (is_contents_visible || bb.GetWidth() >= g.Style.TabMinWidthForUnselectedCloseButton)
|
|
|
- if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == close_button_id)
|
|
|
+ if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == tab_id || g.ActiveId == close_button_id)
|
|
|
close_button_visible = true;
|
|
|
if (close_button_visible)
|
|
|
{
|