Logo Search packages:      
Sourcecode: tagua version File versions  Download package

void Board::onMouseMove ( const QPoint &  pos,
int  button 
) [virtual]

mouse move event

Definition at line 528 of file board.cpp.

References clearTags(), converter(), m_drag_info, m_entity, m_sprites, m_square_size, and setTags().

                                                         {
  Point point = converter()->toLogical(pos);

  if (m_drag_info) {
    Q_ASSERT(m_drag_info->sprite);
    // check drag threshold
    if (!m_drag_info->dragStarted) {
      QPoint delta = pos - m_drag_info->real;
      if (delta.x() * delta.x() + delta.y() * delta.y() > DragInfo::DRAG_THRESHOLD) {
        m_drag_info->dragStarted = true;
      }
    }
    if (m_drag_info->dragStarted)
      m_drag_info->sprite->moveTo(pos - QPoint(m_square_size / 2, m_square_size / 2) );

    // highlight valid moves
    NormalUserMove move = m_entity.lock()->createMove(m_drag_info->from,  point);
    bool valid = m_sprites.valid(point);
    if (valid) {
      InteractionType action = m_entity.lock()->validTurn(m_drag_info->from);
      if (action == Moving)
        valid = m_entity.lock()->testMove(move);
    }

    if (valid)
      setTags("validmove", point);
    else
      clearTags("validmove");
  }
  else if (m_entity.lock()->oneClickMoves()) {
    if(point == m_hinting_pos)
      return;

    AbstractPiece::Ptr hint;

    if (m_sprites.valid(point)) {
      if (AbstractMove::Ptr move = m_entity.lock()->testMove(
                              m_entity.lock()->createMove(Point::invalid(), point))) {
        // set move hint
        hint = m_entity.lock()->moveHint(move);
      }
    }

    updateHinting(point, hint);
  }
}


Generated by  Doxygen 1.6.0   Back to index