paddingTop/Bottom

This commit is contained in:
rebornix
2023-07-10 14:54:41 -07:00
parent e7dd992637
commit a2daa8d69e
8 changed files with 38 additions and 38 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ export interface IPagedListOptions<T> {
readonly mouseSupport?: boolean;
readonly horizontalScrolling?: boolean;
readonly scrollByPage?: boolean;
readonly additionalScrollHeight?: number;
readonly paddingBottom?: number;
}
function fromPagedListOptions<T>(modelProvider: () => IPagedModel<T>, options: IPagedListOptions<T>): IListOptions<number> {
+15 -15
View File
@@ -56,13 +56,13 @@ export interface IListViewAccessibilityProvider<T> {
}
export interface IListViewOptionsUpdate {
readonly additionalScrollHeight?: number;
readonly smoothScrolling?: boolean;
readonly horizontalScrolling?: boolean;
readonly scrollByPage?: boolean;
readonly mouseWheelScrollSensitivity?: number;
readonly fastScrollSensitivity?: number;
readonly topPadding?: number;
readonly paddingTop?: number;
readonly paddingBottom?: number;
}
export interface IListViewOptions<T> extends IListViewOptionsUpdate {
@@ -281,7 +281,7 @@ export class ListView<T> implements IListView<T> {
private items: IItem<T>[];
private itemId: number;
private rangeMap: RangeMap;
private topPadding: number;
private paddingTop: number;
private cache: RowCache<T>;
private renderers = new Map<string, IListRenderer<any /* TODO@joao */, any>>();
private lastRenderTop: number;
@@ -300,7 +300,7 @@ export class ListView<T> implements IListView<T> {
private setRowLineHeight: boolean;
private setRowHeight: boolean;
private supportDynamicHeights: boolean;
private additionalScrollHeight: number;
private paddingBottom: number;
private accessibilityProvider: ListViewAccessibilityProvider<T>;
private scrollWidth: number | undefined;
@@ -366,8 +366,8 @@ export class ListView<T> implements IListView<T> {
this.items = [];
this.itemId = 0;
this.topPadding = options.topPadding ?? 0;
this.rangeMap = new RangeMap(this.topPadding);
this.paddingTop = options.paddingTop ?? 0;
this.rangeMap = new RangeMap(this.paddingTop);
for (const renderer of renderers) {
this.renderers.set(renderer.templateId, renderer);
@@ -389,7 +389,7 @@ export class ListView<T> implements IListView<T> {
this._horizontalScrolling = options.horizontalScrolling ?? DefaultOptions.horizontalScrolling;
this.domNode.classList.toggle('horizontal-scrolling', this._horizontalScrolling);
this.additionalScrollHeight = typeof options.additionalScrollHeight === 'undefined' ? 0 : options.additionalScrollHeight;
this.paddingBottom = typeof options.paddingBottom === 'undefined' ? 0 : options.paddingBottom;
this.accessibilityProvider = new ListViewAccessibilityProvider(options.accessibilityProvider);
@@ -444,8 +444,8 @@ export class ListView<T> implements IListView<T> {
}
updateOptions(options: IListViewOptionsUpdate) {
if (options.additionalScrollHeight !== undefined) {
this.additionalScrollHeight = options.additionalScrollHeight;
if (options.paddingBottom !== undefined) {
this.paddingBottom = options.paddingBottom;
this.scrollableElement.setScrollDimensions({ scrollHeight: this.scrollHeight });
}
@@ -475,12 +475,12 @@ export class ListView<T> implements IListView<T> {
this.scrollableElement.updateOptions(scrollableOptions);
}
if (options.topPadding !== undefined && options.topPadding !== this.topPadding) {
if (options.paddingTop !== undefined && options.paddingTop !== this.paddingTop) {
// trigger a rerender
this.topPadding = options.topPadding;
this.paddingTop = options.paddingTop;
const lastRenderRange = this.getRenderRange(this.lastRenderTop, this.lastRenderHeight);
const offset = options.topPadding - this.rangeMap.topPadding;
this.rangeMap.topPadding = options.topPadding;
const offset = options.paddingTop - this.rangeMap.paddingTop;
this.rangeMap.paddingTop = options.paddingTop;
this.render(lastRenderRange, Math.max(0, this.lastRenderTop + offset), this.lastRenderHeight, undefined, undefined, true);
this.setScrollTop(this.lastRenderTop);
@@ -622,7 +622,7 @@ export class ListView<T> implements IListView<T> {
// TODO@joao: improve this optimization to catch even more cases
if (start === 0 && deleteCount >= this.items.length) {
this.rangeMap = new RangeMap(this.topPadding);
this.rangeMap = new RangeMap(this.paddingTop);
this.rangeMap.splice(0, 0, inserted);
deleted = this.items;
this.items = inserted;
@@ -1037,7 +1037,7 @@ export class ListView<T> implements IListView<T> {
}
get scrollHeight(): number {
return this._scrollHeight + (this.horizontalScrolling ? 10 : 0) + this.additionalScrollHeight;
return this._scrollHeight + (this.horizontalScrolling ? 10 : 0) + this.paddingBottom;
}
// Events
+2 -2
View File
@@ -991,13 +991,13 @@ export interface IListOptions<T> extends IListOptionsUpdate {
readonly mouseSupport?: boolean;
readonly horizontalScrolling?: boolean;
readonly scrollByPage?: boolean;
readonly additionalScrollHeight?: number;
readonly paddingBottom?: number;
readonly transformOptimization?: boolean;
readonly smoothScrolling?: boolean;
readonly scrollableElementChangeOptions?: ScrollableElementChangeOptions;
readonly alwaysConsumeMouseWheel?: boolean;
readonly initialSize?: Dimension;
readonly topPadding?: number;
readonly paddingTop?: number;
}
export interface IListStyles {
+12 -12
View File
@@ -91,20 +91,20 @@ export class RangeMap {
private groups: IRangedGroup[] = [];
private _size = 0;
private _topPadding = 0;
private _paddingTop = 0;
get topPadding() {
return this._topPadding;
get paddingTop() {
return this._paddingTop;
}
set topPadding(topPadding: number) {
this._topPadding = topPadding;
this._size = this._topPadding + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
set paddingTop(topPadding: number) {
this._paddingTop = topPadding;
this._size = this._paddingTop + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
}
constructor(topPadding?: number) {
this._topPadding = topPadding || 0;
this._size = this._topPadding;
this._paddingTop = topPadding || 0;
this._size = this._paddingTop;
}
splice(index: number, deleteCount: number, items: IItem[] = []): void {
@@ -119,7 +119,7 @@ export class RangeMap {
}));
this.groups = concat(before, middle, after);
this._size = this._topPadding + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
this._size = this._paddingTop + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
}
/**
@@ -150,12 +150,12 @@ export class RangeMap {
return -1;
}
if (position < this._topPadding) {
if (position < this._paddingTop) {
return 0;
}
let index = 0;
let size = this._topPadding;
let size = this._paddingTop;
for (const group of this.groups) {
const count = group.range.end - group.range.start;
@@ -196,7 +196,7 @@ export class RangeMap {
const newCount = count + groupCount;
if (index < newCount) {
return this._topPadding + position + ((index - count) * group.size);
return this._paddingTop + position + ((index - count) * group.size);
}
position += groupCount * group.size;
@@ -268,7 +268,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
mouseSupport: true,
multipleSelectionSupport: false,
typeNavigationEnabled: true,
additionalScrollHeight: 0,
paddingBottom: 0,
// transformOptimization: (isMacintosh && isNative) || getTitleBarStyle(this.configurationService, this.environmentService) === 'native',
styleController: (_suffix: string) => { return this._list!; },
overrideStyles: {
@@ -869,10 +869,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
multipleSelectionSupport: true,
selectionNavigation: true,
typeNavigationEnabled: true,
additionalScrollHeight: 0,
paddingBottom: 0,
transformOptimization: false, //(isMacintosh && isNative) || getTitleBarStyle(this.configurationService, this.environmentService) === 'native',
initialSize: this._dimension,
topPadding: this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType),
paddingTop: this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType),
styleController: (_suffix: string) => { return this._list; },
overrideStyles: {
listBackground: notebookEditorBackground,
@@ -1766,12 +1766,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
const newCellListHeight = newBodyHeight;
if (this._list.getRenderHeight() < newCellListHeight) {
// the new dimension is larger than the list viewport, update its additional height first, otherwise the list view will move down a bit (as the `scrollBottom` will move down)
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, topPadding: topInserToolbarHeight });
this._list.updateOptions({ paddingBottom: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, paddingTop: topInserToolbarHeight });
this._list.layout(newCellListHeight, dimension.width);
} else {
// the new dimension is smaller than the list viewport, if we update the additional height, the `scrollBottom` will move up, which moves the whole list view upwards a bit. So we run a layout first.
this._list.layout(newCellListHeight, dimension.width);
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, topPadding: topInserToolbarHeight });
this._list.updateOptions({ paddingBottom: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, paddingTop: topInserToolbarHeight });
}
this._overlayContainer.style.visibility = 'visible';
@@ -139,8 +139,8 @@ suite('NotebookCellList', () => {
});
const cellList = createNotebookCellList(instantiationService);
// without additionalscrollheight, the last 20 px will always be hidden due to `topInsertToolbarHeight`
cellList.updateOptions({ additionalScrollHeight: 100 });
// without paddingBottom, the last 20 px will always be hidden due to `topInsertToolbarHeight`
cellList.updateOptions({ paddingBottom: 100 });
cellList.attachViewModel(viewModel);
// render height 210, it can render 3 full cells and 1 partial cell
@@ -97,7 +97,7 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
accessibilityProvider: instantiationService.createInstance(TerminalTabsAccessibilityProvider),
smoothScrolling: _configurationService.getValue<boolean>('workbench.list.smoothScrolling'),
multipleSelectionSupport: true,
additionalScrollHeight: TerminalTabsListSizes.TabHeight,
paddingBottom: TerminalTabsListSizes.TabHeight,
dnd: instantiationService.createInstance(TerminalTabsDragAndDrop),
openOnSingleClick: true
},