mirror of https://github.com/ocornut/imgui
Tables: Honor width/weight passed to TableSetupColumn() after .ini load since we don't actually restore that data currently.
Demo: Remove filter from Advanced Table demo since it's breaking with clipping.
This commit is contained in:
parent
0e7b3f2f2f
commit
5431cbd3f0
|
@ -3661,14 +3661,14 @@ static void ShowDemoWindowTables()
|
|||
{
|
||||
for (int column = 0; column < column_count; column++)
|
||||
{
|
||||
ImGui::TableNextCell();
|
||||
// Make the UI compact because there are so many fields
|
||||
ImGui::TableNextCell();
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(style.FramePadding.x, 2));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, 2));
|
||||
ImGui::PushID(column);
|
||||
ImGui::AlignTextToFramePadding(); // FIXME-TABLE: Workaround for wrong text baseline propagation
|
||||
ImGui::Text("Column '%s'", column_names[column]);
|
||||
ImGui::Text("Flags for '%s'", column_names[column]);
|
||||
ImGui::CheckboxFlags("_NoResize", (unsigned int*)&column_flags[column], ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::CheckboxFlags("_NoClipX", (unsigned int*)&column_flags[column], ImGuiTableColumnFlags_NoClipX);
|
||||
ImGui::CheckboxFlags("_NoHide", (unsigned int*)&column_flags[column], ImGuiTableColumnFlags_NoHide);
|
||||
|
@ -3880,8 +3880,8 @@ static void ShowDemoWindowTables()
|
|||
{
|
||||
// The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide);
|
||||
ImGui::TableSetupColumn("Size", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 10);
|
||||
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 20);
|
||||
ImGui::TableSetupColumn("Size", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 6);
|
||||
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed, ImGui::GetFontSize() * 10);
|
||||
ImGui::TableAutoHeaders();
|
||||
|
||||
// Simple storage to output a dummy file-system.
|
||||
|
@ -4043,10 +4043,10 @@ static void ShowDemoWindowTables()
|
|||
static float inner_width_without_scroll = 0.0f; // Fill
|
||||
static float inner_width_with_scroll = 0.0f; // Auto-extend
|
||||
static bool outer_size_enabled = true;
|
||||
static bool lock_left_column_visibility = false;
|
||||
static bool lock_first_column_visibility = false;
|
||||
static bool show_headers = true;
|
||||
static bool show_wrapped_text = false;
|
||||
static ImGuiTextFilter filter;
|
||||
//static ImGuiTextFilter filter;
|
||||
//ImGui::SetNextItemOpen(true, ImGuiCond_Once); // FIXME-TABLE: Enabling this results in initial clipped first pass on table which affects sizing
|
||||
if (ImGui::TreeNodeEx("Options"))
|
||||
{
|
||||
|
@ -4130,10 +4130,10 @@ static void ShowDemoWindowTables()
|
|||
ImGui::SameLine(); HelpMarker("Specify height of the Selectable item.");
|
||||
ImGui::DragInt("items_count", &items_count, 0.1f, 0, 5000);
|
||||
ImGui::Combo("contents_type (first column)", &contents_type, contents_type_names, IM_ARRAYSIZE(contents_type_names));
|
||||
filter.Draw("filter");
|
||||
//filter.Draw("filter");
|
||||
ImGui::Checkbox("show_headers", &show_headers);
|
||||
ImGui::Checkbox("show_wrapped_text", &show_wrapped_text);
|
||||
ImGui::Checkbox("lock_left_column_visibility", &lock_left_column_visibility);
|
||||
ImGui::Checkbox("lock_first_column_visibility", &lock_first_column_visibility);
|
||||
ImGui::Unindent();
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
@ -4168,7 +4168,7 @@ static void ShowDemoWindowTables()
|
|||
// Declare columns
|
||||
// We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications.
|
||||
// This is so our sort function can identify a column given our own identifier. We could also identify them based on their index!
|
||||
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed | (lock_left_column_visibility ? ImGuiTableColumnFlags_NoHide : 0), -1.0f, MyItemColumnID_ID);
|
||||
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed | (lock_first_column_visibility ? ImGuiTableColumnFlags_NoHide : 0), -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 Long Label", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_WidthStretch, 1.0f, MyItemColumnID_Quantity);// , ImGuiTableColumnFlags_None | ImGuiTableColumnFlags_WidthAlwaysAutoResize);
|
||||
|
@ -4209,8 +4209,8 @@ static void ShowDemoWindowTables()
|
|||
#endif
|
||||
{
|
||||
MyItem* item = &items[row_n];
|
||||
if (!filter.PassFilter(item->Name))
|
||||
continue;
|
||||
//if (!filter.PassFilter(item->Name))
|
||||
// continue;
|
||||
|
||||
const bool item_is_selected = selection.contains(item->ID);
|
||||
ImGui::PushID(item->ID);
|
||||
|
|
|
@ -1830,9 +1830,9 @@ struct ImGuiTableColumn
|
|||
ImGuiID UserID; // Optional, value passed to TableSetupColumn()
|
||||
ImGuiTableColumnFlags FlagsIn; // Flags as they were provided by user. See ImGuiTableColumnFlags_
|
||||
ImGuiTableColumnFlags Flags; // Effective flags. See ImGuiTableColumnFlags_
|
||||
float ResizeWeight; // ~1.0f. Master width data when (Flags & _WidthStretch)
|
||||
float MinX; // Absolute positions
|
||||
float MaxX;
|
||||
float ResizeWeight; // ~1.0f. Master width data when (Flags & _WidthStretch)
|
||||
float WidthRequested; // Master width data when !(Flags & _WidthStretch)
|
||||
float WidthGiven; // == (MaxX - MinX). FIXME-TABLE: Store all persistent width in multiple of FontSize?
|
||||
float StartXRows; // Start position for the frame, currently ~(MinX + CellPaddingX)
|
||||
|
@ -1865,8 +1865,7 @@ struct ImGuiTableColumn
|
|||
ImGuiTableColumn()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
ResizeWeight = 1.0f;
|
||||
WidthRequested = WidthGiven = -1.0f;
|
||||
ResizeWeight = WidthRequested = WidthGiven = -1.0f;
|
||||
NameOffset = -1;
|
||||
IsActive = NextIsActive = true;
|
||||
IndexDisplayOrder = IndexWithinActiveSet = -1;
|
||||
|
|
|
@ -585,7 +585,9 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||
else
|
||||
{
|
||||
IM_ASSERT(column->Flags & ImGuiTableColumnFlags_WidthStretch);
|
||||
IM_ASSERT(column->ResizeWeight > 0.0f);
|
||||
const int init_size = (column->ResizeWeight < 0.0f);
|
||||
if (init_size)
|
||||
column->ResizeWeight = 1.0f;
|
||||
total_weights += column->ResizeWeight;
|
||||
if (table->LeftMostStretchedColumnDisplayOrder == -1)
|
||||
table->LeftMostStretchedColumnDisplayOrder = (ImS8)column->IndexDisplayOrder;
|
||||
|
@ -1378,7 +1380,8 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags,
|
|||
flags = column->Flags;
|
||||
|
||||
// Initialize defaults
|
||||
if (table->IsInitializing && !table->IsSettingsLoaded)
|
||||
// FIXME-TABLE: We don't restore widths/weight so let's avoid using IsSettingsLoaded for now
|
||||
if (table->IsInitializing && column->WidthRequested < 0.0f && column->ResizeWeight < 0.0f)// && !table->IsSettingsLoaded)
|
||||
{
|
||||
// Init width or weight
|
||||
// Disable auto-fit if a default fixed width has been specified
|
||||
|
@ -1396,7 +1399,9 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags,
|
|||
{
|
||||
column->ResizeWeight = 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
if (table->IsInitializing && !table->IsSettingsLoaded)
|
||||
{
|
||||
// Init default visibility/sort state
|
||||
if (flags & ImGuiTableColumnFlags_DefaultHide)
|
||||
column->IsActive = column->NextIsActive = false;
|
||||
|
|
Loading…
Reference in New Issue