From: Neil Date: Sat, 17 May 2014 10:32:15 +0000 (+0200) Subject: double-arrow selector X-Git-Tag: 0.1~128 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=afb497fee73e9fdc15da752c4f373feca3b0b57c;p=naja.git double-arrow selector --- diff --git a/naja/widgets/selector.py b/naja/widgets/selector.py index dcbc744..06e63e5 100644 --- a/naja/widgets/selector.py +++ b/naja/widgets/selector.py @@ -3,7 +3,7 @@ import pygame.locals as pgl from naja.constants import KEYS from naja.widgets.base import Container from naja.resources import resources -from naja.resources.mutators import EIGHT_BIT, R270 +from naja.resources.mutators import EIGHT_BIT, R270, R90 from naja.sound import sound @@ -11,19 +11,25 @@ class SelectorWidget(Container): def __init__(self, *args, **kwargs): super(SelectorWidget, self).__init__(*args, **kwargs) self.position = 0 - self.selector = resources.get_image('bits', 'arrow_on.png', - transforms=(R270, EIGHT_BIT)) + self.left_selector = resources.get_image('bits', 'arrow_on.png', + transforms=(R270, EIGHT_BIT)) + self.right_selector = resources.get_image('bits', 'arrow_on.png', + transforms=(R90, EIGHT_BIT)) def render(self, surface): super(SelectorWidget, self).render(surface) - pos = self.selector.get_rect() + pos = self.left_selector.get_rect() selected = self.widgets[self.position] if not selected.is_selectable(): selected = self.change_pos(1) pos = pos.move(selected.pos) - pos = pos.move(-pos.width * 1.5, (selected.size[1] - pos.height) / 2) - surface.blit(self.selector, pos) + left_pos = pos.move(-pos.width * 1.5, + (selected.size[1] - pos.height) / 2) + right_pos = pos.move(selected.size[0] + pos.width * 0.5, + (selected.size[1] - pos.height) / 2) + surface.blit(self.left_selector, left_pos) + surface.blit(self.right_selector, right_pos) def change_pos(self, change): self.position = (self.position + change) % len(self.widgets)