Skip to content

Commit

Permalink
release 0.8.2 use middle mouse button/mousewheel for more standard 3D…
Browse files Browse the repository at this point in the history
… navigation
  • Loading branch information
JamesMcCrae committed Dec 9, 2024
1 parent bee1251 commit f4e0a84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions include/glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class GLWidget : public QGLWidget
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);

void ResetCamera();
void UpdateCamera();
Expand Down
23 changes: 13 additions & 10 deletions src/glwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,6 @@ void GLWidget::mousePressEvent(QMouseEvent *event)
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
const bool ctrl_held = ((event->modifiers() & Qt::ControlModifier) > 0);
const bool shift_held = ((event->modifiers() & Qt::ShiftModifier) > 0);

QVector2D p(event->x(), height() - event->y());
p *= devicePixelRatio();
Expand Down Expand Up @@ -2038,21 +2037,19 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event)
break;

case STATE_ORBIT:

if (ctrl_held) {
cam.Zoom(mouse_diff);
} else if (shift_held) {
cam.Dolly(mouse_diff);
} else {
cam.Orbit(mouse_diff);
}

cam.Orbit(mouse_diff);
break;

default:
break;
}

} else if (event->buttons() & Qt::MiddleButton) {
if (ctrl_held) {
cam.Zoom(mouse_diff);
} else {
cam.Dolly(mouse_diff);
}
} else if (event->buttons() & Qt::RightButton) {
if (state == STATE_PEN_DRAG) {
active_section.MoveCtrlPointMouseRayIntersect(mouse_pos,
Expand Down Expand Up @@ -2244,6 +2241,12 @@ void GLWidget::mouseReleaseEvent(QMouseEvent *event)
// updateGL();
}

void GLWidget::wheelEvent(QWheelEvent *event) {
const float zoomFactor = 0.2f;
const QPoint angle = event->angleDelta();
cam.Zoom(QVector2D(angle.x(), angle.y()) * zoomFactor);
}

void GLWidget::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
Expand Down
5 changes: 4 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
MainWindow::MainWindow()
{
// title/window stuff
window_title = "FlatFab 0.8.1";
window_title = "FlatFab 0.8.2";
setWindowTitle(window_title);

// release 0.8.2
// use middle mouse button/mousewheel for more standard 3D navigation

// release 0.8.1
// modernize for Qt5, formatting, fix all compiler warnings

Expand Down

0 comments on commit f4e0a84

Please sign in to comment.