From 79b8560beec2453e13e072f2917b01d8cf573cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir=20=28rar=29?= Date: Tue, 31 Dec 2024 17:09:29 +0100 Subject: [PATCH] fix headers getheader size needs to be compensated by the scroll diff it s garbage since needs to take frozen pane in account but whatever --- src/plugins/ui_stateful/sheetview.ts | 12 +++++++++--- src/stores/grid_renderer_store.ts | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/plugins/ui_stateful/sheetview.ts b/src/plugins/ui_stateful/sheetview.ts index c57cfdf9c..0452b7fe9 100644 --- a/src/plugins/ui_stateful/sheetview.ts +++ b/src/plugins/ui_stateful/sheetview.ts @@ -422,12 +422,12 @@ export class SheetViewPlugin extends UIPlugin { referenceIndex: HeaderIndex, index: HeaderIndex ): Pixel { - const sheetId = this.getters.getActiveSheetId(); - const visibleCols = this.getters.getSheetViewVisibleCols(); - const visibleRows = this.getters.getSheetViewVisibleRows(); if (index < referenceIndex) { return -this.getColRowOffsetInViewport(dimension, index, referenceIndex); } + const sheetId = this.getters.getActiveSheetId(); + const visibleCols = this.getters.getSheetViewVisibleCols(); + const visibleRows = this.getters.getSheetViewVisibleRows(); let offset = 0; const visibleIndexes = dimension === "COL" ? visibleCols : visibleRows; for (let i = referenceIndex; i < index; i++) { @@ -436,6 +436,12 @@ export class SheetViewPlugin extends UIPlugin { } offset += this.getters.getHeaderSize(sheetId, dimension, i); } + const viewport = this.getMainInternalViewport(sheetId); + if (dimension === "ROW") { + offset -= viewport.offsetScrollbarY - viewport.offsetY; + } else { + offset -= viewport.offsetScrollbarX - viewport.offsetX; + } return offset; } diff --git a/src/stores/grid_renderer_store.ts b/src/stores/grid_renderer_store.ts index f714c5415..0e250cf6a 100644 --- a/src/stores/grid_renderer_store.ts +++ b/src/stores/grid_renderer_store.ts @@ -405,6 +405,7 @@ export class GridRenderer { ctx.lineWidth = thinLineWidth; ctx.strokeStyle = "#333"; + // FIX the headers to account for the scrolloffset // Columns headers background for (let col = left; col <= right; col++) { const colZone = { left: col, right: col, top: 0, bottom: numberOfRows - 1 }; @@ -471,6 +472,10 @@ export class GridRenderer { } ctx.stroke(); + + // cut that with the top left corner + ctx.fillStyle = "#ffffff"; + ctx.fillRect(0, 0, HEADER_WIDTH, HEADER_HEIGHT); } private drawFrozenPanesHeaders(renderingContext: GridRenderingContext) { @@ -744,6 +749,7 @@ export class GridRenderer { const bottom = visibleRows[visibleRows.length - 1]; const viewport = { left, right, top, bottom }; const sheetId = this.getters.getActiveSheetId(); + // TODO frozen pane don't work for (const row of visibleRows) { for (const col of visibleCols) {