Browse Source

Move most pattern tool buttons to a real toolbar and activate most opengl viewports. However, not the pattern one because pitches are still proxy widgets

master
Nils 4 years ago
parent
commit
8a044f9d04
  1. 7
      qtgui/designer/mainwindow.py
  2. 2
      qtgui/designer/mainwindow.ui
  3. 43
      qtgui/mainwindow.py
  4. 26
      qtgui/pattern_grid.py

7
qtgui/designer/mainwindow.py

@ -2,16 +2,18 @@
# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
# Created by: PyQt5 UI code generator 5.13.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
MainWindow.resize(800, 619)
MainWindow.setWindowTitle("Patroneo")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
@ -189,4 +191,3 @@ class Ui_MainWindow(object):
_translate = QtCore.QCoreApplication.translate
self.actionAddTrack.setIconText(_translate("MainWindow", "Add Track"))
self.actionClone_Selected_Track.setIconText(_translate("MainWindow", "Clone selected Track"))

2
qtgui/designer/mainwindow.ui

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
<height>619</height>
</rect>
</property>
<property name="windowTitle">

43
qtgui/mainwindow.py

@ -36,7 +36,7 @@ from template.qtgui.about import About
import engine.api as api
from .songeditor import SongEditor, TrackLabelEditor
from .timeline import Timeline
from .pattern_grid import PatternGrid
from .pattern_grid import PatternGrid, VelocityControls, TransposeControls
from .resources import *
class MainWindow(TemplateMainWindow):
@ -117,17 +117,17 @@ class MainWindow(TemplateMainWindow):
self.ui.songEditorView.parentMainWindow = self
self.songEditor = SongEditor(parentView=self.ui.songEditorView)
self.ui.songEditorView.setScene(self.songEditor)
#self.ui.songEditorView.setViewport(QtWidgets.QOpenGLWidget())
self.ui.songEditorView.setViewport(QtWidgets.QOpenGLWidget())
self.ui.trackEditorView.parentMainWindow = self
self.trackLabelEditor = TrackLabelEditor(parentView=self.ui.trackEditorView)
self.ui.trackEditorView.setScene(self.trackLabelEditor)
#self.ui.trackEditorView.setViewport(QtWidgets.QOpenGLWidget())
self.ui.trackEditorView.setViewport(QtWidgets.QOpenGLWidget())
self.ui.timelineView.parentMainWindow = self
self.timeline = Timeline(parentView=self.ui.timelineView)
self.ui.timelineView.setScene(self.timeline)
#self.ui.timelineView.setViewport(QtWidgets.QOpenGLWidget())
self.ui.timelineView.setViewport(QtWidgets.QOpenGLWidget())
#Sync the vertical trackEditorView scrollbar (which is never shown) with the songEditorView scrollbar.
self.ui.songEditorView.setVerticalScrollBar(self.ui.trackEditorView.verticalScrollBar()) #this seems backwards, but it is correct :)
@ -135,13 +135,18 @@ class MainWindow(TemplateMainWindow):
#Sync the horizontal timelineView scrollbar (which is never shown) with the songEditorView scrollbar.
self.ui.songEditorView.setHorizontalScrollBar(self.ui.timelineView.horizontalScrollBar()) #this seems backwards, but it is correct :)
##Pattern Editor
##Pattern Editor
self.ui.gridView.parentMainWindow = self
self.patternGrid = PatternGrid(parentView=self.ui.gridView)
self.ui.gridView.setScene(self.patternGrid)
self.ui.gridView.setRenderHints(QtGui.QPainter.TextAntialiasing)
#self.ui.gridView.setViewport(QtWidgets.QOpenGLWidget())
self.patternToolbar = QtWidgets.QToolBar()
self.ui.patternArea.layout().insertWidget(0, self.patternToolbar)
self._populatePatternToolbar()
#Toolbar, which needs the widgets above already established
self._populateToolbar()
@ -205,6 +210,28 @@ class MainWindow(TemplateMainWindow):
newTrackExporDict = api.createSiblingTrack(self.currentTrackId)
self.chooseCurrentTrack(newTrackExporDict)
def _populatePatternToolbar(self):
self.patternToolbar.contextMenuEvent = api.nothing #remove that annoying Checkbox context menu
spacerItemLeft = QtWidgets.QWidget()
spacerItemLeft.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
spacerItemRight = QtWidgets.QWidget()
spacerItemRight.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
self.patternToolbar.addWidget(spacerItemLeft)
#spacerItemRight is added as last widget
#Actual widgets
velocityControls = VelocityControls(mainWindow=self, patternScene=self.patternGrid)
self.patternToolbar.addWidget(velocityControls)
transposeControls = TransposeControls(parentScene=self.patternGrid)
self.patternToolbar.addWidget(transposeControls)
#Finally add a spacer to center all widgets
self.patternToolbar.addWidget(spacerItemRight)
def _populateToolbar(self):
self.ui.toolBar.contextMenuEvent = api.nothing #remove that annoying Checkbox context menu
@ -450,3 +477,9 @@ class MainWindow(TemplateMainWindow):
value = s.numberOfSubdivisions.value()
error= ("fail", "delete", "merge")[s.errorHandling.currentIndex()]
api.convert_subdivisions(value, error)
#Override template functions
def _stretchXCoordinates(*args): pass

26
qtgui/pattern_grid.py

@ -24,7 +24,7 @@ from template.engine import pitch
from PyQt5 import QtCore, QtGui, QtWidgets, QtOpenGL
SIZE_UNIT = 40
SIZE_TOP_OFFSET = 75
SIZE_TOP_OFFSET = 40
SIZE_BOTTOM_OFFSET = 35
SIZE_RIGHT_OFFSET = 80
@ -69,21 +69,13 @@ class PatternGrid(QtWidgets.QGraphicsScene):
self.trackName = QtWidgets.QGraphicsSimpleTextItem("")
self.trackName.setBrush(self.textColor)
self.addItem(self.trackName)
#self.addItem(self.trackName)
self.trackName.setPos(0,0)
self.scale = Scale(parentScene=self)
self.addItem(self.scale)
self.scale.setPos(-20, SIZE_TOP_OFFSET)
velocityControlsProxy = self.addWidget(VelocityControls(parentScene=self))
velocityControlsProxy.setPos(0, 25) #we can't get the height of the track name properly. So it was trial and error...
velocityControlsProxy.setZValue(_zValuesRelativeToScene["scale"]) #so the drop down menu is above the steps
tranposeControlsProxy = self.addWidget(TransposeControls(parentScene=self))
tranposeControlsProxy.setPos(velocityControlsProxy.geometry().width() + 10, 25) #we can't get the height of the track name properly. So it was trial and error...
tranposeControlsProxy.setZValue(_zValuesRelativeToScene["scale"]) #so the drop down menu is above the steps
self._middleMouseDown = False
#self.ticksToPixelRatio set by callback_timeSignatureChanged
@ -885,9 +877,11 @@ class Playhead(QtWidgets.QGraphicsLineItem):
self.hide()
class VelocityControls(QtWidgets.QWidget):
def __init__(self, parentScene):
self.parentScene = parentScene
def __init__(self, mainWindow, patternScene):
super().__init__()
self.parentScene = patternScene
self.mainWindow = mainWindow
layout = QtWidgets.QHBoxLayout()
layout.setSpacing(0)
@ -909,9 +903,9 @@ class VelocityControls(QtWidgets.QWidget):
def _mouseWheelEvent(self, event):
event.accept()
if event.angleDelta().y() > 0: #up
api.changePatternVelocity(trackId=self.parentScene.parentView.parentMainWindow.currentTrackId, steps=10)
api.changePatternVelocity(trackId=self.mainWindow.currentTrackId, steps=10)
else: #down
api.changePatternVelocity(trackId=self.parentScene.parentView.parentMainWindow.currentTrackId, steps=-10)
api.changePatternVelocity(trackId=self.mainWindow.currentTrackId, steps=-10)
#The steps got redrawn, therefore their velocity numbers are now invislbe again. We are still in hover modus:
self.parentScene.showVelocities()
@ -922,12 +916,12 @@ class VelocityControls(QtWidgets.QWidget):
self.parentScene.hideVelocities()
def velocityUp(self):
api.changePatternVelocity(trackId=self.parentScene.parentView.parentMainWindow.currentTrackId, steps=1)
api.changePatternVelocity(trackId=self.mainWindow.currentTrackId, steps=1)
#The steps got redrawn, therefore their velocity numbers are now invislbe again. We are still in hover modus:
self.parentScene.showVelocities()
def velocityDown(self):
api.changePatternVelocity(trackId=self.parentScene.parentView.parentMainWindow.currentTrackId, steps=-1)
api.changePatternVelocity(trackId=self.mainWindow.currentTrackId, steps=-1)
#The steps got redrawn, therefore their velocity numbers are now invislbe again. We are still in hover modus:
self.parentScene.showVelocities()

Loading…
Cancel
Save