-
-
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.
- Loading branch information
Showing
7 changed files
with
187 additions
and
43 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
31 changes: 31 additions & 0 deletions
31
src/js/external/core/application/ExternalShape/service/ExternalShapeUpdateService.ts
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,31 @@ | ||
import type { Shape } from "@/core/domain/model/Shape"; | ||
import type { BoundsImpl } from "@/interface/BoundsImpl"; | ||
|
||
/** | ||
* @description Shapeのグラフィックスレコード更新とバウンディングボックス更新 | ||
* Update Shape graphics record and bounding box | ||
* | ||
* @param {Shape} shape | ||
* @param {Float32Array} recodes | ||
* @param {object} bounds | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = ( | ||
shape: Shape, | ||
recodes: Float32Array | number[], | ||
bounds: BoundsImpl | ||
): void => { | ||
// 描画レコードを更新 | ||
// todo Float32ArrayをAnimation Toolの描画レコードに変換する | ||
shape.recodes.length = 0; | ||
shape.recodes.push(...Array.from(recodes)); | ||
|
||
// 描画反映のバウンディングボックスを更新 | ||
const rawBounds = shape.getRawBounds(); | ||
rawBounds.xMin = bounds.xMin; | ||
rawBounds.yMin = bounds.yMin; | ||
rawBounds.xMax = bounds.xMax; | ||
rawBounds.yMax = bounds.yMax; | ||
}; |
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
36 changes: 20 additions & 16 deletions
36
...application/LibraryArea/Shape/usecase/LibraryAreaUpdateShapeGraphicsHistoryUndoUseCase.ts
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 |
---|---|---|
@@ -1,40 +1,44 @@ | ||
import type { Shape } from "@/core/domain/model/Shape"; | ||
import type { InstanceImpl } from "@/interface/InstanceImpl"; | ||
import type { ShapeSaveObjectImpl } from "@/interface/ShapeSaveObjectImpl"; | ||
import { execute as externalWorkSpaceRegisterInstanceService } from "@/external/core/application/ExternalWorkSpace/service/ExternalWorkSpaceRegisterInstanceService"; | ||
import { $getWorkSpace } from "@/core/application/CoreUtil"; | ||
import { execute as externalWorkSpaceRemoveInstanceService } from "@/external/core/application/ExternalWorkSpace/service/ExternalWorkSpaceRemoveInstanceService"; | ||
import { execute as libraryAreaReloadUseCase } from "@/controller/application/LibraryArea/usecase/LibraryAreaReloadUseCase"; | ||
import { Shape } from "@/core/domain/model/Shape"; | ||
import { $SCREEN_STAGE_AREA_ID } from "@/config/ScreenConfig"; | ||
import { execute as screenDisplayObjectChangeElementUseCase } from "@/screen/application/DisplayObject/usecase/ScreenDisplayObjectChangeElementUseCase"; | ||
|
||
/** | ||
* @description 新規Shape追加処理のUndo関数 | ||
* Undo function for new Shape addition process | ||
* @description Shapeの描画レコード更新処理のUndo関数 | ||
* Undo function of Shape drawing record update processing | ||
* | ||
* @param {number} work_space_id | ||
* @param {object} shape_object | ||
* @param {object} before_shape_object | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = ( | ||
export const execute = async ( | ||
work_space_id: number, | ||
shape_object: ShapeSaveObjectImpl | ||
): void => { | ||
before_shape_object: ShapeSaveObjectImpl | ||
): Promise<void> => { | ||
|
||
const workSpace = $getWorkSpace(work_space_id); | ||
if (!workSpace) { | ||
return ; | ||
} | ||
|
||
const shape: InstanceImpl<Shape> | null = workSpace.getLibrary(shape_object.id); | ||
if (!shape) { | ||
const element: HTMLElement | null = document | ||
.getElementById($SCREEN_STAGE_AREA_ID); | ||
if (!element) { | ||
return ; | ||
} | ||
|
||
// 内部情報から削除 | ||
externalWorkSpaceRemoveInstanceService(workSpace, shape); | ||
// 更新前のShapeを生成 | ||
const shape = new Shape(before_shape_object); | ||
|
||
// 内部情報に登録 | ||
externalWorkSpaceRegisterInstanceService(workSpace, shape); | ||
|
||
// 起動中のプロジェクトならライブラリを再描画 | ||
if (workSpace.active) { | ||
libraryAreaReloadUseCase(); | ||
// 配置されてるDisplayObjectのElementを入れ替える | ||
screenDisplayObjectChangeElementUseCase(shape.id); | ||
} | ||
}; |
1 change: 0 additions & 1 deletion
1
...ler/application/LibraryArea/Shape/usecase/LibraryAreaUpdateShapeGraphicsHistoryUseCase.ts
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
94 changes: 94 additions & 0 deletions
94
src/js/screen/application/DisplayObject/usecase/ScreenDisplayObjectChangeElementUseCase.ts
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,94 @@ | ||
import { $SCREEN_STAGE_AREA_ID } from "@/config/ScreenConfig"; | ||
import { $getCurrentWorkSpace } from "@/core/application/CoreUtil"; | ||
import { $poolCanvas } from "@/global/GlobalUtil"; | ||
import { $setReDrawState } from "../../ScreenArea/ScreenAreaUtil"; | ||
import { execute as shapeCreateDisplayObjectElementUseCase } from "@/core/application/Shape/usecase/ShapeCreateDisplayObjectElementUseCase"; | ||
import { $SHAPE_TYPE } from "@/config/InstanceConfig"; | ||
|
||
/** | ||
* @description 指定ライブラリのDisplayObjectのElementを入れ替える | ||
* Replace the Element of the specified library's DisplayObject | ||
* | ||
* @param {number} library_id | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = async (library_id: number): Promise<void> => | ||
{ | ||
const element: HTMLElement | null = document | ||
.getElementById($SCREEN_STAGE_AREA_ID); | ||
if (!element) { | ||
return ; | ||
} | ||
|
||
const workSpace = $getCurrentWorkSpace(); | ||
const instance = workSpace.getLibrary(library_id); | ||
if (!instance) { | ||
return ; | ||
} | ||
|
||
const movieClip = workSpace.scene; | ||
const frame = movieClip.currentFrame; | ||
for (let idx = 0; idx < movieClip.layers.length; ++idx) { | ||
const layer = movieClip.layers[idx]; | ||
if (!layer) { | ||
continue; | ||
} | ||
|
||
const activeCharacters = layer.getActiveCharacters(frame); | ||
if (!activeCharacters.length) { | ||
continue; | ||
} | ||
|
||
const elements = element | ||
.querySelectorAll(`layer-id-${layer.id}`); | ||
|
||
for (let idx = 0; idx < activeCharacters.length; ++idx) { | ||
|
||
const character = activeCharacters[idx]; | ||
if (!character) { | ||
continue; | ||
} | ||
|
||
if (character.libraryId !== library_id) { | ||
continue; | ||
} | ||
|
||
const node = elements[character.depth]; | ||
if (!node) { | ||
continue; | ||
} | ||
|
||
// 既存のcanvasをキャッシュに戻す | ||
const canvas = node.children[0] as HTMLCanvasElement; | ||
if (canvas) { | ||
$poolCanvas(canvas); | ||
} | ||
|
||
// 既存のElementを削除 | ||
node.remove(); | ||
|
||
// 変更前のShapeを描画したelementを再配置 | ||
$setReDrawState(true); | ||
switch (instance.type) { | ||
|
||
case $SHAPE_TYPE: | ||
await shapeCreateDisplayObjectElementUseCase( | ||
workSpace.id, | ||
instance, | ||
element, | ||
layer, | ||
character | ||
); | ||
break; | ||
|
||
default: | ||
break; | ||
|
||
} | ||
$setReDrawState(false); | ||
} | ||
|
||
} | ||
}; |