From dea38ce9556bfa37ed27fa0db9d2232cf4e5c82c Mon Sep 17 00:00:00 2001 From: GigabiteStudios Date: Thu, 18 Jun 2026 19:54:03 -0500 Subject: [PATCH] feat(graph): add lane-colored ribbons and connectors --- src/ui/gitree_ui.cpp | 12 +++++++++--- src/ui/graph_renderer.cpp | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/ui/gitree_ui.cpp b/src/ui/gitree_ui.cpp index d035055..f428e8e 100644 --- a/src/ui/gitree_ui.cpp +++ b/src/ui/gitree_ui.cpp @@ -595,10 +595,10 @@ void draw_ref_badge(const RefBadge& badge, int index, int lane) { const ImVec2 minimum = ImGui::GetItemRectMin(); const ImVec2 maximum = ImGui::GetItemRectMax(); ImDrawList* draw = ImGui::GetWindowDrawList(); - ImU32 background = GraphRenderer::laneColor(lane, badge.current ? 205 : 135); - if (ImGui::IsItemHovered()) background = GraphRenderer::laneColor(lane, badge.current ? 235 : 175); + ImU32 background = GraphRenderer::laneColor(lane, badge.current ? 165 : 90); + if (ImGui::IsItemHovered()) background = GraphRenderer::laneColor(lane, badge.current ? 195 : 125); draw->AddRectFilled(minimum, maximum, background); - draw->AddRect(minimum, maximum, GraphRenderer::laneColor(lane, 220)); + draw->AddRect(minimum, maximum, GraphRenderer::laneColor(lane, badge.current ? 210 : 145)); float x = minimum.x + ui(6.0f); const float text_y = minimum.y + (chip_size.y - ImGui::GetFontSize()) * 0.5f; @@ -759,6 +759,12 @@ void draw_commit_table() { float chip_x = reference_origin.x + ui(3.0f); float chip_y = reference_origin.y + ui(0.5f); const float chip_right = reference_origin.x + chip_line_width; + if (!commit.refs.empty()) { + const float connector_y = reference_origin.y + row_height * 0.5f; + ImGui::GetWindowDrawList()->AddLine( + {reference_origin.x, connector_y}, {chip_right + ui(6.0f), connector_y}, + GraphRenderer::laneColor(commit.lane, 120), ui(1.0f)); + } for (int ref_index = 0; ref_index < static_cast(commit.refs.size()); ++ref_index) { const float badge_width = ref_badge_width(commit.refs[ref_index]); if (chip_x > reference_origin.x + ui(3.0f) && chip_x + badge_width > chip_right) { diff --git a/src/ui/graph_renderer.cpp b/src/ui/graph_renderer.cpp index 6ce89b4..559f2cc 100644 --- a/src/ui/graph_renderer.cpp +++ b/src/ui/graph_renderer.cpp @@ -38,8 +38,23 @@ void GraphRenderer::drawRow(int row, const CommitInfo& commit, const float lane_spacing = px(18.0f); const float x = origin.x + px(15.0f) + lane_spacing * commit.lane; const float y = origin.y + content_height * 0.5f; + const float cell_right = origin.x + ImGui::GetContentRegionAvail().x; const float row_clip_padding = ImGui::GetStyle().CellPadding.y + px(1.0f); + // GitKraken-style lane ribbon: a quiet tint carries the branch color through + // the rest of the graph column while the far edge remains crisply identifiable. + draw->AddRectFilled( + {x, origin.y - row_clip_padding}, + {cell_right, origin.y + content_height + row_clip_padding}, + laneColor(commit.lane, 38)); + draw->AddLine( + {cell_right - px(1.0f), origin.y - row_clip_padding}, + {cell_right - px(1.0f), origin.y + content_height + row_clip_padding}, + laneColor(commit.lane, 220), px(2.0f)); + if (!commit.refs.empty()) + draw->AddLine({origin.x - ImGui::GetStyle().CellPadding.x, y}, {x, y}, + laneColor(commit.lane, 150), px(1.0f)); + std::vector row_offsets(row_heights.size() + 1, 0.0f); for (size_t index = 0; index < row_heights.size(); ++index) row_offsets[index + 1] = row_offsets[index] + row_heights[index];