From 39ccd56eef53a4c42badf47909ab31c94ef7f633 Mon Sep 17 00:00:00 2001 From: baydam Date: Wed, 3 Feb 2016 00:40:12 +0000 Subject: [PATCH] Fix: #197 Put the zoom toolbar in the bottom-right corner --- MM.h | 2 ++ MainWindow.cpp | 4 ++++ MapperGLCanvas.cpp | 23 +++++++++++++++-------- MapperGLCanvas.h | 2 ++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/MM.h b/MM.h index 754a86a..daf3f4e 100644 --- a/MM.h +++ b/MM.h @@ -47,6 +47,8 @@ public: static const int DEFAULT_WINDOW_HEIGHT = 480; static const int TOP_TOOLBAR_ICON_SIZE = 48; static const int BOTTOM_TOOLBAR_ICON_SIZE = 32; + static const int ZOOM_TOOLBAR_ICON_SIZE = 22; + static const int ZOOM_TOOLBAR_BUTTON_SIZE = 32; // Style. static const QColor WHITE; diff --git a/MainWindow.cpp b/MainWindow.cpp index 74a3bcf..0f069c2 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -2522,6 +2522,10 @@ void MainWindow::updateCanvases() sourceCanvas->update(); destinationCanvas->update(); outputWindow->getCanvas()->update(); + + // Update position of zoom toolbar + sourceCanvas->moveZoomToolbar(canvasSplitter->widget(0)->rect()); + destinationCanvas->moveZoomToolbar(canvasSplitter->widget(1)->rect()); } diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index eb9c2c0..8e9169e 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -133,33 +133,33 @@ void MapperGLCanvas::createZoomToolsLayout() // Zoom In button _zoomInButton = new QPushButton; _zoomInButton->setIcon(QIcon(":/zoom-in")); - _zoomInButton->setIconSize(QSize(22, 22)); + _zoomInButton->setIconSize(QSize(MM::ZOOM_TOOLBAR_ICON_SIZE, MM::ZOOM_TOOLBAR_ICON_SIZE)); _zoomInButton->setToolTip(tr("Enlarge the shape")); - _zoomInButton->setFixedSize(32, 32); + _zoomInButton->setFixedSize(MM::ZOOM_TOOLBAR_BUTTON_SIZE, MM::ZOOM_TOOLBAR_BUTTON_SIZE); _zoomInButton->setObjectName("zoom-in"); connect(_zoomInButton, SIGNAL(clicked()), this, SLOT(increaseZoomLevel())); // Zoom Out button _zoomOutButton = new QPushButton; _zoomOutButton->setIcon(QIcon(":/zoom-out")); - _zoomOutButton->setIconSize(QSize(22, 22)); + _zoomOutButton->setIconSize(QSize(MM::ZOOM_TOOLBAR_ICON_SIZE, MM::ZOOM_TOOLBAR_ICON_SIZE)); _zoomOutButton->setToolTip(tr("Shrink the shape")); - _zoomOutButton->setFixedSize(32, 32); + _zoomOutButton->setFixedSize(MM::ZOOM_TOOLBAR_BUTTON_SIZE, MM::ZOOM_TOOLBAR_BUTTON_SIZE); _zoomOutButton->setObjectName("zoom-out"); connect(_zoomOutButton, SIGNAL(clicked()), this, SLOT(decreaseZoomLevel())); // Reset to normal size button. _resetZoomButton = new QPushButton; _resetZoomButton->setIcon(QIcon(":/reset-zoom")); - _resetZoomButton->setIconSize(QSize(22, 22)); + _resetZoomButton->setIconSize(QSize(MM::ZOOM_TOOLBAR_ICON_SIZE, MM::ZOOM_TOOLBAR_ICON_SIZE)); _resetZoomButton->setToolTip(tr("Reset the shape to the normal size")); - _resetZoomButton->setFixedSize(32, 32); + _resetZoomButton->setFixedSize(MM::ZOOM_TOOLBAR_BUTTON_SIZE, MM::ZOOM_TOOLBAR_BUTTON_SIZE); _resetZoomButton->setObjectName("reset-zoom"); connect(_resetZoomButton, SIGNAL(clicked()), this, SLOT(resetZoomLevel())); // Fit to view button _fitToViewButton = new QPushButton; _fitToViewButton->setIcon(QIcon(":/zoom-fit")); - _fitToViewButton->setIconSize(QSize(22, 22)); + _fitToViewButton->setIconSize(QSize(MM::ZOOM_TOOLBAR_ICON_SIZE, MM::ZOOM_TOOLBAR_ICON_SIZE)); _fitToViewButton->setToolTip(tr("Fit the shape to content view")); - _fitToViewButton->setFixedSize(32, 32); + _fitToViewButton->setFixedSize(MM::ZOOM_TOOLBAR_BUTTON_SIZE, MM::ZOOM_TOOLBAR_BUTTON_SIZE); _fitToViewButton->setObjectName("zoom-fit"); connect(_fitToViewButton, SIGNAL(clicked()), this, SLOT(fitShapeInView())); @@ -189,6 +189,13 @@ void MapperGLCanvas::createZoomToolsLayout() _zoomToolBar->setLayout(buttonsLayout); } +void MapperGLCanvas::moveZoomToolbar(const QRect &rect) +{ + + _zoomToolBar->move(rect.width() - _zoomToolBar->width(), + rect.height() - _zoomToolBar->height()); +} + // void MapperGLCanvas::mousePressEvent(QMouseEvent* event) diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h index 9e72064..79a663b 100644 --- a/MapperGLCanvas.h +++ b/MapperGLCanvas.h @@ -96,6 +96,8 @@ public: // Apply zoom to view void applyZoomToView(); + // Set the zoom toolbar position + void moveZoomToolbar(const QRect &rect); protected: // void initializeGL();