Merge lp:~oliwee/openlp/newtransition into lp:openlp

Proposed by Oliver Wieland
Status: Needs review
Proposed branch: lp:~oliwee/openlp/newtransition
Merge into: lp:openlp
Diff against target: 525 lines (+208/-34)
7 files modified
openlp/core/lib/htmlbuilder.py (+83/-17)
openlp/core/lib/json/theme.json (+1/-0)
openlp/core/lib/theme.py (+36/-2)
openlp/core/ui/themeform.py (+13/-1)
openlp/core/ui/themewizard.py (+14/-2)
tests/functional/openlp_core_lib/test_htmlbuilder.py (+59/-11)
tests/functional/openlp_core_lib/test_theme.py (+2/-1)
To merge this branch: bzr merge lp:~oliwee/openlp/newtransition
Reviewer Review Type Date Requested Status
OpenLP Core Pending
Review via email: mp+248188@code.launchpad.net

Description of the change

Added a second type of transition, which is more a crossfade than a fade-out-then-fade-in.
Added / adapted tests for htmlbuilder to match the new html code

To post a comment you must log in.
lp:~oliwee/openlp/newtransition updated
2494. By Oliver Wieland

fixed test_theme
adapted to new count of theme variables
added assert for new variable

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Hey Oliver,

Are you still interested in adding this feature to OpenLP? Trunk is open for code, and it would be great to have more transitions.

Revision history for this message
Oliver Wieland (oliwee) wrote :

> Hey Oliver,
>
> Are you still interested in adding this feature to OpenLP? Trunk is open for
> code, and it would be great to have more transitions.
Hey, Raoul,
sorry for delay...
I have a few private problems here at the moment, so I don't have any time for OpenLP. When I have more time, I would like to work on this again.

Be blessed

Unmerged revisions

2494. By Oliver Wieland

fixed test_theme
adapted to new count of theme variables
added assert for new variable

2493. By Oliver Wieland

merged actual trunk

2492. By Oliver Wieland

Fixed problems with vertical align
Fixed tests

2491. By Oliver Wieland

Inserted a combo box into theme manager to select transition type
Tests for htmlbuilder adapted (not ready)

2490. By Oliver Wieland

new Transition between slides

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/lib/htmlbuilder.py'
--- openlp/core/lib/htmlbuilder.py 2015-01-18 13:39:21 +0000
+++ openlp/core/lib/htmlbuilder.py 2015-01-31 10:17:29 +0000
@@ -117,6 +117,9 @@
117 .lyricsmain {117 .lyricsmain {
118 -webkit-text-stroke: 0.125em #000000; -webkit-text-fill-color: #FFFFFF; text-shadow: #000000 5px 5px;118 -webkit-text-stroke: 0.125em #000000; -webkit-text-fill-color: #FFFFFF; text-shadow: #000000 5px 5px;
119 }119 }
120 .lyricstext {
121 -webkit-transition: opacity 0.4s ease;
122 }
120123
121 sup {124 sup {
122 font-size: 0.6em;125 font-size: 0.6em;
@@ -128,6 +131,7 @@
128 <script>131 <script>
129 var timer = null;132 var timer = null;
130 var transition = false;133 var transition = false;
134 var transition_type = '0';
131135
132 function show_video(state, path, volume, loop, variable_value){136 function show_video(state, path, volume, loop, variable_value){
133 // Sometimes video.currentTime stops slightly short of video.duration and video.ended is intermittent!137 // Sometimes video.currentTime stops slightly short of video.duration and video.ended is intermittent!
@@ -342,16 +346,34 @@
342 /*346 /*
343 Show the text.347 Show the text.
344 */348 */
345 var text = document.getElementById(id);349 var text1 = document.getElementById(id).childNodes[0];
346 if(text == null) return;350 var text2 = document.getElementById(id).childNodes[1];
351 if(text1 == null) return;
352 if(text2 == null) return;
347 if(!transition){353 if(!transition){
348 text.innerHTML = new_text;354 text1.innerHTML = new_text;
355 text2.innerHTML = new_text;
349 return;356 return;
350 }357 }
351 // Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.358 if(transition_type == 0){
352 text.style.opacity = '0.1';359 // Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
353 // Fade new text in after the old text has finished fading out.360 text1.style.opacity = '0.1';
354 timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);361 // Fade new text in after the old text has finished fading out.
362 timer = window.setTimeout(function(){_show_text(text1, new_text)}, 400);
363 }else{
364 // Toggle visible text element by fading out / in
365 if (text1.style.opacity == '1'){
366 text2.innerHTML = new_text;
367 text1.style.opacity = '0';
368 text2.style.opacity = '1';
369 }
370 else{
371 text1.innerHTML = new_text;
372 text2.style.opacity = '0';
373 text1.style.opacity = '1';
374 }
375 timer = window.setTimeout(function(){timer = null;}, 400);
376 }
355 }377 }
356378
357 function _show_text(text, new_text) {379 function _show_text(text, new_text) {
@@ -381,7 +403,7 @@
381403
382 <div id="alert" style="visibility:hidden"></div>404 <div id="alert" style="visibility:hidden"></div>
383405
384 <div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>406 <div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"><div id="lyricstext1" class="lyricstext" style="opacity:1;"></div><div id="lyricstext2" class="lyricstext" style="opacity:0;position:absolute;top:0px;left:0px;"></div></div></div>
385 <div id="footer" class="footer"></div>407 <div id="footer" class="footer"></div>
386 <div id="black" class="size"></div>408 <div id="black" class="size"></div>
387 </body>409 </body>
@@ -448,6 +470,7 @@
448<script>470<script>
449 var timer = null;471 var timer = null;
450 var transition = %s;472 var transition = %s;
473 var transition_type = %s;
451 %s474 %s
452475
453 function show_image(src){476 function show_image(src){
@@ -474,6 +497,7 @@
474 }497 }
475 document.getElementById('black').style.display = black;498 document.getElementById('black').style.display = black;
476 document.getElementById('lyricsmain').style.visibility = lyrics;499 document.getElementById('lyricsmain').style.visibility = lyrics;
500 document.getElementById('lyricsmain2').style.visibility = lyrics;
477 document.getElementById('image').style.visibility = lyrics;501 document.getElementById('image').style.visibility = lyrics;
478 document.getElementById('footer').style.visibility = lyrics;502 document.getElementById('footer').style.visibility = lyrics;
479 }503 }
@@ -501,23 +525,51 @@
501 new_text = '<span>' + new_text + '</span>';525 new_text = '<span>' + new_text + '</span>';
502 }526 }
503 }527 }
504 text_fade('lyricsmain', new_text);528 txt = document.getElementById('lyricsmain2');
529 if(window.getComputedStyle(txt).textAlign == 'justify'){
530 if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
531 new_text = new_text.replace(/(\s|&nbsp;)+(?![^<]*>)/g,
532 function(match) {
533 return '</span>' + match + '<span>';
534 });
535 new_text = '<span>' + new_text + '</span>';
536 }
537 }
538 text_fade('lyricsmain', 'lyricsmain2', new_text);
505 }539 }
506540
507 function text_fade(id, new_text){541 function text_fade(id, id2, new_text){
508 /*542 /*
509 Show the text.543 Show the text.
510 */544 */
511 var text = document.getElementById(id);545 var text1 = document.getElementById(id);
512 if(text == null) return;546 var text2 = document.getElementById(id2);
547 if(text1 == null) return;
548 if(text2 == null) return;
513 if(!transition){549 if(!transition){
514 text.innerHTML = new_text;550 text1.innerHTML = new_text;
551 text2.innerHTML = new_text;
515 return;552 return;
516 }553 }
517 // Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.554 if(transition_type == 0){
518 text.style.opacity = '0.1';555 // Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
519 // Fade new text in after the old text has finished fading out.556 text1.style.opacity = '0.1';
520 timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);557 // Fade new text in after the old text has finished fading out.
558 timer = window.setTimeout(function(){_show_text(text1, new_text)}, 400);
559 }else{
560 // Toggle visible text element by fading out / in
561 if (text1.style.opacity == '1'){
562 text2.innerHTML = new_text;
563 text1.style.opacity = '0';
564 text2.style.opacity = '1';
565 }
566 else{
567 text1.innerHTML = new_text;
568 text2.style.opacity = '0';
569 text1.style.opacity = '1';
570 }
571 timer = window.setTimeout(function(){timer = null;}, 400);
572 }
521 }573 }
522574
523 function _show_text(text, new_text) {575 function _show_text(text, new_text) {
@@ -541,6 +593,7 @@
541<img id="image" class="size" %s />593<img id="image" class="size" %s />
542%s594%s
543<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>595<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>
596<div class="lyricstable"><div id="lyricsmain2" style="opacity:0" class="lyricscell lyricsmain"></div></div>
544<div id="footer" class="footer"></div>597<div id="footer" class="footer"></div>
545<div id="black" class="size"></div>598<div id="black" class="size"></div>
546</body>599</body>
@@ -587,6 +640,7 @@
587 build_footer_css(item, height),640 build_footer_css(item, height),
588 build_lyrics_css(item),641 build_lyrics_css(item),
589 'true' if theme_data and theme_data.display_slide_transition and is_live else 'false',642 'true' if theme_data and theme_data.display_slide_transition and is_live else 'false',
643 get_transition_type(item),
590 js_additions,644 js_additions,
591 bgimage_src,645 bgimage_src,
592 image_src,646 image_src,
@@ -754,3 +808,15 @@
754 lyrics_html = style % (item.footer.x(), bottom, item.footer.width(),808 lyrics_html = style % (item.footer.x(), bottom, item.footer.width(),
755 theme.font_footer_name, theme.font_footer_size, theme.font_footer_color, whitespace)809 theme.font_footer_name, theme.font_footer_size, theme.font_footer_color, whitespace)
756 return lyrics_html810 return lyrics_html
811
812def get_transition_type(item):
813 """
814 Returns the transition type of the theme
815
816 :param item: Service Item to be processed.
817 """
818 theme= item.theme_data
819 if not theme:
820 return '0'
821
822 return theme.display_slide_transition_type
757\ No newline at end of file823\ No newline at end of file
758824
=== modified file 'openlp/core/lib/json/theme.json'
--- openlp/core/lib/json/theme.json 2013-10-18 18:10:47 +0000
+++ openlp/core/lib/json/theme.json 2015-01-31 10:17:29 +0000
@@ -11,6 +11,7 @@
11 "display" :{11 "display" :{
12 "horizontal_align": 0,12 "horizontal_align": 0,
13 "slide_transition": false,13 "slide_transition": false,
14 "slide_transition_type": 0,
14 "vertical_align": 015 "vertical_align": 0
15 },16 },
16 "font": {17 "font": {
1718
=== modified file 'openlp/core/lib/theme.py'
--- openlp/core/lib/theme.py 2015-01-18 13:39:21 +0000
+++ openlp/core/lib/theme.py 2015-01-31 10:17:29 +0000
@@ -140,6 +140,33 @@
140 Names = ['top', 'middle', 'bottom']140 Names = ['top', 'middle', 'bottom']
141141
142142
143class TransitionType(object):
144 """
145 Type enumeration for backgrounds.
146 """
147 Fadeout_fadein = 0
148 Crossfade = 1
149
150 @staticmethod
151 def to_string(transition_type):
152 """
153 Return a string representation of a transition type.
154 """
155 if transition_type == TransitionType.Fadeout_fadein:
156 return 'Fade Out - Fade In'
157 elif transition_type == TransitionType.Crossfade:
158 return 'Crossfade'
159
160 @staticmethod
161 def from_string(type_string):
162 """
163 Return a transition type for the given string.
164 """
165 if type_string == 'Fade Out - Fade In':
166 return TransitionType.Fadeout_fadein
167 elif type_string == 'Crossfade':
168 return TransitionType.Crossfade
169
143BOOLEAN_LIST = ['bold', 'italics', 'override', 'outline', 'shadow', 'slide_transition']170BOOLEAN_LIST = ['bold', 'italics', 'override', 'outline', 'shadow', 'slide_transition']
144171
145INTEGER_LIST = ['size', 'line_adjustment', 'x', 'height', 'y', 'width', 'shadow_size', 'outline_size',172INTEGER_LIST = ['size', 'line_adjustment', 'x', 'height', 'y', 'width', 'shadow_size', 'outline_size',
@@ -318,13 +345,14 @@
318 element.appendChild(value)345 element.appendChild(value)
319 background.appendChild(element)346 background.appendChild(element)
320347
321 def add_display(self, horizontal, vertical, transition):348 def add_display(self, horizontal, vertical, transition, transition_type):
322 """349 """
323 Add a Display options.350 Add a Display options.
324351
325 :param horizontal: The horizontal alignment of the text.352 :param horizontal: The horizontal alignment of the text.
326 :param vertical: The vertical alignment of the text.353 :param vertical: The vertical alignment of the text.
327 :param transition: Whether the slide transition is active.354 :param transition: Whether the slide transition is active.
355 _param transition_type: Type of the slide transition.
328 """356 """
329 background = self.theme_xml.createElement('display')357 background = self.theme_xml.createElement('display')
330 self.theme.appendChild(background)358 self.theme.appendChild(background)
@@ -343,6 +371,11 @@
343 value = self.theme_xml.createTextNode(str(transition))371 value = self.theme_xml.createTextNode(str(transition))
344 element.appendChild(value)372 element.appendChild(value)
345 background.appendChild(element)373 background.appendChild(element)
374 # Slide Transition Type
375 element = self.theme_xml.createElement('slideTransitionType')
376 value = self.theme_xml.createTextNode(str(transition_type))
377 element.appendChild(value)
378 background.appendChild(element)
346379
347 def child_element(self, element, tag, value):380 def child_element(self, element, tag, value):
348 """381 """
@@ -555,5 +588,6 @@
555 self.add_display(588 self.add_display(
556 self.display_horizontal_align,589 self.display_horizontal_align,
557 self.display_vertical_align,590 self.display_vertical_align,
558 self.display_slide_transition591 self.display_slide_transition,
592 self.display_slide_transition_type
559 )593 )
560594
=== modified file 'openlp/core/ui/themeform.py'
--- openlp/core/ui/themeform.py 2015-01-18 13:39:21 +0000
+++ openlp/core/ui/themeform.py 2015-01-31 10:17:29 +0000
@@ -28,7 +28,7 @@
28from PyQt4 import QtCore, QtGui28from PyQt4 import QtCore, QtGui
2929
30from openlp.core.common import Registry, RegistryProperties, UiStrings, translate30from openlp.core.common import Registry, RegistryProperties, UiStrings, translate
31from openlp.core.lib.theme import BackgroundType, BackgroundGradientType31from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, TransitionType
32from openlp.core.lib.ui import critical_error_message_box32from openlp.core.lib.ui import critical_error_message_box
33from openlp.core.ui import ThemeLayoutForm33from openlp.core.ui import ThemeLayoutForm
34from openlp.core.utils import get_images_filter, is_not_image_file34from openlp.core.utils import get_images_filter, is_not_image_file
@@ -88,6 +88,7 @@
88 self.main_font_combo_box.activated.connect(self.calculate_lines)88 self.main_font_combo_box.activated.connect(self.calculate_lines)
89 self.footer_font_combo_box.activated.connect(self.update_theme)89 self.footer_font_combo_box.activated.connect(self.update_theme)
90 self.footer_size_spin_box.valueChanged.connect(self.update_theme)90 self.footer_size_spin_box.valueChanged.connect(self.update_theme)
91 self.transitions_combo_box.currentIndexChanged.connect(self.on_transitions_combo_box_current_index_changed)
9192
92 def set_defaults(self):93 def set_defaults(self):
93 """94 """
@@ -134,6 +135,7 @@
134 self.background_page.registerField('horizontal', self.horizontal_combo_box)135 self.background_page.registerField('horizontal', self.horizontal_combo_box)
135 self.background_page.registerField('vertical', self.vertical_combo_box)136 self.background_page.registerField('vertical', self.vertical_combo_box)
136 self.background_page.registerField('slide_transition', self.transitions_check_box)137 self.background_page.registerField('slide_transition', self.transitions_check_box)
138 self.background_page.registerField('slide_transition_type', self.transitions_combo_box)
137 self.background_page.registerField('name', self.theme_name_edit)139 self.background_page.registerField('name', self.theme_name_edit)
138140
139 def calculate_lines(self):141 def calculate_lines(self):
@@ -366,6 +368,7 @@
366 self.setField('horizontal', self.theme.display_horizontal_align)368 self.setField('horizontal', self.theme.display_horizontal_align)
367 self.setField('vertical', self.theme.display_vertical_align)369 self.setField('vertical', self.theme.display_vertical_align)
368 self.setField('slide_transition', self.theme.display_slide_transition)370 self.setField('slide_transition', self.theme.display_slide_transition)
371 self.setField('slide_transition_type', self.theme.display_slide_transition_type)
369372
370 def set_preview_page_values(self):373 def set_preview_page_values(self):
371 """374 """
@@ -464,6 +467,14 @@
464 """467 """
465 self.theme.font_footer_color = color468 self.theme.font_footer_color = color
466469
470 def on_transitions_combo_box_current_index_changed(self, index):
471 """
472 Transition style Combo box has changed.
473 """
474 # do not allow updates when screen is building for the first time.
475 if self.update_theme_allowed:
476 self.theme.transition_type = TransitionType.to_string(index)
477
467 def update_theme(self):478 def update_theme(self):
468 """479 """
469 Update the theme object from the UI for fields not already updated480 Update the theme object from the UI for fields not already updated
@@ -496,6 +507,7 @@
496 self.theme.display_horizontal_align = self.horizontal_combo_box.currentIndex()507 self.theme.display_horizontal_align = self.horizontal_combo_box.currentIndex()
497 self.theme.display_vertical_align = self.vertical_combo_box.currentIndex()508 self.theme.display_vertical_align = self.vertical_combo_box.currentIndex()
498 self.theme.display_slide_transition = self.field('slide_transition')509 self.theme.display_slide_transition = self.field('slide_transition')
510 self.theme.display_slide_transition_type = self.field('slide_transition_type')
499511
500 def accept(self):512 def accept(self):
501 """513 """
502514
=== modified file 'openlp/core/ui/themewizard.py'
--- openlp/core/ui/themewizard.py 2015-01-18 13:39:21 +0000
+++ openlp/core/ui/themewizard.py 2015-01-31 10:17:29 +0000
@@ -26,7 +26,7 @@
2626
27from openlp.core.common import UiStrings, translate, is_macosx27from openlp.core.common import UiStrings, translate, is_macosx
28from openlp.core.lib import build_icon, ColorButton28from openlp.core.lib import build_icon, ColorButton
29from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType29from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType, TransitionType
30from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets30from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets
3131
3232
@@ -257,9 +257,17 @@
257 self.alignment_layout.addRow(self.vertical_label, self.vertical_combo_box)257 self.alignment_layout.addRow(self.vertical_label, self.vertical_combo_box)
258 self.transitions_label = QtGui.QLabel(self.alignment_page)258 self.transitions_label = QtGui.QLabel(self.alignment_page)
259 self.transitions_label.setObjectName('transitions_label')259 self.transitions_label.setObjectName('transitions_label')
260 self.transitions_properties_layout = QtGui.QHBoxLayout()
261 self.transitions_properties_layout.setObjectName('transitions_properties_layout')
260 self.transitions_check_box = QtGui.QCheckBox(self.alignment_page)262 self.transitions_check_box = QtGui.QCheckBox(self.alignment_page)
261 self.transitions_check_box.setObjectName('transitions_check_box')263 self.transitions_check_box.setObjectName('transitions_check_box')
262 self.alignment_layout.addRow(self.transitions_label, self.transitions_check_box)264 self.transitions_properties_layout.addWidget(self.transitions_check_box)
265 self.transitions_properties_layout.addSpacing(20)
266 self.transitions_combo_box = QtGui.QComboBox(self.alignment_page)
267 self.transitions_combo_box.addItems(['', ''])
268 self.transitions_combo_box.setObjectName('transitions_combo_box')
269 self.transitions_properties_layout.addWidget(self.transitions_combo_box)
270 self.alignment_layout.addRow(self.transitions_label, self.transitions_properties_layout)
263 self.alignment_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer)271 self.alignment_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer)
264 theme_wizard.addPage(self.alignment_page)272 theme_wizard.addPage(self.alignment_page)
265 # Area Position Page273 # Area Position Page
@@ -458,6 +466,10 @@
458 self.horizontal_combo_box.setItemText(HorizontalType.Center, translate('OpenLP.ThemeWizard', 'Center'))466 self.horizontal_combo_box.setItemText(HorizontalType.Center, translate('OpenLP.ThemeWizard', 'Center'))
459 self.horizontal_combo_box.setItemText(HorizontalType.Justify, translate('OpenLP.ThemeWizard', 'Justify'))467 self.horizontal_combo_box.setItemText(HorizontalType.Justify, translate('OpenLP.ThemeWizard', 'Justify'))
460 self.transitions_label.setText(translate('OpenLP.ThemeWizard', 'Transitions:'))468 self.transitions_label.setText(translate('OpenLP.ThemeWizard', 'Transitions:'))
469 self.transitions_combo_box.setItemText(TransitionType.Fadeout_fadein,
470 translate('OpenLP.ThemeWizard', 'Fade out - Fade in'))
471 self.transitions_combo_box.setItemText(TransitionType.Crossfade,
472 translate('OpenLP.ThemeWizard', 'Crossfade'))
461 self.area_position_page.setTitle(translate('OpenLP.ThemeWizard', 'Output Area Locations'))473 self.area_position_page.setTitle(translate('OpenLP.ThemeWizard', 'Output Area Locations'))
462 self.area_position_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Allows you to change and move the'474 self.area_position_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Allows you to change and move the'
463 ' Main and Footer areas.'))475 ' Main and Footer areas.'))
464476
=== modified file 'tests/functional/openlp_core_lib/test_htmlbuilder.py'
--- tests/functional/openlp_core_lib/test_htmlbuilder.py 2014-07-24 21:57:16 +0000
+++ tests/functional/openlp_core_lib/test_htmlbuilder.py 2015-01-31 10:17:29 +0000
@@ -8,7 +8,7 @@
88
9from openlp.core.common import Settings9from openlp.core.common import Settings
10from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_lyrics_css, build_lyrics_outline_css, \10from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_lyrics_css, build_lyrics_outline_css, \
11 build_lyrics_format_css, build_footer_css11 build_lyrics_format_css, build_footer_css, get_transition_type
12from openlp.core.lib.theme import HorizontalType, VerticalType12from openlp.core.lib.theme import HorizontalType, VerticalType
13from tests.functional import MagicMock, patch13from tests.functional import MagicMock, patch
14from tests.helpers.testmixin import TestMixin14from tests.helpers.testmixin import TestMixin
@@ -65,6 +65,7 @@
65<script>65<script>
66 var timer = null;66 var timer = null;
67 var transition = false;67 var transition = false;
68 var transition_type = 0;
68 plugin JS69 plugin JS
6970
70 function show_image(src){71 function show_image(src){
@@ -91,6 +92,7 @@
91 }92 }
92 document.getElementById('black').style.display = black;93 document.getElementById('black').style.display = black;
93 document.getElementById('lyricsmain').style.visibility = lyrics;94 document.getElementById('lyricsmain').style.visibility = lyrics;
95 document.getElementById('lyricsmain2').style.visibility = lyrics;
94 document.getElementById('image').style.visibility = lyrics;96 document.getElementById('image').style.visibility = lyrics;
95 document.getElementById('footer').style.visibility = lyrics;97 document.getElementById('footer').style.visibility = lyrics;
96 }98 }
@@ -100,7 +102,7 @@
100 }102 }
101103
102 function show_text(new_text){104 function show_text(new_text){
103 var match = /-webkit-text-fill-color:[^;"]+/gi;105 var match = /-webkit-text-fill-color:[^;\"]+/gi;
104 if(timer != null)106 if(timer != null)
105 clearTimeout(timer);107 clearTimeout(timer);
106 /*108 /*
@@ -118,23 +120,51 @@
118 new_text = '<span>' + new_text + '</span>';120 new_text = '<span>' + new_text + '</span>';
119 }121 }
120 }122 }
121 text_fade('lyricsmain', new_text);123 txt = document.getElementById('lyricsmain2');
124 if(window.getComputedStyle(txt).textAlign == 'justify'){
125 if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
126 new_text = new_text.replace(/(\s|&nbsp;)+(?![^<]*>)/g,
127 function(match) {
128 return '</span>' + match + '<span>';
129 });
130 new_text = '<span>' + new_text + '</span>';
131 }
132 }
133 text_fade('lyricsmain', 'lyricsmain2', new_text);
122 }134 }
123135
124 function text_fade(id, new_text){136 function text_fade(id, id2, new_text){
125 /*137 /*
126 Show the text.138 Show the text.
127 */139 */
128 var text = document.getElementById(id);140 var text1 = document.getElementById(id);
129 if(text == null) return;141 var text2 = document.getElementById(id2);
142 if(text1 == null) return;
143 if(text2 == null) return;
130 if(!transition){144 if(!transition){
131 text.innerHTML = new_text;145 text1.innerHTML = new_text;
146 text2.innerHTML = new_text;
132 return;147 return;
133 }148 }
134 // Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.149 if(transition_type == 0){
135 text.style.opacity = '0.1';150 // Fade text out. 0.1 to minimize the time "nothing" is shown on the screen.
136 // Fade new text in after the old text has finished fading out.151 text1.style.opacity = '0.1';
137 timer = window.setTimeout(function(){_show_text(text, new_text)}, 400);152 // Fade new text in after the old text has finished fading out.
153 timer = window.setTimeout(function(){_show_text(text1, new_text)}, 400);
154 }else{
155 // Toggle visible text element by fading out / in
156 if (text1.style.opacity == '1'){
157 text2.innerHTML = new_text;
158 text1.style.opacity = '0';
159 text2.style.opacity = '1';
160 }
161 else{
162 text1.innerHTML = new_text;
163 text2.style.opacity = '0';
164 text1.style.opacity = '1';
165 }
166 timer = window.setTimeout(function(){timer = null;}, 400);
167 }
138 }168 }
139169
140 function _show_text(text, new_text) {170 function _show_text(text, new_text) {
@@ -158,6 +188,7 @@
158<img id="image" class="size" style="display:none;" />188<img id="image" class="size" style="display:none;" />
159plugin HTML189plugin HTML
160<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>190<div class="lyricstable"><div id="lyricsmain" style="opacity:1" class="lyricscell lyricsmain"></div></div>
191<div class="lyricstable"><div id="lyricsmain2" style="opacity:0" class="lyricscell lyricsmain"></div></div>
161<div id="footer" class="footer"></div>192<div id="footer" class="footer"></div>
162<div id="black" class="size"></div>193<div id="black" class="size"></div>
163</body>194</body>
@@ -230,6 +261,7 @@
230 # Mocked arguments.261 # Mocked arguments.
231 item = MagicMock()262 item = MagicMock()
232 item.bg_image_bytes = None263 item.bg_image_bytes = None
264 item.theme_data.display_slide_transition_type = 0
233 screen = MagicMock()265 screen = MagicMock()
234 is_live = False266 is_live = False
235 background = None267 background = None
@@ -238,6 +270,7 @@
238 plugin.get_display_javascript.return_value = 'plugin JS'270 plugin.get_display_javascript.return_value = 'plugin JS'
239 plugin.get_display_html.return_value = 'plugin HTML'271 plugin.get_display_html.return_value = 'plugin HTML'
240 plugins = [plugin]272 plugins = [plugin]
273 self.maxDiff = None
241274
242 # WHEN: Create the html.275 # WHEN: Create the html.
243 html = build_html(item, screen, is_live, background, plugins=plugins)276 html = build_html(item, screen, is_live, background, plugins=plugins)
@@ -358,3 +391,18 @@
358391
359 # THEN: Footer should wrap392 # THEN: Footer should wrap
360 self.assertEqual(FOOTER_CSS_WRAP, css, 'The footer strings should be equal.')393 self.assertEqual(FOOTER_CSS_WRAP, css, 'The footer strings should be equal.')
394
395 def get_transition_type_test(self):
396 """
397 Test the get_transition_type() function
398 """
399 # GIVEN: Create a theme.
400 item = MagicMock()
401 item.theme_data.display_slide_transition_type = 1
402
403 #WHEN: get transition type
404 transition_type = get_transition_type(item);
405
406 #THEN: transition type should be 1
407 self.assertEqual(1, transition_type, 'The transition type should be 1.');
408
361\ No newline at end of file409\ No newline at end of file
362410
=== modified file 'tests/functional/openlp_core_lib/test_theme.py'
--- tests/functional/openlp_core_lib/test_theme.py 2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_core_lib/test_theme.py 2015-01-31 10:17:29 +0000
@@ -61,4 +61,5 @@
61 self.assertTrue(default_theme.font_footer_name == "Arial",61 self.assertTrue(default_theme.font_footer_name == "Arial",
62 'The theme should have a font_footer_name of Arial')62 'The theme should have a font_footer_name of Arial')
63 self.assertTrue(default_theme.font_main_bold is False, 'The theme should have a font_main_bold of false')63 self.assertTrue(default_theme.font_main_bold is False, 'The theme should have a font_main_bold of false')
64 self.assertTrue(len(default_theme.__dict__) == 47, 'The theme should have 47 variables')64 self.assertTrue(default_theme.display_slide_transition_type is 0, 'The theme should have a slide_transition_type of 0')
65 self.assertTrue(len(default_theme.__dict__) == 48, 'The theme should have 48 variables')