Skip to content

Commit 7b96209

Browse files
committed
update for compatibility between 1.83 and 1.84 WIP
1 parent a2c2ca2 commit 7b96209

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,11 @@ namespace IGFD
574574
}
575575

576576
bool item_add;
577-
if (flags & ImGuiSelectableFlags_Disabled)
577+
const bool disabled_item = (flags & ImGuiSelectableFlags_Disabled) != 0;
578+
if (disabled_item)
578579
{
579580
ImGuiItemFlags backup_item_flags = g.CurrentItemFlags;
580-
g.CurrentItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus;
581+
g.CurrentItemFlags |= ImGuiItemFlags_Disabled;
581582
item_add = ItemAdd(bb, id);
582583
g.CurrentItemFlags = backup_item_flags;
583584
}
@@ -595,6 +596,10 @@ namespace IGFD
595596
if (!item_add)
596597
return false;
597598

599+
const bool disabled_global = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
600+
if (disabled_item && !disabled_global)
601+
PushDisabled(true);
602+
598603
// FIXME: We can standardize the behavior of those two, we could also keep the fast path of override ClipRect + full push on render only,
599604
// which would be advantageous since most selectable are not selected.
600605
if (span_all_columns && window->DC.CurrentColumns)
@@ -607,17 +612,24 @@ namespace IGFD
607612
if (flags & ImGuiSelectableFlags_NoHoldingActiveID) { button_flags |= ImGuiButtonFlags_NoHoldingActiveId; }
608613
if (flags & ImGuiSelectableFlags_SelectOnClick) { button_flags |= ImGuiButtonFlags_PressedOnClick; }
609614
if (flags & ImGuiSelectableFlags_SelectOnRelease) { button_flags |= ImGuiButtonFlags_PressedOnRelease; }
610-
if (flags & ImGuiSelectableFlags_Disabled) { button_flags |= ImGuiButtonFlags_Disabled; }
611615
if (flags & ImGuiSelectableFlags_AllowDoubleClick) { button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; }
612616
if (flags & ImGuiSelectableFlags_AllowItemOverlap) { button_flags |= ImGuiButtonFlags_AllowItemOverlap; }
613617

614-
if (flags & ImGuiSelectableFlags_Disabled)
615-
selected = false;
616-
617618
const bool was_selected = selected;
618619
bool hovered, held;
619620
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
620621

622+
// Auto-select when moved into
623+
// - This will be more fully fleshed in the range-select branch
624+
// - This is not exposed as it won't nicely work with some user side handling of shift/control
625+
// - We cannot do 'if (g.NavJustMovedToId != id) { selected = false; pressed = was_selected; }' for two reasons
626+
// - (1) it would require focus scope to be set, need exposing PushFocusScope() or equivalent (e.g. BeginSelection() calling PushFocusScope())
627+
// - (2) usage will fail with clipped items
628+
// The multi-select API aim to fix those issues, e.g. may be replaced with a BeginSelection() API.
629+
if ((flags & ImGuiSelectableFlags_SelectOnNav) && g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == window->DC.NavFocusScopeIdCurrent)
630+
if (g.NavJustMovedToId == id)
631+
selected = pressed = true;
632+
621633
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard
622634
if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover)))
623635
{
@@ -644,22 +656,23 @@ namespace IGFD
644656
{
645657
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
646658
RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
647-
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
648659
}
660+
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
649661

650662
if (span_all_columns && window->DC.CurrentColumns)
651663
PopColumnsBackground();
652664
else if (span_all_columns && g.CurrentTable)
653665
TablePopBackgroundChannel();
654666

655-
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
656667
RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb);
657-
if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();
658668

659669
// Automatically close popups
660670
if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(g.CurrentItemFlags & ImGuiItemFlags_SelectableDontClosePopup))
661671
CloseCurrentPopup();
662672

673+
if (disabled_item && !disabled_global)
674+
PopDisabled();
675+
663676
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags);
664677
return pressed;
665678
}

0 commit comments

Comments
 (0)