Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1:/tmp/cvs-serv5475
Modified Files:
osd.py
Log Message:
added border support for drawstringframed
Index: osd.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/osd.py,v
retrieving revision 1.114
retrieving revision 1.115
diff -C2 -d -r1.114 -r1.115
*** osd.py 1 Jan 2004 15:53:18 -0000 1.114
--- osd.py 1 Jan 2004 17:40:24 -0000 1.115
***************
*** 11,14 ****
--- 11,17 ----
# -----------------------------------------------------------------------
# $Log$
+ # Revision 1.115 2004/01/01 17:40:24 dischi
+ # added border support for drawstringframed
+ #
# Revision 1.114 2004/01/01 15:53:18 dischi
# move the shadow code into osd.py
***************
*** 773,777 ****
def drawstringframed(self, string, x, y, width, height, font, fgcolor=None,
bgcolor=None, align_h='left', align_v='top', mode='hard',
! layer=None, shadow=None, ellipses='...'):
"""
draws a string (text) in a frame. This tries to fit the
--- 776,780 ----
def drawstringframed(self, string, x, y, width, height, font, fgcolor=None,
bgcolor=None, align_h='left', align_v='top', mode='hard',
! shadow=None, border_color=None, layer=None, ellipses='...'):
"""
draws a string (text) in a frame. This tries to fit the
***************
*** 793,796 ****
--- 796,802 ----
or 'soft' (based on words)
- shadow can be a list of (x, y, color)
+ - border_color is a border around the text.
+
+ You can't use border_color and shadow at the same time
"""
if not string:
***************
*** 802,817 ****
shadow_x = 0
shadow_y = 0
if height == -1:
height = font.height
else:
height -= abs(shadow_y)
! width -= abs(shadow_x)
if shadow_x < 0:
x -= shadow_x
if shadow_y < 0:
y -= shadow_y
!
line_height = font.height * 1.1
if int(line_height) < line_height:
--- 808,831 ----
shadow_x = 0
shadow_y = 0
+
+ border_radius = 0
+ if border_color != None:
+ border_radius = int(font.ptsize/10)
if height == -1:
height = font.height
+ elif border_color != None:
+ height -= border_radius
else:
height -= abs(shadow_y)
! width = width - (abs(shadow_x) + border_radius * 2)
if shadow_x < 0:
x -= shadow_x
if shadow_y < 0:
y -= shadow_y
! x += border_radius
! y += border_radius
!
line_height = font.height * 1.1
if int(line_height) < line_height:
***************
*** 872,876 ****
if shadow:
shadow_color = self._sdlcol(shadow[2])
!
for w, l in lines:
if not l:
--- 886,892 ----
if shadow:
shadow_color = self._sdlcol(shadow[2])
! if border_color != None:
! border_color = self._sdlcol(border_color)
!
for w, l in lines:
if not l:
***************
*** 886,903 ****
--- 902,935 ----
# when searching the cache
render = font.font.render(l, 1, fgcolor)
+
+ # calc x/y positions based on align
if align_h == 'right':
x0 = x + width - render.get_size()[0]
elif align_h == 'center':
x0 = x + int((width - render.get_size()[0]) / 2)
+
if bgcolor:
+ # draw a box around the text if we have a bgcolor
self.drawbox(x0, y0, x0+render.get_size()[0],
y0+render.get_size()[1], color=bgcolor, fill=1,
layer=layer)
+ if border_color:
+ # draw the text 8 times with the border_color to get
+ # the border effect
+ for ox in (-border_radius, 0, border_radius):
+ for oy in (-border_radius, 0, border_radius):
+ if ox and oy:
+ layer.blit(font.font.render(l, 1, border_color),
+ (x0+ox, y0+oy))
if shadow:
+ # draw the text in the shadow_color to get a shadow
layer.blit(font.font.render(l, 1, shadow_color),
(x0+shadow_x, y0+shadow_y))
+
+ # draw the text in the fgcolor
layer.blit(render, (x0, y0))
except:
print "Render failed, skipping..."
+
if x0 < min_x:
min_x = x0
***************
*** 906,909 ****
--- 938,943 ----
y0 += line_height
+ # change max_x, min_x, y and height_needed to reflect the
+ # changes from border and shadow
if shadow:
if shadow_x < 0:
***************
*** 916,919 ****
--- 950,960 ----
else:
height_needed += shadow_y
+
+ if border_color:
+ max_x += border_radius
+ min_x -= border_radius
+ y -= border_radius
+ height_needed += border_radius * 2
+
return r, (min_x, y, max_x, y+height_needed)
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog