Browse Source

Sensible opengl widget values for better scrolling when dragging

master
Nils 9 months ago
parent
commit
74b58302a4
  1. 1
      CHANGELOG
  2. 30
      qtgui/scoreview.py

1
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.

30
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

Loading…
Cancel
Save