Skip to content

Commit

Permalink
Don't prevent horizontal scroll in follow mode (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
variar committed Apr 27, 2021
1 parent 8e26da8 commit 3e7a413
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/ui/src/abstractlogview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ void AbstractLogView::mousePressEvent( QMouseEvent* mouseEvent )

const auto filePos = convertCoordToFilePos( mouseEvent->pos() );

if ( line.has_value() && !selection_.isPortionSelected( *line, filePos.x(), filePos.x() ) ) {
if ( line.has_value()
&& !selection_.isPortionSelected( *line, filePos.x(), filePos.x() ) ) {
selection_.selectLine( *line );
emit updateLineNumber( *line );
textAreaCache_.invalid_ = true;
Expand Down Expand Up @@ -669,6 +670,22 @@ void AbstractLogView::wheelEvent( QWheelEvent* wheelEvent )
{
emit activity();

int y_delta = 0;
auto pixel_delta = wheelEvent->pixelDelta();

if ( pixel_delta.isNull() ) {
y_delta = static_cast<int>(
std::floor( static_cast<float>( wheelEvent->angleDelta().y() ) / 0.7f ) );
}
else {
y_delta = pixel_delta.y();
}

if (y_delta == 0) {
QAbstractScrollArea::wheelEvent( wheelEvent );
return;
}

// LOG_DEBUG << "wheelEvent";

// This is to handle the case where follow mode is on, but the user
Expand All @@ -683,17 +700,6 @@ void AbstractLogView::wheelEvent( QWheelEvent* wheelEvent )
else if ( wheelEvent->phase() == Qt::ScrollEnd )
followElasticHook_.release();

int y_delta = 0;
auto pixel_delta = wheelEvent->pixelDelta();

if ( pixel_delta.isNull() ) {
y_delta = static_cast<int>(
std::floor( static_cast<float>( wheelEvent->angleDelta().y() ) / 0.7f ) );
}
else {
y_delta = pixel_delta.y();
}

// LOG_DEBUG << "Elastic " << y_delta;
followElasticHook_.move( -y_delta );
}
Expand Down

0 comments on commit 3e7a413

Please sign in to comment.