1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-12 02:00:58 +01:00

Internals: move ItemHandleShortcut() next to Shortcut(), it's calling it anyhow. (#456)

This commit is contained in:
ocornut 2024-05-23 17:17:54 +02:00
parent a689fa262a
commit 0eb025f484

View File

@ -9687,6 +9687,28 @@ void ImGui::SetNextItemShortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags)
g.NextItemData.ShortcutFlags = flags;
}
void ImGui::ItemHandleShortcut(ImGuiID id)
{
ImGuiContext& g = *GImGui;
ImGuiInputFlags flags = g.NextItemData.ShortcutFlags;
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetNextItemShortcut) == 0); // Passing flags not supported by SetNextItemShortcut()!
if (flags & ImGuiInputFlags_Tooltip)
{
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasShortcut;
g.LastItemData.Shortcut = g.NextItemData.Shortcut;
}
if (!Shortcut(g.NextItemData.Shortcut, flags & ImGuiInputFlags_SupportedByShortcut, id) || g.NavActivateId != 0)
return;
// FIXME: Generalize Activation queue?
g.NavActivateId = id; // Will effectively disable clipping.
g.NavActivateFlags = ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_FromShortcut;
//if (g.ActiveId == 0 || g.ActiveId == id)
g.NavActivateDownId = g.NavActivatePressedId = id;
NavHighlightActivated(id);
}
bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags)
{
return Shortcut(key_chord, flags, ImGuiKeyOwner_Any);
@ -10004,7 +10026,6 @@ void ImGuiStackSizes::CompareWithContextState(ImGuiContext* ctx)
// [SECTION] ITEM SUBMISSION
//-----------------------------------------------------------------------------
// - KeepAliveID()
// - ItemHandleShortcut() [Internal]
// - ItemAdd()
//-----------------------------------------------------------------------------
@ -10018,28 +10039,6 @@ void ImGui::KeepAliveID(ImGuiID id)
g.ActiveIdPreviousFrameIsAlive = true;
}
void ImGui::ItemHandleShortcut(ImGuiID id)
{
ImGuiContext& g = *GImGui;
ImGuiInputFlags flags = g.NextItemData.ShortcutFlags;
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetNextItemShortcut) == 0); // Passing flags not supported by SetNextItemShortcut()!
if (flags & ImGuiInputFlags_Tooltip)
{
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasShortcut;
g.LastItemData.Shortcut = g.NextItemData.Shortcut;
}
if (!Shortcut(g.NextItemData.Shortcut, flags & ImGuiInputFlags_SupportedByShortcut, id) || g.NavActivateId != 0)
return;
// FIXME: Generalize Activation queue?
g.NavActivateId = id; // Will effectively disable clipping.
g.NavActivateFlags = ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_FromShortcut;
//if (g.ActiveId == 0 || g.ActiveId == id)
g.NavActivateDownId = g.NavActivatePressedId = id;
NavHighlightActivated(id);
}
// Declare item bounding box for clipping and interaction.
// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
// declare their minimum size requirement to ItemSize() and provide a larger region to ItemAdd() which is used drawing/interaction.