Skip to content

Commit 7088a16

Browse files
authored
SCM Graph - tweak rendering for expanded history items (microsoft#249897)
1 parent fd7158c commit 7088a16

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

src/vs/workbench/contrib/scm/browser/media/scm.css

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,14 @@
133133
align-items: center;
134134
}
135135

136-
.scm-view .monaco-list-row .monaco-tl-twistie.collapsed + .monaco-tl-contents > .history-item > .graph-container {
137-
border-left-color: transparent !important;
136+
.scm-view .monaco-list-row .monaco-tl-twistie:not(.collapsed) + .monaco-tl-contents > .history-item > .graph-container > svg > path:last-of-type {
137+
stroke-width: 3px;
138138
}
139139

140140
.scm-view .monaco-list-row .history-item > .graph-container {
141141
display: flex;
142142
flex-shrink: 0;
143143
height: 22px;
144-
border-left-width: 3px;
145-
border-left-style: solid;
146144
}
147145

148146
.scm-view .monaco-list-row .history-item > .graph-container.current > .graph > circle:last-child {
@@ -642,8 +640,6 @@
642640
.scm-view .monaco-list-row .history-item-change > .graph-placeholder {
643641
position: absolute;
644642
height: 22px;
645-
border-left-width: 3px;
646-
border-left-style: solid;
647643
}
648644

649645
.scm-view .monaco-list-row .history-item-change > .label-container {
@@ -659,7 +655,6 @@
659655
.scm-history-view .history-item-load-more {
660656
display: flex;
661657
height: 22px;
662-
padding-left: 3px;
663658
}
664659

665660
.scm-history-view .history-item-load-more .graph-placeholder {

src/vs/workbench/contrib/scm/browser/scmHistory.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ function getLabelColorIdentifier(historyItem: ISCMHistoryItem, colorMap: Map<str
5656
return undefined;
5757
}
5858

59-
function createPath(colorIdentifier: string): SVGPathElement {
59+
function createPath(colorIdentifier: string, strokeWidth = 1): SVGPathElement {
6060
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
6161
path.setAttribute('fill', 'none');
62-
path.setAttribute('stroke-width', '1px');
62+
path.setAttribute('stroke-width', `${strokeWidth}px`);
6363
path.setAttribute('stroke-linecap', 'round');
6464
path.style.stroke = asCssVariable(colorIdentifier);
6565

@@ -80,8 +80,8 @@ function drawCircle(index: number, radius: number, strokeWidth: number, colorIde
8080
return circle;
8181
}
8282

83-
function drawVerticalLine(x1: number, y1: number, y2: number, color: string): SVGPathElement {
84-
const path = createPath(color);
83+
function drawVerticalLine(x1: number, y1: number, y2: number, color: string, strokeWidth = 1): SVGPathElement {
84+
const path = createPath(color, strokeWidth);
8585
path.setAttribute('d', `M ${x1} ${y1} V ${y2}`);
8686

8787
return path;
@@ -240,14 +240,15 @@ export function renderSCMHistoryItemGraph(historyItemViewModel: ISCMHistoryItemV
240240
return svg;
241241
}
242242

243-
export function renderSCMHistoryGraphPlaceholder(columns: ISCMHistoryItemGraphNode[]): HTMLElement {
243+
export function renderSCMHistoryGraphPlaceholder(columns: ISCMHistoryItemGraphNode[], highlightIndex?: number): HTMLElement {
244244
const elements = svgElem('svg', {
245245
style: { height: `${SWIMLANE_HEIGHT}px`, width: `${SWIMLANE_WIDTH * (columns.length + 1)}px`, }
246246
});
247247

248248
// Draw |
249249
for (let index = 0; index < columns.length; index++) {
250-
const path = drawVerticalLine(SWIMLANE_WIDTH * (index + 1), 0, SWIMLANE_HEIGHT, columns[index].color);
250+
const strokeWidth = index === highlightIndex ? 3 : 1;
251+
const path = drawVerticalLine(SWIMLANE_WIDTH * (index + 1), 0, SWIMLANE_HEIGHT, columns[index].color, strokeWidth);
251252
elements.root.append(path);
252253
}
253254

@@ -354,18 +355,13 @@ export function toISCMHistoryItemViewModelArray(
354355
return viewModels;
355356
}
356357

357-
export function getHistoryItemColor(historyItemViewModel: ISCMHistoryItemViewModel): string {
358+
export function getHistoryItemIndex(historyItemViewModel: ISCMHistoryItemViewModel): number {
358359
const historyItem = historyItemViewModel.historyItem;
359360
const inputSwimlanes = historyItemViewModel.inputSwimlanes;
360-
const outputSwimlanes = historyItemViewModel.outputSwimlanes;
361361

362362
// Find the history item in the input swimlanes
363363
const inputIndex = inputSwimlanes.findIndex(node => node.id === historyItem.id);
364364

365365
// Circle index - use the input swimlane index if present, otherwise add it to the end
366-
const circleIndex = inputIndex !== -1 ? inputIndex : inputSwimlanes.length;
367-
368-
// Circle color - use the output swimlane color if present, otherwise the input swimlane color
369-
return circleIndex < outputSwimlanes.length ? outputSwimlanes[circleIndex].color :
370-
circleIndex < inputSwimlanes.length ? inputSwimlanes[circleIndex].color : historyItemRefColor;
366+
return inputIndex !== -1 ? inputIndex : inputSwimlanes.length;
371367
}

src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { asCssVariable, ColorIdentifier, foreground } from '../../../../platform
2828
import { IFileIconTheme, IThemeService } from '../../../../platform/theme/common/themeService.js';
2929
import { IViewPaneOptions, ViewAction, ViewPane, ViewPaneShowActions } from '../../../browser/parts/views/viewPane.js';
3030
import { IViewDescriptorService, ViewContainerLocation } from '../../../common/views.js';
31-
import { renderSCMHistoryItemGraph, toISCMHistoryItemViewModelArray, SWIMLANE_WIDTH, renderSCMHistoryGraphPlaceholder, historyItemHoverLabelForeground, historyItemHoverDefaultLabelBackground, getHistoryItemColor } from './scmHistory.js';
31+
import { renderSCMHistoryItemGraph, toISCMHistoryItemViewModelArray, SWIMLANE_WIDTH, renderSCMHistoryGraphPlaceholder, historyItemHoverLabelForeground, historyItemHoverDefaultLabelBackground, getHistoryItemIndex } from './scmHistory.js';
3232
import { getHistoryItemEditorTitle, getHistoryItemHoverContent, getProviderKey, isSCMHistoryItemChangeNode, isSCMHistoryItemChangeViewModelTreeElement, isSCMHistoryItemLoadMoreTreeElement, isSCMHistoryItemViewModelTreeElement, isSCMRepository } from './util.js';
3333
import { ISCMHistoryItem, ISCMHistoryItemChange, ISCMHistoryItemGraphNode, ISCMHistoryItemRef, ISCMHistoryItemViewModel, ISCMHistoryProvider, SCMHistoryItemChangeViewModelTreeElement, SCMHistoryItemLoadMoreTreeElement, SCMHistoryItemViewModelTreeElement } from '../common/history.js';
3434
import { HISTORY_VIEW_PANE_ID, ISCMProvider, ISCMRepository, ISCMService, ISCMViewService, ViewMode } from '../common/scm.js';
@@ -441,7 +441,6 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemVie
441441
templateData.graphContainer.textContent = '';
442442
templateData.graphContainer.classList.toggle('current', historyItemViewModel.isCurrent);
443443
templateData.graphContainer.appendChild(renderSCMHistoryItemGraph(historyItemViewModel));
444-
templateData.graphContainer.style.borderLeftColor = asCssVariable(getHistoryItemColor(historyItemViewModel));
445444

446445
const historyItemRef = provider.historyProvider.get()?.historyItemRef?.get();
447446
const extraClasses = historyItemRef?.revision === historyItem.id ? ['history-item-current'] : [];
@@ -669,16 +668,13 @@ class HistoryItemChangeRenderer implements ICompressibleTreeRenderer<SCMHistoryI
669668

670669
private _renderGraphPlaceholder(templateData: HistoryItemChangeTemplate, historyItemViewModel: ISCMHistoryItemViewModel, graphColumns: ISCMHistoryItemGraphNode[]): void {
671670
const graphPlaceholderSvgWidth = SWIMLANE_WIDTH * (graphColumns.length + 1);
672-
const graphPlaceholderElementWidth = graphPlaceholderSvgWidth + 3 /* left border */;
673-
674-
const marginLeft = graphPlaceholderElementWidth - 16 /* .monaco-tl-indent left */;
671+
const marginLeft = graphPlaceholderSvgWidth - 16 /* .monaco-tl-indent left */;
675672
templateData.rowElement.style.marginLeft = `${marginLeft}px`;
676673

677674
templateData.graphPlaceholder.textContent = '';
678675
templateData.graphPlaceholder.style.left = `${-1 * marginLeft}px`;
679676
templateData.graphPlaceholder.style.width = `${graphPlaceholderSvgWidth}px`;
680-
templateData.graphPlaceholder.style.borderLeftColor = asCssVariable(getHistoryItemColor(historyItemViewModel));
681-
templateData.graphPlaceholder.appendChild(renderSCMHistoryGraphPlaceholder(graphColumns));
677+
templateData.graphPlaceholder.appendChild(renderSCMHistoryGraphPlaceholder(graphColumns, getHistoryItemIndex(historyItemViewModel)));
682678
}
683679

684680
disposeTemplate(templateData: HistoryItemChangeTemplate): void {

0 commit comments

Comments
 (0)