Author: duncan
Date: Thu Dec 13 15:34:08 2007
New Revision: 10204
Log:
Fixed the problem with rc.poll no longer existing
Fixed the mode being 0 which stopped the alpha blend mode working
Added _debug_ statements to function calls
Cleaned up the code a bit
Modified:
branches/rel-1/freevo/src/animation/base.py
branches/rel-1/freevo/src/animation/transition.py
branches/rel-1/freevo/src/image/viewer.py
Modified: branches/rel-1/freevo/src/animation/base.py
==============================================================================
--- branches/rel-1/freevo/src/animation/base.py (original)
+++ branches/rel-1/freevo/src/animation/base.py Thu Dec 13 15:34:08 2007
@@ -33,6 +33,7 @@
import pygame.time
import osd, render
+from kaa.notifier import Timer
class BaseAnimation:
"""
@@ -54,16 +55,16 @@
next_update = 0 # timestamp for next update
- def __init__(self, rectstyle, fps=20, bg_update=True,
- bg_wait=False, bg_redraw=False):
+ def __init__(self, rectstyle, fps=20, bg_update=True, bg_wait=False,
bg_redraw=False):
+ _debug_('__init__(rectstyle=%r, fps=%r, bg_update=%r, bg_wait=%r,
bg_redraw=%r)' % \
+ (rectstyle, fps, bg_update, bg_wait, bg_redraw), 2)
self.rect = Rect(rectstyle)
self.bg_update = bg_update
self.bg_wait = bg_wait
self.bg_redraw = bg_redraw
- self.surface = Surface( (self.rect.width,
- self.rect.height)).convert()
+ self.surface = Surface((self.rect.width, self.rect.height)).convert()
self.set_fps(fps)
@@ -72,6 +73,7 @@
"""
Helper for creating surfaces
"""
+ _debug_('get_surface(width=%r, height=%r)' % (width, height), 2)
return Surface( (width, height), 0, 32)
@@ -79,6 +81,7 @@
"""
Helper for getting osd singleton
"""
+ _debug_('get_osd()', 2)
return osd.get_singleton()
@@ -86,6 +89,7 @@
"""
Sets the desired fps
"""
+ _debug_('set_fps(fps=%r)' % (fps), 2)
self.interval = int(1000.0/float(fps))
@@ -93,6 +97,7 @@
"""
Update the background
"""
+ _debug_('set_screen_background()', 2)
if not self.background:
self.background = osd.get_singleton().getsurface(rect=self.rect)
self.updates = []
@@ -121,6 +126,7 @@
def get_rect(self):
+ _debug_('get_rect()', 2)
return self.rect
@@ -128,6 +134,7 @@
"""
Starts the animation
"""
+ _debug_('start()', 2)
render.get_singleton().add_animation(self)
if not self.bg_wait:
self.active = True
@@ -137,6 +144,7 @@
"""
Stops the animation from being polled
"""
+ _debug_('stop()', 2)
self.active = False
@@ -144,14 +152,13 @@
"""
Flags the animation to be removed from the animation list
"""
+ _debug_('remove()', 2)
self.active = False
# set the org. bg if we use this
if self.bg_update:
- osd.get_singleton().putsurface(self.background,
- self.rect.left,
- self.rect.top)
- osd.get_singleton().update( [self.rect] )
+ osd.get_singleton().putsurface(self.background, self.rect.left,
self.rect.top)
+ osd.get_singleton().update([self.rect])
self.delete = True
@@ -163,7 +170,7 @@
@note: If the rect passed damages our rect, but no actual blit is done
on osd.screen, we'll end up with a copy of our animation in our bg.
This is BAD.
"""
-
+ _debug_('damage(rectstyles=%r)' % (rectstyles), 2)
if not (self.bg_redraw or self.bg_update) or rectstyles == None:
return
@@ -180,7 +187,10 @@
def poll(self, current_time):
-
+ """
+ Poll the animations
+ """
+ _debug_('poll(current_time=%r)' % (current_time), 2)
if self.next_update < current_time:
self.next_update = current_time + self.interval
@@ -195,4 +205,5 @@
"""
Overload to do stuff with the surface
"""
+ _debug_('draw()', 2)
pass
Modified: branches/rel-1/freevo/src/animation/transition.py
==============================================================================
--- branches/rel-1/freevo/src/animation/transition.py (original)
+++ branches/rel-1/freevo/src/animation/transition.py Thu Dec 13 15:34:08 2007
@@ -55,6 +55,7 @@
@param direction: vertical/horizontal
"""
BaseAnimation.__init__(self, surf1.get_rect(), fps, bg_update=False)
+ _debug_('__init__(surf1=%r, surf2=%r, mode=%r, direction=%r, fps=%r)'
% (surf1, surf2, mode, direction, fps), 2)
self.steps = fps
self.mode = mode
@@ -69,11 +70,11 @@
self.surf_blend1 = surf1.convert()
self.surf_blend2 = surf2.convert()
-
self.prepare()
def prepare(self):
+ _debug_('prepare()', 2)
# random effect
if self.mode == -1:
@@ -117,16 +118,33 @@
def draw(self):
+ _debug_('draw()', 2)
if self.finished:
return
getattr(self, self.drawfuncs[self.mode])()
+ def draw_blend_alpha(self):
+ _debug_('draw_blend_alpha()', 2)
+
+ alpha = self.blend_alphas[self.index_alpha]
+
+ self.surf_blend2.set_alpha(alpha)
+ self.surface.blit(self.surf_blend1, (0, 0))
+ self.surface.blit(self.surf_blend2, (0, 0))
+
+ self.index_alpha += 1
+
+ if self.index_alpha > len(self.blend_alphas) - 1:
+ self.finished = True
+
+
def draw_wipe(self):
"""
Plain wipe
"""
+ _debug_('draw_wipe()', 2)
if self.offset_x > self.rect.width:
self.offset_x = self.rect.width
self.finished = True
@@ -158,7 +176,7 @@
XXX not working!
"""
-
+ _debug_('draw_wipe_alpha()', 2)
if self.line > self.size[0] - 1:
self.finished = True
@@ -197,17 +215,3 @@
self.surface.blit(self.surf_blend1, (0, 0))
self.surface.blit(self.surf_blend2, (0, 0))
-
-
- def draw_blend_alpha(self):
-
- alpha = self.blend_alphas[self.index_alpha]
-
- self.surf_blend2.set_alpha(alpha)
- self.surface.blit(self.surf_blend1, (0, 0))
- self.surface.blit(self.surf_blend2, (0, 0))
-
- self.index_alpha += 1
-
- if self.index_alpha > len(self.blend_alphas) - 1:
- self.finished = True
Modified: branches/rel-1/freevo/src/image/viewer.py
==============================================================================
--- branches/rel-1/freevo/src/image/viewer.py (original)
+++ branches/rel-1/freevo/src/image/viewer.py Thu Dec 13 15:34:08 2007
@@ -42,6 +42,7 @@
import time
from animation import render, Transition
+import pygame
# Module variable that contains an initialized ImageViewer() object
_singleton = None
@@ -73,6 +74,7 @@
self.slideshow = True
self.app_mode = 'image'
self.last_image = (None, None)
+ self.render = render.get_singleton()
self.osd = osd.get_singleton()
self.osd_height = self.osd.height
self.osd_width = self.osd.width * float(config.IMAGEVIEWER_ASPECT)
@@ -263,7 +265,7 @@
bbx += zoom[1]
bby += zoom[2]
- if (last_image and self.last_image[0] != item and
config.IMAGEVIEWER_BLEND_MODE):
+ if (last_image and self.last_image[0] != item and
config.IMAGEVIEWER_BLEND_MODE != None):
screen = self.osd.screen.convert()
screen.fill((0,0,0,0))
screen.blit(self.osd.zoomsurface(image, scale, bbx, bby, bbw, bbh,
@@ -272,15 +274,16 @@
self.drawosd(layer=screen)
blend = Transition(self.osd.screen, screen,
config.IMAGEVIEWER_BLEND_MODE)
+ clock = pygame.time.Clock()
blend.start()
while not blend.finished:
- rc.poll()
+ self.render.update()
+ #blend.poll(pygame.time.get_ticks())
blend.remove()
else:
self.osd.clearscreen(color=self.osd.COL_BLACK)
- self.osd.drawsurface(image, x, y, scale, bbx, bby, bbw, bbh,
- rotation=self.rotation)
+ self.osd.drawsurface(image, x, y, scale, bbx, bby, bbw, bbh,
rotation=self.rotation)
# update the OSD
self.drawosd()
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog