-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get display window by px (#222)
- Loading branch information
1 parent
7296668
commit d1a2d3c
Showing
10 changed files
with
200 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// DO NOT EDIT. CODE GENERATED BY gents. | ||
import {DisplayWindow} from './display_window' | ||
|
||
export interface DisplayWindowWithStartPoint { | ||
window: DisplayWindow | ||
startX: number | ||
startY: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './workbook' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import {getID} from '@/core/ioc/id' | ||
import {injectable} from 'inversify' | ||
import { | ||
ActionEffect, | ||
CustomFunc, | ||
Transaction, | ||
Workbook, | ||
initWasm, | ||
} from '@logisheets_bg' | ||
import {DisplayWindowWithStartPoint} from 'packages/web/src/bindings' | ||
|
||
@injectable() | ||
export class WorkbookService { | ||
readonly id = getID() | ||
|
||
public constructor(funcs: readonly CustomFunc[]) { | ||
this._init(funcs) | ||
} | ||
|
||
public registryCustomFunc(f: CustomFunc) { | ||
this._workbook.registryCustomFunc(f) | ||
} | ||
|
||
public registryRender(render: () => void) { | ||
this._workbook.registerUpdateCallback(render) | ||
} | ||
|
||
public handleTransaction( | ||
transaction: Transaction, | ||
undoable: boolean | ||
): ActionEffect { | ||
return this._workbook.execTransaction(transaction, undoable) | ||
} | ||
|
||
public getDisplayWindow( | ||
sheetIdx: number, | ||
startX: number, | ||
startY: number, | ||
endX: number, | ||
endY: number | ||
): DisplayWindowWithStartPoint { | ||
const ws = this._workbook.getWorksheet(sheetIdx) | ||
return ws.getDisplayWindowWithStartPoint(startX, startY, endX, endY) | ||
} | ||
|
||
public undo() { | ||
this._workbook.undo() | ||
return | ||
} | ||
|
||
public redo() { | ||
this._workbook.redo() | ||
} | ||
|
||
public loadWorkbook(content: Uint8Array, name: string) { | ||
this._workbook.load(content, name) | ||
} | ||
|
||
private async _init(funcs: readonly CustomFunc[]) { | ||
await initWasm() | ||
this._workbookImpl = new Workbook() | ||
funcs.forEach((f) => { | ||
this._workbook.registryCustomFunc(f) | ||
}) | ||
} | ||
|
||
private get _workbook(): Workbook { | ||
if (!this._workbookImpl) throw Error('') | ||
return this._workbookImpl | ||
} | ||
|
||
private _workbookImpl: Workbook | undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters