annotate light8/stage.py @ 2430:1082f0725c32

fix PlayerState semantics
author drewp@bigasterisk.com
date Tue, 28 May 2024 15:34:03 -0700
parents fca9832d207f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 44
diff changeset
1 from Tix import *
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
2
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
3 def printevent(ev):
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
4 for k in dir(ev):
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
5 if not k.startswith('__'):
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
6 print k,getattr(ev,k)
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
7 print ""
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
8
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
9 textstyle={'font':'arial 9','fill':'white'}
14
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
10
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
11 class Stage(Canvas):
45b12307c695 Initial revision
drewp
parents:
diff changeset
12
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 """a fancy widget that shows light locations (and optionally their
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 aim locations on an image of the stage. you can select or
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 multiselect lights and drag them up or down to change their
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 brightness.
45b12307c695 Initial revision
drewp
parents:
diff changeset
17
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 ctrl-a is select all,
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 ctrl-shift-a or clicking on no light deselects all,
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 re-clicking a light with shift key down toggles whether it's in the selection.
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 ctrl-drag-rectangle deselects the lights in the rectangle,
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 shift-drag-rectangle selects the lights in the rectangle,
45b12307c695 Initial revision
drewp
parents:
diff changeset
23 drag-rectangle selects only the lights in the rectangle.
45b12307c695 Initial revision
drewp
parents:
diff changeset
24
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
25 a light can be selected on its location point, its aim point
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
26 (which may or may not be present), or its name.
45b12307c695 Initial revision
drewp
parents:
diff changeset
27
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 lights should be able to be interactively 'locked', which blocks
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 them from being selected.
45b12307c695 Initial revision
drewp
parents:
diff changeset
30
17
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
31 API:
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
32 __init__(parent,**kw)
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
33 put pass any canvas options you want
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
34
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
35 setimage(stageimage)
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
36 sets image to given filename (ppm, gif, etc) and resizes the
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
37 canvas to the image size
17
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
38
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
39 addlight(name, location, aim=None)
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
40 location and aim are pixel coord tuples. name will be passed
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
41 back to you in the callback (see below)
17
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
42
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
43 setsubediting(se)
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
44 give a subediting object to receive the 'startlevelchange' and
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
45 'levelchange' messages
17
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
46
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 14
diff changeset
47
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
48 """
45b12307c695 Initial revision
drewp
parents:
diff changeset
49 def __init__(self,parent,**kw):
45b12307c695 Initial revision
drewp
parents:
diff changeset
50 Canvas.__init__(self,parent,**kw)
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
51
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
52 self.bind("<ButtonPress>", self.press)
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
53 self.bind("<Motion>", self.motion)
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
54 self.bind("<ButtonRelease>", self.release)
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
55 self.bind("<Control-Key-a>", lambda ev: self.selectall())
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
56 self.bind("<Control-Key-A>", lambda ev: self.clearselection())
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
57 # self.bind("<Control-Shift-Key-a>",self.handlecontrol_a)
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
58
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
59 self.halo=11 # search radius for clicked items
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
60
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
61 self.mode=None # as you perform with the mouse, this goes
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
62 # from None to 'pressed','rectangle','levelchange', etc
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
63
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
64 self.alllights=[]
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
65 self.selectedlights=[]
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
66 self.alllighttags={} # tag: name lookup
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
67
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
68 self.subeditor = None
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
69
77
5649f5d9c798 hid the image
drewp
parents: 69
diff changeset
70
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
71 def setimage(self,stageimage):
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
72 img = Image('photo',file=stageimage)
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
73 self.img=img # can't lose this!
102
e04f7b552bcd - scroll wheel works everywhere
dmcc
parents: 101
diff changeset
74 # print img.width()
238
fca9832d207f turn on background image in stage.py
drewp@bigasterisk.com
parents: 102
diff changeset
75 self.create_image(0,0,anchor='nw',image=img)
fca9832d207f turn on background image in stage.py
drewp@bigasterisk.com
parents: 102
diff changeset
76 self.config(width=img.width(),height=img.height())
77
5649f5d9c798 hid the image
drewp
parents: 69
diff changeset
77
5649f5d9c798 hid the image
drewp
parents: 69
diff changeset
78 # we had the picture removed for good luck, but we remember
5649f5d9c798 hid the image
drewp
parents: 69
diff changeset
79 # what the dimensions formerly was
101
a995fd1a8f03 result of 7.12 performance
dmcc
parents: 77
diff changeset
80 self.config(width=821,height=681, bg="grey40")
77
5649f5d9c798 hid the image
drewp
parents: 69
diff changeset
81
37
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
82
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
83 def setsubediting(self,subeditor):
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
84 self.subeditor = subeditor
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
85
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
86 # (17:00:06) drewp: if yes, then self.itemconfigure(tagOrId, text=...)
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
87 def updatelightlevel(self, name, level):
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
88 tag = self.nametag(name)
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
89 self.itemconfigure("level_%s" % tag, text=level)
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
90
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
91 #
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
92 # selection management
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
93 #
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
94 def updateselectionboxes(self):
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
95 "make selection boxes that match self.selectedlights"
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
96 self.delete("selectbox")
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
97 for l in self.selectedlights:
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
98 for c in self.getlightbboxes(l):
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
99 self.create_rectangle(c[0]-2,c[1]-2,c[2]+2,c[3]+2,
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
100 outline='red',tag="selectbox")
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
101
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
102 def selectall(self):
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
103 self.selectedlights= self.alllights[:]
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
104 self.updateselectionboxes()
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
105 def clearselection(self):
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
106 self.selectedlights=[]
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
107 self.updateselectionboxes()
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
108
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
109 def markfordynselection(self):
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
110 """call this before calls to replacedynselection"""
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
111 self.origselection = self.selectedlights[:]
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
112
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
113 def replacedynselection(self,newlightnames,subtract=0):
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
114 """as a dynamic selection changes, keep calling this function
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
115 with the names of the lights in the dynamic selection. the
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
116 original selection (at the time of markfordynselection) will
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
117 be shown along with any new lights. if subtract=1, the selection will
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
118 be shown MINUS the newlights."""
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
119 if subtract==0:
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
120 # orig selection plus any newlights that weren't in the orig
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
121 # selection
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
122 self.selectedlights = self.origselection[:] + \
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
123 [l for l in newlightnames if l not in self.origselection]
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
124 else:
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
125 # orig selection lights except those that are in the newlightnames
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
126 # list
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
127 self.selectedlights = [l for l in self.origselection
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
128 if l not in newlightnames]
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
129 self.updateselectionboxes()
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
130
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
131 def select(self,lightname,select=1): # select=0 for deselect
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
132 """select or deselect (select=0) a light by name"""
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
133 if select:
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
134 if lightname not in self.selectedlights:
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
135 self.selectedlights.append(lightname)
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
136 elif lightname in self.selectedlights:
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
137 self.selectedlights.remove(lightname)
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
138
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
139 self.updateselectionboxes()
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
140
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
141 #
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
142 # mouse handling
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
143 #
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
144 def press(self,ev):
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
145
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
146 self.mode='pressed'
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
147 self.mousedownpos=(ev.x,ev.y)
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
148 print "click at",self.mousedownpos
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
149
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
150 button=ev.num
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
151 shifted=ev.state & 1
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
152 control=ev.state & 4
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
153 touching=self.findoverlappinglights((ev.x-self.halo,ev.y-self.halo,
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
154 ev.x+self.halo,ev.y+self.halo))
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
155 istouching=len(touching)>0
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
156
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
157 if button==1:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
158 if not istouching:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
159 # clicked in space
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
160 if not shifted and not control and len(self.selectedlights)>0:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
161 # either a deselect (if no motion) or a level change (if motion)
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
162 self.mode = 'deselect-or-rectangle'
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
163 if shifted or control or len(self.selectedlights)==0:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
164 # with shift/control, add/subtract lights to selection
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
165 self.startrectangleselect()
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
166
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
167 else:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
168 # clicked a selectable object
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
169 # toggle selection
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
170 if touching[0] in self.selectedlights:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
171 if shifted or control:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
172 # deselect
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
173 self.select(touching[0],0)
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
174 # and do nothing else
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
175 self.mode=None
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
176 if not shifted:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
177 # select only this light
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
178 self.clearselection()
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
179 self.select(touching[0])
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
180 # and adjust its level
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
181 self.startlevelchange()
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
182
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
183 else:
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
184 # clicked a light that wasn't selected
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
185 if not shifted:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
186 self.clearselection()
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
187 self.select(touching[0])
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
188 # and adjust levels now
37
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
189 self.startlevelchange()
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
190
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
191 if button==3:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
192 self.startlevelchange()
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
193
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
194 def motion(self,ev):
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
195
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
196 coords=(ev.x,ev.y)
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
197
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
198 shifted=ev.state & 1
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
199 control=ev.state & 4
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
200
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
201 if self.mode=='deselect-or-rectangle':
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
202 if (coords[0]-self.mousedownpos[0])**2+(coords[1]-self.mousedownpos[1])**2>self.halo**2:
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
203 if not shifted and not control:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
204 self.clearselection()
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
205 # they moved enough, it's a level change
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
206 self.startrectangleselect()
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
207
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
208
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
209 if self.mode=='levelchange':
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
210 delta = 1.5 * (self.mousedownpos[1]-ev.y)
37
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
211 if self.subeditor:
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
212 self.subeditor.levelchange(self.selectedlights,delta)
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
213
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
214 if self.mode=='rectangle':
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
215 sr = self.find_withtag('selectrect')
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
216 if not sr:
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
217 # make the selection rectangle
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
218 sr=self.create_rectangle( self.mousedownpos[0],
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
219 self.mousedownpos[1],coords[0],coords[1],
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
220 outlinestipple='gray50',outline='yellow',tag='selectrect')
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
221
8
6faae180d1c5 conv image to gif, clean up source formatting
drewp
parents: 7
diff changeset
222 # move rectangle with mouse
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
223 self.coords(sr,*(self.mousedownpos+coords))
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
224
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
225 # redo the dynselection with the new rectangle
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
226 self.replacedynselection(self.findoverlappinglights((self.mousedownpos+coords),1),
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
227 subtract=control)
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
228
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
229 def release(self,ev):
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
230 if self.mode:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
231 if self.mode=='rectangle':
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
232 self.delete('selectrect')
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
233
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
234 if self.mode=='deselect-or-rectangle':
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
235 # they didn't move enough to promote the mode to level, so
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
236 # it's a deselect click
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
237 self.clearselection()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
238
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
239 self.mode=None
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
240
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
241 #
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
242 # subedit type things (correct me if i'm wrong)
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
243 #
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
244
37
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
245 def startlevelchange(self):
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
246 """sets mode to levelchange AND notifies subeditor. this
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
247 should be done exactly once (per mouse drag), when you first
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
248 decide the mode is levelchange"""
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
249 self.mode='levelchange'
37
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
250 if self.subeditor:
115636cca107 subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents: 17
diff changeset
251 self.subeditor.startlevelchange()
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
252 def startrectangleselect(self):
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
253 """sets mode to rectangle AND checkpoints the current selection"""
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
254 self.mode='rectangle'
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
255 self.markfordynselection()
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
256 #
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
257 # light names vs. canvas object tags
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
258 #
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
259 def nametag(self,name):
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
260 "returns a safe version of the name that won't match other names"
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
261 return name.replace(" ","__")
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
262
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
263 def tagtoname(self,tag):
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
264 "finds the real light name for a tag written by nametag()"
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
265 return self.alllighttags[tag]
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
266
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
267 #
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
268 # light methods
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
269 #
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
270 def addlight(self,name,location,aim=None):
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
271 tags='light selectable name_%s' % self.nametag(name)
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
272
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
273 self.create_oval(location[0]-2,location[1]-2,
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
274 location[0]+2,location[1]+2,
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
275 fill='red',tag=tags+" hotspot")
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
276 if aim:
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
277 self.create_oval(aim[0]-2,aim[1]-2,
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
278 aim[0]+2,aim[1]+2,
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
279 fill='blue',tag=tags+" hotspot")
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
280 self.create_line(location[0],location[1],aim[0],aim[1],
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
281 fill='lightblue', arrow='last',arrowshape="9 15 6",tag='light')
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
282
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
283 # shadow
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
284 self.create_text(location[0]-1,location[1]+6,
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
285 anchor='n',text=name,fill='black',
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
286 tag=tags,**dict([(k,v)
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
287 for k,v in textstyle.items() if k!='fill']))
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
288 # text
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
289 self.create_text(location[0],location[1]+5,anchor='n',text=name,
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
290 tag=tags,**textstyle)
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
291
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
292 # level
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
293 self.create_text(location[0]-2,location[1]+13,anchor='n',
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
294 text='0', # will be changed later
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
295 tag='level_%s' % self.nametag(name),**textstyle)
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
296
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
297 self.alllights.append(name)
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
298 self.alllighttags[self.nametag(name)]=name
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
299
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
300 def getlightbboxes(self,tag):
62
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
301 """returns a list of bboxes for a light with a given name_ tag. the
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
302 selection mechanism draws around these bboxes to show that a light is
2f2eb802e93d stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents: 53
diff changeset
303 selected"""
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
304 bboxes=[]
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
305 for o in self.find_withtag("name_%s" % self.nametag(tag)):
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
306 if 'hotspot' in self.gettags(o):
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
307 bboxes.append(self.bbox(o))
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
308 return bboxes
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
309
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
310 def findoverlappinglights(self,box,enclosed=0):
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
311 "returns all the different names for lights that are within (or enclosed by) the box"
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
312 lights=[]
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
313 if enclosed:
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
314 candidates = self.find_enclosed(*box)
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
315 else:
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
316 candidates = self.find_overlapping(*box)
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
317
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
318 for o in candidates:
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
319 for t in self.gettags(o):
7
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
320 if t.startswith("name_"):
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
321 n = self.tagtoname(t[5:])
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
322 if n and (n not in lights):
1b0266dd233a picking and dragging works pretty well (no ctrl yet)
drewp
parents: 6
diff changeset
323 lights.append(n)
6
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
324 return lights
119369e60da1 tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents: 5
diff changeset
325
10
533ac835083f some real lights
drewp
parents: 8
diff changeset
326
14
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
327 def createlights(s):
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
328 s.setimage('guysanddolls.gif')
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
329 s.addlight('desk1',(46, 659), aim=(210, 381))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
330 s.addlight('marry1',(78, 661), aim=(398, 428))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
331 s.addlight('b13',(110, 661))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
332 s.addlight('hotbox1',(147, 657), aim=(402, 327))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
333 s.addlight('edge',(179, 651), aim=(116, 441))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
334 s.addlight('phone',(214, 652), aim=(651, 417))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
335 s.addlight('cuba1',(315, 656), aim=(559, 407))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
336 s.addlight('b22',(347, 661), aim=(247, 458))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
337 s.addlight('b23',(379, 661))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
338 s.addlight('b24',(417, 661))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
339 s.addlight('b25',(455, 658), aim=(520, 466))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
340 s.addlight('desk2',(490, 655), aim=(237, 375))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
341 s.addlight('rock',(571, 655), aim=(286, 304))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
342 s.addlight('b32',(606, 650))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
343 s.addlight('hotbox2',(637, 650), aim=(433, 337))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
344 s.addlight('b34',(671, 651))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
345 s.addlight('marry2',(703, 651), aim=(429, 426))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
346 s.addlight('cuba2',(733, 652), aim=(602, 408))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
347
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
348 s.addlight('sidefill1',(115, 473),aim=(228, 423))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
349 s.addlight('sidefill2',(617, 475),aim=(526, 425))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
350
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
351 s.addlight('cycright',(485, 164),(483, 109))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
352 s.addlight('cycleft',(330, 154),(333, 108))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
353
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
354 s.addlight('upfill1',(275, 325),(262, 237))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
355 s.addlight('upfill2',(333, 326),(330, 229))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
356 s.addlight('upfill3',(473, 325),(454, 226))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
357 s.addlight('upfill4',(541, 325),(528, 223))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
358
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
359 s.addlight('god',(369,549))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
360
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
361 s.addlight('patio1',(42, 560),(12, 512))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
362 s.addlight('patio2',(675, 553),(793, 514))
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
363
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
364 s.addlight('hotback',(413, 476),(414, 396))
10
533ac835083f some real lights
drewp
parents: 8
diff changeset
365
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
366 s.addlight('main 2',(120, 563) ,aim=(241, 472))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
367 s.addlight('main 3',(162, 562) ,aim=(140, 425))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
368 s.addlight('main 4',(208, 560) ,aim=(342, 423))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
369 s.addlight('main 5',(259, 558) ,aim=(433, 450))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
370 s.addlight('main 7',(494, 551) ,aim=(420, 458))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
371 s.addlight('main 8',(528, 554) ,aim=(503, 477))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
372 s.addlight('main 9',(559, 554) ,aim=(544, 479))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
373 s.addlight('main 10',(597, 556),aim=(339, 444))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
374 s.addlight('main 11',(636, 556),aim=(449, 409))
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
375
65
67a1fa40924f fixed some names to match primary names in patch
drewp
parents: 62
diff changeset
376 s.addlight('side r', (785, 609))
67a1fa40924f fixed some names to match primary names in patch
drewp
parents: 62
diff changeset
377 s.addlight('side l', (8, 613))
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
378
69
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
379 s.addlight('cafe1',(174, 476))
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
380 s.addlight('cafe2',(584, 475))
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
381 s.addlight('dream',(329, 477),aim=(267, 309))
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
382 s.addlight('xmas',(555, 56),aim=(438, 284))
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
383
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
384 for y,col in ((300,'red'),(333,'blue'),(364,'gree'),(407,'oran')):
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
385 for i in range(1,5):
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
386 s.addlight('%s%s' % (col,i),(726+10*i,y))
ab0be21b549b result of 7.9.2002 rehearsal
dmcc
parents: 65
diff changeset
387
14
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
388 if __name__=='__main__':
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
389 root=Tk()
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
390 root.tk_focusFollowsMouse()
14
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
391 root.wm_geometry("+376+330")
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
392 s=Stage(root)
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
393 s.setimage('guysanddolls.gif')
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
394 s.pack()
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
395
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
396 createlights(s)
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
397
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
398 class subediting_standin:
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
399 def startlevelchange(self):
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
400 print "start lev change"
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
401 def levelchange(self,lights,delta):
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
402 print "change",lights,delta
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
403 s.setsubediting(subediting_standin())
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 37
diff changeset
404
14
95ba7e14d15a new colors
drewp
parents: 10
diff changeset
405 root.mainloop()