Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1:/tmp/cvs-serv20206/src

Modified Files:
        osd.py 
Log Message:
move the shadow code into osd.py

Index: osd.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/osd.py,v
retrieving revision 1.113
retrieving revision 1.114
diff -C2 -d -r1.113 -r1.114
*** osd.py      31 Dec 2003 16:41:43 -0000      1.113
--- osd.py      1 Jan 2004 15:53:18 -0000       1.114
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.114  2004/01/01 15:53:18  dischi
+ # move the shadow code into osd.py
+ #
  # Revision 1.113  2003/12/31 16:41:43  dischi
  # cache all thumbnails when config.OVERLAY_DIR_STORE_THUMBNAILS
***************
*** 770,774 ****
      def drawstringframed(self, string, x, y, width, height, font, fgcolor=None,
                           bgcolor=None, align_h='left', align_v='top', mode='hard',
!                          layer=None, ellipses='...'):
          """
          draws a string (text) in a frame. This tries to fit the
--- 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
***************
*** 789,799 ****
--- 792,817 ----
          - mode: the way we should break lines/truncate. Can be 'hard'(based on chars)
            or 'soft' (based on words)
+         - shadow can be a list of (x, y, color)
          """
          if not string:
              return '', (x,y,x,y)
  
+         if shadow:
+             shadow_x, shadow_y = shadow[:2]
+         else:
+             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:
***************
*** 803,808 ****
              return string, (x,y,x,y)
              
!         num_lines_left = int((height+line_height-font.height) / line_height)
!         lines = []
          current_ellipses = ''
          hard = mode == 'hard'
--- 821,826 ----
              return string, (x,y,x,y)
              
!         num_lines_left   = int((height+line_height-font.height) / line_height)
!         lines            = []
          current_ellipses = ''
          hard = mode == 'hard'
***************
*** 843,847 ****
              y += int((height - height_needed)/2)
  
!         y0 = y
          min_x = 10000
          max_x = 0
--- 861,865 ----
              y += int((height - height_needed)/2)
  
!         y0    = y
          min_x = 10000
          max_x = 0
***************
*** 850,853 ****
--- 868,876 ----
              layer = self.screen
  
+         if layer:
+             fgcolor  = self._sdlcol(fgcolor)
+             if shadow:
+                 shadow_color = self._sdlcol(shadow[2])
+ 
          for w, l in lines:
              if not l:
***************
*** 855,859 ****
  
              x0 = x
!             if layer != '':
                  try:
                      # render the string. Ignore all the helper functions for that
--- 878,882 ----
  
              x0 = x
!             if layer:
                  try:
                      # render the string. Ignore all the helper functions for that
***************
*** 862,866 ****
                      # redraws changed areas, it doesn't matter and saves the time
                      # when searching the cache
!                     render = font.font.render(l, 1, self._sdlcol(fgcolor))
                      if align_h == 'right':
                          x0 = x + width - render.get_size()[0]
--- 885,889 ----
                      # redraws changed areas, it doesn't matter and saves the time
                      # when searching the cache
!                     render = font.font.render(l, 1, fgcolor)
                      if align_h == 'right':
                          x0 = x + width - render.get_size()[0]
***************
*** 871,874 ****
--- 894,900 ----
                                       y0+render.get_size()[1], color=bgcolor, fill=1,
                                       layer=layer)
+                     if shadow:
+                         layer.blit(font.font.render(l, 1, shadow_color),
+                                    (x0+shadow_x, y0+shadow_y))
                      layer.blit(render, (x0, y0))
                  except:
***************
*** 880,883 ****
--- 906,919 ----
              y0 += line_height
  
+         if shadow:
+             if shadow_x < 0:
+                 min_x += shadow_x
+             else:
+                 max_x += shadow_x
+             if shadow_y < 0:
+                 y += shadow_y
+                 height_needed -= shadow_y
+             else:
+                 height_needed += shadow_y
          return r, (min_x, y, max_x, y+height_needed)
      
***************
*** 1257,1260 ****
--- 1293,1298 ----
      # Convert a 32-bit TRGB color to a 4 element tuple for SDL
      def _sdlcol(self, col):
+         if col==None:
+             return (0,0,0,255)
          a = 255 - ((col >> 24) & 0xff)
          r = (col >> 16) & 0xff




-------------------------------------------------------
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

Reply via email to