import Tool from "../core/tool"
import OrderEditLayer from "./order-edit-layer";



export default class OrderSelectTool extends Tool {
  orderEditLayer : OrderEditLayer;

  constructor(orderEditLayer : OrderEditLayer) {
    super('order-edit-select', 'pointer');
    this.orderEditLayer = orderEditLayer;
  }
  
  override onclick(evt: MouseEvent): void {
  
    if (!this.orderEditLayer) return;

    let pp = this.orderEditLayer.translate(evt._contentPoint);
    console.log('OrderSelectTool@onclick', pp.x, pp.y);
    this.orderEditLayer.orderFill(pp.x , pp.y);
  }

  override ondblclick(evt: MouseEvent): void {
    if (!this.orderEditLayer) return;
    let pp = this.orderEditLayer.translate(evt._contentPoint);
    console.log('OrderSelectTool@ondblclick', pp.x, pp.y);
    let color = this.editor.pickColor(evt._canvasPoint, evt._contentPoint);
    this.orderEditLayer.color = color;
  }


  override onSelect(): void {
    this.orderEditLayer.invalidate();
    this.orderEditLayer.playStop();
  }

}