Mercurial > boomslang
diff gamelib/widgets.py @ 217:146cec58ddd8
Highlight detailed view close button
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Thu, 26 Aug 2010 20:26:41 +0200 |
parents | 20998c650ce1 |
children | 3cedc4f95925 |
line wrap: on
line diff
--- a/gamelib/widgets.py Thu Aug 26 20:02:02 2010 +0200 +++ b/gamelib/widgets.py Thu Aug 26 20:26:41 2010 +0200 @@ -6,6 +6,7 @@ import textwrap import albow.controls +from albow.resource import get_font from pygame.color import Color from pygame.locals import BLEND_ADD @@ -36,6 +37,23 @@ def _draw_all_no_bg(self, surface): pass +class BoomButton(BoomLabel): + + def __init__(self, text, action, screen): + super(BoomLabel, self).__init__(text, font=get_font(20, 'Vera.ttf')) + self.bg_color = (0, 0, 0) + self.action = action + self.screen = screen + + def mouse_down(self, event): + self.action() + self.screen.state_widget.mouse_move(event) + + def mouse_move(self, event): + pos = self.parent.global_to_local(event.pos) + if self.rect.collidepoint(pos): + self.screen.cursor_highlight(True) + class MessageDialog(BoomLabel, CursorWidget):