forked from openlp/openlp
Rendering fixes
This commit is contained in:
parent
46efe3188e
commit
0ffd58346b
@ -221,7 +221,6 @@ class Renderer:
|
|||||||
by = 0
|
by = 0
|
||||||
for (x, y) in bboxes[startline:endline]:
|
for (x, y) in bboxes[startline:endline]:
|
||||||
by += y
|
by += y
|
||||||
print "A ", by, bottom , bboxes
|
|
||||||
if by > bottom:
|
if by > bottom:
|
||||||
good=0
|
good=0
|
||||||
break
|
break
|
||||||
@ -305,8 +304,7 @@ class Renderer:
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
# render after current bottom, but at original left edge
|
# render after current bottom, but at original left edge
|
||||||
# keep track of right edge to see which is biggest
|
# keep track of right edge to see which is biggest
|
||||||
(thisx, bry) = self._render_single_line(line, footer, (x,bry))
|
(thisx, bry) = self._render_single_line(line, footer, (x , bry))
|
||||||
print thisx , bry
|
|
||||||
if (thisx > brx):
|
if (thisx > brx):
|
||||||
brx = thisx
|
brx = thisx
|
||||||
retval = QtCore.QRect(x, y,brx-x, bry-y)
|
retval = QtCore.QRect(x, y,brx-x, bry-y)
|
||||||
@ -334,13 +332,12 @@ class Renderer:
|
|||||||
# We draw the text to see how big it is and then iterate to make it fit
|
# We draw the text to see how big it is and then iterate to make it fit
|
||||||
# when we line wrap we do in in the "lyrics" style, so the second line is
|
# when we line wrap we do in in the "lyrics" style, so the second line is
|
||||||
# right aligned with a "hanging indent"
|
# right aligned with a "hanging indent"
|
||||||
|
|
||||||
print "before ", line
|
|
||||||
words = line.split(u' ')
|
words = line.split(u' ')
|
||||||
thisline = u' '.join(words)
|
thisline = u' '.join(words)
|
||||||
lastword = len(words)
|
lastword = len(words)
|
||||||
lines = []
|
lines = []
|
||||||
maxx = self._rect.width(); maxy=self._rect.height();
|
maxx = self._rect.width();
|
||||||
|
maxy = self._rect.height();
|
||||||
while (len(words)>0):
|
while (len(words)>0):
|
||||||
w , h = self._get_extent_and_render(thisline, footer)
|
w , h = self._get_extent_and_render(thisline, footer)
|
||||||
rhs = w + x
|
rhs = w + x
|
||||||
@ -358,33 +355,30 @@ class Renderer:
|
|||||||
if footer: # dont allow alignment messing with footers
|
if footer: # dont allow alignment messing with footers
|
||||||
align = 0
|
align = 0
|
||||||
else:
|
else:
|
||||||
align = self._theme .display_horizontalAlign
|
align = int(self._theme .display_horizontalAlign)
|
||||||
|
|
||||||
for linenum in range(len(lines)):
|
for linenum in range(len(lines)):
|
||||||
line = lines[linenum]
|
line = lines[linenum]
|
||||||
print "render line ", line
|
|
||||||
#find out how wide line is
|
#find out how wide line is
|
||||||
w , h = self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False)
|
w , h = self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False)
|
||||||
|
|
||||||
if self._theme.display_shadow:
|
if self._theme.display_shadow:
|
||||||
w += self._shadow_offset
|
w += self._shadow_offset
|
||||||
h += self._shadow_offset
|
h += self._shadow_offset
|
||||||
if self._theme.display_outline:
|
if self._theme.display_outline:
|
||||||
w += 2*self._outline_offset # pixels either side
|
w += 2*self._outline_offset # pixels either side
|
||||||
h += 2*self._outline_offset # pixels top/bottom
|
h += 2*self._outline_offset # pixels top/bottom
|
||||||
if align==0: # left align
|
if align == 0: # left align
|
||||||
rightextent = x+w
|
rightextent = x + w
|
||||||
if self._theme.display_wrapStyle == 1 and linenum != 0: # shift right from last line's rh edge
|
if self._theme.display_wrapStyle == 1 and linenum != 0: # shift right from last line's rh edge
|
||||||
rightextent = self._first_line_right_extent + self._right_margin
|
rightextent = self._first_line_right_extent + self._right_margin
|
||||||
if rightextent > maxx:
|
if rightextent > maxx:
|
||||||
rightextent = maxx
|
rightextent = maxx
|
||||||
x = rightextent-w
|
x = rightextent - w
|
||||||
|
|
||||||
elif align == 1: # right align
|
elif align == 1: # right align
|
||||||
rightextent = maxx
|
rightextent = maxx
|
||||||
x = maxx-w
|
x = maxx-w
|
||||||
elif align == 2: # centre
|
elif align == 2: # centre
|
||||||
x = (maxx-w)/2;
|
x = (maxx-w) / 2;
|
||||||
rightextent = x+w
|
rightextent = x+w
|
||||||
# now draw the text, and any outlines/shadows
|
# now draw the text, and any outlines/shadows
|
||||||
if self._theme.display_shadow:
|
if self._theme.display_shadow:
|
||||||
@ -410,7 +404,6 @@ class Renderer:
|
|||||||
color = self._theme.display_outline_color)
|
color = self._theme.display_outline_color)
|
||||||
|
|
||||||
self._get_extent_and_render(line, footer,tlcorner=(x, y), draw=True)
|
self._get_extent_and_render(line, footer,tlcorner=(x, y), draw=True)
|
||||||
# log.debug(u'Line %2d: Render '%s' at (%d, %d) wh=(%d,%d)' % ( linenum, line, x, y,w,h)
|
|
||||||
y += h
|
y += h
|
||||||
if linenum == 0:
|
if linenum == 0:
|
||||||
self._first_line_right_extent = rightextent
|
self._first_line_right_extent = rightextent
|
||||||
|
@ -29,6 +29,9 @@ import sys
|
|||||||
import linecache
|
import linecache
|
||||||
|
|
||||||
def traceit(frame, event, arg):
|
def traceit(frame, event, arg):
|
||||||
|
"""
|
||||||
|
Code to allow calls to be traced by python runtime
|
||||||
|
"""
|
||||||
if event == "line":
|
if event == "line":
|
||||||
lineno = frame.f_lineno
|
lineno = frame.f_lineno
|
||||||
filename = frame.f_globals["__file__"]
|
filename = frame.f_globals["__file__"]
|
||||||
@ -118,12 +121,14 @@ class RenderManager:
|
|||||||
def format_slide(self, words, footer):
|
def format_slide(self, words, footer):
|
||||||
log.debug(u'format slide')
|
log.debug(u'format slide')
|
||||||
self.calculate_default(self.screen_list[self.current_display]['size'])
|
self.calculate_default(self.screen_list[self.current_display]['size'])
|
||||||
|
self.build_text_rectangle(self.themedata)
|
||||||
self.renderer.set_frame_dest(self.width, self.height)
|
self.renderer.set_frame_dest(self.width, self.height)
|
||||||
return self.renderer.format_slide(words, footer)
|
return self.renderer.format_slide(words, footer)
|
||||||
|
|
||||||
def generate_slide(self,main_text, footer_text):
|
def generate_slide(self,main_text, footer_text):
|
||||||
log.debug(u'generate slide')
|
log.debug(u'generate slide')
|
||||||
self.calculate_default(self.screen_list[self.current_display]['size'])
|
self.calculate_default(self.screen_list[self.current_display]['size'])
|
||||||
|
self.build_text_rectangle(self.themedata)
|
||||||
self.renderer.set_frame_dest(self.width, self.height)
|
self.renderer.set_frame_dest(self.width, self.height)
|
||||||
return self.renderer.render_lines(main_text, footer_text)
|
return self.renderer.render_lines(main_text, footer_text)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user