WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-01-2008, 09:22 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
VizMenu still in focus after calling setVisible

Ive got this menu and when I click a button, the menu hides via setVisible. When I want to, I bring the menu back, but when I use the mouse and click the menu title to it is still in focus and does not pop out until i focus its nebore menu title.


To see issue:
Run script
Select Simulation->Next Excersize
Press spacebar
Try to select Simulation

Code:
# coding: UTF-8
import viz
import vizact
import vizinfo
import vizmenu

TITLE_COLOR = (.85, .85, .85)
BGCOLOR = (0.3,0.3,.5)
TITLEBGCOLOR = (0.3,0.3,.5)

class ParameterView:
	def __init__(self, menu, parameter):
		self.parameter = parameter
		self.line = menu.add(viz.TEXT3D, '_'*15)
		self.line.color(TITLE_COLOR)
		self.label = menu.add(viz.TEXT3D, parameter.name)
#		self.slider = menu.add(viz.PROGRESS_BAR, parameter.name)
		self.slider = menu.add(viz.SLIDER)
		self.textBox = menu.add(viz.TEXTBOX)
		self.textBox.length(.5)
		self.parameterName = parameter.name
		self.sliderScaleFactor = parameter.maxValue - parameter.minValue
		
		self.updateViewParameterChanged()
		
		vizact.ontextbox(self.textBox, self.textboxChanged)
		vizact.onslider(self.slider, self.sliderChanged)
		
		vizact.onevent(Parameter.PARAMETER_CHANGED_EVENT, lambda e: (e.obj==self.parameter, None), self.updateViewParameterChanged)

	def setVisible(self, isVisible):
		self.line.visible(isVisible)
		self.label.visible(isVisible)
		self.slider.visible(isVisible)
		self.textBox.visible(isVisible)

	def updateViewParameterChanged(self):
		try:			
			if self.parameter.value != float(self.textBox.get()):
				self.textBox.message(str(self.parameter.value))
		except ValueError:
			self.textBox.message(str(self.parameter.value))
		self.slider.set(self.parameter.value / self.sliderScaleFactor)

	def textboxChanged(self, e=None):
		if self.textBox.get() != '':
			try:
				value = float(self.textBox.get())
				self.parameter.setValue(value)
				self.updateViewParameterChanged()
			except ValueError:
				try:
					self.textBox.message("%1.2f" % (float(e.oldText)))
				except:
					self.textBox.message('')
				viz.message('Enter only numbers')
	
	def sliderChanged(self, e):
		value = self.slider.get() * self.sliderScaleFactor
		self.parameter.setValue(value)
		self.updateViewParameterChanged()
		
	
		
timeInfo = None		
simParametersInfo = None
graphInfo = None
paramHistory = None
messageGroup = None
simMenu = None
def setup():
	global simParametersInfo, timeInfo, graphInfo, paramHistory, messageGroup, simMenu
	
#	ALPHA = .5
#	messageGroup = viz.addGroup(viz.SCREEN, pos=(.5, .80, 0), scale=[1]*3)
#	messageGroup.alpha(ALPHA)
#	background = viz.addTexQuad(messageGroup, scale=(11, 2, 0), pos=[0,0,0])
#	background.zoffset(2)
#	background.alpha(ALPHA)
#	messageGroup.t = viz.addText('asdfasdfsad', parent=messageGroup, color=viz.BLACK, pos=(-.39,.028,0), scale=[.5]*3)
#	messageGroup.t.alpha(ALPHA)
	
	vizmenu.MENU_FONT_SIZE = 25
	vizmenu.HIDDEN_HANGOFF_AMOUNT = 0
	vizmenu.VISIBLE_ANIMATE_SPEED = 10000
	timeInfo = vizmenu.add()
	timeInfo.setAutoHide(viz.OFF)
	simMenu = timeInfo.add('Simulation')
	timeInfo.startSimulationButton = simMenu.add(viz.BUTTON, 'Start')
	timeInfo.resetSimulationButton = simMenu.add(viz.BUTTON, 'Reset')
	timeInfo.resetSimulationButton.visible(viz.OFF)
	timeInfo.nextExercise = simMenu.add(viz.BUTTON, 'Next Exercise')
	sysMenu = timeInfo.add('System')
	timeInfo.graphOnWallCheckbox = sysMenu.add(viz.CHECKBOX, 'Draw graphs on wall')
	timeInfo.parameterHistoryWindowCheckbox = sysMenu.add(viz.CHECKBOX, 'Parameter History Table')
	timeInfo.toggleParmeterWindowsButton = sysMenu.add(viz.BUTTON, 'Toggle Parameter Windows')
	timeInfo.parameterHistoryWindowCheckbox.set(1)
	timeInfo.clearTrialHistoryButton = sysMenu.add(viz.BUTTON, 'Clear History')
	timeInfo.resetViewButton = sysMenu.add(viz.BUTTON, 'Reset View Position')
	timeInfo.showForcesButton = sysMenu.add(viz.CHECKBOX, 'Show Forces')
	
	

def setMenuVisible(isVisable):
	timeInfo.setVisible(isVisable)
	timeInfo.dirty()
	if isVisable == 0:
		simMenu.setVisible(isVisable)
		simMenu.dirty()

parameterList = []
def addParameter(param, menu):
	parameterList.append(ParameterView(menu, param))	
	
def setParameterVisible(param, isVisible):
	for parameterView in parameterList:
		if parameterView.parameter == param:
			parameterView.setVisible(isVisible)

def addOption(name, menu):
	button = menu.add(viz.CHECKBOX, name)
	return button

def addLabel(stringy, menu):
	t = menu.add(viz.TEXT3D, '_'*15)
	t.color(TITLE_COLOR)
	t = menu.add(viz.TEXT3D, stringy)
	t.color(TITLE_COLOR)
	
#def setMessageVisible(isViz):
#	messageGroup.visible(isViz)
#	
#def setMessage(stingy):
#	messageGroup.t.message(stingy)
	
if __name__ == '__main__':
	viz.go()
#	viz.add('gallery.ive')
	viz.clearcolor(viz.SKYBLUE)
	setup()
	
	setMenuVisible(1)
	setMenuVisible(0)
	vizact.onbuttondown(timeInfo.nextExercise, setMenuVisible, 0)
	vizact.onkeydown(' ' , setMenuVisible, 1)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #2  
Old 12-02-2008, 06:42 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Thanks for the bug report, this will be fixed in the next release. If you need the fix sooner, then modify your vizmenu.py by replacing the setVisible function of the MenuBar class with the following code:
Code:
	def setVisible(self,visible,animate=True):
		"""Make the menu hidden or visible"""
		self.__hidden = not visible
		self.__root.clearActions()
		if self.__hidden:
			if animate:
				self.__root.runAction(vizact.moveTo(self.__inactivePos,speed=HIDING_ANIMATE_SPEED,p1=-0.5,p2=0.0))
			else:
				self.__root.translate(self.__inactivePos)
			#Clear tracked item and click state
			self.__clicked = False
			self.__trackitem(None)
		else:
			if animate:
				self.__root.runAction(vizact.goto(self.__activePos,VISIBLE_ANIMATE_SPEED))
			else:
				self.__root.translate(self.__activePos)
Reply With Quote
  #3  
Old 12-02-2008, 07:47 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
thanks for the speedy fix
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vizmenu slider bug? Gladsomebeast Vizard 2 10-22-2008 08:05 PM


All times are GMT -7. The time now is 08:39 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC