import Tool from "../core/tool"
import NumberEditLayer from "./number-edit-layer";



export default class NumberPlayTool extends Tool {
  numberEditLayer : NumberEditLayer;

  constructor(numberEditLayer : NumberEditLayer) {
    super('number-edit-play', 'pointer');
    this.numberEditLayer = numberEditLayer;
  }
  
  override onclick(evt: MouseEvent): void {
  
    if (!this.numberEditLayer) return; 

    console.log('NumberPlayTool@onclick');
    if (!this.numberEditLayer.playInterval) {
      this.numberEditLayer.playStep();
    }
  }

  override ondblclick(evt: MouseEvent): void {
    if (!this.numberEditLayer) return;

    console.log('NumberPlayTool@ondblclick');
    if (!this.numberEditLayer.playInterval) {
      this.numberEditLayer.playAuto();
    } else {
      this.numberEditLayer.playStop();
    }
  }

  override onSelect(): void {
    if (!this.numberEditLayer) return;

    this.numberEditLayer.resetPlay();
    this.numberEditLayer.playAuto();
  }

  override onUnSelect(): void {
    if (!this.numberEditLayer) return;

    this.numberEditLayer.playStop();
  }

}