@ -8146,18 +8146,18 @@ const char* ImGui::GetKeyName(ImGuiKey key)
}
}
// ImGuiMod_Shortcut is translated to either Ctrl or Super.
// ImGuiMod_Shortcut is translated to either Ctrl or Super.
const char * ImGui : : GetKeyChordName ( ImGuiKeyChord key_chord , char * out_buf , int out_buf_size )
const char * ImGui : : GetKeyChordName ( ImGuiKeyChord key_chord )
{
{
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
if ( key_chord & ImGuiMod_Shortcut )
if ( key_chord & ImGuiMod_Shortcut )
key_chord = ConvertShortcutMod ( key_chord ) ;
key_chord = ConvertShortcutMod ( key_chord ) ;
ImFormatString ( out_buf , ( size_t ) out_buf_size , " %s%s%s%s%s " ,
ImFormatString ( g . TempKeychordName , IM_ARRAYSIZE ( g . TempKeychordName ) , " %s%s%s%s%s " ,
( key_chord & ImGuiMod_Ctrl ) ? " Ctrl+ " : " " ,
( key_chord & ImGuiMod_Ctrl ) ? " Ctrl+ " : " " ,
( key_chord & ImGuiMod_Shift ) ? " Shift+ " : " " ,
( key_chord & ImGuiMod_Shift ) ? " Shift+ " : " " ,
( key_chord & ImGuiMod_Alt ) ? " Alt+ " : " " ,
( key_chord & ImGuiMod_Alt ) ? " Alt+ " : " " ,
( key_chord & ImGuiMod_Super ) ? ( g . IO . ConfigMacOSXBehaviors ? " Cmd+ " : " Super+ " ) : " " ,
( key_chord & ImGuiMod_Super ) ? ( g . IO . ConfigMacOSXBehaviors ? " Cmd+ " : " Super+ " ) : " " ,
GetKeyName ( ( ImGuiKey ) ( key_chord & ~ ImGuiMod_Mask_ ) ) ) ;
GetKeyName ( ( ImGuiKey ) ( key_chord & ~ ImGuiMod_Mask_ ) ) ) ;
return out_buf ;
return g . TempKeychordName ;
}
}
// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime)
// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime)
@ -8224,6 +8224,7 @@ static void ImGui::UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt)
for ( int old_routing_idx = rt - > Index [ key - ImGuiKey_NamedKey_BEGIN ] ; old_routing_idx ! = - 1 ; old_routing_idx = routing_entry - > NextEntryIndex )
for ( int old_routing_idx = rt - > Index [ key - ImGuiKey_NamedKey_BEGIN ] ; old_routing_idx ! = - 1 ; old_routing_idx = routing_entry - > NextEntryIndex )
{
{
routing_entry = & rt - > Entries [ old_routing_idx ] ;
routing_entry = & rt - > Entries [ old_routing_idx ] ;
routing_entry - > RoutingCurrScore = routing_entry - > RoutingNextScore ;
routing_entry - > RoutingCurr = routing_entry - > RoutingNext ; // Update entry
routing_entry - > RoutingCurr = routing_entry - > RoutingNext ; // Update entry
routing_entry - > RoutingNext = ImGuiKeyOwner_None ;
routing_entry - > RoutingNext = ImGuiKeyOwner_None ;
routing_entry - > RoutingNextScore = 255 ;
routing_entry - > RoutingNextScore = 255 ;
@ -8363,7 +8364,7 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiInputFlags_RouteMask_ ) ) ; // Check that only 1 routing flag is used
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiInputFlags_RouteMask_ ) ) ; // Check that only 1 routing flag is used
// [DEBUG] Debug break requested by user
// [DEBUG] Debug break requested by user
if ( g . DebugBreakInShortcutRouting = = key_chord )
if ( g . DebugBreakInShortcutRouting ! = 0 & & g . DebugBreakInShortcutRouting = = ConvertShortcutMod ( key_chord ) )
IM_DEBUG_BREAK ( ) ;
IM_DEBUG_BREAK ( ) ;
if ( flags & ImGuiInputFlags_RouteUnlessBgFocused )
if ( flags & ImGuiInputFlags_RouteUnlessBgFocused )
@ -8371,9 +8372,13 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
return false ;
return false ;
// Note how ImGuiInputFlags_RouteAlways won't set routing and thus won't set owner. May want to rework this?
// Note how ImGuiInputFlags_RouteAlways won't set routing and thus won't set owner. May want to rework this?
if ( flags & ImGuiInputFlags_RouteAlways )
if ( flags & ImGuiInputFlags_RouteAlways )
{
IMGUI_DEBUG_LOG_INPUTROUTING ( " SetShortcutRouting(%s, owner_id=0x%08X, flags=%04X) -> always \n " , GetKeyChordName ( key_chord ) , owner_id , flags ) ;
return true ;
return true ;
}
const int score = CalcRoutingScore ( g . CurrentWindow , owner_id , flags ) ;
const int score = CalcRoutingScore ( g . CurrentWindow , owner_id , flags ) ;
IMGUI_DEBUG_LOG_INPUTROUTING ( " SetShortcutRouting(%s, owner_id=0x%08X, flags=%04X) -> score %d \n " , GetKeyChordName ( key_chord ) , owner_id , flags , score ) ;
if ( score = = 255 )
if ( score = = 255 )
return false ;
return false ;
@ -8389,6 +8394,8 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
}
}
// Return routing state for CURRENT frame
// Return routing state for CURRENT frame
if ( routing_data - > RoutingCurr = = routing_id )
IMGUI_DEBUG_LOG_INPUTROUTING ( " --> granting current route \n " ) ;
return routing_data - > RoutingCurr = = routing_id ;
return routing_data - > RoutingCurr = = routing_id ;
}
}
@ -14350,6 +14357,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
{
{
ImGuiDebugAllocInfo * info = & g . DebugAllocInfo ;
ImGuiDebugAllocInfo * info = & g . DebugAllocInfo ;
Text ( " %d current allocations " , info - > TotalAllocCount - info - > TotalFreeCount ) ;
Text ( " %d current allocations " , info - > TotalAllocCount - info - > TotalFreeCount ) ;
if ( SmallButton ( " GC now " ) ) { g . GcCompactAll = true ; }
Text ( " Recent frames with allocations: " ) ;
Text ( " Recent frames with allocations: " ) ;
int buf_size = IM_ARRAYSIZE ( info - > LastEntriesBuf ) ;
int buf_size = IM_ARRAYSIZE ( info - > LastEntriesBuf ) ;
for ( int n = buf_size - 1 ; n > = 0 ; n - - )
for ( int n = buf_size - 1 ; n > = 0 ; n - - )
@ -14437,10 +14445,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGuiKeyRoutingTable * rt = & g . KeysRoutingTable ;
ImGuiKeyRoutingTable * rt = & g . KeysRoutingTable ;
for ( ImGuiKeyRoutingIndex idx = rt - > Index [ key - ImGuiKey_NamedKey_BEGIN ] ; idx ! = - 1 ; )
for ( ImGuiKeyRoutingIndex idx = rt - > Index [ key - ImGuiKey_NamedKey_BEGIN ] ; idx ! = - 1 ; )
{
{
char key_chord_name [ 64 ] ;
ImGuiKeyRoutingData * routing_data = & rt - > Entries [ idx ] ;
ImGuiKeyRoutingData * routing_data = & rt - > Entries [ idx ] ;
ImGuiKeyChord key_chord = key | routing_data - > Mods ;
ImGuiKeyChord key_chord = key | routing_data - > Mods ;
Text ( " %s: 0x%08X " , GetKeyChordName ( key_chord , key_chord_name , IM_ARRAYSIZE ( key_chord_name ) ) , routing_data - > RoutingCurr ) ;
Text ( " %s: 0x%08X (scored %d) " , GetKeyChordName ( key_chord ) , routing_data - > RoutingCurr , routing_data - > RoutingCurrScore ) ;
DebugLocateItemOnHover ( routing_data - > RoutingCurr ) ;
DebugLocateItemOnHover ( routing_data - > RoutingCurr ) ;
if ( g . IO . ConfigDebugIsDebuggerPresent )
if ( g . IO . ConfigDebugIsDebuggerPresent )
{
{
@ -15096,7 +15103,10 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
return ;
return ;
}
}
CheckboxFlags ( " All " , & g . DebugLogFlags , ImGuiDebugLogFlags_EventMask_ ) ;
ImGuiDebugLogFlags all_enable_flags = ImGuiDebugLogFlags_EventMask_ & ~ ImGuiDebugLogFlags_EventInputRouting ;
CheckboxFlags ( " All " , & g . DebugLogFlags , all_enable_flags ) ;
SetItemTooltip ( " (except InputRouting which is spammy) " ) ;
ShowDebugLogFlag ( " ActiveId " , ImGuiDebugLogFlags_EventActiveId ) ;
ShowDebugLogFlag ( " ActiveId " , ImGuiDebugLogFlags_EventActiveId ) ;
ShowDebugLogFlag ( " Clipper " , ImGuiDebugLogFlags_EventClipper ) ;
ShowDebugLogFlag ( " Clipper " , ImGuiDebugLogFlags_EventClipper ) ;
ShowDebugLogFlag ( " Focus " , ImGuiDebugLogFlags_EventFocus ) ;
ShowDebugLogFlag ( " Focus " , ImGuiDebugLogFlags_EventFocus ) ;
@ -15104,6 +15114,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
ShowDebugLogFlag ( " Nav " , ImGuiDebugLogFlags_EventNav ) ;
ShowDebugLogFlag ( " Nav " , ImGuiDebugLogFlags_EventNav ) ;
ShowDebugLogFlag ( " Popup " , ImGuiDebugLogFlags_EventPopup ) ;
ShowDebugLogFlag ( " Popup " , ImGuiDebugLogFlags_EventPopup ) ;
//ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
//ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
ShowDebugLogFlag ( " InputRouting " , ImGuiDebugLogFlags_EventInputRouting ) ;
if ( SmallButton ( " Clear " ) )
if ( SmallButton ( " Clear " ) )
{
{