void QDeclarative1MouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarative1MouseArea); d->moved = false; d->stealMouse = d->preventStealing; if (!d->absorb) QDeclarativeItem::mousePressEvent(event); else { d->longPress = false; d->saveEvent(event); if (d->drag) { d->dragX = drag()->axis() & QDeclarative1Drag::XAxis; d->dragY = drag()->axis() & QDeclarative1Drag::YAxis; } if (d->drag) d->drag->setActive(false); setHovered(true); d->startScene = event->scenePos(); // we should only start timer if pressAndHold is connected to. if (d->isPressAndHoldConnected()) d->pressAndHoldTimer.start(PressAndHoldDelay, this); setKeepMouseGrab(d->stealMouse); event->setAccepted(setPressed(true)); } }
//-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(0, 0, 0); ofNoFill(); drag(segments[0], mouseX, mouseY); for(int i=1; i<numSegments; i++){ Segment* segmentA = segments[i]; Segment* segmentB = segments[i - 1]; drag(segmentA, segmentB->x, segmentB->y); } for(int i=0; i<numSegments; i++){ segments[i]->update(); } }
void IKLine::nextFrame(ci::Vec2f toPosition, float damping) { oldX += (toPosition.x - oldX) * damping; oldY += (toPosition.y - oldY) * damping; drag( _segments[0], oldX, oldY); for (int i = 1; i < segmentNum; i++) { Segment* segmentA = _segments[i]; Segment* segmentB = _segments[i-1]; drag( segmentA, segmentB->x, segmentB->y ); } }
void QSimpleDrag::move(const QMouseEvent *me) { QBasicDrag::move(me); QWindow *window = topLevelAt(me->globalPos()); if (!window) return; const QPoint pos = me->globalPos() - window->geometry().topLeft(); const QPlatformDragQtResponse qt_response = QWindowSystemInterface::handleDrag(window, drag()->mimeData(), pos, drag()->supportedActions()); updateCursor(qt_response.acceptedAction()); setCanDrop(qt_response.isAccepted()); }
void QSimpleDrag::move(const QPoint &globalPos) { //### not high-DPI aware moveShapedPixmapWindow(globalPos); QWindow *window = topLevelAt(globalPos); if (!window) return; const QPoint pos = globalPos - window->geometry().topLeft(); const QPlatformDragQtResponse qt_response = QWindowSystemInterface::handleDrag(window, drag()->mimeData(), pos, drag()->supportedActions()); updateCursor(qt_response.acceptedAction()); setCanDrop(qt_response.isAccepted()); }
void ViewWidget::mouse_left_press_event(QMouseEvent *event) { (void)event; const bool ctrl_pressed = QApplication::keyboardModifiers() & Qt::ControlModifier; // Clear selection if control is not pressed and this item is unselected if ((!mouse_down_item_ || !mouse_down_item_->selected()) && !ctrl_pressed) clear_selection(); // Set the signal selection state if the item has been clicked if (mouse_down_item_) { if (ctrl_pressed) mouse_down_item_->select(!mouse_down_item_->selected()); else mouse_down_item_->select(true); } // Save the offsets of any signals which will be dragged bool item_dragged = false; const auto items = this->items(); for (auto &i : items) if (i->selected()) { item_dragged = true; i->drag(); } // Do the background drag if (!item_dragged) drag(); selection_changed(); }
void QSimpleDrag::drop(const QMouseEvent *me) { QBasicDrag::drop(me); QWindow *window = topLevelAt(me->globalPos()); if (!window) return; const QPoint pos = me->globalPos() - window->geometry().topLeft(); const QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(window, drag()->mimeData(),pos, drag()->supportedActions()); if (response.isAccepted()) { setExecutedDropAction(response.acceptedAction()); } else { setExecutedDropAction(Qt::IgnoreAction); } }
void VHDDExplorer::OnListDrag(wxListEvent& event) { m_drop_target->SetSrcIndx(event.GetIndex()); wxDataObjectSimple obj(wxDF_PRIVATE); wxDropSource drag(obj, m_list); drag.DoDragDrop(wxDrag_AllowMove); }
bool eventFilter( QObject *o, QEvent *e ) { if ( e->type() == QEvent::MouseMove ) { if ( static_cast<QMouseEvent*>(e)->buttons() & Qt::LeftButton ) return drag( qobject_cast<Token*>(o) ); } else if ( e->type() == QEvent::MouseButtonPress ) { if ( static_cast<QMouseEvent*>(e)->buttons() & Qt::LeftButton ) { setCursor( qobject_cast<QWidget*>(o), Qt::ClosedHandCursor ); return true; // don't propagate to parents } return false; } else if ( e->type() == QEvent::MouseButtonRelease ) { if ( !( static_cast<QMouseEvent*>(e)->buttons() & Qt::LeftButton ) ) { setCursor( qobject_cast<QWidget*>(o), Qt::OpenHandCursor ); emit static_cast<TokenDropTarget*>( parent() )->focusReceived( qobject_cast<QWidget*>(o) ); return true; // don't propagate to parents } return false; } else if ( e->type() == QEvent::FocusIn ) emit static_cast<TokenDropTarget*>( parent() )->focusReceived( qobject_cast<QWidget*>(o) ); else if ( e->type() == QEvent::Hide ) { setCursor( qobject_cast<QWidget*>(o), Qt::OpenHandCursor ); return false; } return false; }
void CModViewView::OnMouseMove(UINT nFlags, CPoint point) { CView::OnMouseMove(nFlags, point); GetCursorPos(&point); if (!DraggingMouse()) { ScreenToClient(&point); g_iViewAreaMouseX = point.x; g_iViewAreaMouseY = point.y; return; } static int _i=0; // OutputDebugString(va("(%d): x:(%d) y:(%d) (dragstart: %d %d)\n",_i++,point.x,point.y, DragStartPoint.x,DragStartPoint.y)); if (drag( (mkey_enum)nFlags, point.x, point.y )) { SetCursorPos(DragStartPoint.x,DragStartPoint.y); //OutputDebugString("drag-painting\n"); Invalidate(false); //UpdateWindow(); } }
void GidaspowDrag::setForce() const { // get viscosity field #ifdef comp const volScalarField nufField = particleCloud_.turbulence().mu() / rho_; #else const volScalarField& nufField = particleCloud_.turbulence().nu(); #endif for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) { //if(mask[index][0]) //{ vector drag(0,0,0); label cellI = particleCloud_.cellIDs()[index][0]; if (cellI > -1) // particle Found { vector Us = particleCloud_.velocity(index); vector Ur = U_[cellI]-Us; scalar magUr = mag(Ur); scalar ds = 2*particleCloud_.radius(index); scalar voidfraction = particleCloud_.voidfraction(index); scalar rho = rho_[cellI]; scalar nuf = nufField[cellI]; scalar CdMagUrLag=0;//Cd of the very particle scalar KslLag; //momentum exchange of the very particle if(voidfraction > 0.8) //dilute { CdMagUrLag = (24.0*nuf/(ds*voidfraction)) *(scalar(1)+0.15*Foam::pow(ds*voidfraction*magUr/nuf, 0.687)); KslLag = 0.75*((1-voidfraction)*rho*voidfraction*CdMagUrLag /(ds*Foam::pow(voidfraction,2.65))); } else //dense { KslLag = (150*Foam::pow(1-voidfraction,2)*nuf*rho)/ (voidfraction*ds*ds+SMALL) + (1.75*(1-voidfraction) * magUr * rho)/ ((ds)); } //divide by number of particles per unit volume - Enwald (Int J Multiphase Flow, 22, 21-61, pp39 KslLag /= (particleCloud_.averagingM().UsWeightField()[cellI]/particleCloud_.mesh().V()[cellI]); drag = KslLag*Ur; if (modelType_=="B") drag /= voidfraction; } // set force on particle if(treatExplicit_) for(int j=0;j<3;j++) expForces()[index][j] += drag[j]; else for(int j=0;j<3;j++) impForces()[index][j] += drag[j]; for(int j=0;j<3;j++) DEMForces()[index][j] += drag[j]; //}// end if mask }// end loop particles }
void CCurveTextJig::doIt() { AcDbObjectId eId; if(!m_pCurvetext) return; double startDist = m_pCurvetext->getStartDist(); double length = m_pCurvetext->getLength(); m_pCurvetext->setInJig(true); // sets the input point monitor // curDoc()->inputPointManager()->addPointMonitor(&m_InputPoint); // starts the drag sequence // AcEdJig::DragStatus stat = drag(); // remove the input point monitor // curDoc()->inputPointManager()->removePointMonitor(&m_InputPoint); m_pCurvetext->setInJig(false); // if cancel, resets the orignal state // if(stat == AcEdJig::kCancel) { m_pCurvetext->setStartDist(startDist); m_pCurvetext->setLength(length); m_pCurvetext->recordGraphicsModified(); return; } }
void QtUtil :: Grid3DView :: keyReleaseEvent (QKeyEvent * e) { switch (e -> key ()) { case Qt :: Key_Shift: if (0 == m_drag_info .di && 0 == m_drag_info .dk) { m_drag_info = DragInfo (); QWidget :: keyReleaseEvent (e); update (); return; } drag (to_global (m_drag_info .di, m_drag_info .dk)); m_drag_info = DragInfo (); break; case Qt :: Key_Up: case Qt :: Key_Down: if (false == m_drag_info .dragging) { QWidget :: keyReleaseEvent (e); return; } m_drag_info .dk = 0; update (); break; case Qt :: Key_Left: case Qt :: Key_Right: if (false == m_drag_info .dragging) { QWidget :: keyReleaseEvent (e); return; } m_drag_info .di = 0; update (); break; }; e -> accept (); }
// ------------------------------------------------------------------------ // window to display an adventure map // ------------------------------------------------------------------------ void t_adventure_map_window::left_button_up( t_mouse_event const& event ) { assert( m_frame ); if (m_dragging) { drag( event.screen_point ); release_mouse(); m_dragging = false; } if (m_object_mover != 0) { halt_movement(); return; } if ( m_spell_targeter != 0 ) { m_spell_targeter->cast_spell( *this, event.client_point ); clear_spell_targeter(); return; } t_army* army = m_frame->get_selected_army(); if (army == 0) return; // otherwise, move the temporary hero. t_adventure_path_point path_point; t_adventure_path path; // abort if this is not a valid location. if (!get_path_point( event.client_point, path_point )) return; if (!(show_move_path())) { m_frame->get_path_finder()->get_path( path_point, path ); army->set_path( path ); } // check if the army has a valid path, and the path matches this point. if (army->get_destination() == path_point) { // start army moving. m_frame->start_army_moving( army ); return; } if (!m_frame->get_path_finder()->get_path( path_point, path )) { army->set_path( path ); return; } army->set_path( path ); m_map->display_path( path, army->get_movement() ); m_frame->update_buttons(); }
void QSimpleDrag::cancel() { QBasicDrag::cancel(); if (drag() && m_current_window) { QWindowSystemInterface::handleDrag(m_current_window, 0, QPoint(), Qt::IgnoreAction); m_current_window = 0; } }
void Menu::press(const Event& e) { NEEDMOTION(false) Canvas* c = canvas(); if (c != nil) { impl_->save_cursor(c); drag(e); } }
void Client::takeButtonPress( Window w, unsigned int button, bool mod1, int x, int y) { if ( w == close_button ) { awaiting_close = true; ws->painter()->setButtonBackground( close_button, Painter::CLOSE_BUTTON, active, true, button_size, button_size ); } if ( w == iconize_button ) { awaiting_iconize = true; ws->painter()->setButtonBackground( iconize_button, Painter::ICONIZE_BUTTON, active, true, button_size, button_size ); } if ( w == titlebar || w == frame ) { raise(); redraw( true, true ); if ( button == 1 && !awaiting_close && !awaiting_iconize ) drag(); } else if ( isWindow( w ) ) { if ( mod1 ) { /* mod click */ switch (button) { case 1: raise(); redraw( true, true ); drag(); break; case 2: break; case 3: raise(); redraw( true, true ); resize(); break; } } } }
void SnakeLayer::update(float dt) { if (direction == Point::ZERO) return; drag(dt); truncate(); if (testDie()) return; testPick(); }
void DropView::MouseMoved(BPoint where, uint32 code, const BMessage *msg) { // check for our drag message if (msg != NULL && msg->what == dropWhat) { // if we ain't occupied, aren't about to be and // the mouse just entered if (!hasOccupant && !occupantLoading && code == B_ENTERED_VIEW) { // you can drop that here! // give the user some visual feedback drawHighlight = true; // force redraw Invalidate(Bounds()); } else if (code == B_EXITED_VIEW) { // it left, stop highlighting drawHighlight = false; // force redraw Invalidate(Bounds()); } } else if (msg != NULL && msg->what == JE_CONTAINER_VIEW_DND && isDragging) { // this is a drag initiated by us // if the mouse is leaving the view, then our occupant // is being removed if (code == B_EXITED_VIEW) { // tell the main window our plugin is gone ((MainWindow *)Window())->UnloadPlugin(piType,id); ToggleOccupant(false); } } else if (trackingMouse) { // we're tracking the mouse after it clicked on us float dx = where.x - mouseDownPt.x; // delta x float dy = where.y - mouseDownPt.y; // delta y float dp = (float)sqrt((dx*dx)+(dy*dy)); // delta magnitude // if the mouse has moved futher than 5 pixels in any direction if (dp > 5.0) { // initiate a drag BMessage drag(JE_CONTAINER_VIEW_DND); DragMessage(&drag, new BBitmap(iconBitmap), B_OP_OVER, BPoint(where.x-2.0, where.y-2.0)); // stop tracking the mouse trackingMouse = false; // our occupant is being dragged isDragging = true; } } }
void TunnelDragJig::doIt() { setDispPrompt( _T( "\n指定基点:" ) ); if( kNormal != acquirePoint( basePt ) ) return; if( kNormal == drag() ) { CopyBack( m_pWS, m_objId ); } }
void GoafDragJig::doIt() { setDispPrompt( _T( "\nÖ¸¶¨»ùµã£º" ) ); if( kNormal != acquirePoint( basePt ) ) return; if( kNormal == drag() ) { CopyBack( m_pGoaf, m_objId ); } }
void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response) { setCanDrop(response.isAccepted()); if (canDrop()) { updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers())); } else { updateCursor(Qt::IgnoreAction); } }
void QWaylandDrag::updateTarget(const QString &mimeType) { setCanDrop(!mimeType.isEmpty()); if (canDrop()) { updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers())); } else { updateCursor(Qt::IgnoreAction); } }
void IDBTabButtonBarButton::mouseMoveEvent(QMouseEvent *event) { int newX = event->screenPos().x()+mouseOffset_; // IDBTabButtonBarList *list = qobject_cast<IDBTabButtonBarList *>(parentWidget()); if (event->pos().y() > -20 && event->pos().y() < HEIGHT_DEFULT+20 && newX > -WIDTH_DEFULT && newX < parentWindow_->width() - 200 ) { move(newX,0); int newTabIndex = (newX+WIDTH_DEFULT/2)/WIDTH_DEFULT; parentWindow_->moveButton(tabIndex_,newTabIndex); }else{ parentWindow_->removeButton(tabIndex_); QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); QString tabName = text(); dataStream << tabName; QMimeData *mimeData = new QMimeData(); mimeData->setData("tab/x-idblayoutwindow-idbtab", itemData); QPixmap pixmap(300,200); pixmap.fill( Qt::black ); QPainter painter(&pixmap); painter.setPen( Qt::gray ); painter.fillRect(QRectF(20,0,200,25),Qt::gray); painter.drawRect(0,0,299,199); painter.setPen( Qt::black ); QPoint point = QPoint( 30, 15 ); painter.drawText( point, tabName ); IDBDrag drag(this); drag.setMimeData(mimeData); drag.setHotSpot(QPoint(0, 0)); drag.setPixmap(pixmap); QPixmap cursorPixmap(1,1); cursorPixmap.fill(); drag.setDragCursor(cursorPixmap,Qt::IgnoreAction); switch (drag.exec(Qt::MoveAction)) { case Qt::MoveAction: mouseOffset_ = 0; moveByIndex(); break; case Qt::IgnoreAction: mouseOffset_ = 0; IDBLayoutManager::instance().createWindow(this); break; default: break; } IDBLayoutManager::instance().tryCloseWindow(); } }
void Ctrl3DRotate::drag(int x, int y, float *mout){ drag(x,y); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); //glRotatef(mssh.angle_r, mssh.norm_rx, mssh.norm_ry, mssh.norm_rz) glRotatef(angle_r, norm_rx, norm_ry, norm_rz); glMultMatrixf(m); glGetFloatv(GL_MODELVIEW_MATRIX,mout); glPopMatrix(); }
void rocket::update() { calcmass(); for (int i = 0; i < parts.size(); i++) { parts[i]->update(); } gravity(); drag(); pos += vel * DELTATIME; collision(); time += DELTATIME; }
void QWaylandDrag::startDrag() { if (!shapedPixmapWindow()) { QBasicDrag::startDrag(); QBasicDrag::cancel(); } QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle()); m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon); QBasicDrag::startDrag(); }
NotationSelector::FollowMode NotationSelector::handleMouseMove(const NotationMouseEvent *e) { if (!m_updateRect) return NoFollow; // std::cout << "NotationSelector::handleMouseMove: staff is " // << m_selectedStaff << ", m_updateRect is " << m_updateRect // << std::endl; if (!m_selectedStaff) m_selectedStaff = e->staff; int w = int(e->sceneX - m_selectionRect->x()); int h = int(e->sceneY - m_selectionRect->y()); NOTATION_DEBUG << "NotationSelector::handleMouseMove: w: " << w << " h: " << h << endl; if (m_clickedElement /* && !m_clickedElement->isRest() */) { // Fine (micro-position) drag is BROKEN, and I'm bypassing its mangled corpse. // if (m_startedFineDrag) { // dragFine(e->sceneX, e->sceneY, false); // } else if (m_clickedShift) { // if (w > 2 || w < -2 || h > 2 || h < -2) { // dragFine(e->sceneX, e->sceneY, false); // } // } else if ((w > 3 || w < -3 || h > 3 || h < -3) && !m_clickedShift) { // std::cout << "Dragging from Code Point Bravo: w: " << w << " h: " << h << std::endl; drag(e->sceneX, e->sceneY, false); } } else { // Qt rectangle dimensions appear to be 1-based if (w > 0) ++w; else --w; if (h > 0) ++h; else --h; QPointF p0(m_selectionOrigin); QPointF p1(e->sceneX, e->sceneY); QRectF r = QRectF(p0, p1).normalized(); m_selectionRect->setRect(r.x() + 0.5, r.y() + 0.5, r.width(), r.height()); m_selectionRect->show(); setViewCurrentSelection(true); } return FollowMode(FollowHorizontal | FollowVertical); }
void move(Client *c, int but) { if(c == 0) return; if(drag(c, but) == 0) return; active(c); top(c); XRaiseWindow(dpy, c->parent); XMoveWindow(dpy, c->parent, c->x-BORDER, c->y-BORDER); sendconfig(c); }
int QDeclarativeMouseArea::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDeclarativeItem::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 16) qt_static_metacall(this, _c, _id, _a); _id -= 16; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = mouseX(); break; case 1: *reinterpret_cast< qreal*>(_v) = mouseY(); break; case 2: *reinterpret_cast< bool*>(_v) = hovered(); break; case 3: *reinterpret_cast< bool*>(_v) = pressed(); break; case 4: *reinterpret_cast< bool*>(_v) = isEnabled(); break; case 5: *reinterpret_cast< Qt::MouseButtons*>(_v) = pressedButtons(); break; case 6: *reinterpret_cast< Qt::MouseButtons*>(_v) = acceptedButtons(); break; case 7: *reinterpret_cast< bool*>(_v) = hoverEnabled(); break; case 8: *reinterpret_cast< QDeclarativeDrag**>(_v) = drag(); break; case 9: *reinterpret_cast< bool*>(_v) = preventStealing(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 4: setEnabled(*reinterpret_cast< bool*>(_v)); break; case 6: setAcceptedButtons(*reinterpret_cast< Qt::MouseButtons*>(_v)); break; case 7: setHoverEnabled(*reinterpret_cast< bool*>(_v)); break; case 9: setPreventStealing(*reinterpret_cast< bool*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }