diff --git a/browser/src/layer/tile/CanvasSectionContainer.ts b/browser/src/layer/tile/CanvasSectionContainer.ts index 4c214386c..074863f6c 100644 --- a/browser/src/layer/tile/CanvasSectionContainer.ts +++ b/browser/src/layer/tile/CanvasSectionContainer.ts @@ -1,6 +1,46 @@ declare var L: any; declare var app: any; +/** + * Used to initialize a new anonymous CanvasSectionObject from its properties. + * See documentation of CanvasSectionObject properties for description + */ +interface SectionInitProperties { + name: string; + backgroundColor?: string; + borderColor?: string; + anchor?: string | Array; + position: Array; + size: Array; + expand: string; + processingOrder: number; + drawingOrder: number; + zIndex: number; + interactable: boolean; + showSection?: boolean; + sectionProperties?: any; + onInitialize?: () => void; + onMouseMove?: (point: Array, dragDistance: Array, e: MouseEvent) => void; + onMouseDown?: (point: Array, e: MouseEvent) => void; + onMouseUp?: (point: Array, e: MouseEvent) => void; + onMouseEnter?: (point: Array, e: MouseEvent) => void; + onMouseLeave?: (point: Array, e: MouseEvent) => void; + onClick?: (point: Array, e: MouseEvent) => void; + onDoubleClick?: (point: Array, e: MouseEvent) => void; + onContextMenu?: (e?: MouseEvent) => void; + onMouseWheel?: (point: Array, delta: Array, e: MouseEvent) => void; + onLongPress?: (point: Array, e: MouseEvent) => void; + onMultiTouchStart?: (e: TouchEvent) => void; + onMultiTouchMove?: (point: Array, dragDistance: number, e: TouchEvent) => void; + onMultiTouchEnd?: (e: TouchEvent) => void; + onResize?: () => void; + onDraw?: (frameCount?: number, elapsedTime?: number) => void; + onDrawArea?: (area?: cool.Bounds, paneTopLeft?: cool.Point, canvasContext?: CanvasRenderingContext2D) => void; + onNewDocumentTopLeft?: (size: Array) => void; + onRemove?: () => void; + onAnimationEnded?: (frameCount: number, elapsedTime: number) => void; +} + // Below classes are for managing the canvas layout. /* Potential values are separated with '|' @@ -261,7 +301,7 @@ class CanvasSectionObject { /// Do not implement this. This function is added by section container. This returns if Calc document is in RTL mode isCalcRTL: () => boolean; - constructor (options: any) { + constructor (options: SectionInitProperties) { this.name = options.name; this.backgroundColor = options.backgroundColor ? options.backgroundColor: null; this.borderColor = options.borderColor ? options.borderColor: null; @@ -1831,7 +1871,7 @@ class CanvasSectionContainer { return true; } - createSection (options: any, parentSectionName: string = null) { + createSection (options: SectionInitProperties, parentSectionName: string = null) { if (this.newSectionChecks(options)) { // Every section can draw from Point(0, 0), their drawings will be translated to myTopLeft position. var newSection: CanvasSectionObject = new CanvasSectionObject(options);