feat(graph): add lane-colored ribbons and connectors

This commit is contained in:
2026-06-18 19:54:03 -05:00
parent 067ad577ef
commit dea38ce955
2 changed files with 24 additions and 3 deletions

View File

@@ -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<int>(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) {

View File

@@ -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<float> 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];