More updates

This commit is contained in:
Tim Bentley 2010-07-14 18:36:48 +01:00
parent 84792a779a
commit 366c11e15a
6 changed files with 44 additions and 38 deletions

View File

@ -86,7 +86,6 @@ def build_html(theme, screen, alert, image):
build_alert(theme, width, height, alert),
build_image(theme, width, height, alert),
build_image_src(theme, width, height, alert, image))
print html
return html
def build_video(theme, width, height, alert):
@ -128,8 +127,8 @@ def build_lyrics(theme, width, height, alert):
position: absolute;
left: 0px;
top: 0px;
width: 640px;
height: 480px;
width: 1024px;
height: 768px;
z-index:3;
%s;
%s;
@ -149,6 +148,7 @@ def build_lyrics(theme, width, height, alert):
# 1px is the blur radius
outline = u'text-outline: %spx 1px %s' %\
(theme.display_outline_size, theme.display_outline_color)
outline = u'text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white'
lyrics_html = lyrics % (shadow, outline, theme.font_main_name, theme.font_main_proportion)
print lyrics_html
return lyrics_html

View File

@ -98,6 +98,20 @@ class Renderer(object):
self.frame.width(),
self.frame.height())
def set_text_rectangle(self, rect_main, rect_footer):
"""
Sets the rectangle within which text should be rendered.
``rect_main``
The main text block.
``rect_footer``
The footer text block.
"""
log.debug(u'set_text_rectangle %s , %s' % (rect_main, rect_footer))
self._rect = rect_main
self._rect_footer = rect_footer
def set_frame_dest(self, frame_width, frame_height, preview=False):
"""
Set the size of the slide.
@ -181,7 +195,6 @@ class Renderer(object):
old_html_text = temp_text
page.append(shell % old_html_text)
formatted.append(page)
log.debug(u'format_slide - End')
#return split_text
return formatted
@ -257,20 +270,6 @@ class Renderer(object):
split_pages.append(page)
return split_pages
def set_text_rectangle(self, rect_main, rect_footer):
"""
Sets the rectangle within which text should be rendered.
``rect_main``
The main text block.
``rect_footer``
The footer text block.
"""
log.debug(u'set_text_rectangle %s , %s' % (rect_main, rect_footer))
self._rect = rect_main
self._rect_footer = rect_footer
def generate_frame_from_lines(self, lines, footer_lines=None):
"""
Render a set of lines according to the theme, and return the block

View File

@ -129,6 +129,7 @@ class RenderManager(object):
self.calculate_default(self.screens.current[u'size'])
self.renderer.set_theme(self.themedata)
self.build_text_rectangle(self.themedata)
self.renderer.set_frame_dest(self.width, self.height)
return self.renderer.bg_frame
def build_text_rectangle(self, theme):

View File

@ -124,11 +124,16 @@ class ServiceItem(object):
def render(self):
"""
The render method is what generates the frames for the screen.
The render method is what generates the frames for the screen and
obtains the display information from the renderemanager.
At this point all the slides are build for the given
display size.
"""
log.debug(u'Render called')
self._display_frames = []
self.clear_cache()
self.bg_frame = None
self.just_rendered = True
if self.service_item_type == ServiceItemType.Text:
log.debug(u'Formatting slides')
if self.theme is None:
@ -151,6 +156,8 @@ class ServiceItem(object):
if len(self._display_frames) in self.cache.keys():
del self.cache[len(self._display_frames)]
log.log(15, u'Formatting took %4s' % (time.time() - before))
self.bg_frame = self.render_manager.renderer.bg_frame
self.themedata = self.render_manager.themedata
elif self.service_item_type == ServiceItemType.Image:
for slide in self._raw_frames:
slide[u'image'] = resize_image(slide[u'image'],
@ -167,22 +174,21 @@ class ServiceItem(object):
has generated by the render method above.
"""
log.debug(u'render individual')
changed = False
if self.theme is None:
bg_image = self.render_manager.set_override_theme(None)
else:
bg_image = self.render_manager.set_override_theme(self.theme)
# if self.theme is None:
# bg_image = self.render_manager.set_override_theme(None)
# else:
# bg_image = self.render_manager.set_override_theme(self.theme)
raw_html = self._display_frames[row][u'text'].split(u'\n')
if self.cache.get(row):
frame = self.cache[row]
# if self.cache.get(row):
# frame = self.cache[row]
# else:
if raw_html[0]:
frame = self.render_manager.generate_slide(raw_html,
self.raw_footer)
else:
if raw_html[0]:
frame = self.render_manager.generate_slide(raw_html,
self.raw_footer)
else:
frame = self.render_manager.generate_slide(raw_html, u'')
self.cache[row] = frame
return bg_image, frame, raw_html[0]
frame = self.render_manager.generate_slide(raw_html, u'')
self.cache[row] = frame
return frame, raw_html[0]
def add_from_image(self, path, title, image):
"""

View File

@ -255,13 +255,10 @@ class WebViewer(DisplayWidget):
self.alerttext = "<p>Red Alert! Raise Shields!</p>"
def next(self):
print "next"
if self.currslide:
print "2"
self.frame.evaluateJavaScript("startfade('" + self.slide2 + "')")
#self.frame.findFirstElement('div#lyrics').setInnerXml(self.slide2)
else:
print "1"
self.frame.evaluateJavaScript("startfade('" + self.slide1 + "')")
#self.frame.findFirstElement('div#lyrics').setInnerXml(self.slide1)
self.currslide = not self.currslide

View File

@ -779,7 +779,11 @@ class SlideController(QtGui.QWidget):
self.updatePreview()
else:
before = time.time()
changed, frame, raw_html = self.serviceItem.get_rendered_frame(row)
if self.serviceItem.just_rendered:
self.serviceItem.just_rendered = False
if self.isLive:
self.displayManager.buildHtml(self.serviceItem.bg_frame)
frame, raw_html = self.serviceItem.get_rendered_frame(row)
if isinstance(frame, QtGui.QImage):
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
else:
@ -788,7 +792,6 @@ class SlideController(QtGui.QWidget):
15, u'Slide Rendering took %4s' % (time.time() - before))
if self.isLive:
if self.serviceItem.is_text():
self.displayManager.buildHtml(changed)
self.displayManager.text(raw_html)
else:
self.displayManager.displayImage(frame)