Mercurial > boomslang
diff gamelib/cursor.py @ 70:213e47dea4d0
Funkier cursor handling
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Mon, 23 Aug 2010 20:54:04 +0200 |
parents | 05346a412b55 |
children | c76f2fad2af5 |
line wrap: on
line diff
--- a/gamelib/cursor.py Mon Aug 23 20:50:36 2010 +0200 +++ b/gamelib/cursor.py Mon Aug 23 20:54:04 2010 +0200 @@ -3,9 +3,15 @@ # Sprite Cursor from albow.screen import Screen +from albow.widget import Widget from albow.resource import get_image import pygame.mouse as mouse from pygame.sprite import Sprite, RenderUpdates +import pygame.cursors +import pygame.mouse + +# FIXME: make this a all transparent cursor +BLANK_CURSOR=pygame.cursors.broken_x class CursorSprite(Sprite): "A Sprite that follows the Cursor" @@ -18,6 +24,15 @@ def update(self): self.rect.midtop = mouse.get_pos() +class CursorWidget(Widget): + """Mix-in widget to ensure that mouse_move is propogated to parents""" + + def mouse_move(self, event): + self.call_parent_handler('mouse_move', event) + + def get_cursor(self, event): + return BLANK_CURSOR + class CursorSpriteScreen(Screen): "A Screen with a CursorSprite" @@ -29,8 +44,12 @@ self.cursor_group = RenderUpdates(sprite) def draw(self, surface): - self.cursor_group.update() - self.cursor_group.draw(surface) + if self.get_cursor(None) == pygame.mouse.get_cursor(): + self.cursor_group.update() + self.cursor_group.draw(surface) def mouse_move(self, event): self.invalidate() + + def get_cursor(self, event): + return BLANK_CURSOR