From ef9c4c73c3ced82fc57deee6549995f55889abf3 Mon Sep 17 00:00:00 2001 From: BigBahss Date: Tue, 13 Oct 2020 10:14:16 -0400 Subject: [PATCH] Remove scrollArea surrounding graphicsView_Map --- forms/mainwindow.ui | 134 +++++++------------------------------------- src/editor.cpp | 28 ++------- src/mainwindow.cpp | 1 - 3 files changed, 25 insertions(+), 138 deletions(-) diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 3e7535e5..e79eebd8 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -350,129 +350,37 @@ 0 - + - 1 + 0 0 + + false + + + false + - Qt::ScrollBarAlwaysOff + Qt::ScrollBarAsNeeded - Qt::ScrollBarAlwaysOff + Qt::ScrollBarAsNeeded - - true + + QAbstractScrollArea::AdjustIgnored + + + QGraphicsView::NoDrag + + + QGraphicsView::AnchorUnderMouse + + + QGraphicsView::AnchorUnderMouse - - - - 0 - 0 - 543 - 600 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 166 - 16 - - - - - - - - Qt::Horizontal - - - - 166 - 16 - - - - - - - - Qt::Vertical - - - - 16 - 166 - - - - - - - - - 0 - 0 - - - - false - - - false - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAsNeeded - - - QAbstractScrollArea::AdjustIgnored - - - QGraphicsView::NoDrag - - - - - - - Qt::Vertical - - - - 16 - 166 - - - - - - diff --git a/src/editor.cpp b/src/editor.cpp index 9b052982..2652c4e6 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -898,33 +898,13 @@ void Editor::scaleMapView(int s) { if ((scale_exp + s) <= 5 && (scale_exp + s) >= -2) // sane limits { if (s == 0) - s = -scale_exp; - - scale_exp += s; - - double base = scale_base; - double exp = scale_exp; - double sfactor = pow(base, s); - - const auto mapAnchor = ui->graphicsView_Map->transformationAnchor(); - const auto connectionsAnchor = ui->graphicsView_Connections->transformationAnchor(); - ui->graphicsView_Map->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - ui->graphicsView_Connections->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + scale_exp = 0; + else + scale_exp += s; + double sfactor = pow(scale_base, s); ui->graphicsView_Map->scale(sfactor, sfactor); ui->graphicsView_Connections->scale(sfactor, sfactor); - - int width = static_cast(ceil((scene->width()) * pow(base, exp))) + 2; - int height = static_cast(ceil((scene->height()) * pow(base, exp))) + 2; - QSize viewSize = ui->scrollAreaWidgetContents_5->size(); - int minWidth = qMin(width, viewSize.width()); - int minHeight = qMin(height, viewSize.height()); - - ui->graphicsView_Map->setFixedSize(minWidth, minHeight); - ui->graphicsView_Connections->setFixedSize(minWidth, minHeight); - - ui->graphicsView_Map->setTransformationAnchor(mapAnchor); - ui->graphicsView_Connections->setTransformationAnchor(connectionsAnchor); } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 394e58d8..38f51b9d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -563,7 +563,6 @@ void MainWindow::refreshMapScene() ui->graphicsView_Map->setScene(editor->scene); ui->graphicsView_Map->setSceneRect(editor->scene->sceneRect()); - ui->graphicsView_Map->setFixedSize(width, height); ui->graphicsView_Map->editor = editor; ui->graphicsView_Connections->setScene(editor->scene);