mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 07:01:04 +01:00 
			
		
		
		
	Refactor: added INPUTS section index, moved IsMouseHoveringRect() to INPUTS section.
This commit is contained in:
		
							
								
								
									
										87
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										87
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -7921,25 +7921,55 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
 | 
				
			|||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
// [SECTION] INPUTS
 | 
					// [SECTION] INPUTS
 | 
				
			||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// - GetKeyData() [Internal]
 | 
				
			||||||
// Test if mouse cursor is hovering given rectangle
 | 
					// - GetKeyIndex() [Internal]
 | 
				
			||||||
// NB- Rectangle is clipped by our current clip setting
 | 
					// - GetKeyName()
 | 
				
			||||||
// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
 | 
					// - GetKeyChordName() [Internal]
 | 
				
			||||||
bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
 | 
					// - CalcTypematicRepeatAmount() [Internal]
 | 
				
			||||||
{
 | 
					// - GetTypematicRepeatRate() [Internal]
 | 
				
			||||||
    ImGuiContext& g = *GImGui;
 | 
					// - GetKeyPressedAmount() [Internal]
 | 
				
			||||||
 | 
					// - GetKeyVector2d() [Internal]
 | 
				
			||||||
    // Clip
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
    ImRect rect_clipped(r_min, r_max);
 | 
					// - GetRoutingIdFromOwnerId() [Internal]
 | 
				
			||||||
    if (clip)
 | 
					// - GetShortcutRoutingData() [Internal]
 | 
				
			||||||
        rect_clipped.ClipWith(g.CurrentWindow->ClipRect);
 | 
					// - CalcRoutingScore() [Internal]
 | 
				
			||||||
 | 
					// - SetShortcutRouting() [Internal]
 | 
				
			||||||
    // Expand for touch input
 | 
					// - TestShortcutRouting() [Internal]
 | 
				
			||||||
    const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding);
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
    if (!rect_for_touch.Contains(g.IO.MousePos))
 | 
					// - IsKeyDown()
 | 
				
			||||||
        return false;
 | 
					// - IsKeyPressed()
 | 
				
			||||||
    return true;
 | 
					// - IsKeyReleased()
 | 
				
			||||||
}
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// - IsMouseDown()
 | 
				
			||||||
 | 
					// - IsMouseClicked()
 | 
				
			||||||
 | 
					// - IsMouseReleased()
 | 
				
			||||||
 | 
					// - IsMouseDoubleClicked()
 | 
				
			||||||
 | 
					// - GetMouseClickedCount()
 | 
				
			||||||
 | 
					// - IsMouseHoveringRect() [Internal]
 | 
				
			||||||
 | 
					// - IsMouseDragPastThreshold() [Internal]
 | 
				
			||||||
 | 
					// - IsMouseDragging()
 | 
				
			||||||
 | 
					// - GetMousePos()
 | 
				
			||||||
 | 
					// - GetMousePosOnOpeningCurrentPopup()
 | 
				
			||||||
 | 
					// - IsMousePosValid()
 | 
				
			||||||
 | 
					// - IsAnyMouseDown()
 | 
				
			||||||
 | 
					// - GetMouseDragDelta()
 | 
				
			||||||
 | 
					// - ResetMouseDragDelta()
 | 
				
			||||||
 | 
					// - GetMouseCursor()
 | 
				
			||||||
 | 
					// - SetMouseCursor()
 | 
				
			||||||
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// - SetNextFrameWantCaptureKeyboard()
 | 
				
			||||||
 | 
					// - SetNextFrameWantCaptureMouse()
 | 
				
			||||||
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// - GetInputSourceName() [Internal]
 | 
				
			||||||
 | 
					// - DebugPrintInputEvent() [Internal]
 | 
				
			||||||
 | 
					// - UpdateInputEvents() [Internal]
 | 
				
			||||||
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// - GetKeyOwner() [Internal]
 | 
				
			||||||
 | 
					// - TestKeyOwner() [Internal]
 | 
				
			||||||
 | 
					// - SetKeyOwner() [Internal]
 | 
				
			||||||
 | 
					// - SetItemKeyOwner() [Internal]
 | 
				
			||||||
 | 
					// - Shortcut() [Internal]
 | 
				
			||||||
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key)
 | 
					ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -8357,6 +8387,25 @@ int ImGui::GetMouseClickedCount(ImGuiMouseButton button)
 | 
				
			|||||||
    return g.IO.MouseClickedCount[button];
 | 
					    return g.IO.MouseClickedCount[button];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Test if mouse cursor is hovering given rectangle
 | 
				
			||||||
 | 
					// NB- Rectangle is clipped by our current clip setting
 | 
				
			||||||
 | 
					// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
 | 
				
			||||||
 | 
					bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ImGuiContext& g = *GImGui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Clip
 | 
				
			||||||
 | 
					    ImRect rect_clipped(r_min, r_max);
 | 
				
			||||||
 | 
					    if (clip)
 | 
				
			||||||
 | 
					        rect_clipped.ClipWith(g.CurrentWindow->ClipRect);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Expand for touch input
 | 
				
			||||||
 | 
					    const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding);
 | 
				
			||||||
 | 
					    if (!rect_for_touch.Contains(g.IO.MousePos))
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Return if a mouse click/drag went past the given threshold. Valid to call during the MouseReleased frame.
 | 
					// Return if a mouse click/drag went past the given threshold. Valid to call during the MouseReleased frame.
 | 
				
			||||||
// [Internal] This doesn't test if the button is pressed
 | 
					// [Internal] This doesn't test if the button is pressed
 | 
				
			||||||
bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold)
 | 
					bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user