Move towards sorting out renderer text sizes

This commit is contained in:
Tim Bentley 2010-01-10 19:03:52 +00:00
parent ee8a92b77f
commit 85bada91ba
3 changed files with 39 additions and 42 deletions

View File

@ -226,7 +226,6 @@ class Renderer(object):
"""
self._rect = rect_main
self._rect_footer = rect_footer
print "render = ", self._rect
def generate_frame_from_lines(self, lines, footer_lines=None):
"""
@ -245,6 +244,7 @@ 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)
print "generate ", self._frame.size()
self._frameOp = QtGui.QImage(self.bg_frame)
x, y = self._correctAlignment(self._rect, bbox)
bbox = self._render_lines_unaligned(lines, False, (x, y), True)

View File

@ -83,6 +83,7 @@ class RenderManager(object):
self.current_display = screen_number
self.calculate_default(
self.screen_list[self.current_display][u'size'])
self.renderer.bg_frame = None
def set_global_theme(self, global_theme, theme_level=ThemeLevel.Global):
"""
@ -141,7 +142,7 @@ class RenderManager(object):
self.screen_list[self.current_display][u'size'])
self.renderer.set_theme(self.themedata)
self.build_text_rectangle(self.themedata)
#Replace the backgrount image from renderer with one from image
#Replace the background image from renderer with one from image
if self.override_background:
if self.save_bg_frame is None:
self.save_bg_frame = self.renderer.bg_frame
@ -182,6 +183,7 @@ class RenderManager(object):
footer_rect = QtCore.QRect(theme.font_footer_x,
theme.font_footer_y, theme.font_footer_width - 1,
theme.font_footer_height - 1)
print "build_text_rectangle", main_rect
self.renderer.set_text_rectangle(main_rect, footer_rect)
def generate_preview(self, themedata):
@ -235,6 +237,7 @@ class RenderManager(object):
"""
log.debug(u'generate slide')
self.build_text_rectangle(self.themedata)
print "set_frame_dest", self.width, self.height
self.renderer.set_frame_dest(self.width, self.height)
return self.renderer.generate_frame_from_lines(main_text, footer_text)
@ -253,3 +256,4 @@ class RenderManager(object):
self.width, self.height, self.screen_ratio )
# 90% is start of footer
self.footer_start = int(self.height * 0.90)
print "calculate_default ", self.width, self.height, self.footer_start

View File

@ -90,22 +90,16 @@ class MainDisplay(DisplayWidget):
self.parent = parent
self.setWindowTitle(u'OpenLP Display')
self.screens = screens
# self.layout = QtGui.QVBoxLayout(self)
# self.layout.setSpacing(0)
# self.layout.setMargin(0)
# self.layout.setObjectName(u'layout')
self.mediaObject = Phonon.MediaObject(self)
self.video = Phonon.VideoWidget()
self.video.setVisible(False)
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
Phonon.createPath(self.mediaObject, self.video)
Phonon.createPath(self.mediaObject, self.audio)
#self.layout.insertWidget(0, self.video)
self.display = QtGui.QLabel(self)
self.display.setScaledContents(True)
self.alertDisplay = QtGui.QLabel(self)
self.alertDisplay.setScaledContents(True)
#self.layout.insertWidget(0, self.display)
self.primary = True
self.displayBlank = False
self.blankFrame = None
@ -150,7 +144,21 @@ class MainDisplay(DisplayWidget):
if scrn[u'number'] == screenNumber:
self.screen = scrn
break
self.setScreenGeometry()
#Sort out screen locations and sizes
print "--------- Set screen geom ------------"
print "display ", self.screen[u'size']
self.setGeometry(self.screen[u'size'])
print "main geom", self.geometry()
print "display geom 1", self.display.geometry()
self.alertScreenPosition = self.screen[u'size'].height() * 0.9
self.alertHeight = self.screen[u'size'].height() - self.alertScreenPosition
self.alertDisplay.setGeometry(
QtCore.QRect(0, self.alertScreenPosition,
self.screen[u'size'].width(),self.alertHeight))
self.video.setGeometry(self.screen[u'size'])
self.display.resize(self.screen[u'size'].width(),
self.screen[u'size'].height())
print "display geom 2", self.display.geometry()
#Build a custom splash screen
self.InitialFrame = QtGui.QImage(
self.screen[u'size'].width(),
@ -172,7 +180,7 @@ class MainDisplay(DisplayWidget):
self.screen[u'size'].height(),
QtGui.QImage.Format_ARGB32_Premultiplied)
painter.begin(self.blankFrame)
painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black)
painter.fillRect(self.blankFrame.rect(), QtCore.Qt.red)
#buid a blank transparent image
self.transparent = QtGui.QPixmap(self.screen[u'size'].width(),
self.screen[u'size'].height())
@ -185,25 +193,6 @@ class MainDisplay(DisplayWidget):
self.setVisible(False)
self.primary = True
def setScreenGeometry(self):
"""
Define and set up the display sizes.
The alert displays are set to 10% of the screen as the video display
is unable to handle transparent pixmaps. This is a problem with QT.
"""
print "--------- Set screen geom ------------"
print "display ", self.screen[u'size']
print "main geom before ", self.geometry()
self.setGeometry(self.screen[u'size'])
print "main geom after ", self.geometry()
print "display geom", self.display.geometry()
self.alertScreenPosition = self.screen[u'size'].height() * 0.9
self.alertHeight = self.screen[u'size'].height() - self.alertScreenPosition
self.alertDisplay.setGeometry(
QtCore.QRect(0, self.alertScreenPosition,
self.screen[u'size'].width(),self.alertHeight))
self.video.setGeometry(self.screen[u'size'])
def resetDisplay(self):
if self.primary:
self.setVisible(False)
@ -222,27 +211,31 @@ class MainDisplay(DisplayWidget):
``frame``
Image frame to be rendered
"""
if self.timer_id != 0 :
self.displayAlert()
elif not self.displayBlank:
# if self.timer_id != 0 :
# self.displayAlert()
print "render display start ", self.display.geometry()
if not self.displayBlank:
if transition:
if self.hasTransition:
print len(self.frame[u'trans'])
if self.frame[u'trans'] is not None:
self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame[u'trans']))
if self.frame is not None:
print "render frame 1 ", self.frame.size()
self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame))
self.repaint()
self.frame = None
if frame[u'trans'] is not None:
print "render frame 2 ", frame[u'trans'].size()
self.display.setPixmap(QtGui.QPixmap.fromImage(frame[u'trans']))
self.repaint()
self.hasTransition = True
self.frame = frame[u'trans']
print "render frame 3 ", frame[u'main'].size()
self.display.setPixmap(QtGui.QPixmap.fromImage(frame[u'main']))
self.repaint()
else:
print "render frame 3 ", frame.size()
self.display.setPixmap(QtGui.QPixmap.fromImage(frame))
if not self.isVisible():
self.setVisible(True)
self.showFullScreen()
self.frame = frame
print "render display end ", self.display.geometry()
def blankDisplay(self, blanked=True):
if blanked: