Basic Tranisitions

This commit is contained in:
Tim Bentley 2009-11-28 09:12:22 +00:00
parent 2247d01d6f
commit 1c60a29d68
3 changed files with 42 additions and 10 deletions

View File

@ -49,6 +49,7 @@ class Renderer(object):
self._theme = None
self._bg_image_filename = None
self._frame = None
self._frameOp = None
self.bg_frame = None
self.bg_image = None
@ -134,6 +135,8 @@ class Renderer(object):
frame_height)
self._frame = QtGui.QImage(frame_width, frame_height,
QtGui.QImage.Format_ARGB32_Premultiplied)
self._frameOp = QtGui.QImage(frame_width, frame_height,
QtGui.QImage.Format_ARGB32_Premultiplied)
if self._bg_image_filename and not self.bg_image:
self.scale_bg_image()
if self.bg_frame is None:
@ -255,13 +258,14 @@ class Renderer(object):
bbox1 = self._render_lines_unaligned(footer_lines, True)
# reset the frame. first time do not worry about what you paint on.
self._frame = QtGui.QImage(self.bg_frame)
self._frameOp = QtGui.QImage(self.bg_frame)
x, y = self._correctAlignment(self._rect, bbox)
bbox = self._render_lines_unaligned(lines, False, (x, y), True)
if footer_lines:
bbox = self._render_lines_unaligned(footer_lines, True,
(self._rect_footer.left(), self._rect_footer.top()), True)
log.debug(u'generate_frame_from_lines - Finish')
return {u'main':self._frame, u'trans':None}
return {u'main':self._frame, u'trans':self._frameOp}
def _generate_background_frame(self):
"""
@ -569,6 +573,22 @@ class Renderer(object):
if draw:
painter.drawText(x, y + metrics.ascent(), line)
painter.end()
# Print 2nd image with 50% weight
painter = QtGui.QPainter()
painter.begin(self._frameOp)
painter.setRenderHint(QtGui.QPainter.Antialiasing);
painter.setOpacity(0.5)
painter.setFont(font)
if color is None:
if footer:
painter.setPen(QtGui.QColor(self._theme.font_footer_color))
else:
painter.setPen(QtGui.QColor(self._theme.font_main_color))
else:
painter.setPen(QtGui.QColor(color))
if draw:
painter.drawText(x, y + metrics.ascent(), line)
painter.end()
return (w, h)
def snoop_Image(self, image, image2=None):

View File

@ -24,6 +24,7 @@
import logging
import os
import time
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon
@ -110,6 +111,7 @@ class MainDisplay(DisplayWidget):
self.timer_id = 0
self.firstTime = True
self.mediaLoaded = False
self.hasTransition = False
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -127,6 +129,7 @@ class MainDisplay(DisplayWidget):
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'media_stop'), self.onMediaStop)
def setup(self, screenNumber):
"""
Sets up the screen on a particular screen.
@ -194,10 +197,19 @@ class MainDisplay(DisplayWidget):
self.displayAlert()
elif not self.displayBlank:
if transition:
if self.hasTransition:
delay = 0.1
self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame[u'trans']))
self.repaint()
time.sleep(delay)
self.display.setPixmap(QtGui.QPixmap.fromImage(frame[u'trans']))
self.repaint()
time.sleep(delay)
self.hasTransition = True
self.display.setPixmap(QtGui.QPixmap.fromImage(frame[u'main']))
self.repaint()
else:
self.display.setPixmap(QtGui.QPixmap.fromImage(frame))
# QtCore.QTimer.singleShot(500, self.aa )
if not self.isVisible():
self.setVisible(True)
self.showFullScreen()

View File

@ -352,14 +352,14 @@ class SlideController(QtGui.QWidget):
self.Songbar.actions[action].setVisible(False)
if item.verse_order:
verses = item.verse_order.split(u' ')
for verse in verses:
if not verse or int(verse) > 12:
break
try:
self.Songbar.actions[verse].setVisible(True)
except:
#More than 20 verses hard luck
pass
# for verse in verses:
# if not verse or int(verse) > 12:
# break
# try:
# self.Songbar.actions[verse].setVisible(True)
# except:
# #More than 20 verses hard luck
# pass
self.Songbar.setVisible(True)
elif item.is_image():
#Not sensible to allow loops with 1 frame