ibp处理鼠标离开和ibp灯的颜色
This commit is contained in:
parent
f9782c1227
commit
7cc534028b
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user