Columns: Fix for explicit content width and scrollbar. (#519, #125)

This commit is contained in:
omar 2017-08-20 21:32:18 +08:00
parent ea493fd8da
commit 54bdd00df7
2 changed files with 4 additions and 4 deletions

View File

@ -10050,10 +10050,10 @@ void ImGui::BeginColumns(const char* id, int columns_count, ImGuiColumnsFlags fl
window->DC.ColumnsCount = columns_count;
window->DC.ColumnsFlags = flags;
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : window->Size.x;
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->Size.x -window->ScrollbarSizes.x);
window->DC.ColumnsMinX = window->DC.IndentX - g.Style.ItemSpacing.x; // Lock our horizontal range
//window->DC.ColumnsMaxX = content_region_width - window->Scroll.x -((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x;
window->DC.ColumnsMaxX = content_region_width - window->Scroll.x - window->ScrollbarSizes.x;
window->DC.ColumnsMaxX = content_region_width - window->Scroll.x;
window->DC.ColumnsStartPosY = window->DC.CursorPos.y;
window->DC.ColumnsStartMaxPosX = window->DC.CursorMaxPos.x;
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.CursorPos.y;

View File

@ -1623,13 +1623,13 @@ void ImGui::ShowTestWindow(bool* p_open)
if (ImGui::TreeNode("Horizontal Scrolling"))
{
ImGui::SetNextWindowContentWidth(2000);
ImGui::SetNextWindowContentWidth(1500);
ImGui::BeginChild("##scrollingregion", ImVec2(0, 120), false, ImGuiWindowFlags_HorizontalScrollbar);
ImGui::Columns(10);
for (int i = 0; i < 20; i++)
for (int j = 0; j < 10; j++)
{
ImGui::Text("Line %d Column %d", i, j);
ImGui::Text("Line %d Column %d...", i, j);
ImGui::NextColumn();
}
ImGui::Columns(1);