
void mousePressed() {
  if (!draggingAsset) {
    if (mouseButton == CENTER) {
      if (!zoomedState && scaleFactor == 1.0) {
        zoom(3);
      } else {
        reset();
      }
      zoomedState = !zoomedState;
    } else if (mouseButton == RIGHT) {
      for (int i=0; i < activeMarkers; i++) {
        if (marker[i].hover()) {
          marker[i].rightClicked();
        }
      }
    } else if (mouseButton == LEFT) {
      for (int i=0; i < activeMarkers; i++) {
        if (marker[i].hover()) {
          marker[i].leftClicked();
        }
      }
    }
  }
}

void mouseClicked(MouseEvent evt) {
  if (evt.getCount() == 2) {
    draggingAsset = false;
    for (int i=0; i < activeMarkers; i++) {
      if (marker[i].hover()) {
        marker[i].drag = false;
        marker[i].locked = !marker[i].locked;
      }
    }
  }
}

void mouseReleased() {
  if (draggingAsset) {
    draggingAsset = false;
    marker[clickedMarkerID].drag = false;
  }
}

void mouseDragged(MouseEvent e) {
  if (zoomedState  && !draggingAsset) {
    translateX += mouseX - pmouseX;
    translateY += mouseY - pmouseY;
    collisionDetection();
  } else if (draggingAsset) {
    marker[clickedMarkerID].canvasPosX = viewX - marker[clickedMarkerID].canvasImgW/2;
    marker[clickedMarkerID].canvasPosY = viewY - marker[clickedMarkerID].canvasImgH/2;
  }
}

void mouseWheel(MouseEvent e) {
  float factor = e.getCount() > 0 ? 1.0/1.05 : e.getCount() < 0 ? 1.05 : 1.0;
  if (!draggingAsset) {
    zoom(factor);
    zoomedState = true;
    if (scaleFactor <= 1.0 &&  e.getCount() > 0) {
      reset();
    }
  } else {
    marker[clickedMarkerID].canvasPosX += marker[clickedMarkerID].canvasImgW/2;
    marker[clickedMarkerID].canvasImgW *= factor;
    marker[clickedMarkerID].canvasPosX -= marker[clickedMarkerID].canvasImgW/2;
    marker[clickedMarkerID].canvasPosY += marker[clickedMarkerID].canvasImgH/2;
    marker[clickedMarkerID].canvasImgH *= factor;
    marker[clickedMarkerID].canvasPosY -= marker[clickedMarkerID].canvasImgH/2;
  }
}

void keyPressed() {
  if (draggingAsset) {
    if (key == DELETE) {
      marker[clickedMarkerID].kill();
    }
  }
  if (key == 's') {
    save_gse();
    println("Saved");
  }
  if (key == ENTER){
    //+ frame.setSize
   // fullScreen();
  }
}