Update of /cvsroot/freevo/freevo/src/skins/main
In directory sc8-pr-cvs1:/tmp/cvs-serv31418/skins/main

Modified Files:
        listing_area.py skin_utils.py 
Log Message:
Changes in the table code of menu items:
o use percentage again, pixel sizes are bad because they don't scale
o add special handling to avoid hardcoding texts in the skin file
o new function for the skin: text_or_icon for this handling

Format for this texts inside a table:
ICON_<ORIENTATION>_<IMAGE_NAME>_<TEXT IF NO IMAGE IS THERE>



Index: listing_area.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/skins/main/listing_area.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** listing_area.py     22 Oct 2003 03:00:12 -0000      1.11
--- listing_area.py     22 Oct 2003 18:26:09 -0000      1.12
***************
*** 10,13 ****
--- 10,22 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.12  2003/10/22 18:26:09  dischi
+ # Changes in the table code of menu items:
+ # o use percentage again, pixel sizes are bad because they don't scale
+ # o add special handling to avoid hardcoding texts in the skin file
+ # o new function for the skin: text_or_icon for this handling
+ #
+ # Format for this texts inside a table:
+ # ICON_<ORIENTATION>_<IMAGE_NAME>_<TEXT IF NO IMAGE IS THERE>
+ #
  # Revision 1.11  2003/10/22 03:00:12  gsbarbieri
  # Support icons instead of labels "on", "off" and "auto"
***************
*** 400,466 ****
                  # item _must_ have that many tabs as the table needs!!!
                  if hasattr(menu, 'table'):
!                     if -1 in menu.table:
!                         # calculate the remaining space to use instead of -1
!                         space_taken = 0
!                         divisors = 0
!                         for i in menu.table:
!                             if i >= 1:
!                                 space_taken += i
!                             elif i <= 0:
!                                 divisors += 1
!                             # else -> percentage
!                             
!                         if divisors > 0:
!                             space_left = ( width - space_taken - hskip * 2 ) / 
divisors
!                             for i in range( len( menu.table ) ):
!                                 if menu.table[ i ] <= 0:
!                                     menu.table[ i ] = space_left
!                         
!                     table_x = x0 + x_icon + hskip
!                     y0 += vskip
                      for i in range(len(menu.table)):
!                         table_w = menu.table[i]
!                         # XXX TODO: handle values between 0 and 1 as percentage.
!                         
!                         my_text = text.split( '\t' )
!                         
!                         # Quick Hack to show icons instead of label for "on", "off" 
and "auto"
!                         use_text=1
!                         if my_text[ i ] in ( _("on"), _("off"), _("auto") ):
!                             img = None
!                             if my_text[ i ] == _( "on" ):
!                                 img = "on"
!                             elif my_text[ i ] == _( "off" ):
!                                 img = "off"
!                             elif my_text[ i ] == _( "auto" ):
!                                 img = "auto"
! 
!                             # check if there's the image
!                             image = None
!                             try:                                
!                                 img = area.images[ img ].filename
!                                 image = osd.loadbitmap( img , True )
!                                 my_width, my_height = image.get_size()
!                             except:
!                                 # Fallback to text mode
!                                 use_text = 1
!                                 
!                             if image:
!                                 my_w = min( table_w, my_width )
!                                 my_h = min( vspace - vskip * 2, my_height )
                                  
!                                 if my_width == my_height:
!                                     my_w = my_h = min( my_w, my_h )
!                                 self.draw_image( img, ( table_x + (table_w - my_w) / 
2,
!                                                         y0,
!                                                         my_w, my_h ) )
!                                 use_text = 0                            
! 
!                         if use_text:
!                             self.write_text(my_text[i], val.font, content,
!                                             x=table_x, y=y0, width=table_w, 
height=-1,
                                              align_h=val.align, mode='hard')
!                         
!                         table_x += table_w + hskip
                  else:
                      self.write_text(text, val.font, content, x=x0 + hskip + x_icon,
--- 409,433 ----
                  # item _must_ have that many tabs as the table needs!!!
                  if hasattr(menu, 'table'):
!                     table_x = x0 + hskip + x_icon
!                     table_text = text.split('\t')
                      for i in range(len(menu.table)):
!                         table_w = ((width-icon_x-len(table_text)*5)*menu.table[i]) / 
100
!                         if i != len(menu.table) - 1:
!                             table_w += 5
!                         x_mod = 0
!                         if table_text[i].find('ICON_') == 0:
!                             x_mod, table_text[i] = text_or_icon(area, table_text[i], 
table_x,
!                                                                 table_w, val.font)
!                             if not isinstance(table_text[i], str):
!                                 self.draw_image(table_text[i], (table_x + x_mod, y0 
+ vskip))
!                                 table_text[i] = ''
                                  
!                         if table_text[i]:
!                             self.write_text(table_text[i], val.font, content,
!                                             x=table_x + x_mod,
!                                             y=y0 + vskip, width=table_w, height=-1,
                                              align_h=val.align, mode='hard')
!                         table_x += table_w + 5
! 
                  else:
                      self.write_text(text, val.font, content, x=x0 + hskip + x_icon,

Index: skin_utils.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/skins/main/skin_utils.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** skin_utils.py       3 Sep 2003 21:13:48 -0000       1.6
--- skin_utils.py       22 Oct 2003 18:26:10 -0000      1.7
***************
*** 10,13 ****
--- 10,22 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.7  2003/10/22 18:26:10  dischi
+ # Changes in the table code of menu items:
+ # o use percentage again, pixel sizes are bad because they don't scale
+ # o add special handling to avoid hardcoding texts in the skin file
+ # o new function for the skin: text_or_icon for this handling
+ #
+ # Format for this texts inside a table:
+ # ICON_<ORIENTATION>_<IMAGE_NAME>_<TEXT IF NO IMAGE IS THERE>
+ #
  # Revision 1.6  2003/09/03 21:13:48  dischi
  # fix aspect calc to check if correction is needed
***************
*** 168,169 ****
--- 177,223 ----
      return cimage, width, height
      
+ 
+ def text_or_icon(settings, string, x, width, font):
+     l = string.split('_')
+     if len(l) != 4:
+         return string
+     try:
+         height = font.h
+         image = settings.images[l[2].lower()].filename
+         if image:
+             cname = '%s-%s-%s-%s-%s' % (image, x, l[1], width, height)
+             cimage = format_imagecache[cname]
+             if cimage:
+                 return cimage
+             
+             image = osd.loadbitmap(image)
+             if not image:
+                 raise KeyError
+             i_w, i_h = image.get_size()
+             original_width = width
+             if int(float(width * i_h) / i_w) > height:
+                 width =  int(float(height * i_w) / i_h)
+             else:
+                 height = int(float(width * i_h) / i_w)
+         
+             cimage = pygame.transform.scale(image, (width, height))
+             cimage.set_alpha(cimage.get_alpha(), RLEACCEL)
+             x_mod = 0
+             if l[1] == 'CENTER':
+                 x_mod = (original_width - width) / 2
+             if l[1] == 'RIGHT':
+                 x_mod = original_width - width
+             format_imagecache[cname] = x_mod, cimage
+             return x_mod, cimage
+     except KeyError:
+         _debug_('no image %s' % l[2])
+         pass
+ 
+     mod_x = width - font.font.stringsize(l[3])
+     if mod_x < 0:
+         mod_x = 0
+     if l[1] == 'CENTER':
+         return mod_x / 2, l[3]
+     if l[1] == 'RIGHT':
+         return mod_x, l[3]
+     return 0, l[3]




-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to