Tables: renamed ImGuiTableFlags_NoClipX to ImGuiTableFlags_NoClip, clarified purpose, moved lower in the list as it doesn't need to be so prominent.

This commit is contained in:
ocornut 2020-09-23 16:42:44 +02:00
parent 8ec05fc034
commit 36b2f3b4f1
3 changed files with 19 additions and 18 deletions

12
imgui.h
View File

@ -1052,12 +1052,12 @@ enum ImGuiTableFlags_
ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, // Draw all borders. ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, // Draw all borders.
ImGuiTableFlags_BordersFullHeightV = 1 << 11, // Borders covers all rows even when Headers are being used. Allow resizing from any rows. ImGuiTableFlags_BordersFullHeightV = 1 << 11, // Borders covers all rows even when Headers are being used. Allow resizing from any rows.
// Padding, Sizing // Padding, Sizing
ImGuiTableFlags_NoClipX = 1 << 14, // Disable pushing clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow) ImGuiTableFlags_SizingPolicyFixedX = 1 << 12, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAlwaysAutoResize policy. Read description above for more details.
ImGuiTableFlags_SizingPolicyFixedX = 1 << 15, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAlwaysAutoResize policy. Read description above for more details. ImGuiTableFlags_SizingPolicyStretchX = 1 << 13, // Default if ScrollX is off. Columns will default to use _WidthStretch policy. Read description above for more details.
ImGuiTableFlags_SizingPolicyStretchX = 1 << 16, // Default if ScrollX is off. Columns will default to use _WidthStretch policy. Read description above for more details. ImGuiTableFlags_NoHeadersWidth = 1 << 14, // Disable header width contribution to automatic width calculation.
ImGuiTableFlags_NoHeadersWidth = 1 << 17, // Disable header width contribution to automatic width calculation. ImGuiTableFlags_NoHostExtendY = 1 << 15, // (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_NoHostExtendY = 1 << 18, // (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 << 16, // (FIXME-TABLE) Disable code that keeps column always minimally visible when table width gets too small and horizontal scrolling is off.
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 19, // (FIXME-TABLE) Disable code that keeps column always minimally visible when table width gets too small and horizontal scrolling is off. ImGuiTableFlags_NoClip = 1 << 17, // Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options.
// Scrolling // Scrolling
ImGuiTableFlags_ScrollX = 1 << 20, // 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_ScrollX = 1 << 20, // 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 << 21, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. ImGuiTableFlags_ScrollY = 1 << 21, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size.

View File

@ -3828,7 +3828,7 @@ static void ShowDemoWindowTables()
flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyFixedX); // Can't specify both sizing polices so we clear the other flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyFixedX); // Can't specify both sizing polices so we clear the other
ImGui::SameLine(); HelpMarker("Default if _ScrollX if enabled. Makes columns use _WidthFixed by default, or _WidthAlwaysAutoResize if _Resizable is not set."); ImGui::SameLine(); HelpMarker("Default if _ScrollX if enabled. Makes columns use _WidthFixed by default, or _WidthAlwaysAutoResize if _Resizable is not set.");
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", (unsigned int*)&flags, ImGuiTableFlags_Resizable); ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", (unsigned int*)&flags, ImGuiTableFlags_Resizable);
ImGui::CheckboxFlags("ImGuiTableFlags_NoClipX", (unsigned int*)&flags, ImGuiTableFlags_NoClipX); ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", (unsigned int*)&flags, ImGuiTableFlags_NoClip);
if (ImGui::BeginTable("##3ways", 3, flags, ImVec2(0, 100))) if (ImGui::BeginTable("##3ways", 3, flags, ImVec2(0, 100)))
{ {
@ -4296,7 +4296,6 @@ static void ShowDemoWindowTables()
ImGui::BulletText("Padding, Sizing:"); ImGui::BulletText("Padding, Sizing:");
ImGui::Indent(); ImGui::Indent();
ImGui::CheckboxFlags("ImGuiTableFlags_NoClipX", (unsigned int*)&flags, ImGuiTableFlags_NoClipX);
if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", (unsigned int*)&flags, ImGuiTableFlags_SizingPolicyStretchX)) if (ImGui::CheckboxFlags("ImGuiTableFlags_SizingPolicyStretchX", (unsigned int*)&flags, ImGuiTableFlags_SizingPolicyStretchX))
flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyStretchX); // Can't specify both sizing polices so we clear the other flags &= ~(ImGuiTableFlags_SizingPolicyMaskX_ ^ ImGuiTableFlags_SizingPolicyStretchX); // Can't specify both sizing polices so we clear the other
ImGui::SameLine(); HelpMarker("[Default if ScrollX is off]\nFit all columns within available width (or specified inner_width). Fixed and Stretch columns allowed."); ImGui::SameLine(); HelpMarker("[Default if ScrollX is off]\nFit all columns within available width (or specified inner_width). Fixed and Stretch columns allowed.");
@ -4307,6 +4306,8 @@ static void ShowDemoWindowTables()
ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", (unsigned int*)&flags, ImGuiTableFlags_NoHostExtendY); ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", (unsigned int*)&flags, ImGuiTableFlags_NoHostExtendY);
ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", (unsigned int*)&flags, ImGuiTableFlags_NoKeepColumnsVisible); ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", (unsigned int*)&flags, ImGuiTableFlags_NoKeepColumnsVisible);
ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled."); ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled.");
ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", (unsigned int*)&flags, ImGuiTableFlags_NoClip);
ImGui::SameLine(); HelpMarker("Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options.");
ImGui::Unindent(); ImGui::Unindent();
ImGui::BulletText("Scrolling:"); ImGui::BulletText("Scrolling:");
@ -4424,7 +4425,7 @@ static void ShowDemoWindowTables()
for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++) for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++)
#else #else
{ {
for (int row_n = 0; row_n < items_count; n++) for (int row_n = 0; row_n < items_count; row_n++)
#endif #endif
{ {
MyItem* item = &items[row_n]; MyItem* item = &items[row_n];

View File

@ -124,10 +124,10 @@ inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags)
if ((flags & ImGuiTableFlags_NoHostExtendY) && (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0) if ((flags & ImGuiTableFlags_NoHostExtendY) && (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0)
flags &= ~ImGuiTableFlags_NoHostExtendY; flags &= ~ImGuiTableFlags_NoHostExtendY;
// Adjust flags: we don't support NoClipX with (FreezeColumns > 0) // Adjust flags: we don't support NoClip with (FreezeColumns > 0)
// We could with some work but it doesn't appear to be worth the effort. // We could with some work but it doesn't appear to be worth the effort.
if (flags & ImGuiTableFlags_ScrollFreezeColumnsMask_) //if (flags & ImGuiTableFlags_ScrollFreezeColumnsMask_)
flags &= ~ImGuiTableFlags_NoClipX; // flags &= ~ImGuiTableFlags_NoClip;
return flags; return flags;
} }
@ -503,7 +503,7 @@ void ImGui::TableUpdateDrawChannels(ImGuiTable* table)
// - FreezeRows || FreezeColumns --> 1+N*2 (unless scrolling value is zero) // - FreezeRows || FreezeColumns --> 1+N*2 (unless scrolling value is zero)
// - FreezeRows && FreezeColunns --> 2+N*2 (unless scrolling value is zero) // - FreezeRows && FreezeColunns --> 2+N*2 (unless scrolling value is zero)
const int freeze_row_multiplier = (table->FreezeRowsCount > 0) ? 2 : 1; const int freeze_row_multiplier = (table->FreezeRowsCount > 0) ? 2 : 1;
const int channels_for_row = (table->Flags & ImGuiTableFlags_NoClipX) ? 1 : table->ColumnsVisibleCount; const int channels_for_row = (table->Flags & ImGuiTableFlags_NoClip) ? 1 : table->ColumnsVisibleCount;
const int channels_for_background = 1; const int channels_for_background = 1;
const int channels_for_dummy = (table->ColumnsVisibleCount < table->ColumnsCount || table->VisibleUnclippedMaskByIndex != table->VisibleMaskByIndex) ? +1 : 0; const int channels_for_dummy = (table->ColumnsVisibleCount < table->ColumnsCount || table->VisibleUnclippedMaskByIndex != table->VisibleMaskByIndex) ? +1 : 0;
const int channels_total = channels_for_background + (channels_for_row * freeze_row_multiplier) + channels_for_dummy; const int channels_total = channels_for_background + (channels_for_row * freeze_row_multiplier) + channels_for_dummy;
@ -518,7 +518,7 @@ void ImGui::TableUpdateDrawChannels(ImGuiTable* table)
{ {
column->DrawChannelRowsBeforeFreeze = (ImS8)(draw_channel_current); column->DrawChannelRowsBeforeFreeze = (ImS8)(draw_channel_current);
column->DrawChannelRowsAfterFreeze = (ImS8)(draw_channel_current + (table->FreezeRowsCount > 0 ? channels_for_row : 0)); column->DrawChannelRowsAfterFreeze = (ImS8)(draw_channel_current + (table->FreezeRowsCount > 0 ? channels_for_row : 0));
if (!(table->Flags & ImGuiTableFlags_NoClipX)) if (!(table->Flags & ImGuiTableFlags_NoClip))
draw_channel_current++; draw_channel_current++;
} }
else else
@ -910,7 +910,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
// Initial state // Initial state
ImGuiWindow* inner_window = table->InnerWindow; ImGuiWindow* inner_window = table->InnerWindow;
if (table->Flags & ImGuiTableFlags_NoClipX) if (table->Flags & ImGuiTableFlags_NoClip)
table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, 1); table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, 1);
else else
inner_window->DrawList->PushClipRect(inner_window->ClipRect.Min, inner_window->ClipRect.Max, false); inner_window->DrawList->PushClipRect(inner_window->ClipRect.Min, inner_window->ClipRect.Max, false);
@ -1017,7 +1017,7 @@ void ImGui::EndTable()
table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y); table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y);
table->LastOuterHeight = table->OuterRect.GetHeight(); table->LastOuterHeight = table->OuterRect.GetHeight();
if (!(flags & ImGuiTableFlags_NoClipX)) if (!(flags & ImGuiTableFlags_NoClip))
inner_window->DrawList->PopClipRect(); inner_window->DrawList->PopClipRect();
inner_window->ClipRect = inner_window->DrawList->_ClipRectStack.back(); inner_window->ClipRect = inner_window->DrawList->_ClipRectStack.back();
@ -1050,7 +1050,7 @@ void ImGui::EndTable()
// Flatten channels and merge draw calls // Flatten channels and merge draw calls
table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, 0); table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, 0);
if ((table->Flags & ImGuiTableFlags_NoClipX) == 0) if ((table->Flags & ImGuiTableFlags_NoClip) == 0)
TableReorderDrawChannelsForMerge(table); TableReorderDrawChannelsForMerge(table);
table->DrawSplitter.Merge(inner_window->DrawList); table->DrawSplitter.Merge(inner_window->DrawList);
@ -1808,7 +1808,7 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
window->DC.CursorPos.y = ImMax(window->DC.CursorPos.y, table->RowPosY2); window->DC.CursorPos.y = ImMax(window->DC.CursorPos.y, table->RowPosY2);
window->SkipItems = column->SkipItems; window->SkipItems = column->SkipItems;
if (table->Flags & ImGuiTableFlags_NoClipX) if (table->Flags & ImGuiTableFlags_NoClip)
{ {
table->DrawSplitter.SetCurrentChannel(window->DrawList, 1); table->DrawSplitter.SetCurrentChannel(window->DrawList, 1);
} }