-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from VisActor/feat/component-controller
feat: support image shape edit controller
- Loading branch information
Showing
11 changed files
with
200 additions
and
49 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
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
50 changes: 50 additions & 0 deletions
50
packages/vstory/src/edit/edit-component/shape-selection.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,50 @@ | ||
// import { StoryGraphicType } from '../../dsl/constant'; | ||
import { StoryComponentType } from '../../constants/character'; | ||
import type { VRenderPointerEvent } from '../../interface/type'; | ||
import type { IEditSelectionInfo } from '../interface'; | ||
import { type IEditComponent } from '../interface'; | ||
import { BaseSelection } from './base-selection'; | ||
import type { ITransformControl, IUpdateParams, TransformAttributes } from './edit-control/transform-control'; | ||
import { TransformControl } from './edit-control/transform-control'; | ||
import { RectSelection } from './rect-selection'; | ||
|
||
export class ShapeSelection extends RectSelection implements IEditComponent { | ||
readonly level = 3; | ||
readonly type: string = 'shape'; | ||
readonly editCharacterType: string = StoryComponentType.SHAPE; | ||
|
||
// protected _createLayoutComponent(attributes: Partial<TransformAttributes>): ITransformControl { | ||
// return new TransformControl(this, attributes); | ||
// } | ||
|
||
updateComponent() { | ||
const actionInfo = this._actionInfo as IEditSelectionInfo; | ||
if (!(actionInfo && actionInfo.character)) { | ||
return; | ||
} | ||
const symbol = actionInfo.character.graphic.graphic; | ||
const { width, height } = symbol.attribute; | ||
const group = actionInfo.character.getGraphicParent(); | ||
const { angle, x, y } = group.attribute; | ||
this._layoutComponent.updateBoundsAndAngle( | ||
{ | ||
x1: x, | ||
y1: y, | ||
x2: x + width, | ||
y2: y + height | ||
}, | ||
angle | ||
); | ||
} | ||
|
||
protected handlerTransformChange(data: IUpdateParams, event?: VRenderPointerEvent): void { | ||
if (this._activeCharacter) { | ||
const { x, y, width, height } = data; | ||
this._activeCharacter.setAttributes({ | ||
...data, | ||
x: x + width / 2, | ||
y: y + height / 2 | ||
}); | ||
} | ||
} | ||
} |
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