mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	Scrolling: SetScrollFromPosY() tweak to match change in a0d53fee81084a547bf21f46e736ea89f79fffb5 with similar desirable jump/discontinuity at each limit to skip the (ItemSpacing>WindowPadding) difference (followup to 0e5b64ecd2, #150)
				
					
				
			This commit is contained in:
		| @@ -5709,9 +5709,13 @@ void ImGui::SetScrollFromPosY(float pos_y, float center_y_ratio) | |||||||
|     ImGuiWindow* window = GetCurrentWindow(); |     ImGuiWindow* window = GetCurrentWindow(); | ||||||
|     IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); |     IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); | ||||||
|     window->ScrollTarget.y = (float)(int)(pos_y + window->Scroll.y); |     window->ScrollTarget.y = (float)(int)(pos_y + window->Scroll.y); | ||||||
|     if (center_y_ratio <= 0.0f && window->ScrollTarget.y <= window->WindowPadding.y)    // Minor hack to make "scroll to top" take account of WindowPadding, else it would scroll to (WindowPadding.y - ItemSpacing.y) |  | ||||||
|         window->ScrollTarget.y = 0.0f; |  | ||||||
|     window->ScrollTargetCenterRatio.y = center_y_ratio; |     window->ScrollTargetCenterRatio.y = center_y_ratio; | ||||||
|  |  | ||||||
|  |     // Minor hack to to make scrolling to top/bottom of window take account of WindowPadding, it looks more right to the user this way | ||||||
|  |     if (center_y_ratio <= 0.0f && window->ScrollTarget.y <= window->WindowPadding.y) | ||||||
|  |         window->ScrollTarget.y = 0.0f; | ||||||
|  |     else if (center_y_ratio >= 1.0f && window->ScrollTarget.y >= window->SizeContents.y - window->WindowPadding.y + GImGui->Style.ItemSpacing.y) | ||||||
|  |         window->ScrollTarget.y = window->SizeContents.y; | ||||||
| } | } | ||||||
|  |  | ||||||
| // center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. | // center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user