Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement 'Pan view' mouse drag mode. #1114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/basegui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6024,6 +6024,9 @@ void BaseGui::processMouseMovedDiff(QPoint diff) {
if (pref->drag_function == Preferences::MoveWindow && !pref->tablet_mode) {
moveWindowDiff(diff);
}
else if (pref->drag_function == Preferences::PanView && !pref->tablet_mode && mplayerwindow != nullptr) {
mplayerwindow->moveLayer(diff.x(), diff.y());
}
}

void BaseGui::moveWindowDiff(QPoint diff) {
Expand Down
9 changes: 7 additions & 2 deletions src/mplayerwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,13 @@ double MplayerWindow::zoom() { return zoom_factor; }
void MplayerWindow::moveLayer( int offset_x, int offset_y ) {
int x = videolayer->x();
int y = videolayer->y();

videolayer->move( x + offset_x, y + offset_y );
int nx = x + offset_x;
int ny = y + offset_y;
if (nx > 0) { nx = 0; }
if (ny > 0) { ny = 0; }
if (nx < width() - videolayer->width() && videolayer->width() > width()) { nx = width() - videolayer->width(); }
if (ny < height() - videolayer->height() && videolayer->height() > height()) { ny = height() - videolayer->height(); }
videolayer->move(nx, ny);
}

void MplayerWindow::moveLeft() {
Expand Down
2 changes: 1 addition & 1 deletion src/mplayerwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public slots:
void moveRight();
void moveUp();
void moveDown();
void moveLayer( int offset_x, int offset_y );
void incZoom();
void decZoom();

Expand All @@ -141,7 +142,6 @@ protected slots:
virtual void mouseReleaseEvent( QMouseEvent * e);
virtual void mouseDoubleClickEvent( QMouseEvent * e );
virtual void wheelEvent( QWheelEvent * e );
void moveLayer( int offset_x, int offset_y );

signals:
//void rightButtonReleased( QPoint p );
Expand Down
2 changes: 1 addition & 1 deletion src/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Preferences {
BelowNormal = 4, Idle = 5 };
enum WheelFunction { DoNothing = 1, Seeking = 2, Volume = 4, Zoom = 8,
ChangeSpeed = 16 };
enum DragFunction { DragDisabled = 0, MoveWindow = 1, Gestures = 2 };
enum DragFunction { DragDisabled = 0, MoveWindow = 1, Gestures = 2, PanView = 3 };
enum OptionState { Detect = -1, Disabled = 0, Enabled = 1 };
enum H264LoopFilter { LoopDisabled = 0, LoopEnabled = 1, LoopDisabledOnHD = 2 };
enum AutoAddToPlaylistFilter { NoFiles = 0, VideoFiles = 1, AudioFiles = 2, MultimediaFiles = 3, ConsecutiveFiles = 4 };
Expand Down
1 change: 1 addition & 0 deletions src/prefinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void PrefInput::retranslateStrings() {
drag_function_combo->clear();
drag_function_combo->addItem( tr("None"), Preferences::DragDisabled);
drag_function_combo->addItem( tr("Move window"), Preferences::MoveWindow);
drag_function_combo->addItem( tr("Pan view"), Preferences::PanView);
#ifdef MOUSE_GESTURES
drag_function_combo->addItem( tr("Seek and volume"), Preferences::Gestures);
#endif
Expand Down