mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	Tables: added ImGuiTableFlags_NoHostExtendX instead of using outer_size.x == 0.0f. Changed default outer_size to (0.0f, 0.0f). (#3605)
This commit is contained in:
		| @@ -3957,7 +3957,7 @@ static void ShowDemoWindowTables() | ||||
|         ImGui::PopID(); | ||||
|         PopStyleCompact(); | ||||
|  | ||||
|         outer_size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 7); | ||||
|         outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 7); | ||||
|         if (ImGui::BeginTable("##table2", column_count, flags, outer_size)) | ||||
|         { | ||||
|             for (int cell = 0; cell < 10 * column_count; cell++) | ||||
| @@ -3999,8 +3999,8 @@ static void ShowDemoWindowTables() | ||||
|  | ||||
|         // When using ScrollX or ScrollY we need to specify a size for our table container! | ||||
|         // Otherwise by default the table will fit all available space, like a BeginChild() call. | ||||
|         ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 8); | ||||
|         if (ImGui::BeginTable("##table1", 3, flags, size)) | ||||
|         ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8); | ||||
|         if (ImGui::BeginTable("##table1", 3, flags, outer_size)) | ||||
|         { | ||||
|             ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible | ||||
|             ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_None); | ||||
| @@ -4053,7 +4053,7 @@ static void ShowDemoWindowTables() | ||||
|  | ||||
|         // When using ScrollX or ScrollY we need to specify a size for our table container! | ||||
|         // Otherwise by default the table will fit all available space, like a BeginChild() call. | ||||
|         ImVec2 outer_size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 8); | ||||
|         ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8); | ||||
|         if (ImGui::BeginTable("##table1", 7, flags, outer_size)) | ||||
|         { | ||||
|             ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); | ||||
| @@ -4154,8 +4154,8 @@ static void ShowDemoWindowTables() | ||||
|             = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ||||
|             | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ||||
|             | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable; | ||||
|         ImVec2 size = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 9); | ||||
|         if (ImGui::BeginTable("##table", column_count, flags, size)) | ||||
|         ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 9); | ||||
|         if (ImGui::BeginTable("##table", column_count, flags, outer_size)) | ||||
|         { | ||||
|             for (int column = 0; column < column_count; column++) | ||||
|                 ImGui::TableSetupColumn(column_names[column], column_flags[column]); | ||||
| @@ -4312,18 +4312,18 @@ static void ShowDemoWindowTables() | ||||
|         ImGui::SetNextItemOpen(open_action != 0); | ||||
|     if (ImGui::TreeNode("Outer size")) | ||||
|     { | ||||
|         // Showcasing use of outer_size.x == 0.0f and ImGuiTableFlags_NoHostExtendY | ||||
|         // The default value of outer_size.x is -FLT_MIN which right-align tables. | ||||
|         // Using outer_size.x == 0.0f on a table with no scrolling and no stretch column we can make them tighter. | ||||
|         ImGui::Text("Using auto/all width, using NoHostExtendY:"); | ||||
|         // Showcasing use of ImGuiTableFlags_NoHostExtendX and ImGuiTableFlags_NoHostExtendY | ||||
|         // Important to that note how the two flags have slightly different behaviors! | ||||
|         ImGui::Text("Using NoHostExtendX and NoHostExtendY:"); | ||||
|         PushStyleCompact(); | ||||
|         static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit; | ||||
|         static bool fixed_fill = false; | ||||
|         ImGui::Checkbox("fill", &fixed_fill); | ||||
|         static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoHostExtendX; | ||||
|         ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX); | ||||
|         ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used."); | ||||
|         ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY); | ||||
|         ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible."); | ||||
|         PopStyleCompact(); | ||||
|  | ||||
|         ImVec2 outer_size = ImVec2(fixed_fill ? -FLT_MIN : 0.0f, TEXT_BASE_HEIGHT * 5.5f); | ||||
|         ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 5.5f); | ||||
|         if (ImGui::BeginTable("##table3", 3, flags, outer_size)) | ||||
|         { | ||||
|             for (int row = 0; row < 10; row++) | ||||
| @@ -4766,7 +4766,7 @@ static void ShowDemoWindowTables() | ||||
|         ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0)."); | ||||
|         PopStyleCompact(); | ||||
|  | ||||
|         if (ImGui::BeginTable("##table", 4, flags, ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 15), 0.0f)) | ||||
|         if (ImGui::BeginTable("##table", 4, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 15), 0.0f)) | ||||
|         { | ||||
|             // Declare columns | ||||
|             // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. | ||||
| @@ -4836,7 +4836,7 @@ static void ShowDemoWindowTables() | ||||
|         static int freeze_cols = 1; | ||||
|         static int freeze_rows = 1; | ||||
|         static int items_count = IM_ARRAYSIZE(template_items_names) * 2; | ||||
|         static ImVec2 outer_size_value = ImVec2(-FLT_MIN, TEXT_BASE_HEIGHT * 12); | ||||
|         static ImVec2 outer_size_value = ImVec2(0.0f, TEXT_BASE_HEIGHT * 12); | ||||
|         static float row_min_height = 0.0f; // Auto | ||||
|         static float inner_width_with_scroll = 0.0f; // Auto-extend | ||||
|         static bool outer_size_enabled = true; | ||||
| @@ -4879,7 +4879,10 @@ static void ShowDemoWindowTables() | ||||
|             { | ||||
|                 EditTableSizingFlags(&flags); | ||||
|                 ImGui::SameLine(); HelpMarker("In the Advanced demo we override the policy of each column so those table-wide settings have less effect that typical."); | ||||
|                 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX); | ||||
|                 ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used."); | ||||
|                 ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY); | ||||
|                 ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible."); | ||||
|                 ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible); | ||||
|                 ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled."); | ||||
|                 ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths); | ||||
| @@ -4985,7 +4988,7 @@ static void ShowDemoWindowTables() | ||||
|             ImGui::TableSetupColumn("Name",         ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Name); | ||||
|             ImGui::TableSetupColumn("Action",       ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Action); | ||||
|             ImGui::TableSetupColumn("Quantity",     ImGuiTableColumnFlags_PreferSortDescending, 0.0f, MyItemColumnID_Quantity); | ||||
|             ImGui::TableSetupColumn("Description",  ImGuiTableColumnFlags_WidthStretch, 0.0f, MyItemColumnID_Description); | ||||
|             ImGui::TableSetupColumn("Description",  (flags & ImGuiTableFlags_NoHostExtendX) ? 0 : ImGuiTableColumnFlags_WidthStretch, 0.0f, MyItemColumnID_Description); | ||||
|             ImGui::TableSetupColumn("Hidden",       ImGuiTableColumnFlags_DefaultHide | ImGuiTableColumnFlags_NoSort); | ||||
|             ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user