@univerjs/engine-render 0.1.11 → 0.1.13
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.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +11656 -10388
- package/lib/types/base-object.d.ts +30 -22
- package/lib/types/basics/const.d.ts +7 -2
- package/lib/types/basics/group-transform.d.ts +16 -0
- package/lib/types/basics/i-document-skeleton-cached.d.ts +5 -4
- package/lib/types/basics/i-events.d.ts +9 -0
- package/lib/types/basics/index.d.ts +1 -0
- package/lib/types/basics/interfaces.d.ts +4 -9
- package/lib/types/basics/offset-rotation-axis.d.ts +3 -0
- package/lib/types/basics/tools.d.ts +34 -2
- package/lib/types/basics/transform.d.ts +8 -0
- package/lib/types/basics/transformer-config.d.ts +37 -0
- package/lib/types/basics/vector2.d.ts +44 -2
- package/lib/types/components/component.d.ts +2 -2
- package/lib/types/components/docs/doc-background.d.ts +3 -3
- package/lib/types/components/docs/doc-component.d.ts +4 -4
- package/lib/types/components/docs/document.d.ts +3 -4
- package/lib/types/components/docs/extensions/line.d.ts +1 -1
- package/lib/types/components/docs/layout/doc-skeleton.d.ts +2 -2
- package/lib/types/components/docs/layout/model/glyph.d.ts +1 -1
- package/lib/types/components/docs/text-selection/text-range.d.ts +6 -0
- package/lib/types/components/docs/text-selection/text-selection-render-manager.d.ts +1 -0
- package/lib/types/components/extension.d.ts +7 -2
- package/lib/types/components/sheets/column-header.d.ts +2 -2
- package/lib/types/components/sheets/extensions/background.d.ts +2 -1
- package/lib/types/components/sheets/extensions/font.d.ts +3 -2
- package/lib/types/components/sheets/extensions/marker.d.ts +1 -1
- package/lib/types/components/sheets/extensions/sheet-extension.d.ts +8 -1
- package/lib/types/components/sheets/interfaces.d.ts +47 -0
- package/lib/types/components/sheets/row-header.d.ts +2 -2
- package/lib/types/components/sheets/sheet-component.d.ts +4 -4
- package/lib/types/components/sheets/sheet-skeleton.d.ts +10 -22
- package/lib/types/components/sheets/spreadsheet.d.ts +52 -11
- package/lib/types/custom/custom-object.d.ts +2 -2
- package/lib/types/engine.d.ts +5 -0
- package/lib/types/group.d.ts +22 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/layer.d.ts +3 -3
- package/lib/types/scene-viewer.d.ts +3 -3
- package/lib/types/scene.d.ts +14 -6
- package/lib/types/scene.input-manager.d.ts +5 -0
- package/lib/types/scene.transformer.d.ts +59 -40
- package/lib/types/shape/image.d.ts +54 -0
- package/lib/types/shape/index.d.ts +1 -1
- package/lib/types/shape/regular-polygon.d.ts +4 -1
- package/lib/types/shape/rich-text.d.ts +2 -3
- package/lib/types/shape/shape.d.ts +4 -3
- package/lib/types/thin-engine.d.ts +1 -0
- package/lib/types/thin-scene.d.ts +11 -2
- package/lib/types/viewport.d.ts +134 -16
- package/lib/umd/index.js +2 -2
- package/package.json +10 -7
- package/lib/types/services/object-transform-manager.service.d.ts +0 -41
- package/lib/types/shape/picture.d.ts +0 -24
|
@@ -2,49 +2,21 @@ import { Nullable, Disposable, Observable } from '@univerjs/core';
|
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { IMouseEvent, IPointerEvent } from './basics/i-events';
|
|
4
4
|
import { Group } from './group';
|
|
5
|
-
import {
|
|
5
|
+
import { Scene } from './scene';
|
|
6
|
+
import { ITransformerConfig } from './basics/transformer-config';
|
|
6
7
|
|
|
7
8
|
declare enum MoveObserverType {
|
|
8
9
|
MOVE_START = 0,
|
|
9
10
|
MOVING = 1,
|
|
10
11
|
MOVE_END = 2
|
|
11
12
|
}
|
|
12
|
-
interface IChangeObserverConfig {
|
|
13
|
+
export interface IChangeObserverConfig {
|
|
13
14
|
objects: Map<string, BaseObject>;
|
|
14
15
|
moveX?: number;
|
|
15
16
|
moveY?: number;
|
|
17
|
+
angle?: number;
|
|
16
18
|
type: MoveObserverType;
|
|
17
19
|
}
|
|
18
|
-
export interface ITransformerConfig {
|
|
19
|
-
hoverEnabled?: boolean;
|
|
20
|
-
hoverEnterFunc?: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
21
|
-
hoverLeaveFunc?: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
22
|
-
rotateEnabled?: boolean;
|
|
23
|
-
rotationSnaps?: number[];
|
|
24
|
-
rotationSnapTolerance?: number;
|
|
25
|
-
rotateAnchorOffset?: number;
|
|
26
|
-
rotateSize?: number;
|
|
27
|
-
rotateCornerRadius?: number;
|
|
28
|
-
borderEnabled?: boolean;
|
|
29
|
-
borderStroke?: string;
|
|
30
|
-
borderStrokeWidth?: number;
|
|
31
|
-
borderDash?: number[];
|
|
32
|
-
borderSpacing: number;
|
|
33
|
-
resizeEnabled?: boolean;
|
|
34
|
-
enabledAnchors?: number[];
|
|
35
|
-
anchorFill?: string;
|
|
36
|
-
anchorStroke?: string;
|
|
37
|
-
anchorStrokeWidth?: number;
|
|
38
|
-
anchorSize?: number;
|
|
39
|
-
anchorCornerRadius?: number;
|
|
40
|
-
keepRatio?: boolean;
|
|
41
|
-
centeredScaling?: boolean;
|
|
42
|
-
flipEnabled?: boolean;
|
|
43
|
-
ignoreStroke?: boolean;
|
|
44
|
-
boundBoxFunc?: Nullable<(oldBox: BaseObject, newBox: BaseObject) => BaseObject>;
|
|
45
|
-
useSingleNodeRotation?: boolean;
|
|
46
|
-
shouldOverdrawWholeArea?: boolean;
|
|
47
|
-
}
|
|
48
20
|
/**
|
|
49
21
|
* Transformer constructor. Transformer is a special type of group that allow you transform
|
|
50
22
|
* primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes
|
|
@@ -52,6 +24,7 @@ export interface ITransformerConfig {
|
|
|
52
24
|
*/
|
|
53
25
|
export declare class Transformer extends Disposable implements ITransformerConfig {
|
|
54
26
|
private _scene;
|
|
27
|
+
isCropper: boolean;
|
|
55
28
|
hoverEnabled: boolean;
|
|
56
29
|
hoverEnterFunc: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
57
30
|
hoverLeaveFunc: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
@@ -74,6 +47,8 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
74
47
|
anchorCornerRadius: number;
|
|
75
48
|
keepRatio: boolean;
|
|
76
49
|
centeredScaling: boolean;
|
|
50
|
+
zeroLeft: number;
|
|
51
|
+
zeroTop: number;
|
|
77
52
|
/**
|
|
78
53
|
* leftTop centerTop rightTop
|
|
79
54
|
* leftMiddle rightMiddle
|
|
@@ -88,10 +63,11 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
88
63
|
onChangeStartObservable: Observable<IChangeObserverConfig>;
|
|
89
64
|
onChangingObservable: Observable<IChangeObserverConfig>;
|
|
90
65
|
onChangeEndObservable: Observable<IChangeObserverConfig>;
|
|
91
|
-
onClearControlObservable: Observable<
|
|
66
|
+
onClearControlObservable: Observable<boolean>;
|
|
92
67
|
onCreateControlObservable: Observable<Group>;
|
|
93
68
|
private _startOffsetX;
|
|
94
69
|
private _startOffsetY;
|
|
70
|
+
private _startStateMap;
|
|
95
71
|
private _viewportScrollX;
|
|
96
72
|
private _viewportScrollY;
|
|
97
73
|
private _moveObserver;
|
|
@@ -99,30 +75,73 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
99
75
|
private _cancelFocusObserver;
|
|
100
76
|
private _transformerControlMap;
|
|
101
77
|
private _selectedObjectMap;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
78
|
+
private _observerObjectMap;
|
|
79
|
+
private _copperControl;
|
|
80
|
+
private _copperSelectedObject;
|
|
81
|
+
private _moveBufferSkip;
|
|
82
|
+
private _debounceClearFunc;
|
|
83
|
+
constructor(_scene: Scene, config?: ITransformerConfig);
|
|
84
|
+
changeNotification(): this;
|
|
85
|
+
getSelectedObjectMap(): Map<string, BaseObject>;
|
|
86
|
+
resetProps(config?: ITransformerConfig): void;
|
|
87
|
+
getScene(): Scene;
|
|
88
|
+
clearControls(changeSelf?: boolean): void;
|
|
89
|
+
updateControl(): void;
|
|
90
|
+
debounceRefreshControls(): void;
|
|
91
|
+
clearSelectedObjects(): void;
|
|
92
|
+
refreshControls(): this;
|
|
93
|
+
createControlForCopper(applyObject: BaseObject): void;
|
|
94
|
+
clearCopperControl(): void;
|
|
95
|
+
setSelectedControl(applyObject: BaseObject): void;
|
|
96
|
+
private _getConfig;
|
|
97
|
+
attachTo(applyObject: BaseObject): BaseObject;
|
|
98
|
+
detachFrom(applyObject: BaseObject): BaseObject;
|
|
106
99
|
dispose(): void;
|
|
107
100
|
private _initialProps;
|
|
108
|
-
private
|
|
101
|
+
private _checkMoveBoundary;
|
|
102
|
+
private _moving;
|
|
103
|
+
private _moveBufferBlocker;
|
|
109
104
|
private _anchorMoving;
|
|
105
|
+
private _moveFunc;
|
|
106
|
+
private _getMovePoint;
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
private _applyRotationForResult;
|
|
111
|
+
private _updateCloseKeepRatioState;
|
|
112
|
+
private _getLimitedSize;
|
|
113
|
+
private _resizeLeftTop;
|
|
114
|
+
private _resizeRightBottom;
|
|
115
|
+
private _resizeLeftBottom;
|
|
116
|
+
private _resizeRightTop;
|
|
117
|
+
private _fixMoveLtRb;
|
|
118
|
+
private _fixMoveLbRt;
|
|
110
119
|
private _attachEventToAnchor;
|
|
120
|
+
private _recoverySizeBoundary;
|
|
111
121
|
private _attachEventToRotate;
|
|
122
|
+
private _rotateMoving;
|
|
112
123
|
private _getOutlinePosition;
|
|
113
124
|
private _getRotateAnchorCursor;
|
|
125
|
+
private _getCopperAnchorPosition;
|
|
114
126
|
private _getRotateAnchorPosition;
|
|
115
127
|
private _createResizeAnchor;
|
|
128
|
+
private _createCopperResizeAnchor;
|
|
129
|
+
private _getNorthEastPoints;
|
|
130
|
+
private _getNorthWestPoints;
|
|
131
|
+
private _getSouthEastPoints;
|
|
132
|
+
private _getSouthWestPoints;
|
|
116
133
|
private _checkTransformerType;
|
|
117
134
|
private _updateControlIterator;
|
|
118
135
|
private _updateControl;
|
|
119
136
|
private _hideControl;
|
|
120
137
|
private _attachHover;
|
|
121
|
-
private
|
|
138
|
+
private _clearControls;
|
|
139
|
+
private _clearControlMap;
|
|
122
140
|
private _createControl;
|
|
123
141
|
private _getTopScene;
|
|
124
|
-
private _moving;
|
|
125
142
|
private _updateActiveObjectList;
|
|
143
|
+
private _findGroupObject;
|
|
126
144
|
private _addCancelObserver;
|
|
145
|
+
private _smoothAccuracy;
|
|
127
146
|
}
|
|
128
147
|
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ISrcRect, Nullable, PresetGeometryType } from '@univerjs/core';
|
|
2
|
+
import { UniverRenderingContext } from '../context';
|
|
3
|
+
import { IObjectFullState, IViewportInfo, RENDER_CLASS_TYPE } from '../basics';
|
|
4
|
+
import { IShapeProps, Shape } from './shape';
|
|
5
|
+
|
|
6
|
+
export interface IImageProps extends IShapeProps {
|
|
7
|
+
image?: HTMLImageElement;
|
|
8
|
+
url?: string;
|
|
9
|
+
success?: () => void;
|
|
10
|
+
fail?: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* 20.1.8.55 srcRect (Source Rectangle)
|
|
13
|
+
*/
|
|
14
|
+
srcRect?: Nullable<ISrcRect>;
|
|
15
|
+
/**
|
|
16
|
+
* 20.1.9.18 prstGeom (Preset geometry)
|
|
17
|
+
*/
|
|
18
|
+
prstGeom?: Nullable<PresetGeometryType>;
|
|
19
|
+
}
|
|
20
|
+
export declare class Image extends Shape<IImageProps> {
|
|
21
|
+
protected _props: IImageProps;
|
|
22
|
+
protected _native: Nullable<HTMLImageElement>;
|
|
23
|
+
private _renderByCropper;
|
|
24
|
+
private _transformCalculateSrcRect;
|
|
25
|
+
constructor(id: string, config: IImageProps);
|
|
26
|
+
get srcRect(): Nullable<ISrcRect>;
|
|
27
|
+
get prstGeom(): Nullable<PresetGeometryType>;
|
|
28
|
+
get classType(): RENDER_CLASS_TYPE;
|
|
29
|
+
transformByStateCloseCropper(option: IObjectFullState): void;
|
|
30
|
+
changeSource(url: string): void;
|
|
31
|
+
resetSize(): void;
|
|
32
|
+
setPrstGeom(prstGeom?: Nullable<PresetGeometryType>): void;
|
|
33
|
+
setSrcRect(srcRect?: Nullable<ISrcRect>): void;
|
|
34
|
+
getProps(): IImageProps;
|
|
35
|
+
getNative(): Nullable<HTMLImageElement>;
|
|
36
|
+
getNativeSize(): {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
};
|
|
40
|
+
closeRenderByCropper(): void;
|
|
41
|
+
openRenderByCropper(): void;
|
|
42
|
+
calculateTransformWithSrcRect(): {
|
|
43
|
+
left: number;
|
|
44
|
+
top: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
angle: number;
|
|
48
|
+
};
|
|
49
|
+
private _transformBySrcRect;
|
|
50
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
51
|
+
protected _draw(ctx: UniverRenderingContext): void;
|
|
52
|
+
private _init;
|
|
53
|
+
private _updateSrcRectByTransform;
|
|
54
|
+
}
|
|
@@ -17,7 +17,7 @@ export * from './circle';
|
|
|
17
17
|
export * from './control';
|
|
18
18
|
export * from './drawing';
|
|
19
19
|
export * from './path';
|
|
20
|
-
export * from './
|
|
20
|
+
export * from './image';
|
|
21
21
|
export * from './rect';
|
|
22
22
|
export * from './regular-polygon';
|
|
23
23
|
export * from './rich-text';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IObjectFullState } from '../basics/interfaces';
|
|
2
|
-
import { IPoint } from '../basics/vector2';
|
|
2
|
+
import { IPoint, Vector2 } from '../basics/vector2';
|
|
3
3
|
import { UniverRenderingContext } from '../context';
|
|
4
4
|
import { IShapeProps, Shape } from './shape';
|
|
5
5
|
|
|
@@ -12,6 +12,9 @@ export declare class RegularPolygon extends Shape<IRegularPolygonProps> {
|
|
|
12
12
|
constructor(key?: string, props?: IRegularPolygonProps);
|
|
13
13
|
get pointsGroup(): IPoint[][];
|
|
14
14
|
static drawWith(ctx: UniverRenderingContext, props: IRegularPolygonProps | RegularPolygon): void;
|
|
15
|
+
isHit(coord: Vector2): boolean;
|
|
16
|
+
private _contains;
|
|
17
|
+
private _isOnLine;
|
|
15
18
|
updatePointGroup(pointGroup: IPoint[][]): void;
|
|
16
19
|
resizePolygon(preValue: IObjectFullState): void;
|
|
17
20
|
toJson(): {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { IDocumentData, IStyleBase, ITransformState, LocaleService } from '@univerjs/core';
|
|
2
2
|
import { BaseObject } from '../base-object';
|
|
3
|
-
import {
|
|
3
|
+
import { IViewportInfo } from '../basics/vector2';
|
|
4
4
|
import { UniverRenderingContext } from '../context';
|
|
5
5
|
|
|
6
6
|
export interface IRichTextProps extends ITransformState, IStyleBase {
|
|
7
7
|
text?: string;
|
|
8
8
|
richText?: IDocumentData;
|
|
9
9
|
zIndex: number;
|
|
10
|
-
isTransformer?: boolean;
|
|
11
10
|
forceRender?: boolean;
|
|
12
11
|
}
|
|
13
12
|
export declare const RICHTEXT_OBJECT_ARRAY: string[];
|
|
@@ -33,7 +32,7 @@ export declare class RichText extends BaseObject {
|
|
|
33
32
|
height: number;
|
|
34
33
|
} | undefined;
|
|
35
34
|
setProps(props?: IRichTextProps): this | undefined;
|
|
36
|
-
render(mainCtx: UniverRenderingContext, bounds?:
|
|
35
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
37
36
|
toJson(): {
|
|
38
37
|
[x: string]: any;
|
|
39
38
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IScale, Nullable } from '@univerjs/core';
|
|
2
2
|
import { BaseObject } from '../base-object';
|
|
3
3
|
import { IObjectFullState } from '../basics/interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { IViewportInfo, Vector2 } from '../basics/vector2';
|
|
5
5
|
import { UniverRenderingContext } from '../context';
|
|
6
6
|
|
|
7
7
|
export type LineJoin = 'round' | 'bevel' | 'miter';
|
|
@@ -37,7 +37,7 @@ export interface IShapeProps extends IObjectFullState {
|
|
|
37
37
|
parent?: IScale;
|
|
38
38
|
}
|
|
39
39
|
export declare const SHAPE_OBJECT_ARRAY: string[];
|
|
40
|
-
export declare abstract class Shape<T> extends BaseObject {
|
|
40
|
+
export declare abstract class Shape<T extends IShapeProps> extends BaseObject {
|
|
41
41
|
private _hoverCursor;
|
|
42
42
|
private _moveCursor;
|
|
43
43
|
private _fillRule;
|
|
@@ -98,9 +98,10 @@ export declare abstract class Shape<T> extends BaseObject {
|
|
|
98
98
|
* @param {UniverRenderingContext} ctx SheetContext to render on
|
|
99
99
|
*/
|
|
100
100
|
private static _renderStroke;
|
|
101
|
+
private static _removeShadow;
|
|
101
102
|
private static _setFillStyles;
|
|
102
103
|
private static _setStrokeStyles;
|
|
103
|
-
render(mainCtx: UniverRenderingContext, bounds?:
|
|
104
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
104
105
|
setProps(props?: T): this | undefined;
|
|
105
106
|
toJson(): {
|
|
106
107
|
[x: string]: any;
|
|
@@ -24,6 +24,7 @@ export declare abstract class ThinEngine<T extends IDisposable> extends Disposab
|
|
|
24
24
|
abstract setRemainCapture(): void;
|
|
25
25
|
hasActiveScene(): boolean;
|
|
26
26
|
dispose(): void;
|
|
27
|
+
getParent(): void;
|
|
27
28
|
remainScene(key: string): T | undefined;
|
|
28
29
|
abstract clearCanvas(): void;
|
|
29
30
|
abstract getCanvas(): Canvas;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventState, Nullable, Observer, Disposable, Observable } from '@univerjs/core';
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { CURSOR_TYPE, EVENT_TYPE, RENDER_CLASS_TYPE } from './basics/const';
|
|
4
|
-
import { IKeyboardEvent, IMouseEvent, IPointerEvent, IWheelEvent } from './basics/i-events';
|
|
4
|
+
import { IDragEvent, IKeyboardEvent, IMouseEvent, IPointerEvent, IWheelEvent } from './basics/i-events';
|
|
5
5
|
import { ITransformChangeState } from './basics/interfaces';
|
|
6
6
|
import { Transform } from './basics/transform';
|
|
7
7
|
import { Vector2 } from './basics/vector2';
|
|
@@ -15,6 +15,10 @@ export declare abstract class ThinScene extends Disposable {
|
|
|
15
15
|
onPointerUpObserver: Observable<IMouseEvent | IPointerEvent>;
|
|
16
16
|
onPointerEnterObserver: Observable<IMouseEvent | IPointerEvent>;
|
|
17
17
|
onPointerLeaveObserver: Observable<IMouseEvent | IPointerEvent>;
|
|
18
|
+
onDragEnterObserver: Observable<IDragEvent>;
|
|
19
|
+
onDragOverObserver: Observable<IDragEvent>;
|
|
20
|
+
onDragLeaveObserver: Observable<IDragEvent>;
|
|
21
|
+
onDropObserver: Observable<IDragEvent>;
|
|
18
22
|
onDblclickObserver: Observable<IMouseEvent | IPointerEvent>;
|
|
19
23
|
onTripleClickObserver: Observable<IMouseEvent | IPointerEvent>;
|
|
20
24
|
onMouseWheelObserver: Observable<IWheelEvent>;
|
|
@@ -59,6 +63,10 @@ export declare abstract class ThinScene extends Disposable {
|
|
|
59
63
|
abstract triggerPointerLeave(evt: IPointerEvent | IMouseEvent): void;
|
|
60
64
|
abstract triggerPointerOver(evt: IPointerEvent | IMouseEvent): void;
|
|
61
65
|
abstract triggerPointerEnter(evt: IPointerEvent | IMouseEvent): void;
|
|
66
|
+
abstract triggerDragEnter(evt: IDragEvent | IMouseEvent): void;
|
|
67
|
+
abstract triggerDragOver(evt: IDragEvent | IMouseEvent): void;
|
|
68
|
+
abstract triggerDragLeave(evt: IDragEvent | IMouseEvent): void;
|
|
69
|
+
abstract triggerDrop(evt: IDragEvent | IMouseEvent): void;
|
|
62
70
|
abstract render(parentCtx?: UniverRenderingContext): void;
|
|
63
71
|
abstract getParent(): any;
|
|
64
72
|
dispose(): void;
|
|
@@ -67,7 +75,8 @@ export declare abstract class ThinScene extends Disposable {
|
|
|
67
75
|
abstract addObjects(objects: BaseObject[], zIndex?: number): void;
|
|
68
76
|
abstract getEngine(): any;
|
|
69
77
|
abstract setObjectBehavior(o: BaseObject): void;
|
|
70
|
-
|
|
78
|
+
attachTransformerTo(o: BaseObject): void;
|
|
79
|
+
detachTransformerFrom(o: BaseObject): void;
|
|
71
80
|
makeDirtyNoParent(state?: boolean): ThinScene;
|
|
72
81
|
makeDirty(state?: boolean): this;
|
|
73
82
|
abstract pick(coord: Vector2): Nullable<BaseObject | ThinScene>;
|
package/lib/types/viewport.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EventState, IPosition, Nullable, Observable } from '@univerjs/core';
|
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { IWheelEvent } from './basics/i-events';
|
|
4
4
|
import { Transform } from './basics/transform';
|
|
5
|
-
import {
|
|
5
|
+
import { IBoundRectNoAngle, IViewportInfo, Vector2 } from './basics/vector2';
|
|
6
6
|
import { UniverRenderingContext } from './context';
|
|
7
7
|
import { BaseScrollBar } from './shape/base-scroll-bar';
|
|
8
8
|
import { ThinScene } from './thin-scene';
|
|
@@ -21,13 +21,24 @@ interface IViewProps extends IViewPosition {
|
|
|
21
21
|
isWheelPreventDefaultX?: boolean;
|
|
22
22
|
isWheelPreventDefaultY?: boolean;
|
|
23
23
|
active?: boolean;
|
|
24
|
+
isRelativeX?: boolean;
|
|
25
|
+
isRelativeY?: boolean;
|
|
26
|
+
allowCache?: boolean;
|
|
27
|
+
bufferEdgeX?: number;
|
|
28
|
+
bufferEdgeY?: number;
|
|
24
29
|
}
|
|
25
30
|
export interface IScrollObserverParam {
|
|
26
31
|
viewport?: Viewport;
|
|
32
|
+
/**
|
|
33
|
+
* scrollX for scrollbar
|
|
34
|
+
*/
|
|
27
35
|
scrollX?: number;
|
|
28
36
|
scrollY?: number;
|
|
29
37
|
x?: number;
|
|
30
38
|
y?: number;
|
|
39
|
+
/**
|
|
40
|
+
* scrollX for viewport
|
|
41
|
+
*/
|
|
31
42
|
actualScrollX?: number;
|
|
32
43
|
actualScrollY?: number;
|
|
33
44
|
limitX?: number;
|
|
@@ -40,25 +51,36 @@ interface IScrollBarPosition {
|
|
|
40
51
|
}
|
|
41
52
|
export declare class Viewport {
|
|
42
53
|
/**
|
|
43
|
-
*
|
|
44
|
-
* use
|
|
45
|
-
*
|
|
54
|
+
* scrollX means scroll x value for scrollbar in viewMain
|
|
55
|
+
* use getBarScroll to get scrolling value(scrollX, scrollY) for scrollbar
|
|
46
56
|
*/
|
|
47
57
|
scrollX: number;
|
|
48
58
|
scrollY: number;
|
|
59
|
+
_preScrollX: number;
|
|
60
|
+
_preScrollY: number;
|
|
49
61
|
/**
|
|
50
62
|
* The actual scroll offset equals the distance from the content area position to the top, and there is a conversion relationship with scrollX and scrollY
|
|
51
|
-
* use
|
|
63
|
+
* use getActualScroll to get scrolling value for spreadsheet.
|
|
52
64
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
viewportScrollX: number;
|
|
66
|
+
viewportScrollY: number;
|
|
67
|
+
preViewportScrollX: number;
|
|
68
|
+
preViewportScrollY: number;
|
|
69
|
+
_deltaViewportScrollX: number;
|
|
70
|
+
_deltaViewportScrollY: number;
|
|
55
71
|
onMouseWheelObserver: Observable<IWheelEvent>;
|
|
56
72
|
onScrollAfterObserver: Observable<IScrollObserverParam>;
|
|
57
73
|
onScrollBeforeObserver: Observable<IScrollObserverParam>;
|
|
58
74
|
onScrollStopObserver: Observable<IScrollObserverParam>;
|
|
59
75
|
onScrollByBarObserver: Observable<IScrollObserverParam>;
|
|
60
|
-
private
|
|
76
|
+
private _viewportKey;
|
|
77
|
+
/**
|
|
78
|
+
* viewport top origin value in logic, scale does not affect it.
|
|
79
|
+
*/
|
|
61
80
|
private _topOrigin;
|
|
81
|
+
/**
|
|
82
|
+
* viewport left origin value in logic, scale does not affect it.
|
|
83
|
+
*/
|
|
62
84
|
private _leftOrigin;
|
|
63
85
|
private _bottomOrigin;
|
|
64
86
|
private _rightOrigin;
|
|
@@ -75,8 +97,6 @@ export declare class Viewport {
|
|
|
75
97
|
private _isWheelPreventDefaultX;
|
|
76
98
|
private _isWheelPreventDefaultY;
|
|
77
99
|
private _scrollStopNum;
|
|
78
|
-
private _preScrollX;
|
|
79
|
-
private _preScrollY;
|
|
80
100
|
private _renderClipState;
|
|
81
101
|
private _active;
|
|
82
102
|
private _paddingStartX;
|
|
@@ -85,12 +105,43 @@ export declare class Viewport {
|
|
|
85
105
|
private _paddingEndY;
|
|
86
106
|
private _isRelativeX;
|
|
87
107
|
private _isRelativeY;
|
|
88
|
-
|
|
89
|
-
|
|
108
|
+
/**
|
|
109
|
+
* viewbound of cache area, cache area is slightly bigger than viewbound.
|
|
110
|
+
*/
|
|
111
|
+
private _cacheBound;
|
|
112
|
+
private _preCacheBound;
|
|
113
|
+
private _preCacheVisibleBound;
|
|
114
|
+
/**
|
|
115
|
+
* bound of visible area
|
|
116
|
+
*/
|
|
117
|
+
private _viewBound;
|
|
118
|
+
private _preViewBound;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the viewport needs to be updated.
|
|
121
|
+
* In future, viewMain dirty would not affect othew viewports.
|
|
122
|
+
*/
|
|
123
|
+
private _isDirty;
|
|
124
|
+
private _cacheCanvas;
|
|
125
|
+
/**
|
|
126
|
+
* The configuration comes from the props.allowCache passed in during viewport initialization.
|
|
127
|
+
* When _allowCache is true, a cacheCanvas will be created.
|
|
128
|
+
*/
|
|
129
|
+
private _allowCache;
|
|
130
|
+
/**
|
|
131
|
+
* Buffer Area size, default is zero
|
|
132
|
+
*/
|
|
133
|
+
bufferEdgeX: number;
|
|
134
|
+
bufferEdgeY: number;
|
|
135
|
+
constructor(viewportKey: string, scene: ThinScene, props?: IViewProps);
|
|
136
|
+
initCacheCanvas(props?: IViewProps): void;
|
|
137
|
+
/**
|
|
138
|
+
* test
|
|
139
|
+
*/
|
|
140
|
+
_testDisplayCache(): void;
|
|
90
141
|
get scene(): ThinScene;
|
|
91
142
|
get width(): Nullable<number>;
|
|
92
143
|
get height(): Nullable<number>;
|
|
93
|
-
get
|
|
144
|
+
get viewportKey(): string;
|
|
94
145
|
get topOrigin(): number;
|
|
95
146
|
get leftOrigin(): number;
|
|
96
147
|
get bottomOrigin(): number;
|
|
@@ -108,16 +159,40 @@ export declare class Viewport {
|
|
|
108
159
|
private set left(value);
|
|
109
160
|
private set bottom(value);
|
|
110
161
|
private set right(value);
|
|
162
|
+
get viewBound(): IBoundRectNoAngle;
|
|
163
|
+
get cacheBound(): IBoundRectNoAngle | null;
|
|
164
|
+
set cacheBound(val: IBoundRectNoAngle | null);
|
|
165
|
+
get preCacheBound(): IBoundRectNoAngle | null;
|
|
166
|
+
set preCacheBound(val: IBoundRectNoAngle | null);
|
|
111
167
|
enable(): void;
|
|
112
168
|
disable(): void;
|
|
169
|
+
/**
|
|
170
|
+
* 物理 canvas 大小改变时调用(调整 window 大小时触发)
|
|
171
|
+
*/
|
|
113
172
|
resetSizeAndScrollBar(): void;
|
|
114
173
|
setScrollBar(instance: BaseScrollBar): void;
|
|
115
174
|
removeScrollBar(): void;
|
|
175
|
+
/**
|
|
176
|
+
* 和 resetSizeAndScrollBar 不同
|
|
177
|
+
* 此方法是调整冻结行列设置时 & 初始化时触发, resize window 时并不会触发
|
|
178
|
+
*
|
|
179
|
+
* 注意参数 position 不一定有 height & width 对于 viewMain 只有 left top bottom right
|
|
180
|
+
* this.width this.height 也有可能是 undefined
|
|
181
|
+
* 因此应通过 _getViewPortSize 获取宽高
|
|
182
|
+
* @param position
|
|
183
|
+
*/
|
|
116
184
|
resize(position: IViewPosition): void;
|
|
117
185
|
setPadding(param: IPosition): void;
|
|
118
186
|
resetPadding(): void;
|
|
119
187
|
/**
|
|
188
|
+
*
|
|
189
|
+
* 改动 scrollbar 的位置,不是 viewport content 滚动
|
|
120
190
|
* scroll to position, absolute
|
|
191
|
+
* 只有 viewMain 才会被调用 scrollTo 其他 viewport 都不会调用此方法
|
|
192
|
+
* 具体在 scroll.controller 中
|
|
193
|
+
*
|
|
194
|
+
* Debug
|
|
195
|
+
* window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
|
|
121
196
|
* @param pos
|
|
122
197
|
* @returns
|
|
123
198
|
*/
|
|
@@ -155,6 +230,10 @@ export declare class Viewport {
|
|
|
155
230
|
x: number;
|
|
156
231
|
y: number;
|
|
157
232
|
};
|
|
233
|
+
/**
|
|
234
|
+
* get actual scroll value by scrollXY
|
|
235
|
+
* @returns
|
|
236
|
+
*/
|
|
158
237
|
getTransformedScroll(): {
|
|
159
238
|
x: number;
|
|
160
239
|
y: number;
|
|
@@ -162,8 +241,19 @@ export declare class Viewport {
|
|
|
162
241
|
getScrollBar(): Nullable<BaseScrollBar>;
|
|
163
242
|
updateScroll(param: IScrollObserverParam): this;
|
|
164
243
|
getScrollBarTransForm(): Transform;
|
|
244
|
+
shouldIntoRender(): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* engine.renderLoop ---> scene.render ---> layer.render ---> viewport.render
|
|
247
|
+
* that means each layer call all viewports to render
|
|
248
|
+
* @param parentCtx 如果 layer._allowCache true, 那么 parentCtx 是 layer 中的 cacheCtx
|
|
249
|
+
* @param objects
|
|
250
|
+
* @param isMaxLayer
|
|
251
|
+
* @param isLast last viewport would
|
|
252
|
+
*/
|
|
165
253
|
render(parentCtx?: UniverRenderingContext, objects?: BaseObject[], isMaxLayer?: boolean): void;
|
|
166
|
-
|
|
254
|
+
private _makeDefaultViewport;
|
|
255
|
+
private _calcViewportInfo;
|
|
256
|
+
getBounding(): IViewportInfo;
|
|
167
257
|
getRelativeVector(coord: Vector2): Vector2;
|
|
168
258
|
getAbsoluteVector(coord: Vector2): Vector2;
|
|
169
259
|
onMouseWheel(evt: IWheelEvent, state: EventState): void;
|
|
@@ -176,15 +266,43 @@ export declare class Viewport {
|
|
|
176
266
|
isLimitedX: boolean;
|
|
177
267
|
isLimitedY: boolean;
|
|
178
268
|
} | undefined;
|
|
179
|
-
|
|
269
|
+
markDirty(state?: boolean): void;
|
|
270
|
+
get isDirty(): boolean;
|
|
271
|
+
private _isForceDirty;
|
|
272
|
+
markForceDirty(state?: boolean): void;
|
|
273
|
+
resetPrevCacheBounds(): void;
|
|
274
|
+
get isForceDirty(): boolean;
|
|
275
|
+
private _resizeCacheCanvas;
|
|
180
276
|
private _getViewPortSize;
|
|
181
277
|
private _scrollRendered;
|
|
182
278
|
private _triggerScrollStop;
|
|
279
|
+
/**
|
|
280
|
+
* Scroll Viewport
|
|
281
|
+
* Only the 'viewMain' will enter this function, other viewports will not.
|
|
282
|
+
*
|
|
283
|
+
* caller: scroll.controller viewportMain.proscrollTo(config)
|
|
284
|
+
* @param scrollType
|
|
285
|
+
* @param pos viewMain 滚动条的位置
|
|
286
|
+
* @param isTrigger
|
|
287
|
+
*/
|
|
183
288
|
private _scroll;
|
|
184
|
-
|
|
289
|
+
expandBounds(value: {
|
|
290
|
+
top: number;
|
|
291
|
+
left: number;
|
|
292
|
+
bottom: number;
|
|
293
|
+
right: number;
|
|
294
|
+
}): IBoundRectNoAngle;
|
|
295
|
+
updatePrevCacheBounds(viewBound?: IBoundRectNoAngle): void;
|
|
296
|
+
private _calcCacheUpdate;
|
|
185
297
|
private _diffViewBound;
|
|
298
|
+
private _calcDiffCacheBound;
|
|
186
299
|
private _drawScrollbar;
|
|
187
300
|
private _setWithAndHeight;
|
|
188
301
|
private _getBoundScale;
|
|
302
|
+
/**
|
|
303
|
+
* main canvas element resize
|
|
304
|
+
* called by this.scene.getEngine()?.onTransformChangeObservable.add
|
|
305
|
+
*/
|
|
306
|
+
private _mainCanvasResizeHandler;
|
|
189
307
|
}
|
|
190
308
|
export {};
|