package org.academiadecodigo.enuminatti.paint.grid;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class Cursor {

    // TODO: create a dedicated rectangle for the cursor
    // TODO: create a preview rectangle for the current swatch

    private Grid grid;
    private int col;
    private int row;
    private Swatch currentSwatch;

    Cursor(Grid grid, int col, int row) {
        this.grid = grid;
        this.col = col;
        this.row = row;
        this.currentSwatch = Swatch.BLACK;
    }

    void moveDown() {
        row += (row + 1 >= grid.getRows()) ? 0 : 1;
    }

    void moveUp() {
        row = Math.max(0, row - 1);
    }

    void moveRight() {
        col += (col + 1 >= grid.getCols()) ? 0 : 1;
    }

    void moveLeft() {
        col = Math.max(0, col - 1);
    }

    public int getCol() {
        return col;
    }

    public int getRow() {
        return row;
    }

    public Position getPos() {
        return new Position(col, row);
    }

    public Swatch getCurrentSwatch() {
        return currentSwatch;
    }

    public void toggleSwatch() {
        currentSwatch = currentSwatch.getNextColor();
    }
}
