Change submodules icon to folder, expand row highlight left bound, scale ref badge text size down

This commit is contained in:
2026-06-19 16:05:34 -05:00
parent 7a39b4aa20
commit 2ca9c6bf77
2 changed files with 17 additions and 9 deletions

View File

@@ -1661,7 +1661,7 @@ void draw_sidebar(float width) {
section_heights[2], section_heights[2],
next_open_indices[2] < section_open.size() ? section_heights[next_open_indices[2]] / g_ui_scale : 0.0f, next_open_indices[2] < section_open.size() ? section_heights[next_open_indices[2]] / g_ui_scale : 0.0f,
minimum_height, next_open_indices[2], next_open_indices[2] != last_open, section_open[2] && last_open != 2); minimum_height, next_open_indices[2], next_open_indices[2] != last_open, section_open[2] && last_open != 2);
section(ICON_TB_FOLDER_TREE " SUBMODULES", repo().submodules, ICON_TB_FOLDER_TREE, section(ICON_TB_FOLDER_TREE " SUBMODULES", repo().submodules, ICON_TB_FOLDER,
"Add submodule", "Add submodule", SidebarItemKind::submodule, 3, "Add submodule", "Add submodule", SidebarItemKind::submodule, 3,
section_heights[3], 0.0f, minimum_height, section_open.size(), false, false); section_heights[3], 0.0f, minimum_height, section_open.size(), false, false);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
@@ -1687,7 +1687,8 @@ float outline_icon_width(const char* icon) {
float ref_badge_width(const RefBadge& badge) { float ref_badge_width(const RefBadge& badge) {
const std::string display_name = ref_display_name(badge); const std::string display_name = ref_display_name(badge);
float width = ImGui::CalcTextSize(display_name.c_str()).x + ui(12.0f); const float text_scale = 0.82f;
float width = ImGui::CalcTextSize(display_name.c_str()).x * text_scale + ui(12.0f);
if (badge.kind == RefKind::local) { if (badge.kind == RefKind::local) {
width += outline_icon_width(ICON_TB_DEVICE_LAPTOP) + ui(6.0f); width += outline_icon_width(ICON_TB_DEVICE_LAPTOP) + ui(6.0f);
if (badge.current) width += outline_icon_width(ICON_TB_CHECK) + ui(5.0f); if (badge.current) width += outline_icon_width(ICON_TB_CHECK) + ui(5.0f);
@@ -1771,8 +1772,10 @@ void draw_ref_badge(const RefBadge& badge, int widget_index, int commit_index, i
const float rounding = ui(3.0f); const float rounding = ui(3.0f);
draw->AddRectFilled(minimum, maximum, background, rounding, corners); draw->AddRectFilled(minimum, maximum, background, rounding, corners);
const float text_scale = 0.82f;
const float label_width = ImGui::CalcTextSize(display_name.c_str()).x * text_scale;
float x = minimum.x + ui(5.0f); float x = minimum.x + ui(5.0f);
const float text_y = minimum.y + (chip_size.y - ImGui::GetFontSize()) * 0.5f; const float text_y = minimum.y + (chip_size.y - ImGui::GetFontSize() * text_scale) * 0.5f;
const float icon_y = minimum.y + (chip_size.y - g_outline_icon_size) * 0.5f; const float icon_y = minimum.y + (chip_size.y - g_outline_icon_size) * 0.5f;
const ImU32 color = badge.current ? IM_COL32(248, 250, 252, 255) : IM_COL32(197, 203, 212, 255); const ImU32 color = badge.current ? IM_COL32(248, 250, 252, 255) : IM_COL32(197, 203, 212, 255);
const auto draw_icon = [&](const char* icon) { const auto draw_icon = [&](const char* icon) {
@@ -1781,8 +1784,13 @@ void draw_ref_badge(const RefBadge& badge, int widget_index, int commit_index, i
x += outline_icon_width(icon) + ui(5.0f); x += outline_icon_width(icon) + ui(5.0f);
}; };
if (badge.current) draw_icon(ICON_TB_CHECK); if (badge.current) draw_icon(ICON_TB_CHECK);
draw->AddText({x, text_y}, color, display_name.c_str());
x += ImGui::CalcTextSize(display_name.c_str()).x + ui(5.0f); // Draw text with smaller font scale
ImGui::PushFont(nullptr, ImGui::GetStyle().FontSizeBase * text_scale);
draw->AddText(ImGui::GetFont(), ImGui::GetFontSize(), {x, text_y}, color, display_name.c_str());
ImGui::PopFont();
x += label_width + ui(5.0f);
if (badge.kind == RefKind::local) draw_icon(ICON_TB_DEVICE_LAPTOP); if (badge.kind == RefKind::local) draw_icon(ICON_TB_DEVICE_LAPTOP);
if (show_cloud) draw_icon(ICON_TB_CLOUD); if (show_cloud) draw_icon(ICON_TB_CLOUD);
if (show_tag) draw_icon(ICON_TB_TAG); if (show_tag) draw_icon(ICON_TB_TAG);
@@ -2046,9 +2054,9 @@ void draw_commit_table() {
mouse.y >= row_top && mouse.y < row_top + row_height; mouse.y >= row_top && mouse.y < row_top + row_height;
if (selected || hovered) { if (selected || hovered) {
ImDrawList* draw = ImGui::GetWindowDrawList(); ImDrawList* draw = ImGui::GetWindowDrawList();
draw->PushClipRect({message_left, table_body_clip_top}, draw->PushClipRect({row_left, table_body_clip_top},
{row_right, table_body_clip_bottom}, false); {row_right, table_body_clip_bottom}, false);
draw->AddRectFilled({message_left, row_top}, {row_right, row_top + row_height}, draw->AddRectFilled({row_left, row_top}, {row_right, row_top + row_height},
selected ? IM_COL32(45, 58, 84, 155) : IM_COL32(70, 77, 90, 55)); selected ? IM_COL32(45, 58, 84, 155) : IM_COL32(70, 77, 90, 55));
draw->PopClipRect(); draw->PopClipRect();
} }

View File

@@ -124,7 +124,7 @@ float GraphRenderer::requiredWidth(const std::vector<CommitInfo>& commits, float
int maximum_lane = 0; int maximum_lane = 0;
for (const auto& commit : commits) maximum_lane = std::max(maximum_lane, commit.lane); for (const auto& commit : commits) maximum_lane = std::max(maximum_lane, commit.lane);
// Keep one spare lane available for edges that must route around occupied commit lanes. // Keep one spare lane available for edges that must route around occupied commit lanes.
return std::max((68.0f + maximum_lane * 22.0f) * scale, 82.0f * scale); return std::max((68.0f + maximum_lane * 28.0f) * scale, 82.0f * scale);
} }
void GraphRenderer::drawRow(int row, const CommitInfo& commit, void GraphRenderer::drawRow(int row, const CommitInfo& commit,
@@ -135,7 +135,7 @@ void GraphRenderer::drawRow(int row, const CommitInfo& commit,
const ImVec2 origin = ImGui::GetCursorScreenPos(); const ImVec2 origin = ImGui::GetCursorScreenPos();
const float row_height = row_heights[static_cast<size_t>(row)]; const float row_height = row_heights[static_cast<size_t>(row)];
const float content_height = std::max(px(1.0f), row_height - ImGui::GetStyle().CellPadding.y * 2.0f); const float content_height = std::max(px(1.0f), row_height - ImGui::GetStyle().CellPadding.y * 2.0f);
const float lane_spacing = px(22.0f); const float lane_spacing = px(28.0f);
const float x = origin.x + px(17.0f) + lane_spacing * commit.lane; const float x = origin.x + px(17.0f) + lane_spacing * commit.lane;
const float y = origin.y + content_height * 0.5f; const float y = origin.y + content_height * 0.5f;
const float cell_right = origin.x + ImGui::GetContentRegionAvail().x; const float cell_right = origin.x + ImGui::GetContentRegionAvail().x;