Mercurial > code > home > repos > light9
comparison bin/keyboardcomposer @ 520:c10e671adc2c
KC shuffle method order for clarity
Ignore-this: e16a00a0430b2d60b05e3769168707c6
author | drewp@bigasterisk.com |
---|---|
date | Mon, 29 Jun 2009 04:57:53 +0000 |
parents | 259436a06912 |
children | 3f9162973d60 |
comparison
equal
deleted
inserted
replaced
519:f2dbb0b1fb35 | 520:c10e671adc2c |
---|---|
129 self.save_stage_button.pack(side=LEFT) | 129 self.save_stage_button.pack(side=LEFT) |
130 self.sub_name = Entry(self.buttonframe, bg='black', fg='white') | 130 self.sub_name = Entry(self.buttonframe, bg='black', fg='white') |
131 self.sub_name.pack(side=LEFT) | 131 self.sub_name.pack(side=LEFT) |
132 | 132 |
133 self.stop_frequent_update_time = 0 | 133 self.stop_frequent_update_time = 0 |
134 | |
135 def draw_sliders(self): | |
136 self.tk_focusFollowsMouse() | |
137 | |
138 rowcount = -1 | |
139 col = 0 | |
140 last_group = None | |
141 graph = showconfig.getGraph() | |
142 withgroups = sorted((graph.value(sub.uri, L9['group']), | |
143 graph.value(sub.uri, L9['order']), | |
144 sub) | |
145 for sub in self.submasters.get_all_subs()) | |
146 | |
147 for group, order, sub in withgroups: | |
148 group = graph.value(sub.uri, L9['group']) | |
149 | |
150 if col == 0 or group != last_group: # make new row | |
151 row = self.make_row() | |
152 rowcount += 1 | |
153 col = 0 | |
154 current_level = self.current_sub_levels.get(sub.name, 0) | |
155 subtk = self.draw_sub_slider(row, col, sub.name, current_level) | |
156 self.slider_table[(rowcount, col)] = subtk | |
157 self.name_to_subtk[sub.name] = subtk | |
158 | |
159 def slider_changed(x, y, z, subtk=subtk, | |
160 col=col, sub=sub, rowcount=rowcount): | |
161 subtk.scale.draw_indicator_colors() | |
162 self.send_levels() | |
163 if rowcount == self.current_row: | |
164 self.send_to_hw(sub.name, col + 1) | |
165 | |
166 subtk.slider_var.trace('w', slider_changed) | |
167 | |
168 # initial position | |
169 self.send_to_hw(sub.name, col + 1) | |
170 col = (col + 1) % 8 | |
171 last_group = group | |
172 | |
173 def draw_sub_slider(self, row, col, name, current_level): | |
174 subtk = SubmasterTk(row, name, current_level) | |
175 subtk.place(relx=col / 8, rely=0, relwidth=1 / 8, relheight=1) | |
176 self.setup_key_nudgers(subtk.scale) | |
177 | |
178 self.slider_vars[name] = subtk.slider_var | |
179 return subtk | |
134 | 180 |
135 def toggle_slider_connectedness(self): | 181 def toggle_slider_connectedness(self): |
136 self.use_hw_sliders = not self.use_hw_sliders | 182 self.use_hw_sliders = not self.use_hw_sliders |
137 if self.use_hw_sliders: | 183 if self.use_hw_sliders: |
138 self.sliders.reopen() | 184 self.sliders.reopen() |
139 else: | 185 else: |
140 self.sliders.close() | 186 self.sliders.close() |
141 self.change_row(self.current_row) | 187 self.change_row(self.current_row) |
142 self.rows[self.current_row].focus() | 188 self.rows[self.current_row].focus() |
189 | |
143 def connect_to_hw(self, hw_sliders): | 190 def connect_to_hw(self, hw_sliders): |
144 if hw_sliders: | 191 if hw_sliders: |
145 try: | 192 try: |
146 self.sliders = Sliders(self) | 193 self.sliders = Sliders(self) |
147 except IOError: | 194 except IOError: |
167 keylabel.pack(side=LEFT, expand=1, fill=X) | 214 keylabel.pack(side=LEFT, expand=1, fill=X) |
168 col += 1 | 215 col += 1 |
169 | 216 |
170 keyhintrow.pack(fill=X, expand=0) | 217 keyhintrow.pack(fill=X, expand=0) |
171 self.keyhints = keyhintrow | 218 self.keyhints = keyhintrow |
219 | |
172 def setup_key_nudgers(self, tkobject): | 220 def setup_key_nudgers(self, tkobject): |
173 for d, keys in nudge_keys.items(): | 221 for d, keys in nudge_keys.items(): |
174 for key in keys: | 222 for key in keys: |
175 # lowercase makes full=0 | 223 # lowercase makes full=0 |
176 keysym = "<KeyPress-%s>" % key | 224 keysym = "<KeyPress-%s>" % key |
241 try: | 289 try: |
242 subtk = self.slider_table[(self.current_row, col)] | 290 subtk = self.slider_table[(self.current_row, col)] |
243 except KeyError: | 291 except KeyError: |
244 return # no slider assigned at that column | 292 return # no slider assigned at that column |
245 subtk.scale.set(value) | 293 subtk.scale.set(value) |
246 | |
247 def draw_sliders(self): | |
248 self.tk_focusFollowsMouse() | |
249 | |
250 rowcount = -1 | |
251 col = 0 | |
252 last_group = None | |
253 graph = showconfig.getGraph() | |
254 withgroups = sorted((graph.value(sub.uri, L9['group']), | |
255 graph.value(sub.uri, L9['order']), | |
256 sub) | |
257 for sub in self.submasters.get_all_subs()) | |
258 | |
259 for group, order, sub in withgroups: | |
260 group = graph.value(sub.uri, L9['group']) | |
261 | |
262 if col == 0 or group != last_group: # make new row | |
263 row = self.make_row() | |
264 rowcount += 1 | |
265 col = 0 | |
266 current_level = self.current_sub_levels.get(sub.name, 0) | |
267 subtk = self.draw_sub_slider(row, col, sub.name, current_level) | |
268 self.slider_table[(rowcount, col)] = subtk | |
269 self.name_to_subtk[sub.name] = subtk | |
270 | |
271 def slider_changed(x, y, z, subtk=subtk, | |
272 col=col, sub=sub, rowcount=rowcount): | |
273 subtk.scale.draw_indicator_colors() | |
274 self.send_levels() | |
275 if rowcount == self.current_row: | |
276 self.send_to_hw(sub.name, col + 1) | |
277 | |
278 subtk.slider_var.trace('w', slider_changed) | |
279 | |
280 # initial position | |
281 self.send_to_hw(sub.name, col + 1) | |
282 col = (col + 1) % 8 | |
283 last_group = group | |
284 | 294 |
285 def send_to_hw(self, subName, hwNum): | 295 def send_to_hw(self, subName, hwNum): |
286 if isinstance(self.sliders, DummySliders): | 296 if isinstance(self.sliders, DummySliders): |
287 return | 297 return |
288 | 298 |
301 row = Frame(self, bd=2, bg='black') | 311 row = Frame(self, bd=2, bg='black') |
302 row.pack(expand=1, fill=BOTH) | 312 row.pack(expand=1, fill=BOTH) |
303 self.setup_key_nudgers(row) | 313 self.setup_key_nudgers(row) |
304 self.rows.append(row) | 314 self.rows.append(row) |
305 return row | 315 return row |
306 def draw_sub_slider(self, row, col, name, current_level): | 316 |
307 subtk = SubmasterTk(row, name, current_level) | |
308 subtk.place(relx=col / 8, rely=0, relwidth=1 / 8, relheight=1) | |
309 self.setup_key_nudgers(subtk.scale) | |
310 | |
311 self.slider_vars[name] = subtk.slider_var | |
312 return subtk | |
313 def highlight_row(self, row): | 317 def highlight_row(self, row): |
314 row = self.rows[row] | 318 row = self.rows[row] |
315 row['bg'] = 'red' | 319 row['bg'] = 'red' |
316 def unhighlight_row(self, row): | 320 def unhighlight_row(self, row): |
317 row = self.rows[row] | 321 row = self.rows[row] |