EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) : EDIT_CONSTRAINT<EDIT_LINE>( aLine ), m_colinearConstraint( NULL ), m_editPoints( aPoints ) { // Dragged segment endings EDIT_POINT& origin = aLine.GetOrigin(); EDIT_POINT& end = aLine.GetEnd(); // Previous and next points, to make constraining lines (adjacent to the dragged line) EDIT_POINT& prevOrigin = *aPoints.Previous( origin, false ); EDIT_POINT& nextEnd = *aPoints.Next( end, false ); // Constraints for segments adjacent to the dragged one m_originSideConstraint = new EC_LINE( origin, prevOrigin ); m_endSideConstraint = new EC_LINE( end, nextEnd ); // Store the current vector of the line m_draggedVector = end.GetPosition() - origin.GetPosition(); // Check for colinearity SEG originSide( origin.GetPosition(), prevOrigin.GetPosition() ); SEG endSide( end.GetPosition(), nextEnd.GetPosition() ); SEG dragged( origin.GetPosition(), end.GetPosition() ); if( dragged.Collinear( originSide ) ) m_colinearConstraint = m_originSideConstraint; else if( dragged.Collinear( endSide ) ) m_colinearConstraint = m_endSideConstraint; }
bool ListBoxDnd::mouseMoveEvent( QMouseEvent * event ) { if ( event->state() & LeftButton ) { if ( ( event->pos() - mousePressPos ).manhattanLength() > 3 ) { ListBoxItemList list; buildList( list ); ListBoxItemDrag * dragobject = new ListBoxItemDrag( list, (dMode & Internal), (QListBox *) src ); // Emit signal for all dragged items QListBoxItem * i = list.first(); while ( i ) { emit dragged( i ); i = list.next(); } if ( dMode & Move ) { removeList( list ); // "hide" items } dragobject->dragCopy(); if ( dMode & Move ) { if ( dropConfirmed ) { // ###FIX: memleak ? in internal mode, only pointers are transfered... //list.setAutoDelete( TRUE ); list.clear(); dropConfirmed = FALSE; } insertList( list ); // "show" items } } } return FALSE; }
Diamond* KDiamond::Board::spawnDiamond(int color) { Diamond* diamond = new Diamond((KDiamond::Color) color, m_renderer, this); connect(diamond, SIGNAL(clicked()), SLOT(slotClicked())); connect(diamond, SIGNAL(dragged(QPoint)), SLOT(slotDragged(QPoint))); return diamond; }
//--------------------------------------------------------------------------- // // The user clicked on the widget // void AmorWidget::mouseReleaseEvent(TQMouseEvent *me) { if ( dragging ) emit dragged( me->globalPos() - clickPos, true ); else if ( me->state() == Qt::RightButton ) emit mouseClicked(clickPos); clickPos = TQPoint(); dragging = false; }
void ThumbnailWidget::mouseMoveEvent(QGraphicsSceneMouseEvent * event) { if(!(event->buttons() & Qt::LeftButton)) return; if((event->scenePos() - drag_start_pos_).manhattanLength() < QApplication::startDragDistance()) return; drag_progress_ = true; emit dragged(this, event->scenePos()); }
//--------------------------------------------------------------------------- // // The user moved the mouse // void AmorWidget::mouseMoveEvent(TQMouseEvent *me) { if ( me->state() == Qt::LeftButton ) { if ( !dragging && (clickPos-me->globalPos()).manhattanLength() > 3 ) dragging = true; if ( dragging ) { emit dragged( me->globalPos() - clickPos, false ); clickPos = me->globalPos(); } } }
void MovableWidget::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::LeftButton && isMousePressed) { QPoint newPos = event->globalPos() - dragPosition; move(newPos); event->accept(); emit dragged(newPos); return; } QWidget::mouseMoveEvent(event); }
void EC_CONVERGING::Apply( EDIT_LINE& aHandle ) { // The dragged segment endpoints EDIT_POINT& origin = aHandle.GetOrigin(); EDIT_POINT& end = aHandle.GetEnd(); if( m_colinearConstraint ) { m_colinearConstraint->Apply( origin ); m_colinearConstraint->Apply( end ); } // The dragged segment SEG dragged( origin.GetPosition(), origin.GetPosition() + m_draggedVector ); // Do not allow points on the adjacent segments move freely m_originSideConstraint->Apply(); m_endSideConstraint->Apply(); EDIT_POINT& prevOrigin = *m_editPoints.Previous( origin, false ); EDIT_POINT& nextEnd = *m_editPoints.Next( end, false ); // Two segments adjacent to the dragged segment SEG originSide = SEG( origin.GetPosition(), prevOrigin.GetPosition() ); SEG endSide = SEG( end.GetPosition(), nextEnd.GetPosition() ); // First intersection point (dragged segment against origin side) if( OPT_VECTOR2I originIntersect = dragged.IntersectLines( originSide ) ) origin.SetPosition( *originIntersect ); // Second intersection point (dragged segment against end side) if( OPT_VECTOR2I endIntersect = dragged.IntersectLines( endSide ) ) end.SetPosition( *endIntersect ); // Check if adjacent segments intersect (did we dragged the line to the point that it may // create a selfintersecting polygon?) originSide = SEG( origin.GetPosition(), prevOrigin.GetPosition() ); endSide = SEG( end.GetPosition(), nextEnd.GetPosition() ); if( OPT_VECTOR2I originEndIntersect = endSide.Intersect( originSide ) ) { origin.SetPosition( *originEndIntersect ); end.SetPosition( *originEndIntersect ); } }
//------------------------------------------------ void TravelingCam::touchMoved(ofTouchEventArgs & touch) { dragged(touch.x, touch.y, 0); }
//------------------------------------------------ void TravelingCam::mouseDragged(ofMouseEventArgs& args) { dragged(args.x, args.y, args.button); }
void DragWidget::mouseMoveEvent(QMouseEvent *event) { int x = event->globalPos().x() - _clickXCoordinate; int y = event->globalPos().y() - _clickYCoordinate; emit dragged(x, y); }