mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	Tables: internal tidying up, calculate WidthAuto in first loop of layout + TableSetupColumn() with unspecified stretch weight leaves it at -1.0f (unset) rather than overrding default. Amend 3b3503e.
				
					
				
			Both changes are intended to have no side-effects. Committed separately from upcoming commit for easier future bissecting. Small demo fix.
This commit is contained in:
		| @@ -4080,15 +4080,15 @@ static void ShowDemoWindowTables() | ||||
|         static int column_count = 3; | ||||
|  | ||||
|         PushStyleCompact(); | ||||
|         ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 22); | ||||
|         ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30); | ||||
|         ImGui::Combo("Contents", &contents_type, "Short Text\0Long Text\0Button\0Fill Button\0InputText\0"); | ||||
|         if (contents_type == CT_FillButton) | ||||
|         { | ||||
|             ImGui::SameLine(); | ||||
|             HelpMarker("Be mindful that using right-alignment (e.g. size.x = -FLT_MIN) creates a feedback loop where contents width can feed into auto-column width can feed into contents width."); | ||||
|         } | ||||
|         ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 22); | ||||
|         ImGui::DragInt("Columns", &column_count, 0.1f, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp); | ||||
|         ImGui::PopItemWidth(); | ||||
|         ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH); | ||||
|         ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH); | ||||
|         ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV); | ||||
| @@ -4181,13 +4181,14 @@ static void ShowDemoWindowTables() | ||||
|         static float inner_width = 1000.0f; | ||||
|         PushStyleCompact(); | ||||
|         ImGui::PushID("flags3"); | ||||
|         ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30); | ||||
|         ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags3, ImGuiTableFlags_ScrollX); | ||||
|         if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretch", &flags3, ImGuiTableFlags_SizingPolicyStretch)) | ||||
|             flags3 &= ~ImGuiTableFlags_SizingPolicyFixed;      // Can't specify both sizing polices so we clear the other | ||||
|         if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyFixed", &flags3, ImGuiTableFlags_SizingPolicyFixed)) | ||||
|             flags3 &= ~ImGuiTableFlags_SizingPolicyStretch;    // Can't specify both sizing polices so we clear the other | ||||
|         ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 10.0f); | ||||
|         ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f"); | ||||
|         ImGui::PopItemWidth(); | ||||
|         ImGui::PopID(); | ||||
|         PopStyleCompact(); | ||||
|         if (ImGui::BeginTable("##table3", 7, flags3 | ImGuiTableFlags_SizingPolicyStretch | ImGuiTableFlags_ContextMenuInBody, outer_size, inner_width)) | ||||
| @@ -4853,8 +4854,8 @@ static void ShowDemoWindowTables() | ||||
|             ImGui::TableSetupColumn("ID",           ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoHide, -1.0f, MyItemColumnID_ID); | ||||
|             ImGui::TableSetupColumn("Name",         ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Name); | ||||
|             ImGui::TableSetupColumn("Action",       ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, -1.0f, MyItemColumnID_Action); | ||||
|             ImGui::TableSetupColumn("Quantity",     ImGuiTableColumnFlags_PreferSortDescending, 1.0f, MyItemColumnID_Quantity); | ||||
|             ImGui::TableSetupColumn("Description",  ImGuiTableColumnFlags_WidthStretch, 1.0f, MyItemColumnID_Description); | ||||
|             ImGui::TableSetupColumn("Quantity",     ImGuiTableColumnFlags_PreferSortDescending, -1.0f, MyItemColumnID_Quantity); | ||||
|             ImGui::TableSetupColumn("Description",  ImGuiTableColumnFlags_WidthStretch, -1.0f, MyItemColumnID_Description); | ||||
|             ImGui::TableSetupColumn("Hidden",       ImGuiTableColumnFlags_DefaultHide | ImGuiTableColumnFlags_NoSort); | ||||
|             ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user