More chord polishing.

This commit is contained in:
Tomas Groth 2017-02-20 22:22:17 +01:00
parent 3edbcff3ab
commit cec3cf5f96
4 changed files with 34 additions and 7 deletions

View File

@ -379,6 +379,14 @@ def expand_and_align_chords_in_line(match):
for c in range(chordlen): for c in range(chordlen):
whitespaces += ' ' whitespaces += ' '
if whitespaces: if whitespaces:
if '_' in whitespaces:
ws_length = len(whitespaces)
if ws_length == 1:
whitespaces = '-'
else:
wsl_mod = ws_length // 2
ws_right = ws_left = ' ' * wsl_mod
whitespaces = ws_left + '-' + ws_right
whitespaces = '<span class="ws">' + whitespaces + '</span>' whitespaces = '<span class="ws">' + whitespaces + '</span>'
return '<span class="chord"><span><strong>' + chord + '</strong></span></span>' + tail + whitespaces + remainder return '<span class="chord"><span><strong>' + chord + '</strong></span></span>' + tail + whitespaces + remainder
@ -414,6 +422,7 @@ def expand_chords(text):
def compare_chord_lyric(chord, lyric): def compare_chord_lyric(chord, lyric):
""" """
Compare the width of chord and lyrics. If chord width is greater than the lyric width the diff is returned.
:param chord: :param chord:
:param lyric: :param lyric:

View File

@ -630,6 +630,10 @@ CHORDS_FORMAT = Template("""
} }
.firstchordline { .firstchordline {
line-height: ${first_chord_line_height}; line-height: ${first_chord_line_height};
}
.ws {
display: ${chords_display};
white-space: pre-wrap;
}""") }""")

View File

@ -76,10 +76,6 @@
line-height: 1.0 line-height: 1.0
} }
.firstchordline {
line-height: 2.1em;
}
.chordline span.chord span { .chordline span.chord span {
position: relative; position: relative;
} }
@ -94,6 +90,10 @@
color: yellow; color: yellow;
} }
.ws {
white-space: pre-wrap;
}
#nextslide .chordline span.chord span strong { #nextslide .chordline span.chord span strong {
color: gray; color: gray;
} }

View File

@ -210,6 +210,16 @@ window.OpenLP = {
if (!$tail && $remainder.charAt(0) == ' ') {for (c = 0; c < $chordlen; c++) {w += '&nbsp;';}} if (!$tail && $remainder.charAt(0) == ' ') {for (c = 0; c < $chordlen; c++) {w += '&nbsp;';}}
} }
if (w!='') { if (w!='') {
if (w[0] == '_') {
ws_length = w.length;
if (ws_length==1) {
w = '-';
} else {
wsl_mod = Math.floor(ws_length / 2);
ws_right = ws_left = new Array(wsl_mod +1).join(' ');
w = ws_left + '-' + ws_right;
}
}
w='<span class="ws">' + w + '</span>'; w='<span class="ws">' + w + '</span>';
} }
return $.grep(['<span class="chord"><span><strong>', $chord, '</strong></span></span>', $tail, w, $remainder, $end], Boolean).join(''); return $.grep(['<span class="chord"><span><strong>', $chord, '</strong></span></span>', $tail, w, $remainder, $end], Boolean).join('');
@ -259,13 +269,16 @@ window.OpenLP = {
} }
text = text.replace(/\n/g, "<br />"); text = text.replace(/\n/g, "<br />");
$("#nextslide").html(text); $("#nextslide").html(text);
$("#nextslide").class("nextslide");
} }
else { else {
text = "<p class=\"nextslide\">" + $("#next-text").val() + ": " + OpenLP.nextSong + "</p>"; text = "<p class=\"nextslide\">" + $("#next-text").val() + ": " + OpenLP.nextSong + "</p>";
$("#nextslide").html(text); $("#nextslide").html(text);
} }
if(!OpenLP.showchords) $(".chordline").toggleClass('chordline1'); if(!OpenLP.showchords) {
$(".chordline").toggleClass('chordline1');
$(".chord").toggle();
$(".ws").toggle();
}
}, },
updateClock: function(data) { updateClock: function(data) {
var div = $("#clock"); var div = $("#clock");
@ -314,6 +327,7 @@ $(document).ready(function() {
}); });
$('#chords').click(function () { $('#chords').click(function () {
OpenLP.showchords = OpenLP.showchords ? false : true; OpenLP.showchords = OpenLP.showchords ? false : true;
OpenLP.updateSlide(); OpenLP.loadSlides();
$
}); });
}); });