package speiger.src.coreengine.rendering.input.events;

import speiger.src.coreengine.utils.eventbus.Event;

public abstract class MouseEvent extends Event {
	final long window;
	int x;
	int y;
	final int originX;
	final int originY;
	
	public MouseEvent(long window, int x, int y) {
		this.window = window;
		this.originX = this.x = x;
		this.originY = this.y = y;
	}

	public long windowId() { return window; }
	public int x() { return x; }
	public void x(int x) { this.x = x; }
	public int y() { return y; }
	public void y(int y) { this.y = y; }
	public int originX() { return originX; }
	public int originY() { return originY; }
	
	public void reset() {
		x = originX;
		y = originY;
	}
	
	//TODO implement support for Scaling
	
	@Override
	public boolean isCancelable() { return true; }
	public boolean isForced() { return false; }
	
	public static class Click extends MouseEvent {
		final int button;
		final boolean press;
		
		public Click(long window, int x, int y, int button, boolean press) {
			super(window, x, y);
			this.button = button;
			this.press = press;
		}
		
		@Override
		public boolean isForced() { return !press; }
		public int button() { return button; }
		public boolean press() { return press; }
	}
	
	public static class Move extends MouseEvent {
		final int xMove;
		final int yMove;
		
		public Move(long window, int x, int y, int xMove, int yMove) {
			super(window, x, y);
			this.xMove = xMove;
			this.yMove = yMove;
		}
		
		public int xMove() { return xMove; }
		public int yMove() { return yMove; }
	}
	
	public static class Scroll extends MouseEvent {
		final int scrollX;
		final int scrollY;
		
		public Scroll(long window, int x, int y, int scrollX, int scrollY) {
			super(window, x, y);
			this.scrollX = scrollX;
			this.scrollY = scrollY;
		}
		
		public int scrollX() { return scrollX; }
		public int scrollY() { return scrollY; }
	}
}
