mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Columns: Fixed Separator from creating an extraneous draw command. Fixed Selectable with SpanAllColumns flag from creating an extraneous draw command. (#125)
This commit is contained in:
		
							
								
								
									
										31
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -8400,13 +8400,13 @@ void ImGui::NextColumn() | ||||
|     { | ||||
|         // New column (columns 1+ cancels out IndentX) | ||||
|         window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + g.Style.ItemSpacing.x; | ||||
|         window->DrawList->ChannelsSetCurrent(columns->Current); | ||||
|         window->DrawList->ChannelsSetCurrent(columns->Current + 1); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         // New row/line | ||||
|         window->DC.ColumnsOffset.x = 0.0f; | ||||
|         window->DrawList->ChannelsSetCurrent(0); | ||||
|         window->DrawList->ChannelsSetCurrent(1); | ||||
|         columns->Current = 0; | ||||
|         columns->LineMinY = columns->LineMaxY; | ||||
|     } | ||||
| @@ -8415,7 +8415,7 @@ void ImGui::NextColumn() | ||||
|     window->DC.CurrentLineSize = ImVec2(0.0f, 0.0f); | ||||
|     window->DC.CurrentLineTextBaseOffset = 0.0f; | ||||
|  | ||||
|     PushColumnClipRect(); | ||||
|     PushColumnClipRect(columns->Current); | ||||
|     PushItemWidth(GetColumnWidth() * 0.65f);  // FIXME-COLUMNS: Move on columns setup | ||||
| } | ||||
|  | ||||
| @@ -8543,6 +8543,25 @@ void ImGui::PushColumnClipRect(int column_index) | ||||
|     PushClipRect(column->ClipRect.Min, column->ClipRect.Max, false); | ||||
| } | ||||
|  | ||||
| // Get into the columns background draw command (which is generally the same draw command as before we called BeginColumns) | ||||
| void ImGui::PushColumnsBackground() | ||||
| { | ||||
|     ImGuiWindow* window = GetCurrentWindowRead(); | ||||
|     ImGuiColumns* columns = window->DC.CurrentColumns; | ||||
|     window->DrawList->ChannelsSetCurrent(0); | ||||
|     int cmd_size = window->DrawList->CmdBuffer.Size; | ||||
|     PushClipRect(columns->BackupClipRect.Min, columns->BackupClipRect.Max, false);  | ||||
|     IM_ASSERT(cmd_size == window->DrawList->CmdBuffer.Size); // Being in channel 0 this should not have created an ImDrawCmd | ||||
| } | ||||
|  | ||||
| void ImGui::PopColumnsBackground() | ||||
| { | ||||
|     ImGuiWindow* window = GetCurrentWindowRead(); | ||||
|     ImGuiColumns* columns = window->DC.CurrentColumns; | ||||
|     window->DrawList->ChannelsSetCurrent(columns->Current + 1); | ||||
|     PopClipRect(); | ||||
| } | ||||
|  | ||||
| ImGuiColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id) | ||||
| { | ||||
|     // We have few columns per window so for now we don't need bother much with turning this into a faster lookup. | ||||
| @@ -8593,6 +8612,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag | ||||
|     columns->MaxX = ImMax(content_region_width - window->Scroll.x, columns->MinX + 1.0f); | ||||
|     columns->BackupCursorPosY = window->DC.CursorPos.y; | ||||
|     columns->BackupCursorMaxPosX = window->DC.CursorMaxPos.x; | ||||
|     columns->BackupClipRect = window->ClipRect; | ||||
|     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); | ||||
| @@ -8626,8 +8646,9 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag | ||||
|  | ||||
|     if (columns->Count > 1) | ||||
|     { | ||||
|         window->DrawList->ChannelsSplit(columns->Count); | ||||
|         PushColumnClipRect(); | ||||
|         window->DrawList->ChannelsSplit(1 + columns->Count); | ||||
|         window->DrawList->ChannelsSetCurrent(1); | ||||
|         PushColumnClipRect(0); | ||||
|     } | ||||
|     PushItemWidth(GetColumnWidth() * 0.65f); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user