directOptionsMenu and item_text_scale

Hello everybody!

gui.viewListBox = DirectOptionMenu(text="options", text_scale=0.8, item_text_scale=(0.8,0.8), scale=0.08, pos=(0, 0, 0) ,items=["Front View", "Reverse View", "Side View", "Top View"],initialitem=0, highlightColor=(0.65,0.65,0.65,1), command=gui.rotateViews, relief=None, popupMarker_relief=None)

problem with the code above. Using item_text_scale(x,y) works to scale the text of the items, but only so far as to rolling over the items. The scale will reset back to 1,1 if you rollover the items and stay that way. Is it possible to set the scale of the rollover state?

Also I would have thought that

item_text_scale(((0.8,0.8),(0.5,0.5),(0.8,0.8),(0.7,0.7)), (0.5, 0.5), (0.8,0.8), (0.5,0.5))

would work using the logic of

items=[("Front View up","Front View pressed","Front View rollover", "Front View disabled" ), "Reverse View", "Side View", "Top View"]

but instead it seems you have to set the individual scales like this

item0_text_scale = (0.8,0.8), item1_text_scale = (0.5,0.5)

etc thus i would have thought

Browsing through DirectOptionMenu.py, I see the following code:

    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

Looks like the DirectOptionMenu wants to adjust the scale of its items directly as you roll over the items. It also looks like, since it resets the item scale to (1,1) after rollover, you have to accept that scale. Clearly, it would be better if it set it to some parameterized scale (like ‘unhighlightScale’?) or didn’t do this at all unless you asked it to; if you’d like to submit a patch to correct this, we’d be happy to accept it–especially if you could design it not to break existing menu code.

In the meantime, is it possible to apply the scale you desire to the overall menu, instead of just to the individual items?

David

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 

Yes I am looking for a 0.8 scale ratio across the whole menu. So as a temp fix I will just change the line

 item['text_scale'] = (1,1)

to

item['text_scale'] = (0.8,0.8)

. With regards to a patch look for something next week / Ill post it then (quite busy ATM).

I’ll work to see if I can’t implement different scales fore each state of the menu item button (up, pressed, rollover, disabled) as well.

Thanks for the reply

Robert.