mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	Internals: Columns: Poke into WorkRect and use them in the GetContentRegionMax() functions. This should be a no-op, but preparing us to transition toward using WorkRect instead of ContentRegionRect.
Removed one use of ContentsRegionRect.
This commit is contained in:
		
							
								
								
									
										35
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -2249,8 +2249,8 @@ static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height) | ||||
|     ImGuiWindow* window = ImGui::GetCurrentWindow(); | ||||
|     window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height;      // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage. | ||||
|     window->DC.PrevLineSize.y = (line_height - GImGui->Style.ItemSpacing.y);    // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. | ||||
|     if (window->DC.CurrentColumns) | ||||
|         window->DC.CurrentColumns->LineMinY = window->DC.CursorPos.y;           // Setting this so that cell Y position are set properly | ||||
|     if (ImGuiColumns* columns = window->DC.CurrentColumns) | ||||
|         columns->LineMinY = window->DC.CursorPos.y;                             // Setting this so that cell Y position are set properly | ||||
| } | ||||
|  | ||||
| // Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1 | ||||
| @@ -3423,7 +3423,7 @@ void ImGui::UpdateMouseWheel() | ||||
|     const bool scroll_allowed = !(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs); | ||||
|     if (scroll_allowed && (g.IO.MouseWheel != 0.0f || g.IO.MouseWheelH != 0.0f) && !g.IO.KeyCtrl) | ||||
|     { | ||||
|         ImVec2 max_step = (window->ContentsRegionRect.GetSize() + window->WindowPadding * 2.0f) * 0.67f; | ||||
|         ImVec2 max_step = window->InnerRect.GetSize() * 0.67f; | ||||
|  | ||||
|         // Vertical Mouse Wheel Scrolling (hold Shift to scroll horizontally) | ||||
|         if (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift) | ||||
| @@ -5872,7 +5872,7 @@ void ImGui::End() | ||||
|  | ||||
|     ImGuiWindow* window = g.CurrentWindow; | ||||
|  | ||||
|     if (window->DC.CurrentColumns != NULL) | ||||
|     if (window->DC.CurrentColumns) | ||||
|         EndColumns(); | ||||
|     PopClipRect();   // Inner window clip rectangle | ||||
|  | ||||
| @@ -6649,7 +6649,7 @@ ImVec2 ImGui::GetContentRegionMax() | ||||
|     ImGuiWindow* window = GImGui->CurrentWindow; | ||||
|     ImVec2 mx = window->ContentsRegionRect.Max - window->Pos; | ||||
|     if (window->DC.CurrentColumns) | ||||
|         mx.x = GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x; | ||||
|         mx.x = window->WorkRect.Max.x - window->Pos.x; | ||||
|     return mx; | ||||
| } | ||||
|  | ||||
| @@ -6659,7 +6659,7 @@ ImVec2 ImGui::GetContentRegionMaxAbs() | ||||
|     ImGuiWindow* window = GImGui->CurrentWindow; | ||||
|     ImVec2 mx = window->ContentsRegionRect.Max; | ||||
|     if (window->DC.CurrentColumns) | ||||
|         mx.x = window->Pos.x + GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x; | ||||
|         mx.x = window->WorkRect.Max.x; | ||||
|     return mx; | ||||
| } | ||||
|  | ||||
| @@ -6672,19 +6672,19 @@ ImVec2 ImGui::GetContentRegionAvail() | ||||
| // In window space (not screen space!) | ||||
| ImVec2 ImGui::GetWindowContentRegionMin() | ||||
| { | ||||
|     ImGuiWindow* window = GetCurrentWindowRead(); | ||||
|     ImGuiWindow* window = GImGui->CurrentWindow; | ||||
|     return window->ContentsRegionRect.Min - window->Pos; | ||||
| } | ||||
|  | ||||
| ImVec2 ImGui::GetWindowContentRegionMax() | ||||
| { | ||||
|     ImGuiWindow* window = GetCurrentWindowRead(); | ||||
|     ImGuiWindow* window = GImGui->CurrentWindow; | ||||
|     return window->ContentsRegionRect.Max - window->Pos; | ||||
| } | ||||
|  | ||||
| float ImGui::GetWindowContentRegionWidth() | ||||
| { | ||||
|     ImGuiWindow* window = GetCurrentWindowRead(); | ||||
|     ImGuiWindow* window = GImGui->CurrentWindow; | ||||
|     return window->ContentsRegionRect.GetWidth(); | ||||
| } | ||||
|  | ||||
| @@ -8655,7 +8655,13 @@ void ImGui::NextColumn() | ||||
|     window->DC.CurrLineTextBaseOffset = 0.0f; | ||||
|  | ||||
|     PushColumnClipRect(columns->Current);     // FIXME-COLUMNS: Could it be an overwrite? | ||||
|     PushItemWidth(GetColumnWidth() * 0.65f);  // FIXME-COLUMNS: Move on columns setup | ||||
|  | ||||
|     // FIXME-COLUMNS: Share code with BeginColumns() - move code on columns setup. | ||||
|     float offset_0 = GetColumnOffset(columns->Current); | ||||
|     float offset_1 = GetColumnOffset(columns->Current + 1); | ||||
|     float width = offset_1 - offset_0; | ||||
|     PushItemWidth(width * 0.65f); | ||||
|     window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x; | ||||
| } | ||||
|  | ||||
| int ImGui::GetColumnIndex() | ||||
| @@ -8851,6 +8857,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag | ||||
|     columns->HostCursorPosY = window->DC.CursorPos.y; | ||||
|     columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x; | ||||
|     columns->HostClipRect = window->ClipRect; | ||||
|     columns->HostWorkRect = window->WorkRect; | ||||
|     columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y; | ||||
|     window->DC.ColumnsOffset.x = 0.0f; | ||||
|     window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); | ||||
| @@ -8888,7 +8895,12 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag | ||||
|         window->DrawList->ChannelsSetCurrent(1); | ||||
|         PushColumnClipRect(0); | ||||
|     } | ||||
|     PushItemWidth(GetColumnWidth() * 0.65f); | ||||
|  | ||||
|     float offset_0 = GetColumnOffset(columns->Current); | ||||
|     float offset_1 = GetColumnOffset(columns->Current + 1); | ||||
|     float width = offset_1 - offset_0; | ||||
|     PushItemWidth(width * 0.65f); | ||||
|     window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x; | ||||
| } | ||||
|  | ||||
| void ImGui::EndColumns() | ||||
| @@ -8960,6 +8972,7 @@ void ImGui::EndColumns() | ||||
|     } | ||||
|     columns->IsBeingResized = is_being_resized; | ||||
|  | ||||
|     window->WorkRect = columns->HostWorkRect; | ||||
|     window->DC.CurrentColumns = NULL; | ||||
|     window->DC.ColumnsOffset.x = 0.0f; | ||||
|     window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user