Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 49 additions & 24 deletions browser/src/canvas/sections/FocusCellSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,44 +74,69 @@ class FocusCellSection extends CanvasSectionObject {
}

public onDraw() {
const cursor = app.calc.cellCursorRectangle;
const adjusted = CellCursorSection.adjustSizePos([
cursor.pX1,
cursor.pY1,
cursor.pWidth,
cursor.pHeight,
]);
const drawColumn = adjusted[2] > 0;
const drawRow = adjusted[3] > 0;

if (!drawColumn && !drawRow) return;

const style = getComputedStyle(document.documentElement).getPropertyValue(
'--column-row-highlight',
);

this.context.fillStyle = style;
this.context.strokeStyle = style;

const colX = adjusted[0] - cursor.pX1;
const colWidth = adjusted[2];
const rowY = adjusted[1] - cursor.pY1;
const rowHeight = adjusted[3];

this.context.globalAlpha = 0.3;

this.context.fillRect(
0,
-app.calc.cellCursorRectangle.pY1,
app.calc.cellCursorRectangle.pWidth,
this.sectionProperties.maxCol,
);
if (drawColumn) {
this.context.fillRect(
colX,
-cursor.pY1,
colWidth,
this.sectionProperties.maxCol,
);
}

this.context.fillRect(
-app.calc.cellCursorRectangle.pX1,
0,
this.sectionProperties.maxRow,
app.calc.cellCursorRectangle.pHeight,
);
if (drawRow) {
this.context.fillRect(
-cursor.pX1,
rowY,
this.sectionProperties.maxRow,
rowHeight,
);
}

this.context.globalAlpha = 1;
this.context.lineWidth = 2 * app.dpiScale;

this.context.strokeRect(
0,
-app.calc.cellCursorRectangle.pY1,
app.calc.cellCursorRectangle.pWidth,
this.sectionProperties.maxCol,
);
if (drawColumn) {
this.context.strokeRect(
colX,
-cursor.pY1,
colWidth,
this.sectionProperties.maxCol,
);
}

this.context.strokeRect(
-app.calc.cellCursorRectangle.pX1,
0,
this.sectionProperties.maxRow,
app.calc.cellCursorRectangle.pHeight,
);
if (drawRow) {
this.context.strokeRect(
-cursor.pX1,
rowY,
this.sectionProperties.maxRow,
rowHeight,
);
}
}
}
Loading