double-arrow selector
authorNeil <neil@dip.sun.ac.za>
Sat, 17 May 2014 10:32:15 +0000 (12:32 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 17 May 2014 10:34:29 +0000 (12:34 +0200)
naja/widgets/selector.py

index dcbc74498b930b3e4d2b31aa6318eae7d59d6b57..06e63e5f24ae73f2f169335d403bb4282621f728 100644 (file)
@@ -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.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
 
 
 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
     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)
 
     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)
         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)
 
     def change_pos(self, change):
         self.position = (self.position + change) % len(self.widgets)