comparison pyntnclick/widgets/base.py @ 678:36d7f7e9650e pyntnclick

Modal magic. (And yes, it is quite magical.)
author Jeremy Thurgood <firxen@gmail.com>
date Sun, 12 Feb 2012 21:47:06 +0200
parents 55d5d384fc16
children fa168b5e2624
comparison
equal deleted inserted replaced
677:a8c42709a689 678:36d7f7e9650e
120 def draw(self, surface): 120 def draw(self, surface):
121 for child in self.children: 121 for child in self.children:
122 child.draw(surface) 122 child.draw(surface)
123 123
124 124
125 class ModalStackContainer(Container):
126
127 def __init__(self, rect, gd, obscure_color=None):
128 super(ModalStackContainer, self).__init__(rect, gd)
129 if obscure_color is None:
130 obscure_color = gd.constants.modal_obscure_color
131 self.obscure_color = convert_color(obscure_color)
132
133 def event(self, ev):
134 """Only the topmost child gets events.
135 """
136 if self.children[-1].event(ev):
137 return True
138
139 if super(Container, self).event(ev):
140 return True
141
142 def draw(self, surface):
143 obscure = pygame.Surface(self.rect.size, SRCALPHA)
144 obscure.fill(self.obscure_color)
145 for child in self.children:
146 surface.blit(obscure, self.rect)
147 child.draw(surface)
148
149
125 class GridContainer(Container): 150 class GridContainer(Container):
126 """Hacky container that only supports grids, won't work with Container 151 """Hacky container that only supports grids, won't work with Container
127 children, or modal children. 152 children, or modal children.
128 """ 153 """
129 154