comparison light8/subediting.py @ 53:032b2b67bc10

result of July 7th on-site editing
author dmcc
date Mon, 08 Jul 2002 14:31:20 +0000
parents 6540879e336e
children ddd3c8f04640
comparison
equal deleted inserted replaced
52:065896b0913c 53:032b2b67bc10
8 8
9 20:41:10 drewp: there are some funny rules 9 20:41:10 drewp: there are some funny rules
10 20:41:37 drewp: if you drag a light that's in the sub you're editing, you'll adjust it from it's position in the sub (Even if that sub is not visialbe, or if the light is doing someting else) 10 20:41:37 drewp: if you drag a light that's in the sub you're editing, you'll adjust it from it's position in the sub (Even if that sub is not visialbe, or if the light is doing someting else)
11 20:41:57 drewp: but if you touch a light that wasnt in the sub, the current light brightness from the stage gets copied into the sub, and then you adjust frmo there 11 20:41:57 drewp: but if you touch a light that wasnt in the sub, the current light brightness from the stage gets copied into the sub, and then you adjust frmo there
12 20:42:05 drewp: i dont know any other rules; but these seem odd 12 20:42:05 drewp: i dont know any other rules; but these seem odd
13 20:42:29 drewp: it may be necessary to highlight which lights are already in the sub, so you know what you're doing as soon as you click on one 13 20:42:29 drewp: it may be necessary to highluight which lights are already in the sub, so you know what you're doing as soon as you click on one
14 """ 14 """
15 def __init__(self,currentoutputlevels): 15 def __init__(self,currentoutputlevels):
16 self.sub=None 16 self.sub=None
17 self.currentoutputlevels = currentoutputlevels 17 self.currentoutputlevels = currentoutputlevels
18 self.widgets={} # subname : widget list
19 self.oldcolors={} # widget : bgcolor
18 20
21 def refresh(self):
22 self.sub=None # this wouldn't last even if we wanted it to;
23 # the Sub objects are rebuilt upon reload
24 self.widgets={}
25 self.oldcolors={}
26
27 def register(self,subname,widget):
28 """tell subediting about any widgets that should be highlighted
29 when a sub is being edited"""
30 if subname not in self.widgets:
31 self.widgets[subname]=[]
32 self.widgets[subname].append(widget)
33 self.oldcolors[widget] = widget.cget('bg')
34
19 def setsub(self,sub): 35 def setsub(self,sub):
20 """sets which (one) sub object should the stage be editing. 36 """sets which (one) sub object should the stage be editing.
21 37
22 this is called by widgets that are set up in the Subpanels interfaces. 38 this is called by widgets that are set up in the Subpanels interfaces.
23 """ 39 """
24 40
25 print "subedit: editing ",sub.name 41 print "subedit: editing ",sub.name
26 self.sub = sub 42 self.sub = sub
43 self.highlighteditsub()
44 def highlighteditsub(self):
45 """based on how widgets got self.register'd, we highlight
46 just the row that's being edited"""
27 47
48 # highlight that row only
49 for n,wl in self.widgets.items():
50 if n==self.sub.name:
51 for w in wl:
52 w.config(bg='red')
53 else:
54 for w in wl:
55 w.config(bg=self.oldcolors[w])
56
28 # 57 #
29 # next two methods are called by the Stage 58 # next two methods are called by the Stage
30 # 59 #
31 def startlevelchange(self): 60 def startlevelchange(self):
32 "stage is about to send some level changes. this method is called by the Stage." 61 """stage is about to send some level changes. this method is
62 called by the Stage."""
33 print "subedit: start-------" 63 print "subedit: start-------"
34 if self.sub is None: 64 if self.sub is None:
35 print "not editing any sub!" 65 print "not editing any sub!"
36 return 66 return
37 67
47 def levelchange(self,lightnames,delta): 77 def levelchange(self,lightnames,delta):
48 """stage sends this message with its light names and a delta 78 """stage sends this message with its light names and a delta
49 0..1 measured from the last startlevelchange call. this method is 79 0..1 measured from the last startlevelchange call. this method is
50 called by the Stage""" 80 called by the Stage"""
51 81
52 print "subedit: level change",lightnames,delta 82 # print "subedit: level change",lightnames,delta
53 if self.sub is None: 83 if self.sub is None:
54 print "not editing any sub!" 84 print "not editing any sub!"
55 return 85 return
56 86
57 updatelevels={} 87 updatelevels={}
60 if l not in self.startlevels: 90 if l not in self.startlevels:
61 # level was not in the sub 91 # level was not in the sub
62 cl = self.getcurrentlevel(l) 92 cl = self.getcurrentlevel(l)
63 if cl is None: 93 if cl is None:
64 print "light '%s' isn't even in the patch! skipping" % l 94 print "light '%s' isn't even in the patch! skipping" % l
65 return 95 continue
66 print "copying current light level",cl,"into the sub" 96 print "copying current light level",cl,"into the sub"
67 self.startlevels[l] = cl 97 self.startlevels[l] = cl
68 98
69 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta)) 99 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta))
70 100