From 74b58302a4ca953aa549f9cfe1e1961064c6c44d Mon Sep 17 00:00:00 2001 From: Nils Date: Tue, 10 May 2022 20:02:01 +0200 Subject: [PATCH] Sensible opengl widget values for better scrolling when dragging --- CHANGELOG | 1 + qtgui/scoreview.py | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7567caa..480be93 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ External contributors notice at the end of the line: (LastName, FirstName / nick ## 2022-07-15 2.1.0 Add functions to move block to start or end of track. +Scroll view when dragging blocks and tracks with the mouse. Add 3/2 to metrical instruction. Autosave when exporting Lilypond .ly or PDF. Command to quickly add text below or above a staff. diff --git a/qtgui/scoreview.py b/qtgui/scoreview.py index 96425df..04113a8 100644 --- a/qtgui/scoreview.py +++ b/qtgui/scoreview.py @@ -23,7 +23,7 @@ import logging; logger = logging.getLogger(__name__); logger.info("import") #Third Party -from PyQt5 import QtCore, QtGui, QtWidgets, QtOpenGL +from PyQt5 import QtCore, QtGui, QtWidgets #Template Modules from template.helper import onlyOne @@ -42,24 +42,28 @@ class ScoreView(QtWidgets.QGraphicsView): self.scoreScene = GuiScore(parentView=self) self.setScene(self.scoreScene) - viewport = QtOpenGL.QGLWidget(QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers)) - viewport.format().setSwapInterval(0) #disable VSync. - viewport.setAutoFillBackground(False) - - viewport = QtWidgets.QOpenGLWidget() - #These special parameters should not matter. Run with the default. - #viewportFormat = QtGui.QSurfaceFormat() - #viewportFormat.setSwapInterval(0) #disable VSync - #viewportFormat.setSamples(2**8) - #viewportFormat.setDefaultFormat(viewportFormat) - #viewport.setFormat(viewportFormat) - self.setViewport(viewport) + opengl = True + if opengl: + #Scrolling without openGl is sluggish. This is a sure improvement. -2022. + from PyQt5 import QtOpenGL + viewport = QtWidgets.QOpenGLWidget() + #viewport = QtOpenGL.QGLWidget(QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers)) + #These special parameters should not matter. Run with the default. + viewportFormat = QtGui.QSurfaceFormat() + viewportFormat.setSwapInterval(0) #disable VSync + viewportFormat.setDefaultFormat(viewportFormat) + viewport.setFormat(viewportFormat) + self.setViewport(viewport) + + self.viewport().setAutoFillBackground(False) self.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) #self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag) + #self.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag) self.setDragMode(QtWidgets.QGraphicsView.NoDrag) + api.callbacks.setCursor.append(self.centerOnCursor) #returns a dict api.callbacks.updateBlockTrack.append(self.updateMode) # We need this after every update because the track is redrawn after each update and we don't know what to show