From 39ff67c3ec9c33b2c9f3e0e841adced8cb1b9592 Mon Sep 17 00:00:00 2001
From: Jacob Wahlman <jacwa448@student.liu.se>
Date: Mon, 4 May 2020 11:58:29 +0200
Subject: [PATCH] fixed smaller things

---
 b_asic/GUI/improved_main_window.py | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/b_asic/GUI/improved_main_window.py b/b_asic/GUI/improved_main_window.py
index 5b02231c..8c8f8cba 100644
--- a/b_asic/GUI/improved_main_window.py
+++ b/b_asic/GUI/improved_main_window.py
@@ -23,7 +23,7 @@ QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,
 QHBoxLayout, QDockWidget, QToolBar, QMenu, QLayout, QSizePolicy, QListWidget,\
 QListWidgetItem, QGraphicsView, QGraphicsScene, QShortcut
 from PyQt5.QtCore import Qt, QSize, QSize
-from PyQt5.QtGui import QIcon, QFont, QPainter, QPen, QBrush, QKeySequence
+from PyQt5.QtGui import QIcon, QFont, QPainter, QPen, QBrush, QKeySequence, QColor
 
 
 MIN_WIDTH_SCENE = 600
@@ -62,27 +62,23 @@ class MainWindow(QMainWindow):
         self.create_graphics_view()
 
     def resizeEvent(self, event):
-        oldSize = event.oldSize()
-        if event.oldSize() == QSize(-1, -1):
-            oldSize = event.size()
-
-        newWidth = oldSize.width() * (oldSize.width() / event.size().width())
-        newHeight = oldSize.height() * (oldSize.height() / event.size().height())
-        self.graphic_view.setGeometry(250, 40, newWidth - 300, newHeight - 100)
+        self.ui.operation_box.setGeometry(10, 10, self.ui.operation_box.width(), self.height())
+        self.graphic_view.setGeometry(self.ui.operation_box.width() + 20, 0, self.width() - self.ui.operation_box.width() - 20, self.height())
         super(MainWindow, self).resizeEvent(event)
 
     def create_graphics_view(self):
         self.scene = QGraphicsScene(self)
         self.graphic_view = QGraphicsView(self.scene, self)
         self.graphic_view.setRenderHint(QPainter.Antialiasing)
-        self.graphic_view.setGeometry(0, 0, self.width(), self.height())
+        self.graphic_view.setGeometry(self.ui.operation_box.width(), 0, self.width(), self.height())
         self.graphic_view.setDragMode(QGraphicsView.ScrollHandDrag)
 
     def wheelEvent(self, event):
-        old_zoom = self.zoom
-        self.zoom += event.angleDelta().y()/2500
-        self.graphic_view.scale(self.zoom, self.zoom)
-        self.zoom = old_zoom
+        if event.modifiers() == Qt.ControlModifier:
+            old_zoom = self.zoom
+            self.zoom += event.angleDelta().y()/2500
+            self.graphic_view.scale(self.zoom, self.zoom)
+            self.zoom = old_zoom
 
     def exit_app(self, checked):
         QApplication.quit()
-- 
GitLab