From 908d8094d68f9ebac716f7b6ff01a731cc58e466 Mon Sep 17 00:00:00 2001 From: Yuan Date: Tue, 10 Oct 2023 17:08:24 +0800 Subject: [PATCH] =?UTF-8?q?ibp=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IBPButton/IBPButtonDrawAssistant.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/graphics/IBPButton/IBPButtonDrawAssistant.ts b/src/graphics/IBPButton/IBPButtonDrawAssistant.ts index 64b3d73..4badb84 100644 --- a/src/graphics/IBPButton/IBPButtonDrawAssistant.ts +++ b/src/graphics/IBPButton/IBPButtonDrawAssistant.ts @@ -1,4 +1,9 @@ -import { GraphicDrawAssistant, IDrawApp } from 'src/jl-graphic'; +import { + GraphicDrawAssistant, + GraphicInteractionPlugin, + IDrawApp, + JlGraphic, +} from 'src/jl-graphic'; import { IBPButton, IBPButtonTemplate, IIBPButtonData } from './IBPButton'; import { FederatedMouseEvent, Point } from 'pixi.js'; @@ -14,6 +19,7 @@ export class IBPButtonDrawAssistant extends GraphicDrawAssistant< 'svguse:../../drawIcon.svg#icon-psl-button', 'IBP按钮' ); + IBPButtonInteraction.init(app); } get ibpButton(): IBPButton { if (!this._ibpButton) { @@ -37,3 +43,26 @@ export class IBPButtonDrawAssistant extends GraphicDrawAssistant< return true; } } +class IBPButtonInteraction extends GraphicInteractionPlugin { + static Name = 'ibp_button_transform'; + constructor(app: IDrawApp) { + super(IBPButtonInteraction.Name, app); + } + static init(app: IDrawApp) { + return new IBPButtonInteraction(app); + } + filter(...grahpics: JlGraphic[]): IBPButton[] { + return grahpics.filter((g): g is IBPButton => g instanceof IBPButton); + } + bind(g: IBPButton): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + } + unbind(g: IBPButton): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + } +}