Update of /cvsroot/freevo/freevo/src/gui/widgets
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22615

Modified Files:
        image.py rectangle.py text.py textbox.py 
Log Message:
internal colors are now lists, not int

Index: image.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/widgets/image.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** image.py    22 Aug 2004 20:06:21 -0000      1.3
--- image.py    7 Sep 2004 18:48:57 -0000       1.4
***************
*** 7,10 ****
--- 7,13 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.4  2004/09/07 18:48:57  dischi
+ # internal colors are now lists, not int
+ #
  # Revision 1.3  2004/08/22 20:06:21  dischi
  # Switch to mevas as backend for all drawing operations. The mevas
***************
*** 19,23 ****
  # make some widgets and boxes work with the new gui interface
  #
- #
  # -----------------------------------------------------------------------
  #
--- 22,25 ----
***************
*** 42,46 ****
  # ----------------------------------------------------------------------
  
- 
  from mevas.image import CanvasImage
  
--- 44,47 ----
***************
*** 51,58 ****
      def __init__(self, image, (x, y), size=None):
          if not image:
!             return None
! 
          CanvasImage.__init__(self, image)
- 
          if size:
              width, height = size
--- 52,59 ----
      def __init__(self, image, (x, y), size=None):
          if not image:
!             CanvasImage.__init__(self, (1,1))
!             return
!         
          CanvasImage.__init__(self, image)
          if size:
              width, height = size
***************
*** 62,69 ****
                  width = (height * float(image_w)) / float(image_h)
              if height == None or height == -1:
!                 # calculate width
                  height = (width * float(image_h)) / float(image_w)
              if width != self.image.width or height != self.image.height:
                  self.image.scale((width, height))
-         self.set_pos((x, y))
  
--- 63,70 ----
                  width = (height * float(image_w)) / float(image_h)
              if height == None or height == -1:
!                 # calculate height
                  height = (width * float(image_h)) / float(image_w)
              if width != self.image.width or height != self.image.height:
                  self.image.scale((width, height))
  
+         self.set_pos((x, y))

Index: textbox.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/widgets/textbox.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** textbox.py  26 Aug 2004 15:30:06 -0000      1.2
--- textbox.py  7 Sep 2004 18:48:57 -0000       1.3
***************
*** 7,10 ****
--- 7,13 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.3  2004/09/07 18:48:57  dischi
+ # internal colors are now lists, not int
+ #
  # Revision 1.2  2004/08/26 15:30:06  dischi
  # bug fix for very small sizes
***************
*** 51,54 ****
--- 54,58 ----
                   fgcolor=None, bgcolor=None):
  
+         self.text = text
          if not text or height < font.height:
              CanvasImage.__init__(self, (1, 1))

Index: rectangle.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/widgets/rectangle.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rectangle.py        22 Aug 2004 20:06:21 -0000      1.4
--- rectangle.py        7 Sep 2004 18:48:57 -0000       1.5
***************
*** 7,10 ****
--- 7,13 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.5  2004/09/07 18:48:57  dischi
+ # internal colors are now lists, not int
+ #
  # Revision 1.4  2004/08/22 20:06:21  dischi
  # Switch to mevas as backend for all drawing operations. The mevas
***************
*** 52,64 ****
      A rectangle object that can be drawn onto a layer
      """
!     def __init__(self, (x, y), (w, h), bgcolor, size=0, color=0, radius=0):
          CanvasImage.__init__(self, ((w, h)))
! 
!         try:
!             color = self._mevascol(color)
!             bgcolor = self._mevascol(bgcolor)
!         except TypeError:
!             pass
!         
          # make sure the radius fits the box
          radius = min(radius, h / 2, w / 2)
--- 55,63 ----
      A rectangle object that can be drawn onto a layer
      """
!     def __init__(self, (x, y), (w, h), bgcolor=None, size=0, color=None, radius=0):
          CanvasImage.__init__(self, ((w, h)))
!         if x or y:
!             self.set_pos((x, y))
!             
          # make sure the radius fits the box
          radius = min(radius, h / 2, w / 2)
***************
*** 68,121 ****
              # Drawing border + filling is very easy because there are
              # no overlapping draw areas
!             if size:
                  for i in range(size):
                      self.draw_rectangle((i, i), (w-2*i, h-2*i), color, 0)
!             self.draw_rectangle((size, size), (w-2*size, h-2*size), bgcolor, 1)
!         else:
!             # Round rectangle. Simple again, if there is no alpha
!             # value and no border. Else, we need do do some tricks by
!             # calling this recursive
!             if size:
!                 if bgcolor[3] == 255:
!                     r, g, b, a = color
!                     r = Rectangle((0,0), (w,h), (r,g,b,255), 0, color, radius)
!                     self.draw_image(r, alpha=a)
                  else:
!                     _debug_('FIXME: round rectangle with border missing')
!             r, g, b, a = bgcolor
!             if a == 255:
!                 # no alpha, just draw
!                 # first set some variables, this part needs some tuning because
!                 # it doesn't look right to me
!                 w -= 2 * size
!                 h -= 2 * size
!                 amplitude = (radius, radius)
!                 radius += 1
!                 self.draw_ellipse((radius+size, radius+size), amplitude, (r,g,b), 1)
!                 self.draw_ellipse((size+w-radius, radius+size), amplitude, (r,g,b), 
1)
!                 self.draw_ellipse((radius+size, size+h-radius), amplitude, (r,g,b), 
1)
!                 self.draw_ellipse((size+w-radius, size+h-radius), amplitude, 
(r,g,b), 1)
!                 self.draw_rectangle((radius+size, size), (w-2*radius, h), (r,g,b), 1)
!                 self.draw_rectangle((size, radius+size), (w, h-2*radius), (r,g,b), 1)
              else:
!                 # alpha value :-(
!                 r = Rectangle((size,size), (w-2*size, h-2*size), (r,g,b,255), 0, 0, 
radius)
!                 self.draw_image(r, alpha=a)
  
!         if x or y:
!             self.set_pos((x, y))
  
  
-     def _mevascol(self, col):
-         """
-         Convert a 32-bit TRGB color to a 4 element tuple
-         """
-         if col == None:
-             return (0,0,0,255)
-         a = 255 - ((col >> 24) & 0xff)
-         r = (col >> 16) & 0xff
-         g = (col >> 8) & 0xff
-         b = (col >> 0) & 0xff
-         c = (r, g, b, a)
-         return c
  
--- 67,114 ----
              # Drawing border + filling is very easy because there are
              # no overlapping draw areas
!             if size and color:
                  for i in range(size):
                      self.draw_rectangle((i, i), (w-2*i, h-2*i), color, 0)
!             if bgcolor:
!                 self.draw_rectangle((size, size), (w-2*size, h-2*size), bgcolor, 1)
!             return
!         
!         # Round rectangle. Simple again, if there is no alpha
!         # value and no border. Else, we need do do some tricks by
!         # calling this recursive
!         if size and color:
!             if not bgcolor or len(bgcolor) == 3 or bgcolor[3] == 255:
!                 r = Rectangle((0,0), (w,h), color[:3], 0, None, radius)
!                 if len(color) == 3:
!                     self.draw_image(r)
                  else:
!                     self.draw_image(r, alpha=color[-1])
              else:
!                 _debug_('FIXME: round rectangle with border missing')
  
!         if not bgcolor:
!             return
  
+         if len(bgcolor) == 3 or bgcolor[3] == 255:
+             # no alpha, just draw
+             # first set some variables, this part needs some tuning because
+             # it doesn't look right to me
+             w -= 2 * size
+             h -= 2 * size
+             amplitude = (radius, radius)
+             radius += 1
+             self.draw_ellipse((radius+size, radius+size), amplitude, bgcolor[:3], 1)
+             self.draw_ellipse((size+w-radius, radius+size), amplitude, bgcolor[:3], 
1)
+             self.draw_ellipse((radius+size, size+h-radius), amplitude, bgcolor[:3], 
1)
+             self.draw_ellipse((size+w-radius, size+h-radius), amplitude, 
bgcolor[:3], 1)
+             self.draw_rectangle((radius+size, size), (w-2*radius, h), bgcolor[:3], 1)
+             self.draw_rectangle((size, radius+size), (w, h-2*radius), bgcolor[:3], 1)
+         else:
+             # alpha value :-(
+             r = Rectangle((size,size), (w-2*size, h-2*size), bgcolor[:3], 0, 0, 
radius)
+             self.draw_image(r, alpha=bgcolor[3])
  
  
+     def __str__(self):
+         return 'Rectangle pos=%sx%s, size=%sx%s, zindex=%s' % \
+                (self.get_pos() + self.get_size() + (self.get_zindex(), ))

Index: text.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/gui/widgets/text.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** text.py     26 Aug 2004 18:12:13 -0000      1.6
--- text.py     7 Sep 2004 18:48:57 -0000       1.7
***************
*** 7,10 ****
--- 7,13 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.7  2004/09/07 18:48:57  dischi
+ # internal colors are now lists, not int
+ #
  # Revision 1.6  2004/08/26 18:12:13  dischi
  # make sure we create valid sizes
***************
*** 62,65 ****
--- 65,69 ----
                   fgcolor=None, bgcolor=None):
  
+         self.text = text
          if not text or height < font.height:
              CanvasImage.__init__(self, (1, 1))
***************
*** 125,129 ****
                  f = os.path.join(config.IMAGE_DIR, 'blend.png')
                  dim_image = mevas.imagelib.open(f)
!                 dim_image.scale((25, font.height))
              self.image.draw_mask(dim_image, (stringsize - 25, 0))
  
--- 129,133 ----
                  f = os.path.join(config.IMAGE_DIR, 'blend.png')
                  dim_image = mevas.imagelib.open(f)
!                 dim_image.scale((25, 1000))
              self.image.draw_mask(dim_image, (stringsize - 25, 0))
  
***************
*** 205,214 ****
              if self.font.shadow.visible:
                  if self.font.shadow.border:
!                     self.border_color  = self._mevascol(self.font.shadow.color)
                      self.border_radius = int(self.font.font.ptsize/10)
                  else:
                      self.shadow_x     = self.font.shadow.y
                      self.shadow_y     = self.font.shadow.x
!                     self.shadow_color = self._mevascol(self.font.shadow.color)
              if not self.fgcolor:
                  self.fgcolor = self.font.color
--- 209,218 ----
              if self.font.shadow.visible:
                  if self.font.shadow.border:
!                     self.border_color  = self.font.shadow.color
                      self.border_radius = int(self.font.font.ptsize/10)
                  else:
                      self.shadow_x     = self.font.shadow.y
                      self.shadow_y     = self.font.shadow.x
!                     self.shadow_color = self.font.shadow.color
              if not self.fgcolor:
                  self.fgcolor = self.font.color
***************
*** 219,225 ****
          # save the new values
          self.font = self.font.font
-         self.fgcolor = self._mevascol(self.fgcolor)
-         if self.bgcolor:
-             self.bgcolor = self._mevascol(self.bgcolor)
  
  
--- 223,226 ----
***************
*** 240,253 ****
  
  
!     def _mevascol(self, col):
!         """
!         Convert a 32-bit TRGB color to a 4 element tuple
!         """
!         if col == None:
!             return (0,0,0,255)
!         a = 255 - ((col >> 24) & 0xff)
!         r = (col >> 16) & 0xff
!         g = (col >> 8) & 0xff
!         b = (col >> 0) & 0xff
!         c = (r, g, b, a)
!         return c
--- 241,249 ----
  
  
!     def __str__(self):
!         if len(self.text) > 20:
!             t = self.text[:20]
!         else:
!             t = self.text
!         return 'Text: "%s", zindex=%s' % (String(t), self.get_zindex())
!     



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to