mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	Columns: Caching columns clipping rectangles (#125)
This commit is contained in:
		
							
								
								
									
										20
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -8607,7 +8607,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     const ImGuiStyle& style = g.Style; | ||||
|  | ||||
|     if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsCount > 1) | ||||
|     if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsCount > 1) // FIXME-OPT: Avoid if vertically clipped. | ||||
|         PopClipRect(); | ||||
|  | ||||
|     ImGuiID id = window->GetID(label); | ||||
| @@ -10021,13 +10021,11 @@ void ImGui::SetColumnWidth(int column_index, float width) | ||||
|  | ||||
| void ImGui::PushColumnClipRect(int column_index) | ||||
| { | ||||
|     ImGuiWindow* window = ImGui::GetCurrentWindow(); | ||||
|     ImGuiWindow* window = GetCurrentWindowRead(); | ||||
|     if (column_index < 0) | ||||
|         column_index = window->DC.ColumnsCurrent; | ||||
|  | ||||
|     float x1 = ImFloor(0.5f + window->Pos.x + ImGui::GetColumnOffset(column_index) - 1.0f); | ||||
|     float x2 = ImFloor(0.5f + window->Pos.x + ImGui::GetColumnOffset(column_index+1) - 1.0f); | ||||
|     ImGui::PushClipRect(ImVec2(x1,-FLT_MAX), ImVec2(x2,+FLT_MAX), true); | ||||
|     PushClipRect(window->DC.ColumnsData[column_index].ClipRect.Min, window->DC.ColumnsData[column_index].ClipRect.Max, false); | ||||
| } | ||||
|  | ||||
| void ImGui::BeginColumns(const char* id, int columns_count, ImGuiColumnsFlags flags) | ||||
| @@ -10066,11 +10064,21 @@ void ImGui::BeginColumns(const char* id, int columns_count, ImGuiColumnsFlags fl | ||||
|         const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index); | ||||
|         KeepAliveID(column_id); | ||||
|         const float default_t = column_index / (float)window->DC.ColumnsCount; | ||||
|         float t = window->DC.StateStorage->GetFloat(column_id, default_t);      // Cheaply store our floating point value inside the integer (could store a union into the map?) | ||||
|         float t = window->DC.StateStorage->GetFloat(column_id, default_t); | ||||
|         if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoForceWithinWindow)) | ||||
|             t = ImMin(t, PixelsToOffsetNorm(window, window->DC.ColumnsMaxX - g.Style.ColumnsMinSpacing * (window->DC.ColumnsCount - column_index))); | ||||
|         window->DC.ColumnsData[column_index].OffsetNorm = t; | ||||
|     } | ||||
|  | ||||
|     // Cache clipping rectangles | ||||
|     for (int column_index = 0; column_index < columns_count; column_index++) | ||||
|     { | ||||
|         float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(column_index) - 1.0f); | ||||
|         float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(column_index + 1) - 1.0f); | ||||
|         window->DC.ColumnsData[column_index].ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX); | ||||
|         window->DC.ColumnsData[column_index].ClipRect.Clip(window->ClipRect); | ||||
|     } | ||||
|  | ||||
|     window->DrawList->ChannelsSplit(window->DC.ColumnsCount); | ||||
|     PushColumnClipRect(); | ||||
|     PushItemWidth(GetColumnWidth() * 0.65f); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user