@univerjs/engine-render 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -127,14 +127,12 @@ export declare function inViewRanges(ranges: IRange[], rowIndex: number, colInde
127
127
  * 在非下方区域中
128
128
  * @param ranges
129
129
  * @param rowIndex
130
- * @returns
131
130
  */
132
131
  export declare function inCurrentAndAboveViewRanges(ranges: IRange[], rowIndex: number): boolean;
133
132
  /**
134
133
  * row 在任意一个 Range 中
135
134
  * @param ranges
136
135
  * @param rowIndex
137
- * @returns
138
136
  */
139
137
  export declare function inRowViewRanges(ranges: IRange[], rowIndex: number): boolean;
140
138
  /**
@@ -50,7 +50,13 @@ export declare class Canvas {
50
50
  getWidth(): number;
51
51
  getHeight(): number;
52
52
  setId(id: string): void;
53
- setSize(width?: number, height?: number, pixelRatioParam?: number): void;
53
+ /**
54
+ * Resize canvas when width or height or devicePixelRatio changed.
55
+ * @param width
56
+ * @param height
57
+ * @param devicePixelRatio
58
+ */
59
+ setSize(width?: number, height?: number, devicePixelRatio?: number): void;
54
60
  setPixelRatio(pixelRatio: number): void;
55
61
  dispose(): void;
56
62
  clear(): void;
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export * from './column-header';
17
+ export * from './constants';
17
18
  export * from './extensions';
18
19
  export * from './interfaces';
19
20
  export * from './row-header';
@@ -1,5 +1,5 @@
1
1
  import { ICellData, ICellDataForSheetInterceptor, ICellInfo, ICellWithCoord, IColAutoWidthInfo, IColumnRange, IPaddingData, IPosition, IRange, IRowAutoHeightInfo, IRowRange, ISize, IStyleData, ITextRotation, IWorksheetData, Nullable, Styles, VerticalAlign, Worksheet, BooleanNumber, DocumentDataModel, HorizontalAlign, IConfigService, IContextService, ImageCacheMap, Injector, LocaleService, ObjectMatrix, WrapStrategy } from '@univerjs/core';
2
- import { IBoundRectNoAngle, IViewportInfo } from '../../basics/vector2';
2
+ import { IBoundRectNoAngle, IPoint, IViewportInfo } from '../../basics/vector2';
3
3
  import { DocumentSkeleton } from '../docs/layout/doc-skeleton';
4
4
  import { Skeleton } from '../skeleton';
5
5
  import { IFontCacheItem, IStylesCache, SHEET_VIEWPORT_KEY } from './interfaces';
@@ -51,12 +51,6 @@ export interface IGetPosByRowColOptions {
51
51
  }
52
52
  export declare class SpreadsheetSkeleton extends Skeleton {
53
53
  readonly worksheet: Worksheet;
54
- /**
55
- * @deprecated avoid use `IWorksheetData` directly, use API provided by `Worksheet`, otherwise
56
- * `ViewModel` will be not working.
57
- */
58
- private _worksheetData;
59
- private _cellData;
60
54
  private _styles;
61
55
  private readonly _contextService;
62
56
  private readonly _configService;
@@ -71,7 +65,8 @@ export declare class SpreadsheetSkeleton extends Skeleton {
71
65
  * Range viewBounds. only update by viewBounds.
72
66
  * It would change multiple times in one frame if there is multiple viewport (after freeze row&col)
73
67
  */
74
- private _visibleRange;
68
+ private _drawingRange;
69
+ private _cacheRangeMap;
75
70
  private _visibleRangeMap;
76
71
  private _overflowCache;
77
72
  private _stylesCache;
@@ -80,6 +75,7 @@ export declare class SpreadsheetSkeleton extends Skeleton {
80
75
  private _handleBorderMatrix;
81
76
  private _handleFontMatrix;
82
77
  private _showGridlines;
78
+ private _gridlinesColor;
83
79
  private _marginTop;
84
80
  private _marginLeft;
85
81
  private _imageCacheMap;
@@ -88,12 +84,13 @@ export declare class SpreadsheetSkeleton extends Skeleton {
88
84
  */
89
85
  private _isRowStylePrecedeColumnStyle;
90
86
  private _renderRawFormula;
91
- constructor(worksheet: Worksheet,
92
87
  /**
93
88
  * @deprecated avoid use `IWorksheetData` directly, use API provided by `Worksheet`, otherwise
94
89
  * `ViewModel` will be not working.
95
90
  */
96
- _worksheetData: IWorksheetData, _cellData: ObjectMatrix<Nullable<ICellData>>, _styles: Styles, _localeService: LocaleService, _contextService: IContextService, _configService: IConfigService, _injector: Injector);
91
+ private _worksheetData;
92
+ private _cellData;
93
+ constructor(worksheet: Worksheet, _styles: Styles, _localeService: LocaleService, _contextService: IContextService, _configService: IConfigService, _injector: Injector);
97
94
  get rowHeightAccumulation(): number[];
98
95
  get rowTotalHeight(): number;
99
96
  get columnWidthAccumulation(): number[];
@@ -105,10 +102,16 @@ export declare class SpreadsheetSkeleton extends Skeleton {
105
102
  * Range of visible area(range in viewBounds)
106
103
  */
107
104
  get rowColumnSegment(): IRowColumnRange;
105
+ /**
106
+ * Get range needs to render.
107
+ * @param viewportKey
108
+ * @returns
109
+ */
108
110
  visibleRangeByViewportKey(viewportKey: SHEET_VIEWPORT_KEY): Nullable<IRowColumnRange>;
109
111
  get stylesCache(): IStylesCache;
110
112
  get overflowCache(): ObjectMatrix<IRange>;
111
113
  get showGridlines(): BooleanNumber;
114
+ get gridlinesColor(): string | undefined;
112
115
  get mergeData(): IRange[];
113
116
  get rowHeaderWidthAndMarginLeft(): number;
114
117
  get columnHeaderHeightAndMarginTop(): number;
@@ -128,17 +131,23 @@ export declare class SpreadsheetSkeleton extends Skeleton {
128
131
  setMarginTop(top: number): void;
129
132
  getFont(rowIndex: number, columnIndex: number): Nullable<IFontCacheItem>;
130
133
  /**
131
- * Get range in visible area (range in viewbounds) and set into this._rowColumnSegment.
132
- * @param bounds
134
+ * Get range in visible area (range in view bounds) and set into this._rowColumnSegment.
135
+ * @param vpInfo
133
136
  * @returns boolean
134
137
  */
135
- updateVisibleRange(bounds?: IViewportInfo): boolean;
138
+ updateVisibleRange(vpInfo?: IViewportInfo): boolean;
139
+ getVisibleRangeByViewport(viewportKey: SHEET_VIEWPORT_KEY): IRowColumnRange | undefined;
140
+ getVisibleRanges(): Map<SHEET_VIEWPORT_KEY, IRowColumnRange>;
136
141
  /**
137
142
  * Set border background and font to this._stylesCache by visible range, which derives from bounds)
138
- * @param bounds viewBounds
143
+ * @param vpInfo viewBounds
139
144
  */
140
- setStylesCache(bounds?: IViewportInfo): Nullable<SpreadsheetSkeleton>;
141
- calculate(bounds?: IViewportInfo): Nullable<SpreadsheetSkeleton>;
145
+ setStylesCache(vpInfo?: IViewportInfo): Nullable<SpreadsheetSkeleton>;
146
+ /**
147
+ * Refresh cache after markDirty by SheetSkeletonManagerService.reCalculate()
148
+ * @param bounds
149
+ */
150
+ calculate(): Nullable<SpreadsheetSkeleton>;
142
151
  private _hasUnMergedCellInRow;
143
152
  /**
144
153
  * Calc all auto height by getDocsSkeletonPageSize in ranges
@@ -162,17 +171,25 @@ export declare class SpreadsheetSkeleton extends Skeleton {
162
171
  */
163
172
  _getMeasuredWidthByCell(cell: ICellDataForSheetInterceptor, currColWidth: number): number;
164
173
  /**
165
- * Calculate data for row col & cell position, then update position value to this._rowHeaderWidth & this._rowHeightAccumulation & this._columnHeaderHeight & this._columnWidthAccumulation.
174
+ * Calculate data for row col & cell position.
175
+ * This method should be called whenever a sheet is dirty.
176
+ * Update position value to this._rowHeaderWidth & this._rowHeightAccumulation & this._columnHeaderHeight & this._columnWidthAccumulation.
166
177
  */
167
178
  private _updateLayout;
168
179
  private _dynamicallyUpdateRowHeaderWidth;
180
+ /**
181
+ * @deprecated use `getRangeByViewport` instead.
182
+ * @param bounds
183
+ */
169
184
  getRangeByBounding(bounds?: IViewportInfo): IRange;
185
+ getRangeByViewport(vpInfo?: IViewportInfo): IRange;
186
+ getCacheRangeByViewport(vpInfo?: IViewportInfo): IRange;
187
+ getRangeByViewBound(bound?: IBoundRectNoAngle): IRange;
170
188
  /**
171
189
  * @deprecated should never expose a property that is provided by another module!
172
190
  * @returns
173
191
  */
174
192
  getWorksheetConfig(): IWorksheetData;
175
- getRangeByViewBound(bound?: IBoundRectNoAngle): IRange;
176
193
  getMergeBounding(startRow: number, startColumn: number, endRow: number, endColumn: number): IRange;
177
194
  /**
178
195
  * expand curr range if it's intersect with merge range.
@@ -386,7 +403,7 @@ export declare class SpreadsheetSkeleton extends Skeleton {
386
403
  private _getOverflowBound;
387
404
  intersectMergeRange(row: number, column: number): boolean;
388
405
  /**
389
- * get the current row and column segment visible merge data
406
+ * Get the current row and column segment visible merge data.
390
407
  * @returns {IRange} The visible merge data
391
408
  */
392
409
  getCurrentRowColumnSegmentMergeData(range?: IRange): IRange[];
@@ -425,5 +442,16 @@ export declare class SpreadsheetSkeleton extends Skeleton {
425
442
  * @returns {ISelectionCell} The cell info with merge data
426
443
  */
427
444
  private _getCellMergeInfo;
445
+ getDistanceFromTopLeft(row: number, col: number): IPoint;
446
+ /**
447
+ * Distance from top left to row
448
+ * @param row
449
+ */
450
+ private _offsetYToRow;
451
+ /**
452
+ * Distance from top left to col
453
+ * @param col
454
+ */
455
+ private _offsetXToCol;
428
456
  }
429
457
  export {};
@@ -66,7 +66,7 @@ export declare class Spreadsheet extends SheetComponent {
66
66
  */
67
67
  makeDirty(state?: boolean): this;
68
68
  setDirtyArea(dirtyBounds: IBoundRectNoAngle[]): void;
69
- renderByViewport(mainCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo, spreadsheetSkeleton: SpreadsheetSkeleton): void;
69
+ renderByViewports(mainCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo, spreadsheetSkeleton: SpreadsheetSkeleton): void;
70
70
  paintNewAreaForScrolling(viewportInfo: IViewportInfo, param: IPaintForScrolling): void;
71
71
  /**
72
72
  * Redraw the entire viewport.
@@ -100,7 +100,6 @@ export declare class Spreadsheet extends SheetComponent {
100
100
  * Clear the guide lines within a range in the table, to make room for merged cells and overflow.
101
101
  */
102
102
  private _clearRectangle;
103
- private _clearBackground;
104
103
  testShowRuler(cacheCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo): void;
105
104
  testGetRandomLightColor(): string;
106
105
  }
@@ -103,6 +103,7 @@ export declare class Engine extends Disposable {
103
103
  getPixelRatio(): number;
104
104
  setContainer(elem: HTMLElement, resize?: boolean): void;
105
105
  resize(): void;
106
+ dprChange(): void;
106
107
  /**
107
108
  * set canvas element size
108
109
  * @param width
@@ -5,6 +5,7 @@ import { IBoundRectNoAngle, IViewportInfo, Vector2 } from './basics/vector2';
5
5
  import { UniverRenderingContext } from './context';
6
6
  import { Scene } from './scene';
7
7
  import { BaseScrollBar } from './shape/base-scroll-bar';
8
+ import { Subject } from 'rxjs';
8
9
  import { Transform } from './basics/transform';
9
10
  import { Canvas as UniverCanvas } from './canvas';
10
11
  interface ILimitedScrollResult {
@@ -63,7 +64,18 @@ interface IViewportScrollPosition {
63
64
  viewportScrollX: number;
64
65
  viewportScrollY: number;
65
66
  }
67
+ export interface IViewportReSizeParam {
68
+ width: number;
69
+ height: number;
70
+ left: number;
71
+ top: number;
72
+ paddingStartX?: number;
73
+ paddingStartY?: number;
74
+ paddingEndX?: number;
75
+ paddingEndY?: number;
76
+ }
66
77
  export declare class Viewport {
78
+ private _viewportKey;
67
79
  /**
68
80
  * scrollX means scroll x value for scrollbar in viewMain
69
81
  * use getBarScroll to get scrolling value(scrollX, scrollY) for scrollbar
@@ -96,7 +108,7 @@ export declare class Viewport {
96
108
  onScrollAfter$: EventSubject<IScrollObserverParam>;
97
109
  onScrollEnd$: EventSubject<IScrollObserverParam>;
98
110
  onScrollByBar$: EventSubject<IScrollObserverParam>;
99
- private _viewportKey;
111
+ onResized$: Subject<IViewportReSizeParam>;
100
112
  /**
101
113
  * viewport top origin value in logic, scale does not affect it.
102
114
  */
@@ -122,28 +134,13 @@ export declare class Viewport {
122
134
  private _scrollStopNum;
123
135
  private _clipViewport;
124
136
  private _active;
125
- private _paddingStartX;
126
137
  /**
127
- * after create a freeze column, there is a "padding distace" from row header to curr viewport.
138
+ * after create a freeze column & row, there is a "padding distance" from row header to curr viewport.
128
139
  */
140
+ private _paddingStartX;
129
141
  private _paddingEndX;
130
- /**
131
- * after create a freeze row, there is a "padding distace" from column header to curr viewport.
132
- */
133
142
  private _paddingStartY;
134
143
  private _paddingEndY;
135
- /**
136
- * Usually for viewport by after freeze, _explicitViewportWidthSet true means viewport's width is specify explicitly.
137
- * ex: ViewMainLeft _explicitViewportWidthSet is true when freeze at a certain col, the width of viewMainLeft is decided by freeze line.
138
- * Usually this prop is false for viewMain, viewport width is decided by engine size - freeze line
139
- */
140
- private _explicitViewportWidthSet;
141
- /**
142
- * _explicitViewportHeightSet true means viewport's height is specify explicitly.
143
- * Used for viewport by after freeze.
144
- * ex: ViewMainTop _explicitViewportHeightSet is true when freeze at a certain row, the height of viewMainTop is decided by freeze line.
145
- */
146
- private _explicitViewportHeightSet;
147
144
  /**
148
145
  * viewbound of cache area, cache area is slightly bigger than viewbound.
149
146
  */
@@ -157,9 +154,12 @@ export declare class Viewport {
157
154
  private _preViewBound;
158
155
  /**
159
156
  * Whether the viewport needs to be updated.
160
- * In future, viewMain dirty would not affect othew viewports.
157
+ * In future, viewMain dirty would not affect other viewports.
161
158
  */
162
159
  private _isDirty;
160
+ /**
161
+ * Canvas for cache if allowCache is true.
162
+ */
163
163
  private _cacheCanvas;
164
164
  /**
165
165
  * The configuration comes from the props.allowCache passed in during viewport initialization.
@@ -237,7 +237,7 @@ export declare class Viewport {
237
237
  isLimitedY: boolean;
238
238
  } | undefined;
239
239
  /**
240
- * Srolling by current position plus delta.
240
+ * Scrolling by current position plus delta.
241
241
  * the most common case is triggered by scroll-timer(in sheet)
242
242
  * @param delta
243
243
  * @returns isLimited
@@ -281,7 +281,7 @@ export declare class Viewport {
281
281
  getScrollBar(): Nullable<BaseScrollBar>;
282
282
  /**
283
283
  * Just record state of scroll. This method won't scroll viewport and scrollbar.
284
- * TODO: @lumixraku this method is so wierd, viewportMain did not call it, now only called in freeze situation.
284
+ * TODO: @lumixraku this method is so wried, viewportMain did not call it, now only called in freeze situation.
285
285
  * @param current
286
286
  * @returns Viewport
287
287
  */
@@ -296,7 +296,11 @@ export declare class Viewport {
296
296
  */
297
297
  render(parentCtx?: UniverRenderingContext, objects?: BaseObject[], isMaxLayer?: boolean): void;
298
298
  private _makeDefaultViewport;
299
- private _calcViewportInfo;
299
+ calcViewportInfo(): IViewportInfo;
300
+ /**
301
+ * Get viewport info
302
+ * @deprecated use `calcViewportInfo`
303
+ */
300
304
  getBounding(): IViewportInfo;
301
305
  /**
302
306
  * convert vector to scene coordinate, include row & col
@@ -384,10 +388,5 @@ export declare class Viewport {
384
388
  private _calcDiffCacheBound;
385
389
  private _drawScrollbar;
386
390
  private _setViewportSize;
387
- /**
388
- * main canvas element resize
389
- * called by this.scene.getEngine()?.onTransformChange$.add
390
- */
391
- private _mainCanvasResizeHandler;
392
391
  }
393
392
  export {};