|
@@ -6160,8 +6160,6 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
const bool disabled_global = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
|
|
const bool disabled_global = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
|
|
if (disabled_item && !disabled_global)
|
|
if (disabled_item && !disabled_global)
|
|
PushDisabled(true);
|
|
PushDisabled(true);
|
|
- if (disabled_item || disabled_global)
|
|
|
|
- selected = false;
|
|
|
|
|
|
|
|
// FIXME: We can standardize the behavior of those two, we could also keep the fast path of override ClipRect + full push on render only,
|
|
// FIXME: We can standardize the behavior of those two, we could also keep the fast path of override ClipRect + full push on render only,
|
|
// which would be advantageous since most selectable are not selected.
|
|
// which would be advantageous since most selectable are not selected.
|
|
@@ -6824,7 +6822,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
ImVec2 popup_pos, pos = window->DC.CursorPos;
|
|
ImVec2 popup_pos, pos = window->DC.CursorPos;
|
|
PushID(label);
|
|
PushID(label);
|
|
if (!enabled)
|
|
if (!enabled)
|
|
- PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
|
|
|
|
|
|
+ PushDisabled();
|
|
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
|
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
|
{
|
|
{
|
|
@@ -6836,7 +6834,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
|
float w = label_size.x;
|
|
float w = label_size.x;
|
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
|
- pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
|
|
|
|
|
|
+ pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups, ImVec2(w, 0.0f));
|
|
RenderText(text_pos, label);
|
|
RenderText(text_pos, label);
|
|
PopStyleVar();
|
|
PopStyleVar();
|
|
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
|
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
|
@@ -6852,12 +6850,12 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
|
- pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(min_w, 0.0f));
|
|
|
|
|
|
+ pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
|
|
RenderText(text_pos, label);
|
|
RenderText(text_pos, label);
|
|
RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right);
|
|
RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right);
|
|
}
|
|
}
|
|
if (!enabled)
|
|
if (!enabled)
|
|
- PopStyleColor();
|
|
|
|
|
|
+ PopDisabled();
|
|
PopID();
|
|
PopID();
|
|
|
|
|
|
const bool hovered = (g.HoveredId == id) && enabled;
|
|
const bool hovered = (g.HoveredId == id) && enabled;
|
|
@@ -6987,11 +6985,11 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
|
|
|
|
|
|
// We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73),
|
|
// We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73),
|
|
// but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only.
|
|
// but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only.
|
|
- ImGuiSelectableFlags flags = ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
|
|
|
|
bool pressed;
|
|
bool pressed;
|
|
PushID(label);
|
|
PushID(label);
|
|
if (!enabled)
|
|
if (!enabled)
|
|
- PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
|
|
|
|
|
|
+ PushDisabled(true);
|
|
|
|
+ const ImGuiSelectableFlags flags = ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_SetNavIdOnHover;
|
|
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
|
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
|
{
|
|
{
|
|
@@ -7029,7 +7027,7 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
|
|
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);
|
|
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);
|
|
}
|
|
}
|
|
if (!enabled)
|
|
if (!enabled)
|
|
- PopStyleColor();
|
|
|
|
|
|
+ PopDisabled();
|
|
PopID();
|
|
PopID();
|
|
|
|
|
|
IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.LastItemStatusFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));
|
|
IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.LastItemStatusFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));
|