|
@@ -1351,9 +1351,9 @@ void ImGuiIO::ClearInputKeys()
|
|
|
MouseWheel = MouseWheelH = 0.0f;
|
|
MouseWheel = MouseWheelH = 0.0f;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static ImGuiInputEvent* FindLatestInputEvent(ImGuiInputEventType type, int arg = -1)
|
|
|
|
|
|
|
+static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1)
|
|
|
{
|
|
{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
|
|
|
|
+ ImGuiContext& g = *ctx;
|
|
|
for (int n = g.InputEventsQueue.Size - 1; n >= 0; n--)
|
|
for (int n = g.InputEventsQueue.Size - 1; n >= 0; n--)
|
|
|
{
|
|
{
|
|
|
ImGuiInputEvent* e = &g.InputEventsQueue[n];
|
|
ImGuiInputEvent* e = &g.InputEventsQueue[n];
|
|
@@ -1372,6 +1372,8 @@ static ImGuiInputEvent* FindLatestInputEvent(ImGuiInputEventType type, int arg =
|
|
|
// - ImGuiKey key: Translated key (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
|
|
// - ImGuiKey key: Translated key (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
|
|
|
// - bool down: Is the key down? use false to signify a key release.
|
|
// - bool down: Is the key down? use false to signify a key release.
|
|
|
// - float analog_value: 0.0f..1.0f
|
|
// - float analog_value: 0.0f..1.0f
|
|
|
|
|
+// IMPORTANT: THIS FUNCTION AND OTHER "ADD" GRABS THE CONTEXT FROM OUR INSTANCE.
|
|
|
|
|
+// WE NEED TO ENSURE THAT ALL FUNCTION CALLS ARE FULLFILLING THIS, WHICH IS WHY GetKeyData() HAS AN EXPLICIT CONTEXT.
|
|
|
void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
|
void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
|
|
{
|
|
{
|
|
|
//if (e->Down) { IMGUI_DEBUG_LOG_IO("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
|
|
//if (e->Down) { IMGUI_DEBUG_LOG_IO("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
|
|
@@ -1380,7 +1382,7 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
|
|
return;
|
|
return;
|
|
|
ImGuiContext& g = *Ctx;
|
|
ImGuiContext& g = *Ctx;
|
|
|
IM_ASSERT(ImGui::IsNamedKeyOrModKey(key)); // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API.
|
|
IM_ASSERT(ImGui::IsNamedKeyOrModKey(key)); // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API.
|
|
|
- IM_ASSERT(!ImGui::IsAliasKey(key)); // Backend cannot submit ImGuiKey_MouseXXX values they are automatically inferred from AddMouseXXX() events.
|
|
|
|
|
|
|
+ IM_ASSERT(ImGui::IsAliasKey(key) == false); // Backend cannot submit ImGuiKey_MouseXXX values they are automatically inferred from AddMouseXXX() events.
|
|
|
IM_ASSERT(key != ImGuiMod_Shortcut); // We could easily support the translation here but it seems saner to not accept it (TestEngine perform a translation itself)
|
|
IM_ASSERT(key != ImGuiMod_Shortcut); // We could easily support the translation here but it seems saner to not accept it (TestEngine perform a translation itself)
|
|
|
|
|
|
|
|
// Verify that backend isn't mixing up using new io.AddKeyEvent() api and old io.KeysDown[] + io.KeyMap[] data.
|
|
// Verify that backend isn't mixing up using new io.AddKeyEvent() api and old io.KeysDown[] + io.KeyMap[] data.
|
|
@@ -1395,8 +1397,8 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
|
|
BackendUsingLegacyNavInputArray = false;
|
|
BackendUsingLegacyNavInputArray = false;
|
|
|
|
|
|
|
|
// Filter duplicate (in particular: key mods and gamepad analog values are commonly spammed)
|
|
// Filter duplicate (in particular: key mods and gamepad analog values are commonly spammed)
|
|
|
- const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_Key, (int)key);
|
|
|
|
|
- const ImGuiKeyData* key_data = ImGui::GetKeyData(key);
|
|
|
|
|
|
|
+ const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)key);
|
|
|
|
|
+ const ImGuiKeyData* key_data = ImGui::GetKeyData(&g, key);
|
|
|
const bool latest_key_down = latest_event ? latest_event->Key.Down : key_data->Down;
|
|
const bool latest_key_down = latest_event ? latest_event->Key.Down : key_data->Down;
|
|
|
const float latest_key_analog = latest_event ? latest_event->Key.AnalogValue : key_data->AnalogValue;
|
|
const float latest_key_analog = latest_event ? latest_event->Key.AnalogValue : key_data->AnalogValue;
|
|
|
if (latest_key_down == down && latest_key_analog == analog_value)
|
|
if (latest_key_down == down && latest_key_analog == analog_value)
|
|
@@ -1462,7 +1464,7 @@ void ImGuiIO::AddMousePosEvent(float x, float y)
|
|
|
ImVec2 pos((x > -FLT_MAX) ? ImFloorSigned(x) : x, (y > -FLT_MAX) ? ImFloorSigned(y) : y);
|
|
ImVec2 pos((x > -FLT_MAX) ? ImFloorSigned(x) : x, (y > -FLT_MAX) ? ImFloorSigned(y) : y);
|
|
|
|
|
|
|
|
// Filter duplicate
|
|
// Filter duplicate
|
|
|
- const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MousePos);
|
|
|
|
|
|
|
+ const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MousePos);
|
|
|
const ImVec2 latest_pos = latest_event ? ImVec2(latest_event->MousePos.PosX, latest_event->MousePos.PosY) : g.IO.MousePos;
|
|
const ImVec2 latest_pos = latest_event ? ImVec2(latest_event->MousePos.PosX, latest_event->MousePos.PosY) : g.IO.MousePos;
|
|
|
if (latest_pos.x == pos.x && latest_pos.y == pos.y)
|
|
if (latest_pos.x == pos.x && latest_pos.y == pos.y)
|
|
|
return;
|
|
return;
|
|
@@ -1484,7 +1486,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
// Filter duplicate
|
|
// Filter duplicate
|
|
|
- const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MouseButton, (int)mouse_button);
|
|
|
|
|
|
|
+ const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
|
|
|
const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
|
|
const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
|
|
|
if (latest_button_down == down)
|
|
if (latest_button_down == down)
|
|
|
return;
|
|
return;
|
|
@@ -1521,7 +1523,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
|
|
ImGuiContext& g = *Ctx;
|
|
ImGuiContext& g = *Ctx;
|
|
|
|
|
|
|
|
// Filter duplicate
|
|
// Filter duplicate
|
|
|
- const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_Focus);
|
|
|
|
|
|
|
+ const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
|
|
|
const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
|
|
const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
|
|
|
if (latest_focused == focused)
|
|
if (latest_focused == focused)
|
|
|
return;
|
|
return;
|
|
@@ -3867,7 +3869,7 @@ void ImGui::MarkItemEdited(ImGuiID id)
|
|
|
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Edited;
|
|
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Edited;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags)
|
|
|
|
|
|
|
+bool ImGui::IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags)
|
|
|
{
|
|
{
|
|
|
// An active popup disable hovering on other windows (apart from its own children)
|
|
// An active popup disable hovering on other windows (apart from its own children)
|
|
|
// FIXME-OPT: This could be cached/stored within the window.
|
|
// FIXME-OPT: This could be cached/stored within the window.
|
|
@@ -7728,13 +7730,13 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
|
|
|
// - Shortcut() [Internal]
|
|
// - Shortcut() [Internal]
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key)
|
|
|
|
|
|
|
+ImGuiKeyData* ImGui::GetKeyData(ImGuiContext* ctx, ImGuiKey key)
|
|
|
{
|
|
{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
|
|
|
|
+ ImGuiContext& g = *ctx;
|
|
|
|
|
|
|
|
// Special storage location for mods
|
|
// Special storage location for mods
|
|
|
if (key & ImGuiMod_Mask_)
|
|
if (key & ImGuiMod_Mask_)
|
|
|
- key = ConvertSingleModFlagToKey(key);
|
|
|
|
|
|
|
+ key = ConvertSingleModFlagToKey(ctx, key);
|
|
|
|
|
|
|
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
|
|
IM_ASSERT(key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_NamedKey_END);
|
|
IM_ASSERT(key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_NamedKey_END);
|
|
@@ -7783,22 +7785,22 @@ IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_ARRAYSIZE(GKeyNames));
|
|
|
|
|
|
|
|
const char* ImGui::GetKeyName(ImGuiKey key)
|
|
const char* ImGui::GetKeyName(ImGuiKey key)
|
|
|
{
|
|
{
|
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
|
|
IM_ASSERT((IsNamedKey(key) || key == ImGuiKey_None) && "Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code.");
|
|
IM_ASSERT((IsNamedKey(key) || key == ImGuiKey_None) && "Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code.");
|
|
|
#else
|
|
#else
|
|
|
if (IsLegacyKey(key))
|
|
if (IsLegacyKey(key))
|
|
|
{
|
|
{
|
|
|
- ImGuiIO& io = GetIO();
|
|
|
|
|
- if (io.KeyMap[key] == -1)
|
|
|
|
|
|
|
+ if (g.IO.KeyMap[key] == -1)
|
|
|
return "N/A";
|
|
return "N/A";
|
|
|
- IM_ASSERT(IsNamedKey((ImGuiKey)io.KeyMap[key]));
|
|
|
|
|
- key = (ImGuiKey)io.KeyMap[key];
|
|
|
|
|
|
|
+ IM_ASSERT(IsNamedKey((ImGuiKey)g.IO.KeyMap[key]));
|
|
|
|
|
+ key = (ImGuiKey)g.IO.KeyMap[key];
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
if (key == ImGuiKey_None)
|
|
if (key == ImGuiKey_None)
|
|
|
return "None";
|
|
return "None";
|
|
|
if (key & ImGuiMod_Mask_)
|
|
if (key & ImGuiMod_Mask_)
|
|
|
- key = ConvertSingleModFlagToKey(key);
|
|
|
|
|
|
|
+ key = ConvertSingleModFlagToKey(&g, key);
|
|
|
if (!IsNamedKey(key))
|
|
if (!IsNamedKey(key))
|
|
|
return "Unknown";
|
|
return "Unknown";
|
|
|
|
|
|
|
@@ -7893,7 +7895,7 @@ static void ImGui::UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt)
|
|
|
// Apply routing to owner if there's no owner already (RoutingCurr == None at this point)
|
|
// Apply routing to owner if there's no owner already (RoutingCurr == None at this point)
|
|
|
if (routing_entry->Mods == g.IO.KeyMods)
|
|
if (routing_entry->Mods == g.IO.KeyMods)
|
|
|
{
|
|
{
|
|
|
- ImGuiKeyOwnerData* owner_data = ImGui::GetKeyOwnerData(key);
|
|
|
|
|
|
|
+ ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
|
|
if (owner_data->OwnerCurr == ImGuiKeyOwner_None)
|
|
if (owner_data->OwnerCurr == ImGuiKeyOwner_None)
|
|
|
owner_data->OwnerCurr = routing_entry->RoutingCurr;
|
|
owner_data->OwnerCurr = routing_entry->RoutingCurr;
|
|
|
}
|
|
}
|
|
@@ -7930,7 +7932,7 @@ ImGuiKeyRoutingData* ImGui::GetShortcutRoutingData(ImGuiKeyChord key_chord)
|
|
|
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
|
|
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
|
|
|
ImGuiKey mods = (ImGuiKey)(key_chord & ImGuiMod_Mask_);
|
|
ImGuiKey mods = (ImGuiKey)(key_chord & ImGuiMod_Mask_);
|
|
|
if (key == ImGuiKey_None)
|
|
if (key == ImGuiKey_None)
|
|
|
- key = ConvertSingleModFlagToKey(mods);
|
|
|
|
|
|
|
+ key = ConvertSingleModFlagToKey(&g, mods);
|
|
|
IM_ASSERT(IsNamedKey(key));
|
|
IM_ASSERT(IsNamedKey(key));
|
|
|
|
|
|
|
|
// Get (in the majority of case, the linked list will have one element so this should be 2 reads.
|
|
// Get (in the majority of case, the linked list will have one element so this should be 2 reads.
|
|
@@ -8436,6 +8438,13 @@ static void ImGui::UpdateMouseInputs()
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiIO& io = g.IO;
|
|
ImGuiIO& io = g.IO;
|
|
|
|
|
|
|
|
|
|
+ // Mouse Wheel swapping flag
|
|
|
|
|
+ // As a standard behavior holding SHIFT while using Vertical Mouse Wheel triggers Horizontal scroll instead
|
|
|
|
|
+ // - We avoid doing it on OSX as it the OS input layer handles this already.
|
|
|
|
|
+ // - FIXME: However this means when running on OSX over Emscripten, Shift+WheelY will incur two swapping (1 in OS, 1 here), canceling the feature.
|
|
|
|
|
+ // - FIXME: When we can distinguish e.g. touchpad scroll events from mouse ones, we'll set this accordingly based on input source.
|
|
|
|
|
+ io.MouseWheelRequestAxisSwap = io.KeyShift && !io.ConfigMacOSXBehaviors;
|
|
|
|
|
+
|
|
|
// Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well)
|
|
// Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well)
|
|
|
if (IsMousePosValid(&io.MousePos))
|
|
if (IsMousePosValid(&io.MousePos))
|
|
|
io.MousePos = g.MouseLastValidPos = ImFloorSigned(io.MousePos);
|
|
io.MousePos = g.MouseLastValidPos = ImFloorSigned(io.MousePos);
|
|
@@ -8596,15 +8605,9 @@ void ImGui::UpdateMouseWheel()
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
// Mouse wheel scrolling
|
|
// Mouse wheel scrolling
|
|
|
- // As a standard behavior holding SHIFT while using Vertical Mouse Wheel triggers Horizontal scroll instead
|
|
|
|
|
- // - We avoid doing it on OSX as it the OS input layer handles this already.
|
|
|
|
|
- // - However this means when running on OSX over Emcripten, Shift+WheelY will incur two swappings (1 in OS, 1 here), cancelling the feature.
|
|
|
|
|
- const bool swap_axis = g.IO.KeyShift && !g.IO.ConfigMacOSXBehaviors;
|
|
|
|
|
- if (swap_axis)
|
|
|
|
|
- {
|
|
|
|
|
- wheel.x = wheel.y;
|
|
|
|
|
- wheel.y = 0.0f;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Read about io.MouseWheelRequestAxisSwap and its issue on Mac+Emscripten in UpdateMouseInputs()
|
|
|
|
|
+ if (g.IO.MouseWheelRequestAxisSwap)
|
|
|
|
|
+ wheel = ImVec2(wheel.y, 0.0f);
|
|
|
|
|
|
|
|
// Maintain a rough average of moving magnitude on both axises
|
|
// Maintain a rough average of moving magnitude on both axises
|
|
|
// FIXME: should by based on wall clock time rather than frame-counter
|
|
// FIXME: should by based on wall clock time rather than frame-counter
|
|
@@ -8800,7 +8803,7 @@ ImGuiID ImGui::GetKeyOwner(ImGuiKey key)
|
|
|
return ImGuiKeyOwner_None;
|
|
return ImGuiKeyOwner_None;
|
|
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
- ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
|
|
|
|
|
|
|
+ ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
|
|
ImGuiID owner_id = owner_data->OwnerCurr;
|
|
ImGuiID owner_id = owner_data->OwnerCurr;
|
|
|
|
|
|
|
|
if (g.ActiveIdUsingAllKeyboardKeys && owner_id != g.ActiveId && owner_id != ImGuiKeyOwner_Any)
|
|
if (g.ActiveIdUsingAllKeyboardKeys && owner_id != g.ActiveId && owner_id != ImGuiKeyOwner_Any)
|
|
@@ -8824,7 +8827,7 @@ bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id)
|
|
|
if (key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END)
|
|
if (key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END)
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
- ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
|
|
|
|
|
|
|
+ ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
|
|
if (owner_id == ImGuiKeyOwner_Any)
|
|
if (owner_id == ImGuiKeyOwner_Any)
|
|
|
return (owner_data->LockThisFrame == false);
|
|
return (owner_data->LockThisFrame == false);
|
|
|
|
|
|
|
@@ -8852,7 +8855,8 @@ void ImGui::SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags)
|
|
|
IM_ASSERT(IsNamedKeyOrModKey(key) && (owner_id != ImGuiKeyOwner_Any || (flags & (ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease)))); // Can only use _Any with _LockXXX flags (to eat a key away without an ID to retrieve it)
|
|
IM_ASSERT(IsNamedKeyOrModKey(key) && (owner_id != ImGuiKeyOwner_Any || (flags & (ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease)))); // Can only use _Any with _LockXXX flags (to eat a key away without an ID to retrieve it)
|
|
|
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetKeyOwner) == 0); // Passing flags not supported by this function!
|
|
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetKeyOwner) == 0); // Passing flags not supported by this function!
|
|
|
|
|
|
|
|
- ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
|
|
|
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
|
+ ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
|
|
owner_data->OwnerCurr = owner_data->OwnerNext = owner_id;
|
|
owner_data->OwnerCurr = owner_data->OwnerNext = owner_id;
|
|
|
|
|
|
|
|
// We cannot lock by default as it would likely break lots of legacy code.
|
|
// We cannot lock by default as it would likely break lots of legacy code.
|
|
@@ -8861,6 +8865,17 @@ void ImGui::SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags)
|
|
|
owner_data->LockThisFrame = (flags & ImGuiInputFlags_LockThisFrame) != 0 || (owner_data->LockUntilRelease);
|
|
owner_data->LockThisFrame = (flags & ImGuiInputFlags_LockThisFrame) != 0 || (owner_data->LockUntilRelease);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Rarely used helper
|
|
|
|
|
+void ImGui::SetKeyOwnersForKeyChord(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags)
|
|
|
|
|
+{
|
|
|
|
|
+ if (key_chord & ImGuiMod_Ctrl) { SetKeyOwner(ImGuiMod_Ctrl, owner_id, flags); }
|
|
|
|
|
+ if (key_chord & ImGuiMod_Shift) { SetKeyOwner(ImGuiMod_Shift, owner_id, flags); }
|
|
|
|
|
+ if (key_chord & ImGuiMod_Alt) { SetKeyOwner(ImGuiMod_Alt, owner_id, flags); }
|
|
|
|
|
+ if (key_chord & ImGuiMod_Super) { SetKeyOwner(ImGuiMod_Super, owner_id, flags); }
|
|
|
|
|
+ if (key_chord & ImGuiMod_Shortcut) { SetKeyOwner(ImGuiMod_Shortcut, owner_id, flags); }
|
|
|
|
|
+ if (key_chord & ~ImGuiMod_Mask_) { SetKeyOwner((ImGuiKey)(key_chord & ~ImGuiMod_Mask_), owner_id, flags); }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// This is more or less equivalent to:
|
|
// This is more or less equivalent to:
|
|
|
// if (IsItemHovered() || IsItemActive())
|
|
// if (IsItemHovered() || IsItemActive())
|
|
|
// SetKeyOwner(key, GetItemID());
|
|
// SetKeyOwner(key, GetItemID());
|
|
@@ -8901,7 +8916,7 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags
|
|
|
// Special storage location for mods
|
|
// Special storage location for mods
|
|
|
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
|
|
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
|
|
|
if (key == ImGuiKey_None)
|
|
if (key == ImGuiKey_None)
|
|
|
- key = ConvertSingleModFlagToKey(mods);
|
|
|
|
|
|
|
+ key = ConvertSingleModFlagToKey(&g, mods);
|
|
|
|
|
|
|
|
if (!IsKeyPressed(key, owner_id, (flags & (ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateMask_))))
|
|
if (!IsKeyPressed(key, owner_id, (flags & (ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateMask_))))
|
|
|
return false;
|
|
return false;
|
|
@@ -11781,10 +11796,11 @@ static void ImGui::NavUpdateWindowing()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Start CTRL+Tab or Square+L/R window selection
|
|
// Start CTRL+Tab or Square+L/R window selection
|
|
|
|
|
+ const ImGuiID owner_id = ImHashStr("###NavUpdateWindowing");
|
|
|
const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
|
|
const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
|
|
|
const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
|
|
const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
|
|
|
- const bool keyboard_next_window = allow_windowing && g.ConfigNavWindowingKeyNext && Shortcut(g.ConfigNavWindowingKeyNext, ImGuiKeyOwner_None, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways);
|
|
|
|
|
- const bool keyboard_prev_window = allow_windowing && g.ConfigNavWindowingKeyPrev && Shortcut(g.ConfigNavWindowingKeyPrev, ImGuiKeyOwner_None, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways);
|
|
|
|
|
|
|
+ const bool keyboard_next_window = allow_windowing && g.ConfigNavWindowingKeyNext && Shortcut(g.ConfigNavWindowingKeyNext, owner_id, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways);
|
|
|
|
|
+ const bool keyboard_prev_window = allow_windowing && g.ConfigNavWindowingKeyPrev && Shortcut(g.ConfigNavWindowingKeyPrev, owner_id, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways);
|
|
|
const bool start_windowing_with_gamepad = allow_windowing && nav_gamepad_active && !g.NavWindowingTarget && IsKeyPressed(ImGuiKey_NavGamepadMenu, 0, ImGuiInputFlags_None);
|
|
const bool start_windowing_with_gamepad = allow_windowing && nav_gamepad_active && !g.NavWindowingTarget && IsKeyPressed(ImGuiKey_NavGamepadMenu, 0, ImGuiInputFlags_None);
|
|
|
const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && (keyboard_next_window || keyboard_prev_window); // Note: enabled even without NavEnableKeyboard!
|
|
const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && (keyboard_next_window || keyboard_prev_window); // Note: enabled even without NavEnableKeyboard!
|
|
|
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
|
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
|
@@ -11795,6 +11811,10 @@ static void ImGui::NavUpdateWindowing()
|
|
|
g.NavWindowingAccumDeltaPos = g.NavWindowingAccumDeltaSize = ImVec2(0.0f, 0.0f);
|
|
g.NavWindowingAccumDeltaPos = g.NavWindowingAccumDeltaSize = ImVec2(0.0f, 0.0f);
|
|
|
g.NavWindowingToggleLayer = start_windowing_with_gamepad ? true : false; // Gamepad starts toggling layer
|
|
g.NavWindowingToggleLayer = start_windowing_with_gamepad ? true : false; // Gamepad starts toggling layer
|
|
|
g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad;
|
|
g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad;
|
|
|
|
|
+
|
|
|
|
|
+ // Register ownership of our mods. Using ImGuiInputFlags_RouteGlobalHigh in the Shortcut() calls instead would probably be correct but may have more side-effects.
|
|
|
|
|
+ if (keyboard_next_window || keyboard_prev_window)
|
|
|
|
|
+ SetKeyOwnersForKeyChord((g.ConfigNavWindowingKeyNext | g.ConfigNavWindowingKeyPrev) & ImGuiMod_Mask_, owner_id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Gamepad update
|
|
// Gamepad update
|
|
@@ -13727,7 +13747,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
{
|
|
{
|
|
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
|
|
{
|
|
{
|
|
|
- ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
|
|
|
|
|
|
|
+ ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
|
|
if (owner_data->OwnerCurr == ImGuiKeyOwner_None)
|
|
if (owner_data->OwnerCurr == ImGuiKeyOwner_None)
|
|
|
continue;
|
|
continue;
|
|
|
Text("%s: 0x%08X%s", GetKeyName(key), owner_data->OwnerCurr,
|
|
Text("%s: 0x%08X%s", GetKeyName(key), owner_data->OwnerCurr,
|