コード例 #1
0
// ******************************************************************
//
// FUNCTIONS
void GridDisplay::midiXYEvent(unsigned char xaxis, unsigned char yaxis) 
{
	int x = (int)(xaxis / 128.0 * grid_->getWidth());
	int y = grid_->getHeight() - 1 - (int)(yaxis / 128.0 * grid_->getHeight());

	std::cout << "midi xy event (" << x << "," << y << ")\n";
	updateXYPosition(x, y);
	playNextTrack();
}
コード例 #2
0
void GridDisplay::mousePressEvent(QMouseEvent *event) 
{
	std::cout << "mouse Press Event" << std::endl;

	if(fullScreenMouseOn)
	{
		QRect screenSize = (QApplication::desktop())->screenGeometry();
		int gridX = mouseCursor->pos().x() / (screenSize.width() / (grid_->getWidth() - 1));
		int gridY = mouseCursor->pos().y() / (screenSize.height() / (grid_->getHeight() - 1));

		if(lastMousePoint != mouseCursor->pos())updateXYPosition(gridX, gridY);
		lastMousePoint = mouseCursor->pos();

		if(grid_->getXPos() != oldXPos || oldYPos != grid_->getYPos()  ) 
		{
			oldXPos = grid_->getXPos();
			oldYPos = grid_->getYPos();
		}
	}
	else
	{
		if(lastMousePoint != mouseCursor->pos()){
		updateXYPosition(event->pos().x() / _cellSize, event->pos().y() / _cellSize);
		}
		lastMousePoint = mouseCursor->pos();
		if(!initDone)
		{
			int k = grid_->getYPos() * grid_->getHeight() + grid_->getXPos();
			if(squareHasInitialized[k])
			{
				squareHasInitialized[k] = false;
				grid_->removeInitFile();
			}			
		}
	}
	playNextTrack();
	repaint();
}
コード例 #3
0
void GridDisplay::mouseMoveEvent(QMouseEvent *event) 
{

	if ( (event->pos().x() >= _winSize) || (event->pos().y() >= _winSize) ) {
		return;
	}
	QToolTip::hideText();
	updateXYPosition(event->pos().x() / _cellSize, event->pos().y() / _cellSize);
	lastMousePoint = mouseCursor->pos();


	if(grid_->isContinuous() && (grid_->getXPos() != oldXPos || oldYPos != grid_->getYPos() ) ) 
	{
		playNextTrack();
		oldXPos = grid_->getXPos();
		oldYPos = grid_->getYPos();
	}
 	emit updateColourMap(grid_->getDensity(grid_->getCurrentIndex()), 10);
	repaint();
}
コード例 #4
0
void GridDisplay::fullScreenMouseMove()
{
	QRect screenSize = (QApplication::desktop())->screenGeometry();

	// map mouse position on screen to a grid location
	int gridX = qRound(mouseCursor->pos().x() / (screenSize.width() / ((float)grid_->getWidth() - 0.5)));
	int gridY = qRound(mouseCursor->pos().y() / (screenSize.height() / ((float)grid_->getHeight() - 0.5)));

	if(lastMousePoint != mouseCursor->pos())updateXYPosition(gridX, gridY);
	lastMousePoint = mouseCursor->pos();
	
	if(grid_->getXPos() != oldXPos || oldYPos != grid_->getYPos()  ) 
	{
		
		playNextTrack();
		oldXPos = grid_->getXPos();
		oldYPos = grid_->getYPos();
		repaint();
	}
}
コード例 #5
0
ファイル: Keypad.cpp プロジェクト: BitMax/marsyas
void Keypad::mousePressEvent(QMouseEvent *event) {
  updateXYPosition(event->pos().x(), event->pos().y());

  //if center square is clicked then move to square 1
  //or if it the root then do nothing
  //Go up the tree
  if ( _currentIndex == 4 ) {
    KeypadSquare *parent = _current->getParent();
    if ( parent ) {
      _currentIndex = parent->getChildId(_current);
      _current = parent;
    }
    //Go down the tree
  } else {
    KeypadSquare *child = _current->getChild(_currentIndex);
    if ( !child ) {
      child = _current->createChild(_currentIndex);
    }
    _current = child;
    _currentIndex = KEYPAD4;
  }
  repaint();
}
コード例 #6
0
ファイル: Keypad.cpp プロジェクト: BitMax/marsyas
void Keypad::mouseMoveEvent(QMouseEvent *event) {
  updateXYPosition(event->pos().x(), event->pos().y());
  repaint();
}
コード例 #7
0
void GridDisplay::keyMove(QKeyEvent *keyEvent)
{

  int gridX = grid_->getXPos();
  int gridY = grid_->getYPos();
  bool reachedEdge;

 // cout<<"GridDisplay::keyMove grid x, y: "<<gridX<<", "<<gridY<<endl;

  // Up key pressed
  if (keyEvent->key() == Qt::Key_Up) {
	gridY -= 1;
	if (gridY < 0) {
		reachedEdge = true;
		QApplication::beep();
	  //gridY = grid_->getHeight() - 1;
		
	  gridY = 0;
	}else reachedEdge = false;
  }

  // Down key pressed
  if (keyEvent->key() == Qt::Key_Down) {
	gridY += 1;
	if (gridY > grid_->getHeight() - 1) {
		reachedEdge = true;
		QApplication::beep();
	 // gridY = 0;
	  gridY = getHeight() - 1;
	}else reachedEdge = false;
  }

  // Left key pressed
  if (keyEvent->key() == Qt::Key_Left) {
    gridX -= 1;
    if (gridX < 0) {
		reachedEdge = true;
		QApplication::beep();
      //gridX = grid_->getHeight() - 1;
	  gridX = 0;
    }else reachedEdge = false;
  }

  // Right key pressed
  if (keyEvent->key() == Qt::Key_Right) {
    gridX += 1;                         
    if (gridX > grid_->getWidth() - 1) {
		reachedEdge = true;
		QApplication::beep();
      //gridX = 0;
	  gridX = grid_->getWidth()-1;
	}else reachedEdge = false;
  }

  // "q" key pressed - Go to the top left grid point
  if (keyEvent->key() == 81) {
	  reachedEdge = false;
	gridX = 0;
	gridY = 0;
  }

  // "w" key pressed - Go to the top right grid point
  if (keyEvent->key() == 87) {
	  reachedEdge = false;
	gridX = grid_->getWidth() - 1;
	gridY = 0;
  }

  // "a" key pressed - Go to the bottom left grid point
  if (keyEvent->key() == 65) {
	  reachedEdge = false;
	gridX = 0;
	gridY = grid_->getHeight() - 1;
  }

  // "s" key pressed - Go to the bottom right grid point
  if (keyEvent->key() == 83) {
	  reachedEdge = false;
	gridX = grid_->getWidth() - 1;;
	gridY = grid_->getHeight() - 1;
  }

  // "x" key pressed - Go to the center grid point
  if (keyEvent->key() == 88) {
	  reachedEdge = false;
	gridX = (grid_->getWidth() - 1) / 2;
	gridY = (grid_->getHeight() - 1) / 2;
  }


  if(!reachedEdge && keyEvent->key() != Qt::Key_Shift)
  {
	updateXYPosition(gridX, gridY);

  playNextTrack();
  oldXPos = grid_->getXPos();
  oldYPos = grid_->getYPos();
  repaint();
  }else if(keyEvent->key() == Qt::Key_Shift){
	  playNextTrack();
  }


}