Exemplo n.º 1
0
class SingleStaff(StaffBase):
    def __init__(self, dialog):
        StaffBase.__init__(self, dialog)
        l = QLabel(i18n("Staves per page:"))
        l.setBuddy(self.systems)
        self.layout().addWidget(l, 0, 1, Qt.AlignRight)
        self.layout().addWidget(self.systems, 0, 2)
        self.clef = ClefSelector(noclef=True, tab=True)
        l = QLabel(i18n("Clef:"))
        l.setBuddy(self.clef)
        self.layout().addWidget(l, 1, 1, Qt.AlignRight)
        self.layout().addWidget(self.clef, 1, 2)
        
    def name(self):
        return i18n("Single Staff")
        
    def default(self):
        self.systems.setValue(12)

    def music(self, layout):
        if self.clef.clef() == 'tab':
            layout.setStaffContexts(['TabStaff'])
            return ['\\new TabStaff { \\music }']
        else:
            if self.clef.clef():
                return ['\\new Staff {{ \\clef "{0}" \\music }}'.format(self.clef.clef())]
            else:
                layout.add('Staff', "\\override Clef #'transparent = ##t")
                return ['\\new Staff { \\music }']
Exemplo n.º 2
0
 def __init__(self, dialog):
     StaffBase.__init__(self, dialog)
     l = QLabel(i18n("Staves per page:"))
     l.setBuddy(self.systems)
     self.layout().addWidget(l, 0, 1, Qt.AlignRight)
     self.layout().addWidget(self.systems, 0, 2)
     self.clef = ClefSelector(noclef=True, tab=True)
     l = QLabel(i18n("Clef:"))
     l.setBuddy(self.clef)
     self.layout().addWidget(l, 1, 1, Qt.AlignRight)
     self.layout().addWidget(self.clef, 1, 2)
Exemplo n.º 3
0
 def createWidget(self):
     w = QWidget()
     w.setLayout(QGridLayout())
     self.clef = ClefSelector(noclef=True, tab=True)
     l = QLabel(i18n("Clef:"))
     l.setBuddy(self.clef)
     w.layout().addWidget(l, 0, 0, Qt.AlignRight)
     w.layout().addWidget(self.clef, 0, 1)
     self.clef.currentIndexChanged.connect(self.clefChanged)
     self.spaceBelow = QSpinBox()
     self.spaceBelow.setRange(0, 25)
     self.spaceBelow.setValue(5)
     w.layout().addWidget(self.spaceBelow, 2, 1)
     l = QLabel(i18n("Space below:"))
     l.setBuddy(self.spaceBelow)
     w.layout().addWidget(l, 2, 0, Qt.AlignRight)
     return w
Exemplo n.º 4
0
class StaffItem(Item):
    def __init__(self, staff, parent):
        Item.__init__(self, staff, parent)
        self.setFlags(self.flags() & ~Qt.ItemIsDropEnabled)
        
    @staticmethod
    def name():
        return i18n("Staff")
    
    @staticmethod
    def symbol():
        return 'clef_none'

    def createWidget(self):
        w = QWidget()
        w.setLayout(QGridLayout())
        self.clef = ClefSelector(noclef=True, tab=True)
        l = QLabel(i18n("Clef:"))
        l.setBuddy(self.clef)
        w.layout().addWidget(l, 0, 0, Qt.AlignRight)
        w.layout().addWidget(self.clef, 0, 1)
        self.clef.currentIndexChanged.connect(self.clefChanged)
        self.spaceBelow = QSpinBox()
        self.spaceBelow.setRange(0, 25)
        self.spaceBelow.setValue(5)
        w.layout().addWidget(self.spaceBelow, 2, 1)
        l = QLabel(i18n("Space below:"))
        l.setBuddy(self.spaceBelow)
        w.layout().addWidget(l, 2, 0, Qt.AlignRight)
        return w
        
    def clefChanged(self, index):
        self.setIcon(0, self.staff.symbolIcon('clef_' + (self.clef.clef() or 'none')))

    def staffCount(self):
        return 1
    
    def music(self, layout):
        clef = self.clef.clef()
        staff = 'TabStaff' if clef == 'tab' else 'Staff'
        layout.addStaffContext(staff)
        music = ['\\new {0} \\with {{'.format(staff)]
        if lilyPondVersion() < (2, 13, 4):
            music.append(
                "\\override VerticalAxisGroup #'minimum-Y-extent = #'(-{0} . 5)".format(
                    self.spaceBelow.value()))
        elif lilyPondVersion() < (2, 14, 0):
            music.append(
                "\\override VerticalAxisGroup #'next-staff-spacing = #'((space . {0}))".format(
                    self.spaceBelow.value() + 5))
        else:
            music.append(
                "\\override VerticalAxisGroup #'next-staff-spacing = #'((basic-distance . {0}))".format(
                    self.spaceBelow.value() + 5))
        if not clef:
            music.append("\\override Clef #'transparent = ##t")
        if not clef or clef == 'tab':
            music.append('} { \\music }')
        else:
            music.append('}} {{ \\clef "{0}" \\music }}'.format(clef))
        return music