1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
# This file is part of the Frescobaldi project, http://www.frescobaldi.org/
#
# Copyright (c) 2008 - 2012 by Wilbert Berendsen
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# See http://www.gnu.org/licenses/ for more information.
"""
The Quick Insert panel barlines and breathing sings Tool.
"""
from __future__ import unicode_literals
import app
import symbols
from . import tool
from . import buttongroup
class BarLines(tool.Tool):
"""Barlines tool in the quick insert panel toolbox.
"""
def __init__(self, panel):
super(BarLines, self).__init__(panel)
self.layout().addWidget(BarlinesGroup(self))
self.layout().addWidget(BreatheGroup(self))
self.layout().addStretch(1)
def icon(self):
"""Should return an icon for our tab."""
return symbols.icon("bar_single")
def title(self):
"""Should return a title for our tab."""
return _("Bar Lines")
def tooltip(self):
"""Returns a tooltip"""
return _("Bar lines, breathing signs, etcetera.")
class BarlinesGroup(buttongroup.ButtonGroup):
def translateUI(self):
self.setTitle(_("Bar Lines"))
def barlines(self):
yield "bar_double", "||", _("Double bar line")
yield "bar_end", "|.", _("Ending bar line")
yield "bar_dotted", ":", _("Dotted bar line")
yield "bar_dashed", "dashed", _("Dashed bar line")
yield "bar_invisible", "", _("Invisible bar line")
yield "bar_repeat_start", "|:", _("Repeat start")
yield "bar_repeat_double", ":|:", _("Repeat both")
yield "bar_repeat_end", ":|", _("Repeat end")
yield "bar_cswc", ":|.:", _("Repeat both (old)")
yield "bar_cswsc", ":|.|:", _("Repeat both (classic)")
yield "bar_tick", "'", _("Tick bar line")
yield "bar_single", "|", _("Single bar line")
yield "bar_sws", "|.|", _("Small-Wide-Small bar line")
yield "bar_ws", ".|", _("Wide-Small bar line")
yield "bar_ww", ".|.", _("Double wide bar line")
yield "bar_segno", "S", _("Segno bar line")
def actionData(self):
self._barlines = {}
for name, ly_text, title in self.barlines():
yield name, symbols.icon(name), None
self._barlines[name] = ly_text
def actionTexts(self):
for name, ly_text, title in self.barlines():
yield name, title
def actionTriggered(self, name):
text = '\\bar "{0}"'.format(self._barlines[name])
self.insertText(text)
class BreatheGroup(buttongroup.ButtonGroup):
def translateUI(self):
self.setTitle(_("Breathing Signs"))
def actionData(self):
for name, title in self.actionTexts():
yield name, symbols.icon(name), None
def actionTexts(self):
yield 'breathe_rcomma', _("Default Breathing Sign")
yield 'breathe_rvarcomma', _("Straight Breathing Sign")
yield 'breathe_caesura_curved', _("Curved Caesura")
yield 'breathe_caesura_straight', _("Straight Caesura")
def actionTriggered(self, name):
if name == 'breathe_rcomma':
self.insertText('\\breathe')
else:
glyph = name[8:].replace('_', '.')
text = ("\\once \\override BreathingSign #'text = "
'#(make-musicglyph-markup "scripts.{0}")\n'
"\\breathe").format(glyph)
self.insertText(text, blankline=True)
|