Mercurial > code > home > repos > light9
annotate 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 |
rev | line source |
---|---|
0 | 1 |
2 from Patch import get_dmx_channel | |
3 | |
4 class Subediting: | |
5 """this class accepts input from Stage and edits subs. the | |
6 Subpanels have widgets to tell us what subs to edit and when to | |
7 save them. this Subediting object has no UI of its own. | |
8 | |
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) | |
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 | |
53 | 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 |
0 | 14 """ |
15 def __init__(self,currentoutputlevels): | |
16 self.sub=None | |
17 self.currentoutputlevels = currentoutputlevels | |
53 | 18 self.widgets={} # subname : widget list |
19 self.oldcolors={} # widget : bgcolor | |
0 | 20 |
53 | 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 | |
0 | 35 def setsub(self,sub): |
36 """sets which (one) sub object should the stage be editing. | |
37 | |
38 this is called by widgets that are set up in the Subpanels interfaces. | |
39 """ | |
40 | |
41 print "subedit: editing ",sub.name | |
42 self.sub = sub | |
53 | 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""" | |
0 | 47 |
53 | 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 | |
0 | 57 # |
58 # next two methods are called by the Stage | |
59 # | |
60 def startlevelchange(self): | |
53 | 61 """stage is about to send some level changes. this method is |
62 called by the Stage.""" | |
0 | 63 print "subedit: start-------" |
64 if self.sub is None: | |
65 print "not editing any sub!" | |
66 return | |
67 | |
68 self.startlevels = self.sub.getlevels() | |
69 | |
70 def getcurrentlevel(self,lightname): | |
71 try: | |
72 ch = get_dmx_channel(lightname) | |
73 except ValueError: | |
74 return None | |
75 return self.currentoutputlevels[ch] | |
76 | |
77 def levelchange(self,lightnames,delta): | |
78 """stage sends this message with its light names and a delta | |
79 0..1 measured from the last startlevelchange call. this method is | |
80 called by the Stage""" | |
81 | |
53 | 82 # print "subedit: level change",lightnames,delta |
0 | 83 if self.sub is None: |
84 print "not editing any sub!" | |
85 return | |
86 | |
87 updatelevels={} | |
88 | |
89 for l in lightnames: | |
90 if l not in self.startlevels: | |
91 # level was not in the sub | |
92 cl = self.getcurrentlevel(l) | |
93 if cl is None: | |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
42
diff
changeset
|
94 print "light '%s' isn't even in the patch! skipping" % l |
53 | 95 continue |
0 | 96 print "copying current light level",cl,"into the sub" |
97 self.startlevels[l] = cl | |
98 | |
99 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta)) | |
100 | |
101 self.sub.reviselevels(updatelevels) | |
102 |