Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheet): change selection to 1.5 (#809)

Univer26d2d83ab87f
diff --git a/packages/sheets-formula/src/common/selection.ts b/packages/sheets-formula/src/common/selection.ts
index e1d27a154b..fd7f91d74a 100644
--- a/packages/sheets-formula/src/common/selection.ts
+++ b/packages/sheets-formula/src/common/selection.ts
@@ -24,7 +24,7 @@ export function getFormulaRefSelectionStyle(themeService: ThemeService, refColor
const fill = new ColorKit(refColor).setAlpha(0.05).toRgbString();
return {
id,
- strokeWidth: 1,
+ strokeWidth: 1.5,
stroke: refColor,
// strokeDash: 10,
fill,
diff --git a/packages/sheets-ui/src/services/selection/selection-shape.ts b/packages/sheets-ui/src/services/selection/selection-shape.ts
index b152fda8eb..bf5c4078cb 100644
--- a/packages/sheets-ui/src/services/selection/selection-shape.ts
+++ b/packages/sheets-ui/src/services/selection/selection-shape.ts
@@ -407,7 +407,9 @@ export class SelectionShape {
endX = fixLineWidthByScale(endX, scale);
endY = fixLineWidthByScale(endY, scale);
- strokeWidth /= scale;
+ const leftAdjustWidth = (strokeWidth + SELECTION_CONTROL_BORDER_BUFFER_WIDTH) / 2 / scale;
+
+ strokeWidth /= this._getPureScale();
AutofillSize /= scale;
AutofillStrokeWidth /= scale;
@@ -415,13 +417,11 @@ export class SelectionShape {
const borderBuffer = SELECTION_CONTROL_BORDER_BUFFER_WIDTH / scale;
- const leftAdjustWidth = strokeWidth + borderBuffer;
-
const fixOnePixelBlurOffset = FIX_ONE_PIXEL_BLUR_OFFSET / scale;
this.leftControl.transformByState({
height: endY - startY,
- left: -leftAdjustWidth / 2 + fixOnePixelBlurOffset,
+ left: -leftAdjustWidth + fixOnePixelBlurOffset,
width: strokeWidth,
strokeWidth: borderBuffer,
top: -borderBuffer / 2 + fixOnePixelBlurOffset,
@@ -434,7 +434,7 @@ export class SelectionShape {
this.rightControl.transformByState({
height: endY - startY,
- left: endX - startX - leftAdjustWidth / 2 + fixOnePixelBlurOffset,
+ left: endX - startX - leftAdjustWidth + fixOnePixelBlurOffset,
width: strokeWidth,
strokeWidth: borderBuffer,
top: -borderBuffer / 2 + fixOnePixelBlurOffset,
@@ -447,8 +447,8 @@ export class SelectionShape {
this.topControl.transformByState({
width: endX - startX + strokeWidth,
- top: -leftAdjustWidth / 2 + fixOnePixelBlurOffset,
- left: -leftAdjustWidth / 2 + fixOnePixelBlurOffset,
+ top: -leftAdjustWidth + fixOnePixelBlurOffset,
+ left: -leftAdjustWidth + fixOnePixelBlurOffset,
height: strokeWidth,
strokeWidth: borderBuffer,
});
@@ -460,9 +460,9 @@ export class SelectionShape {
this.bottomControl.transformByState({
width: endX - startX + strokeWidth,
- top: endY - startY - leftAdjustWidth / 2 + fixOnePixelBlurOffset,
+ top: endY - startY - leftAdjustWidth + fixOnePixelBlurOffset,
height: strokeWidth,
- left: -leftAdjustWidth / 2 + fixOnePixelBlurOffset,
+ left: -leftAdjustWidth + fixOnePixelBlurOffset,
strokeWidth: borderBuffer,
});
@@ -1061,8 +1061,17 @@ export class SelectionShape {
}
private _getScale() {
- const pixelRatio = this._scene.getEngine()?.getPixelRatio() || 1;
+ const pixelRatio = this._getPixelRatio();
const { scaleX, scaleY } = this._scene.getAncestorScale();
return Math.max(scaleX * pixelRatio, scaleY * pixelRatio);
}
+
+ private _getPureScale() {
+ const { scaleX, scaleY } = this._scene.getAncestorScale();
+ return Math.max(scaleX, scaleY);
+ }
+
+ private _getPixelRatio() {
+ return this._scene.getEngine()?.getPixelRatio() || 1;
+ }
}
diff --git a/packages/sheets/src/basics/selection.ts b/packages/sheets/src/basics/selection.ts
index 17d663428a..9c9c0b8bed 100644
--- a/packages/sheets/src/basics/selection.ts
+++ b/packages/sheets/src/basics/selection.ts
@@ -145,18 +145,18 @@ export function getNormalSelectionStyle(themeService: ThemeService): ISelectionS
const styleSheet = themeService.getCurrentTheme();
const fill = new ColorKit(styleSheet.colorBlack).setAlpha(0.1).toRgbString();
return {
- strokeWidth: 1,
+ strokeWidth: 1.5,
stroke: styleSheet.primaryColor,
// strokeDash: 8,
fill,
// widgets: { tl: true, tc: true, tr: true, ml: true, mr: true, bl: true, bc: true, br: true },
widgets: {},
- widgetSize: 6,
+ widgetSize: 8,
widgetStrokeWidth: 1,
widgetStroke: styleSheet.colorWhite,
hasAutoFill: true,
- AutofillSize: 6,
+ AutofillSize: 8,
AutofillStrokeWidth: 1,
AutofillStroke: styleSheet.colorWhite,