1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Tables: Added ImGuiTableFlags_NoKeepColumnsVisible wip flag useful for layout purpose. (WIP)

This commit is contained in:
omar 2020-02-10 15:48:08 +01:00 committed by ocornut
parent 104ec408a8
commit 643cf6fc8c
2 changed files with 13 additions and 11 deletions

21
imgui.h
View File

@ -1040,21 +1040,22 @@ enum ImGuiTableFlags_
ImGuiTableFlags_SizingPolicyStretchX = 1 << 14, // Default if ScrollX is off. Columns will default to use WidthStretch policy. Read description above for more details.
ImGuiTableFlags_NoHeadersWidth = 1 << 15, // Disable header width contribution to automatic width calculation.
ImGuiTableFlags_NoHostExtendY = 1 << 16, // (FIXME-TABLE: Reword as SizingPolicy?) Disable extending past the limit set by outer_size.y, only meaningful when neither of ScrollX|ScrollY are set (data below the limit will be clipped and not visible)
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 17, // (FIXME-TABLE) Disable code that keeps column always minimally visible when table width gets too small.
// Scrolling
ImGuiTableFlags_ScrollX = 1 << 17, // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Because this create a child window, ScrollY is currently generally recommended when using ScrollX.
ImGuiTableFlags_ScrollY = 1 << 18, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size.
ImGuiTableFlags_ScrollX = 1 << 18, // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Because this create a child window, ScrollY is currently generally recommended when using ScrollX.
ImGuiTableFlags_ScrollY = 1 << 19, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size.
ImGuiTableFlags_Scroll = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY,
ImGuiTableFlags_ScrollFreezeTopRow = 1 << 19, // We can lock 1 to 3 rows (starting from the top). Use with ScrollY enabled.
ImGuiTableFlags_ScrollFreeze2Rows = 2 << 19,
ImGuiTableFlags_ScrollFreeze3Rows = 3 << 19,
ImGuiTableFlags_ScrollFreezeLeftColumn = 1 << 21, // We can lock 1 to 3 columns (starting from the left). Use with ScrollX enabled.
ImGuiTableFlags_ScrollFreeze2Columns = 2 << 21,
ImGuiTableFlags_ScrollFreeze3Columns = 3 << 21,
ImGuiTableFlags_ScrollFreezeTopRow = 1 << 20, // We can lock 1 to 3 rows (starting from the top). Use with ScrollY enabled.
ImGuiTableFlags_ScrollFreeze2Rows = 2 << 20,
ImGuiTableFlags_ScrollFreeze3Rows = 3 << 20,
ImGuiTableFlags_ScrollFreezeLeftColumn = 1 << 22, // We can lock 1 to 3 columns (starting from the left). Use with ScrollX enabled.
ImGuiTableFlags_ScrollFreeze2Columns = 2 << 22,
ImGuiTableFlags_ScrollFreeze3Columns = 3 << 22,
// [Internal] Combinations and masks
ImGuiTableFlags_SizingPolicyMaskX_ = ImGuiTableFlags_SizingPolicyStretchX | ImGuiTableFlags_SizingPolicyFixedX,
ImGuiTableFlags_ScrollFreezeRowsShift_ = 19,
ImGuiTableFlags_ScrollFreezeColumnsShift_ = 21,
ImGuiTableFlags_ScrollFreezeRowsShift_ = 20,
ImGuiTableFlags_ScrollFreezeColumnsShift_ = 22,
ImGuiTableFlags_ScrollFreezeRowsMask_ = 0x03 << ImGuiTableFlags_ScrollFreezeRowsShift_,
ImGuiTableFlags_ScrollFreezeColumnsMask_ = 0x03 << ImGuiTableFlags_ScrollFreezeColumnsShift_
};

View File

@ -724,7 +724,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
{
// If horizontal scrolling if disabled, we apply a final lossless shrinking of columns in order to make sure they are all visible.
// Because of this we also know that all of the columns will always fit in table->WorkRect and therefore in table->InnerRect (because ScrollX is off)
max_x = table->WorkRect.Max.x - (table->ColumnsActiveCount - (column->IndexWithinActiveSet + 1)) * min_column_width;
if (!(table->Flags & ImGuiTableFlags_NoKeepColumnsVisible))
max_x = table->WorkRect.Max.x - (table->ColumnsActiveCount - (column->IndexWithinActiveSet + 1)) * min_column_width;
}
if (offset_x + column->WidthGiven > max_x)
column->WidthGiven = ImMax(max_x - offset_x, min_column_width);