From cb3c1da77a5a198719586bed4f42b01dcc436322 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 22 Feb 2015 17:02:17 +0000 Subject: [PATCH] GetColumnOffset() / SetColumnOffset() fixes. (cf #125) Actually ignore window padding, and don't subtract window->DC.ColumnsStartX like older version did. --- imgui.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 00424f23..5bafb8ad 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6362,7 +6362,7 @@ float ImGui::GetColumnOffset(int column_index) const float t = window->DC.ColumnsOffsetsT[column_index]; const float min_x = window->DC.ColumnsStartX; - const float max_x = window->Size.x - (g.Style.ScrollBarWidth) - window->WindowPadding().x; + const float max_x = window->Size.x - (g.Style.ScrollBarWidth);// - window->WindowPadding().x; const float offset = min_x + t * (max_x - min_x); return offset; } @@ -6378,7 +6378,7 @@ void ImGui::SetColumnOffset(int column_index, float offset) const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index); const float min_x = window->DC.ColumnsStartX; - const float max_x = window->Size.x - (g.Style.ScrollBarWidth) - window->WindowPadding().x; + const float max_x = window->Size.x - (window->ScrollbarY);// - window->WindowPadding().x; const float t = (offset - min_x) / (max_x - min_x); window->StateStorage.SetFloat(column_id, t); window->DC.ColumnsOffsetsT[column_index] = t; @@ -8692,6 +8692,32 @@ void ImGui::ShowTestWindow(bool* opened) ImGui::Separator(); ImGui::Spacing(); + // Scrolling columns + /* + ImGui::Text("Scrolling:"); + ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)); + ImGui::Columns(3); + ImGui::Text("ID"); ImGui::NextColumn(); + ImGui::Text("Name"); ImGui::NextColumn(); + ImGui::Text("Path"); ImGui::NextColumn(); + ImGui::Columns(1); + ImGui::Separator(); + ImGui::EndChild(); + ImGui::BeginChild("##scrollingregion", ImVec2(0, 60)); + ImGui::Columns(3); + for (int i = 0; i < 10; i++) + { + ImGui::Text("%04d", i); ImGui::NextColumn(); + ImGui::Text("Foobar"); ImGui::NextColumn(); + ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::EndChild(); + + ImGui::Separator(); + ImGui::Spacing(); + */ + // Create multiple items in a same cell before switching to next column ImGui::Text("Mixed items:"); ImGui::Columns(3, "mixed");