void QcWaveform::mouseMoveEvent( QMouseEvent *ev ) { if( !ev->buttons() ) return; if( _dragAction == Navigate ) { Qt::KeyboardModifiers mods = ev->modifiers(); if( mods & Qt::ShiftModifier ) { double factor = pow( 2, (ev->pos().y() - _dragPoint.y()) * 0.008 ); // zoom to the initial zoom times the factor based on distance from initial position zoomTo( _dragData2 * factor ); } // scroll to the clicked frame minus the current mouse position in frames // _fpp has been adjusted by zooming scrollTo( _dragData - (ev->pos().x() * _fpp) ); } else if( _dragAction == Select ) { sf_count_t frame = qBound( 0, ev->pos().x(), width() ) * _fpp + _beg; setSelection( _curSel, _dragFrame, frame ); update(); Q_EMIT( action() ); } else if( _dragAction == MoveSelection ) { double dpos = ev->pos().x() - _dragPoint.x(); Selection &s = _selections[_curSel]; s.start = _dragFrame + (dpos * _fpp); s.start = qBound( _rangeBeg, s.start, _rangeEnd - s.size ); update(); Q_EMIT( action() ); } else if( _dragAction == MoveCursor ) { _cursorPos = qBound( 0, ev->pos().x(), width() ) * _fpp + _beg; update(); Q_EMIT( metaAction() ); } }
void QcWaveform::mousePressEvent( QMouseEvent *ev ) { _dragAction = NoDragAction; _dragPoint = ev->pos(); _dragFrame = ev->pos().x() * _fpp + _beg; Qt::KeyboardModifiers mods = ev->modifiers(); Qt::MouseButton btn = ev->button(); #ifdef Q_OS_MAC Qt::KeyboardModifier CTRL = Qt::MetaModifier; #else Qt::KeyboardModifier CTRL = Qt::ControlModifier; #endif if( btn == Qt::LeftButton ) { if( (mods & Qt::ShiftModifier) && ( mods & CTRL ) ) { _dragFrame = _selections[_curSel].start; _dragAction = MoveSelection; } else if( mods & Qt::ShiftModifier ) { _dragAction = Select; const Selection &s = _selections[_curSel]; if( _dragFrame < s.start + (s.size*0.5) ) { setSelectionStart( _curSel, _dragFrame ); _dragFrame = s.start + s.size; } else { setSelectionEnd( _curSel, _dragFrame ); _dragFrame = s.start; } Q_EMIT( action() ); } else { if( !(mods & CTRL) ) { _dragAction = Select; _selections[_curSel].start = _dragFrame; _selections[_curSel].size = 0; update(); Q_EMIT( action() ); } if( _cursorEditable ) { _cursorPos = _dragFrame; if( mods & CTRL ) _dragAction = MoveCursor; update(); Q_EMIT( metaAction() ); } } } else if( btn == Qt::RightButton ) { _dragAction = Navigate; _dragData = ev->pos().x() * _fpp + _beg; _dragData2 = zoom(); } }
//------------------------------------------------------------------------------ TextStream& operator<<(TextStream& stream, StrongType<const ObjectHandle&> value) { metaAction(value, [&](const MetaType* metaType, void* raw) { if (metaType && raw) { metaType->streamOut(stream, raw); } else { stream.setState(std::ios_base::failbit); } }); return stream; }