feat(editor): zooming in/out (kind of) via mouse wheel

This commit is contained in:
maelstrom 2025-04-08 01:15:30 +02:00
parent 530789f0b3
commit 7a160cdde8
3 changed files with 8 additions and 3 deletions

View file

@ -212,9 +212,7 @@ void MainGLWidget::handleLinearTransform(QMouseEvent* evt) {
// Apply snapping in the current frame
glm::vec3 diff = centerPoint - (glm::vec3)editorToolHandles->adornee->lock()->position();
// printf("\n=======\nPre-snap: (%f, %f, %f)\n", diff.x, diff.y, diff.z);
if (snappingFactor()) diff = frame.Rotation() * (glm::round(glm::vec3(frame.Inverse().Rotation() * diff) / snappingFactor()) * snappingFactor());
// printf("Post-snap: (%f, %f, %f)\n", diff.x, diff.y, diff.z);
Data::Vector3 oldSize = part->size;
@ -318,6 +316,13 @@ void MainGLWidget::handleCursorChange(QMouseEvent* evt) {
setCursor(Qt::ArrowCursor);
}
void MainGLWidget::wheelEvent(QWheelEvent* evt) {
camera.processMovement(evt->angleDelta().y() < 0 ? DIRECTION_BACKWARDS : DIRECTION_FORWARD, 0.25f);
if (mainWindow()->editSoundEffects && QFile::exists("./assets/excluded/SWITCH3.wav"))
QSound::play("./assets/excluded/SWITCH3.wav");
}
void MainGLWidget::mouseMoveEvent(QMouseEvent* evt) {
handleCameraRotate(evt);
handleObjectDrag(evt);

View file

@ -28,6 +28,7 @@ protected:
void handleCursorChange(QMouseEvent* evt);
std::optional<HandleFace> raycastHandle(glm::vec3 pointDir);
void wheelEvent(QWheelEvent* evt) override;
void mouseMoveEvent(QMouseEvent* evt) override;
void mousePressEvent(QMouseEvent* evt) override;
void mouseReleaseEvent(QMouseEvent* evt) override;

View file

@ -131,7 +131,6 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->actionToggleEditSounds, &QAction::triggered, this, [&](bool state) {
editSoundEffects = state;
printf("%d\n", editSoundEffects);
ui->actionToggleEditSounds->setIcon(QIcon::fromTheme(editSoundEffects ? "audio-volume-high" : "audio-volume-muted"));
});
ui->actionToggleEditSounds->setChecked(true);