|
@@ -3891,6 +3891,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
|
|
g.ActiveIdNoClearOnFocusLoss = false;
|
|
|
g.ActiveIdWindow = window;
|
|
|
g.ActiveIdHasBeenEditedThisFrame = false;
|
|
|
+ g.ActiveIdFromShortcut = false;
|
|
|
if (id)
|
|
|
{
|
|
|
g.ActiveIdIsAlive = id;
|
|
@@ -4100,7 +4101,8 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
|
|
|
if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap)
|
|
|
return false;
|
|
|
if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
|
|
|
- return false;
|
|
|
+ if (!g.ActiveIdFromShortcut)
|
|
|
+ return false;
|
|
|
|
|
|
// Done with rectangle culling so we can perform heavier checks now.
|
|
|
if (!(item_flags & ImGuiItemFlags_NoWindowHoverableCheck) && !IsWindowContentHoverable(window, ImGuiHoveredFlags_None))
|
|
@@ -4160,12 +4162,13 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
|
|
|
}
|
|
|
|
|
|
// FIXME: This is inlined/duplicated in ItemAdd()
|
|
|
+// FIXME: The id != 0 path is not used by our codebase, may get rid of it?
|
|
|
bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
if (!bb.Overlaps(window->ClipRect))
|
|
|
- if (id == 0 || (id != g.ActiveId && id != g.NavId))
|
|
|
+ if (id == 0 || (id != g.ActiveId && id != g.ActiveIdPreviousFrame && id != g.NavId && id != g.NavActivateId))
|
|
|
if (!g.LogEnabled)
|
|
|
return true;
|
|
|
return false;
|
|
@@ -9421,6 +9424,13 @@ bool ImGui::IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiIn
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+void ImGui::SetNextItemShortcut(ImGuiKeyChord key_chord)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasShortcut;
|
|
|
+ g.NextItemData.Shortcut = key_chord;
|
|
|
+}
|
|
|
+
|
|
|
bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags)
|
|
|
{
|
|
|
//ImGuiContext& g = *GImGui;
|
|
@@ -9731,6 +9741,7 @@ void ImGuiStackSizes::CompareWithContextState(ImGuiContext* ctx)
|
|
|
// [SECTION] ITEM SUBMISSION
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// - KeepAliveID()
|
|
|
+// - ItemHandleShortcut() [Internal]
|
|
|
// - ItemAdd()
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
@@ -9744,6 +9755,20 @@ void ImGui::KeepAliveID(ImGuiID id)
|
|
|
g.ActiveIdPreviousFrameIsAlive = true;
|
|
|
}
|
|
|
|
|
|
+static void ItemHandleShortcut(ImGuiID id)
|
|
|
+{
|
|
|
+ // FIXME: Generalize Activation queue?
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ if (ImGui::Shortcut(g.NextItemData.Shortcut, id, ImGuiInputFlags_None) && g.NavActivateId == 0)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ ImGui::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.
|
|
@@ -9785,6 +9810,9 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|
|
if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened))
|
|
|
NavProcessItem();
|
|
|
}
|
|
|
+
|
|
|
+ if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasShortcut)
|
|
|
+ ItemHandleShortcut(id);
|
|
|
}
|
|
|
|
|
|
// Lightweight clear of SetNextItemXXX data.
|
|
@@ -9801,9 +9829,10 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|
|
//const bool is_clipped = IsClippedEx(bb, id);
|
|
|
//if (is_clipped)
|
|
|
// return false;
|
|
|
+ // g.NavActivateId is not necessarily == g.NavId, in the case of remote activation (e.g. shortcuts)
|
|
|
const bool is_rect_visible = bb.Overlaps(window->ClipRect);
|
|
|
if (!is_rect_visible)
|
|
|
- if (id == 0 || (id != g.ActiveId && id != g.ActiveIdPreviousFrame && id != g.NavId))
|
|
|
+ if (id == 0 || (id != g.ActiveId && id != g.ActiveIdPreviousFrame && id != g.NavId && id != g.NavActivateId))
|
|
|
if (!g.LogEnabled)
|
|
|
return false;
|
|
|
|