This commit is contained in:
joylink_fanyuhong 2024-02-20 17:42:53 +08:00
commit 935e12f264
2 changed files with 25 additions and 11 deletions

View File

@ -106,6 +106,7 @@ export class IbpButtonState
// IbpScene使用
export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> {
static Name = 'ibp_button_operate_menu';
isMouseDown = false;
constructor(app: IGraphicScene) {
super(IbpButtonInteraction.Name, app);
}
@ -129,6 +130,7 @@ export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> {
g.off('mouseleave', this.onMouseLeave);
}
onMouseDown(e: FederatedMouseEvent) {
this.isMouseDown = true;
const g = e.target as IBPButton;
const changeState = useIbpStore().ibpButtonOperation;
if (g.datas.isSelfReset) {
@ -138,6 +140,7 @@ export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> {
}
}
onMouseUp(e: FederatedMouseEvent) {
this.isMouseDown = false;
const changeState = useIbpStore().ibpButtonOperation;
const g = e.target as IBPButton;
if (g.datas.isSelfReset) {
@ -145,10 +148,13 @@ export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> {
}
}
onMouseLeave(e: FederatedMouseEvent) {
const changeState = useIbpStore().ibpButtonOperation;
const g = e.target as IBPButton;
if (g.datas.isSelfReset) {
changeState(g.datas.id, false);
if (this.isMouseDown) {
const changeState = useIbpStore().ibpButtonOperation;
const g = e.target as IBPButton;
if (g.datas.isSelfReset) {
changeState(g.datas.id, false);
}
this.isMouseDown = false;
}
}
}

View File

@ -52,13 +52,21 @@ export class IbpLight extends JlGraphic {
}
doRepaint(): void {
this.graphic.clear();
this.graphic
.beginFill(
ibpLightColorMap[this.datas.color ?? 0],
this.state.active ? ibpLightConsts.onAlpha : ibpLightConsts.offAlpha
)
.drawCircle(0, 0, ibpLightConsts.radius)
.endFill();
if (this.datas.color == 0) {
const fillColor = this.state.active ? '#ffffff' : '#676767';
this.graphic
.beginFill(fillColor)
.drawCircle(0, 0, ibpLightConsts.radius)
.endFill();
} else {
this.graphic
.beginFill(
ibpLightColorMap[this.datas.color ?? 1],
this.state.active ? ibpLightConsts.onAlpha : ibpLightConsts.offAlpha
)
.drawCircle(0, 0, ibpLightConsts.radius)
.endFill();
}
}
}