MCPcopy Create free account
hub / github.com/IENT/YUView / mouseMoveEvent

Method mouseMoveEvent

YUViewLib/src/ui/views/MoveAndZoomableView.cpp:295–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295void MoveAndZoomableView::mouseMoveEvent(QMouseEvent *mouse_event)
296{
297 if (mouse_event->source() == Qt::MouseEventSynthesizedBySystem &&
298 (this->viewAction == ViewAction::PINCHING || this->viewAction == ViewAction::DRAGGING_TOUCH))
299 {
300 DEBUG_VIEW("MoveAndZoomableView::mouseMoveEvent ignore system generated touch event");
301 mouse_event->ignore();
302 return;
303 }
304
305 if (mouse_event->buttons() == Qt::NoButton)
306 {
307 // The mouse is moved, but no button is pressed. This should not be caught here. Maybe a mouse
308 // press/release event got lost somewhere. In this case go to the normal mode.
309 if (this->viewAction == ViewAction::DRAGGING ||
310 this->viewAction == ViewAction::DRAGGING_MOUSE_MOVED ||
311 this->viewAction == ViewAction::ZOOM_RECT)
312 {
313 DEBUG_VIEW("MoveAndZoomableView::mouseMoveEvent no Button - abort any action");
314 this->viewAction = ViewAction::NONE;
315 }
316 }
317
318 if (this->viewAction == ViewAction::DRAGGING ||
319 this->viewAction == ViewAction::DRAGGING_MOUSE_MOVED)
320 {
321 // Calculate the new offset from the center position
322 this->setMoveOffset(viewDraggingStartOffset +
323 (mouse_event->pos() - this->viewDraggingMousePosStart));
324
325 if (this->viewAction == ViewAction::DRAGGING)
326 {
327 auto mouseMoved = viewDraggingMousePosStart - mouse_event->pos();
328 if (mouseMoved.manhattanLength() > 3)
329 {
330 this->viewAction = ViewAction::DRAGGING_MOUSE_MOVED;
331 DEBUG_VIEW("MoveAndZoomableView::mouseMoveEvent mouse was moved > 3 pxixels");
332 }
333 }
334
335 DEBUG_VIEW("MoveAndZoomableView::mouseMoveEvent dragging pos " << mouse_event->pos());
336 mouse_event->accept();
337 this->update();
338 }
339 else if (this->viewAction == ViewAction::ZOOM_RECT)
340 {
341 this->viewZoomingMousePos = mouse_event->pos();
342 DEBUG_VIEW("MoveAndZoomableView::mouseMoveEvent zooming pos " << viewZoomingMousePos);
343 mouse_event->accept();
344 this->update();
345 }
346 else
347 this->updateMouseCursor(mouse_event->pos());
348}
349
350void MoveAndZoomableView::mousePressEvent(QMouseEvent *mouse_event)
351{

Callers

nothing calls this directly

Calls 4

setMoveOffsetMethod · 0.95
updateMethod · 0.95
updateMouseCursorMethod · 0.95
posMethod · 0.80

Tested by

no test coverage detected