adding ability to have highlighted menu items also change scale in addition to color

This commit is contained in:
Chris Brunner 2006-06-21 00:23:42 +00:00
parent 8a6a7ee3e2
commit 3224887a2b

View File

@ -21,6 +21,8 @@ class DirectOptionMenu(DirectButton):
('popupMarkerBorder', (.1, .1), None),
# Background color to use to highlight popup menu items
('highlightColor', (.5, .5, .5, 1), None),
# Extra scale to use on highlight popup menu items
('highlightScale', (1, 1), None),
# Alignment to use for text on popup menu button
# Changing this breaks button layout
('text_align', TextNode.ALeft, None),
@ -216,11 +218,15 @@ class DirectOptionMenu(DirectButton):
def _highlightItem(self, item, index):
""" Set frame color of highlighted item, record index """
item['frameColor'] = self['highlightColor']
item['frameSize'] = (self['highlightScale'][0]*self.minX, self['highlightScale'][0]*self.maxX, self['highlightScale'][1]*self.minZ, self['highlightScale'][1]*self.maxZ)
item['text_scale'] = self['highlightScale']
self.highlightedIndex = index
def _unhighlightItem(self, item, frameColor):
""" Clear frame color, clear highlightedIndex """
item['frameColor'] = frameColor
item['frameSize'] = (self.minX, self.maxX, self.minZ, self.maxZ)
item['text_scale'] = (1,1)
self.highlightedIndex = None
def selectHighlightedIndex(self, event = None):