Mercurial > code > home > repos > light9
annotate bin/keyboardcomposer @ 948:8bdd2d35ea61
remove KC old control-l feature
Ignore-this: fce7b92e785c403863f321e3d6c58912
author | drewp@bigasterisk.com |
---|---|
date | Thu, 13 Jun 2013 19:49:29 +0000 |
parents | f7ffd7aeb7f0 |
children | c0f7fc86f89b |
rev | line source |
---|---|
721 | 1 #!bin/python |
214 | 2 |
268
d5858e9fa689
keyboardcomposer destroy fix and cleanups
David McClosky <dmcc@bigasterisk.com>
parents:
264
diff
changeset
|
3 from __future__ import division, nested_scopes |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
4 from run_local import log |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
5 import cgi, os, sys, time, subprocess, logging, random |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
6 from optparse import OptionParser |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
7 import webcolors, colorsys |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
8 from louie import dispatcher |
268
d5858e9fa689
keyboardcomposer destroy fix and cleanups
David McClosky <dmcc@bigasterisk.com>
parents:
264
diff
changeset
|
9 from twisted.internet import reactor, tksupport |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
10 from twisted.web import xmlrpc, server, resource |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
11 from rdflib import URIRef, Literal, RDF |
0 | 12 from Tix import * |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
13 import Tix as tk |
253
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
14 import pickle |
214 | 15 |
16 from light9.Fadable import Fadable | |
947 | 17 from light9.Submaster import Submasters, sub_maxes, PersistentSubmaster |
18 from light9.Patch import get_channel_uri | |
260
7f9d0f04bb2d
KeyboardComposer is now a SubClient
David McClosky <dmcc@bigasterisk.com>
parents:
253
diff
changeset
|
19 from light9.subclient import SubClient |
356
c6aabf5bd3bc
big KC speedup from not reloading config.n3 constantly
Drew Perttula <drewp@bigasterisk.com>
parents:
351
diff
changeset
|
20 from light9 import dmxclient, showconfig, networking, prof |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
21 from light9.uihelpers import toplevelat, bindkeys |
373
e0fc0e6127f4
keyboardcomposer: use submaster group information
David McClosky <dmcc@bigasterisk.com>
parents:
368
diff
changeset
|
22 from light9.namespaces import L9 |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
23 from light9.tkdnd import initTkdnd, dragSourceRegister, dropTargetRegister |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
24 from light9.rdfdb import clientsession |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
25 from light9.rdfdb.syncedgraph import SyncedGraph |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
26 from light9.rdfdb.patch import Patch |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
27 |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
28 from bcf2000 import BCF2000 |
0 | 29 |
30 nudge_keys = { | |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
31 'up' : list('qwertyui'), |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
32 'down' : list('asdfghjk') |
0 | 33 } |
34 | |
366 | 35 class DummySliders: |
36 def valueOut(self, name, value): | |
37 pass | |
479
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
38 def close(self): |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
39 pass |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
40 def reopen(self): |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
41 pass |
366 | 42 |
0 | 43 class SubScale(Scale, Fadable): |
44 def __init__(self, master, *args, **kw): | |
45 self.scale_var = kw.get('variable') or DoubleVar() | |
46 kw.update({'variable' : self.scale_var, | |
136 | 47 'from' : 1, 'to' : 0, 'showvalue' : 0, |
146 | 48 'sliderlength' : 15, 'res' : 0.01, |
49 'width' : 40, 'troughcolor' : 'black', 'bg' : 'grey40', | |
50 'highlightthickness' : 1, 'bd' : 1, | |
51 'highlightcolor' : 'red', 'highlightbackground' : 'black', | |
52 'activebackground' : 'red'}) | |
0 | 53 Scale.__init__(self, master, *args, **kw) |
136 | 54 Fadable.__init__(self, var=self.scale_var, wheel_step=0.05) |
146 | 55 self.draw_indicator_colors() |
56 def draw_indicator_colors(self): | |
57 if self.scale_var.get() == 0: | |
58 self['troughcolor'] = 'black' | |
59 else: | |
60 self['troughcolor'] = 'blue' | |
0 | 61 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
62 class SubmasterBox(Frame): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
63 """ |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
64 this object owns the level of the submaster (the rdf graph is the |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
65 real authority) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
66 """ |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
67 def __init__(self, master, sub, session): |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
68 self.sub = sub |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
69 self.session = session |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
70 bg = sub.graph.value(sub.uri, L9.color, default='#000000') |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
71 rgb = webcolors.hex_to_rgb(bg) |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
72 hsv = colorsys.rgb_to_hsv(*[x/255 for x in rgb]) |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
73 darkBg = webcolors.rgb_to_hex(tuple([x * 255 for x in colorsys.hsv_to_rgb( |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
74 hsv[0], hsv[1], .3)])) |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
75 Frame.__init__(self, master, bd=1, relief='raised', bg=bg) |
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
76 self.name = sub.name |
0 | 77 self.slider_var = DoubleVar() |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
78 self.pauseTrace = False |
0 | 79 self.scale = SubScale(self, variable=self.slider_var, width=20) |
821 | 80 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
81 self.namelabel = Label(self, font="Arial 7", bg=darkBg, |
459 | 82 fg='white', pady=0) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
83 self.sub.graph.addHandler(self.updateName) |
821 | 84 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
85 self.namelabel.pack(side=TOP) |
459 | 86 levellabel = Label(self, textvariable=self.slider_var, font="Arial 7", |
87 bg='black', fg='white', pady=0) | |
146 | 88 levellabel.pack(side=TOP) |
0 | 89 self.scale.pack(side=BOTTOM, expand=1, fill=BOTH) |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
90 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
91 for w in [self, self.namelabel, levellabel]: |
734
d230824728aa
drag submasters out of keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
733
diff
changeset
|
92 dragSourceRegister(w, 'copy', 'text/uri-list', sub.uri) |
d230824728aa
drag submasters out of keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
733
diff
changeset
|
93 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
94 self._slider_var_trace = self.slider_var.trace('w', self.slider_changed) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
95 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
96 sub.graph.addHandler(self.updateLevelFromGraph) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
97 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
98 # initial position |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
99 # self.send_to_hw(sub.name, col + 1) # needs fix |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
100 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
101 def cleanup(self): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
102 self.slider_var.trace_vdelete('w', self._slider_var_trace) |
821 | 103 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
104 def slider_changed(self, *args): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
105 self.scale.draw_indicator_colors() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
106 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
107 if self.pauseTrace: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
108 return |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
109 self.updateGraphWithLevel(self.sub.uri, self.slider_var.get()) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
110 # dispatcher.send("level changed") # in progress |
821 | 111 ###self.send_levels() # use dispatcher? |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
112 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
113 # needs fixing: plan is to use dispatcher or a method call to tell a hardware-mapping object who changed, and then it can make io if that's a current hw slider |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
114 #if rowcount == self.current_row: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
115 # self.send_to_hw(sub.name, col + 1) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
116 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
117 def updateGraphWithLevel(self, uri, level): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
118 """in our per-session graph, we maintain SubSetting objects like this: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
119 |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
120 ?session :subSetting [a :SubSetting; :sub ?s; :level ?l] |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
121 """ |
814
1ae8e6b287e3
improvements to file watching. outline of how resync will work
drewp@bigasterisk.com
parents:
810
diff
changeset
|
122 # move to syncedgraph patchMapping |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
123 |
838
321fc6150ee3
subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents:
821
diff
changeset
|
124 self.sub.graph.patchMapping(context=self.session, |
321fc6150ee3
subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents:
821
diff
changeset
|
125 subject=self.session, |
321fc6150ee3
subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents:
821
diff
changeset
|
126 predicate=L9['subSetting'], |
321fc6150ee3
subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents:
821
diff
changeset
|
127 nodeClass=L9['SubSetting'], |
321fc6150ee3
subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents:
821
diff
changeset
|
128 keyPred=L9['sub'], newKey=uri, |
321fc6150ee3
subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents:
821
diff
changeset
|
129 valuePred=L9['level'], newValue=Literal(level)) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
130 |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
131 def updateLevelFromGraph(self): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
132 """read rdf level, write it to subbox.slider_var""" |
814
1ae8e6b287e3
improvements to file watching. outline of how resync will work
drewp@bigasterisk.com
parents:
810
diff
changeset
|
133 # move this to syncedgraph readMapping |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
134 graph = self.sub.graph |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
135 |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
136 for setting in graph.objects(self.session, L9['subSetting']): |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
137 if graph.value(setting, L9['sub']) == self.sub.uri: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
138 self.pauseTrace = True # don't bounce this update back to server |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
139 try: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
140 self.slider_var.set(graph.value(setting, L9['level'])) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
141 finally: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
142 self.pauseTrace = False |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
143 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
144 def updateName(self): |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
145 def shortUri(u): |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
146 return '.../' + u.split('/')[-1] |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
147 self.namelabel.config(text=self.sub.graph.label(self.sub.uri) or shortUri(self.sub.uri)) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
148 |
253
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
149 class KeyboardComposer(Frame, SubClient): |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
150 def __init__(self, root, graph, session, |
394
0c33ea7d523d
keyboardcomposer: sliders default to true
David McClosky <dmcc@bigasterisk.com>
parents:
393
diff
changeset
|
151 hw_sliders=True): |
146 | 152 Frame.__init__(self, root, bg='black') |
253
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
153 SubClient.__init__(self) |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
154 self.graph = graph |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
155 self.session = session |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
156 self.submasters = Submasters(graph) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
157 self.subbox = {} # sub uri : SubmasterBox |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
158 self.slider_table = {} # coords : SubmasterBox |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
159 self.rows = [] # this holds Tk Frames for each row |
821 | 160 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
161 self.current_row = 0 # should come from session graph |
0 | 162 |
390
5d2b119443f2
keyboardcomposer: fix (one) refresh bug
David McClosky <dmcc@bigasterisk.com>
parents:
389
diff
changeset
|
163 self.use_hw_sliders = hw_sliders |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
164 self.connect_to_hw(hw_sliders) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
165 |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
166 self.make_key_hints() |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
167 self.make_buttons() |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
168 |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
169 self.graph.addHandler(self.redraw_sliders) |
136 | 170 self.send_levels_loop() |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
171 self.graph.addHandler(self.rowFromGraph) |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
172 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
173 def make_buttons(self): |
146 | 174 self.buttonframe = Frame(self, bg='black') |
175 self.buttonframe.pack(side=BOTTOM) | |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
176 |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
177 self.sliders_status_var = IntVar() |
390
5d2b119443f2
keyboardcomposer: fix (one) refresh bug
David McClosky <dmcc@bigasterisk.com>
parents:
389
diff
changeset
|
178 self.sliders_status_var.set(self.use_hw_sliders) |
821 | 179 self.sliders_checkbutton = Checkbutton(self.buttonframe, |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
180 text="Sliders", variable=self.sliders_status_var, |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
181 command=lambda: self.toggle_slider_connectedness(), |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
182 bg='black', fg='white') |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
183 self.sliders_checkbutton.pack(side=LEFT) |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
184 |
821 | 185 self.alltozerobutton = Button(self.buttonframe, text="All to Zero", |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
186 command=self.alltozero, bg='black', fg='white') |
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
187 self.alltozerobutton.pack(side='left') |
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
188 |
821 | 189 self.save_stage_button = Button(self.buttonframe, text="Save", |
190 command=lambda: self.save_current_stage(self.sub_name.get()), | |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
191 bg='black', fg='white') |
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
192 self.save_stage_button.pack(side=LEFT) |
146 | 193 self.sub_name = Entry(self.buttonframe, bg='black', fg='white') |
194 self.sub_name.pack(side=LEFT) | |
389
e708fdcb383c
keyboardcomposer: move sliders toggler to better place
David McClosky <dmcc@bigasterisk.com>
parents:
386
diff
changeset
|
195 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
196 def redraw_sliders(self): |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
197 self.graph.addHandler(self.draw_sliders) |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
198 if len(self.rows): |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
199 self.change_row(self.current_row) |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
200 self.rows[self.current_row].focus() |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
201 |
136 | 202 self.stop_frequent_update_time = 0 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
203 |
520 | 204 def draw_sliders(self): |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
205 for r in self.rows: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
206 r.destroy() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
207 self.rows = [] |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
208 for b in self.subbox.values(): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
209 b.cleanup() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
210 self.subbox.clear() |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
211 self.slider_table.clear() |
821 | 212 |
520 | 213 self.tk_focusFollowsMouse() |
214 | |
945
85ccda959170
KC seems to refresh on new subs now, though it redraws way too many times
drewp@bigasterisk.com
parents:
888
diff
changeset
|
215 self.submasters.findSubs() # trigger graph load, but we read |
85ccda959170
KC seems to refresh on new subs now, though it redraws way too many times
drewp@bigasterisk.com
parents:
888
diff
changeset
|
216 # from get_all_subs, below |
85ccda959170
KC seems to refresh on new subs now, though it redraws way too many times
drewp@bigasterisk.com
parents:
888
diff
changeset
|
217 |
520 | 218 rowcount = -1 |
219 col = 0 | |
220 last_group = None | |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
221 |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
222 # there are unlikely to be any subs at startup because we |
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
223 # probably haven't been called back with the graph data yet |
821 | 224 |
225 withgroups = sorted((self.graph.value(sub.uri, L9['group']), | |
226 self.graph.value(sub.uri, L9['order']), | |
520 | 227 sub) |
228 for sub in self.submasters.get_all_subs()) | |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
229 log.info("withgroups %s", withgroups) |
520 | 230 |
231 for group, order, sub in withgroups: | |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
232 group = self.graph.value(sub.uri, L9['group']) |
520 | 233 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
234 if col == 0 or group != last_group: |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
235 row = self.make_row(group) |
520 | 236 rowcount += 1 |
237 col = 0 | |
238 | |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
239 subbox = SubmasterBox(row, sub, self.session) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
240 subbox.place(relx=col / 8, rely=0, relwidth=1 / 8, relheight=1) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
241 self.subbox[sub.uri] = self.slider_table[(rowcount, col)] = subbox |
520 | 242 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
243 self.setup_key_nudgers(subbox.scale) |
520 | 244 |
245 col = (col + 1) % 8 | |
246 last_group = group | |
821 | 247 |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
248 def toggle_slider_connectedness(self): |
392
53ec93018ee7
keyboardcomposer: remember whether to use hw sliders
David McClosky <dmcc@bigasterisk.com>
parents:
390
diff
changeset
|
249 self.use_hw_sliders = not self.use_hw_sliders |
53ec93018ee7
keyboardcomposer: remember whether to use hw sliders
David McClosky <dmcc@bigasterisk.com>
parents:
390
diff
changeset
|
250 if self.use_hw_sliders: |
386
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
251 self.sliders.reopen() |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
252 else: |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
253 self.sliders.close() |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
254 self.change_row(self.current_row) |
551f06733559
bcf2000 and kc: sliders can be turned off
David McClosky <dmcc@bigasterisk.com>
parents:
385
diff
changeset
|
255 self.rows[self.current_row].focus() |
520 | 256 |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
257 def connect_to_hw(self, hw_sliders): |
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
258 if hw_sliders: |
479
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
259 try: |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
260 self.sliders = Sliders(self) |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
261 except IOError: |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
262 log.info("no hardware sliders") |
479
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
263 self.sliders = DummySliders() |
52a600439ddd
keyboardcomposer: don't need --no-sliders no mo', yo
drewp@bigasterisk.com
parents:
474
diff
changeset
|
264 self.use_hw_sliders = False |
362
fc87327e29c4
CC now attaches to hardware sliders and knobs. tres cool. KC gets a --sliders option to enable the sliders
Drew Perttula <drewp@bigasterisk.com>
parents:
359
diff
changeset
|
265 else: |
366 | 266 self.sliders = DummySliders() |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
267 |
0 | 268 def make_key_hints(self): |
269 keyhintrow = Frame(self) | |
270 | |
271 col = 0 | |
272 for upkey, downkey in zip(nudge_keys['up'], | |
273 nudge_keys['down']): | |
274 # what a hack! | |
275 downkey = downkey.replace('semicolon', ';') | |
136 | 276 upkey, downkey = (upkey.upper(), downkey.upper()) |
0 | 277 |
278 # another what a hack! | |
821 | 279 keylabel = Label(keyhintrow, text='%s\n%s' % (upkey, downkey), |
146 | 280 width=1, font=('Arial', 10), bg='red', fg='white', anchor='c') |
0 | 281 keylabel.pack(side=LEFT, expand=1, fill=X) |
282 col += 1 | |
283 | |
284 keyhintrow.pack(fill=X, expand=0) | |
285 self.keyhints = keyhintrow | |
520 | 286 |
0 | 287 def setup_key_nudgers(self, tkobject): |
288 for d, keys in nudge_keys.items(): | |
289 for key in keys: | |
290 # lowercase makes full=0 | |
291 keysym = "<KeyPress-%s>" % key | |
292 tkobject.bind(keysym, \ | |
293 lambda evt, num=keys.index(key), d=d: \ | |
294 self.got_nudger(num, d)) | |
295 | |
296 # uppercase makes full=1 | |
297 keysym = "<KeyPress-%s>" % key.upper() | |
298 keysym = keysym.replace('SEMICOLON', 'colon') | |
299 tkobject.bind(keysym, \ | |
300 lambda evt, num=keys.index(key), d=d: \ | |
301 self.got_nudger(num, d, full=1)) | |
302 | |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
303 # Row changing: |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
304 # Page dn, C-n, and ] do down |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
305 # Page up, C-p, and ' do up |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
306 for key in '<Prior> <Next> <Control-n> <Control-p> ' \ |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
307 '<Key-bracketright> <Key-apostrophe>'.split(): |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
308 tkobject.bind(key, self.change_row_cb) |
0 | 309 |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
310 def change_row_cb(self, event): |
0 | 311 diff = 1 |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
312 if event.keysym in ('Prior', 'p', 'bracketright'): |
0 | 313 diff = -1 |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
314 self.change_row(self.current_row + diff) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
315 |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
316 def rowFromGraph(self): |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
317 self.change_row(int(self.graph.value(self.session, L9['currentRow'], default=0)), fromGraph=True) |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
318 |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
319 def change_row(self, row, fromGraph=False): |
0 | 320 old_row = self.current_row |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
321 self.current_row = row |
0 | 322 self.current_row = max(0, self.current_row) |
323 self.current_row = min(len(self.rows) - 1, self.current_row) | |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
324 try: |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
325 row = self.rows[self.current_row] |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
326 except IndexError: |
810 | 327 # if we're mid-load, this row might still appear soon. If |
328 # we changed interactively, the user is out of bounds and | |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
329 # needs to be brought back in |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
330 if fromGraph: |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
331 return |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
332 raise |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
333 |
0 | 334 self.unhighlight_row(old_row) |
335 self.highlight_row(self.current_row) | |
336 self.keyhints.pack_configure(before=row) | |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
337 |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
338 if not fromGraph: |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
339 self.graph.patchObject(self.session, self.session, L9['currentRow'], |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
340 Literal(self.current_row)) |
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
341 |
393
e43dcabbf9ba
keyboardcomposer: fix hw slider off by one bug
David McClosky <dmcc@bigasterisk.com>
parents:
392
diff
changeset
|
342 for col in range(1, 9): |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
343 try: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
344 subbox = self.slider_table[(self.current_row, col - 1)] |
474
c4807e96ee90
KC was sending values that didn't match bcf2000 api
drewp@bigasterisk.com
parents:
459
diff
changeset
|
345 self.sliders.valueOut("button-upper%d" % col, True) |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
346 except KeyError: |
376
b74c50018564
upper button lights indicate "dead"ness
David McClosky <dmcc@bigasterisk.com>
parents:
375
diff
changeset
|
347 # unfilled bottom row has holes (plus rows with incomplete |
b74c50018564
upper button lights indicate "dead"ness
David McClosky <dmcc@bigasterisk.com>
parents:
375
diff
changeset
|
348 # groups |
474
c4807e96ee90
KC was sending values that didn't match bcf2000 api
drewp@bigasterisk.com
parents:
459
diff
changeset
|
349 self.sliders.valueOut("button-upper%d" % col, False) |
385
e6f5ffb6a1b4
keyboardcomposer: zero hw sliders not used by row
David McClosky <dmcc@bigasterisk.com>
parents:
384
diff
changeset
|
350 self.sliders.valueOut("slider%d" % col, 0) |
376
b74c50018564
upper button lights indicate "dead"ness
David McClosky <dmcc@bigasterisk.com>
parents:
375
diff
changeset
|
351 continue |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
352 self.send_to_hw(subbox.name, col) |
821 | 353 |
0 | 354 def got_nudger(self, number, direction, full=0): |
395
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
355 try: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
356 subbox = self.slider_table[(self.current_row, number)] |
395
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
357 except KeyError: |
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
358 return |
8a028b896913
keyboardcomposer: ignore non-existent nudgers
David McClosky <dmcc@bigasterisk.com>
parents:
394
diff
changeset
|
359 |
0 | 360 if direction == 'up': |
361 if full: | |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
362 subbox.scale.fade(1) |
0 | 363 else: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
364 subbox.scale.increase() |
0 | 365 else: |
366 if full: | |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
367 subbox.scale.fade(0) |
0 | 368 else: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
369 subbox.scale.decrease() |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
370 |
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
371 def hw_slider_moved(self, col, value): |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
372 value = int(value * 100) / 100 |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
373 try: |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
374 subbox = self.slider_table[(self.current_row, col)] |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
375 except KeyError: |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
376 return # no slider assigned at that column |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
377 subbox.scale.set(value) |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
378 |
801 | 379 def send_to_hw(self, subUri, hwNum): |
366 | 380 if isinstance(self.sliders, DummySliders): |
381 return | |
821 | 382 |
801 | 383 v = round(127 * self.slider_vars[subUri].get()) |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
384 chan = "slider%s" % hwNum |
821 | 385 |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
386 # workaround for some rounding issue, where we receive one |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
387 # value and then decide to send back a value that's one step |
368
ce302e4a73dc
keyboardcomposer: hw startup should move if value is 0
David McClosky <dmcc@bigasterisk.com>
parents:
366
diff
changeset
|
388 # lower. -5 is a fallback for having no last value. hopefully |
ce302e4a73dc
keyboardcomposer: hw startup should move if value is 0
David McClosky <dmcc@bigasterisk.com>
parents:
366
diff
changeset
|
389 # we won't really see it |
ce302e4a73dc
keyboardcomposer: hw startup should move if value is 0
David McClosky <dmcc@bigasterisk.com>
parents:
366
diff
changeset
|
390 if abs(v - self.sliders.lastValue.get(chan, -5)) <= 1: |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
391 return |
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
392 self.sliders.valueOut(chan, v) |
821 | 393 |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
394 def make_row(self, group): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
395 """group is a URI or None""" |
146 | 396 row = Frame(self, bd=2, bg='black') |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
397 row.subGroup = group |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
398 def onDrop(ev): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
399 self.change_group(sub=URIRef(ev.data), row=row) |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
400 return "link" |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
401 |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
402 dropTargetRegister(row, onDrop=onDrop, typeList=['*'], |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
403 hoverStyle=dict(background="#555500")) |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
404 |
0 | 405 row.pack(expand=1, fill=BOTH) |
406 self.setup_key_nudgers(row) | |
407 self.rows.append(row) | |
408 return row | |
409 | |
946
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
410 def change_group(self, sub, row): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
411 """update this sub's group, and maybe other sub groups as needed, so |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
412 this sub displays in this row""" |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
413 group = row.subGroup |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
414 self.graph.patchObject( |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
415 context=self.session, |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
416 subject=sub, predicate=L9['group'], newObject=group) |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
417 |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
418 def subs_in_row(self, row): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
419 """uris of the submasters displayed in this row. untested""" |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
420 rowNum = self.rows.index(row) + 1 |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
421 ret = set() |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
422 for coords, subbox in self.slider_table.items(): |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
423 if coords[0] == rowNum: |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
424 ret.add(subbox.sub.uri) |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
425 return ret |
7e991dba05f4
KC supports dragging into (existing) named groups. still can't make a new group though
drewp@bigasterisk.com
parents:
945
diff
changeset
|
426 |
0 | 427 def highlight_row(self, row): |
428 row = self.rows[row] | |
429 row['bg'] = 'red' | |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
430 |
0 | 431 def unhighlight_row(self, row): |
432 row = self.rows[row] | |
146 | 433 row['bg'] = 'black' |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
434 |
0 | 435 def get_levels(self): |
821 | 436 return dict([(uri, box.slider_var.get()) |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
437 for uri, box in self.subbox.items()]) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
438 |
146 | 439 def get_levels_as_sub(self): |
801 | 440 scaledsubs = [self.submasters.get_sub_by_uri(sub) * level |
286
2848cf5e14c5
keyboardcomposer: skip subs at 0 when combining, temporary subs don't listen for reloads
David McClosky <dmcc@bigasterisk.com>
parents:
278
diff
changeset
|
441 for sub, level in self.get_levels().items() if level > 0.0] |
136 | 442 maxes = sub_maxes(*scaledsubs) |
146 | 443 return maxes |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
444 |
146 | 445 def save_current_stage(self, subname): |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
446 log.info("saving current levels as %s", subname) |
146 | 447 sub = self.get_levels_as_sub() |
947 | 448 |
449 newUri = showconfig.showUri() + "/sub/%s" % subname | |
450 ps = PersistentSubmaster(self.graph, newUri) | |
451 ps.changeName(subname) | |
452 for chanName, v in sub.get_levels().items(): | |
453 chan = get_channel_uri(str(chanName)) | |
454 ps.editLevel(chan, v) | |
455 | |
456 self.sub_name.delete(0, tk.END) | |
457 | |
146 | 458 |
136 | 459 def send_frequent_updates(self): |
460 """called when we get a fade -- send events as quickly as possible""" | |
461 if time.time() <= self.stop_frequent_update_time: | |
462 self.send_levels() | |
463 self.after(10, self.send_frequent_updates) | |
146 | 464 |
275
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
465 def alltozero(self): |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
466 for uri, subbox in self.subbox.items(): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
467 if subbox.scale.scale_var.get() != 0: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
468 subbox.scale.fade(value=0.0, length=0) |
275
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
469 |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
470 # move to web lib |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
471 def postArgGetter(request): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
472 """return a function that takes arg names and returns string |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
473 values. Supports args encoded in the url or in postdata. No |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
474 support for repeated args.""" |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
475 # this is something nevow normally does for me |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
476 request.content.seek(0) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
477 fields = cgi.FieldStorage(request.content, request.received_headers, |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
478 environ={'REQUEST_METHOD': 'POST'}) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
479 def getArg(n): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
480 try: |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
481 return request.args[n][0] |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
482 except KeyError: |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
483 return fields[n].value |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
484 return getArg |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
485 |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
486 |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
487 class LevelServerHttp(resource.Resource): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
488 isLeaf = True |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
489 def __init__(self,name_to_subbox): |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
490 self.name_to_subbox = name_to_subbox |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
491 |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
492 def render_POST(self, request): |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
493 arg = postArgGetter(request) |
821 | 494 |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
495 if request.path == '/fadesub': |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
496 # fadesub?subname=scoop&level=0&secs=.2 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
497 self.name_to_subbox[arg('subname')].scale.fade( |
513
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
498 float(arg('level')), |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
499 float(arg('secs'))) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
500 return "set %s to %s" % (arg('subname'), arg('level')) |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
501 else: |
259436a06912
keyboardcomposer now receives http, not xmlrpc
drewp@bigasterisk.com
parents:
479
diff
changeset
|
502 raise NotImplementedError(repr(request)) |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
503 |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
504 class Sliders(BCF2000): |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
505 def __init__(self, kc): |
745 | 506 devices = ['/dev/snd/midiC1D0', '/dev/snd/midiC2D0', '/dev/snd/midiC3D0'] |
676
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
507 for dev in devices: |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
508 try: |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
509 BCF2000.__init__(self, dev=dev) |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
510 except IOError, e: |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
511 if dev is devices[-1]: |
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
512 raise |
724
27fdbe9a8118
fix sliders device search
Drew Perttula <drewp@bigasterisk.com>
parents:
721
diff
changeset
|
513 else: |
27fdbe9a8118
fix sliders device search
Drew Perttula <drewp@bigasterisk.com>
parents:
721
diff
changeset
|
514 break |
676
adc5d450f890
try multiple device paths for the midi sliders
drewp@bigasterisk.com
parents:
623
diff
changeset
|
515 |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
516 self.kc = kc |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
517 def valueIn(self, name, value): |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
518 kc = self.kc |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
519 if name.startswith("slider"): |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
520 kc.hw_slider_moved(int(name[6:]) - 1, value / 127) |
382
75213189881e
keyboardcomposer: ignore button-upper presses
David McClosky <dmcc@bigasterisk.com>
parents:
379
diff
changeset
|
521 elif name.startswith("button-upper"): |
75213189881e
keyboardcomposer: ignore button-upper presses
David McClosky <dmcc@bigasterisk.com>
parents:
379
diff
changeset
|
522 kc.change_row(kc.current_row) |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
523 elif name.startswith("button-lower"): |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
524 col = int(name[12:]) - 1 |
379
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
525 self.valueOut(name, 0) |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
526 try: |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
527 tkslider = kc.slider_table[(kc.current_row, col)] |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
528 except KeyError: |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
529 return |
546e01adad37
keyboardcomposer: better bumping, save row, bug fixen
David McClosky <dmcc@bigasterisk.com>
parents:
378
diff
changeset
|
530 |
378
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
531 slider_var = tkslider.slider_var |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
532 if slider_var.get() == 1: |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
533 slider_var.set(0) |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
534 else: |
a4c294b8c9c2
keyboardcomposer: reorganize Sliders, add bump buttons
David McClosky <dmcc@bigasterisk.com>
parents:
377
diff
changeset
|
535 slider_var.set(1) |
383
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
536 elif name.startswith("button-corner"): |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
537 button_num = int(name[13:]) - 1 |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
538 if button_num == 1: |
384
d596d932a7f1
keyboardcomposer: flip corner buttons, keep corner lights off
David McClosky <dmcc@bigasterisk.com>
parents:
383
diff
changeset
|
539 diff = -1 |
383
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
540 elif button_num == 3: |
384
d596d932a7f1
keyboardcomposer: flip corner buttons, keep corner lights off
David McClosky <dmcc@bigasterisk.com>
parents:
383
diff
changeset
|
541 diff = 1 |
383
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
542 else: |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
543 return |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
544 |
a78e77f9aa66
keyboardcomposer: some corner buttons change row now
David McClosky <dmcc@bigasterisk.com>
parents:
382
diff
changeset
|
545 kc.change_row(kc.current_row + diff) |
384
d596d932a7f1
keyboardcomposer: flip corner buttons, keep corner lights off
David McClosky <dmcc@bigasterisk.com>
parents:
383
diff
changeset
|
546 self.valueOut(name, 0) |
350
c7478a778992
junky first pass at bcf2000 for keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
343
diff
changeset
|
547 |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
548 def launch(opts, root, graph, session): |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
549 tl = toplevelat("Keyboard Composer - %s" % opts.session, |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
550 existingtoplevel=root, graph=graph, session=session) |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
551 |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
552 kc = KeyboardComposer(tl, graph, session, |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
553 hw_sliders=not opts.no_sliders) |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
554 kc.pack(fill=BOTH, expand=1) |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
555 |
948 | 556 for helpline in ["Bindings: B3 mute"]: |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
557 tk.Label(root,text=helpline, font="Helvetica -12 italic", |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
558 anchor='w').pack(side='top',fill='x') |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
559 |
0 | 560 if __name__ == "__main__": |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
561 parser = OptionParser() |
394
0c33ea7d523d
keyboardcomposer: sliders default to true
David McClosky <dmcc@bigasterisk.com>
parents:
393
diff
changeset
|
562 parser.add_option('--no-sliders', action='store_true', |
430 | 563 help="don't attach to hardware sliders") |
809
7f1aef5fbddb
session cmdline support. KC saves current row in the session
drewp@bigasterisk.com
parents:
808
diff
changeset
|
564 clientsession.add_option(parser) |
570
5037fa2c9983
fix how KC reads its graphs. switch to logging lib and add -v flag
drewp@bigasterisk.com
parents:
559
diff
changeset
|
565 parser.add_option('-v', action='store_true', help="log info level") |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
566 opts, args = parser.parse_args() |
559
3f9162973d60
KC channel color support. use statements like sub:scoop :color "#ffaa77"
drewp@bigasterisk.com
parents:
520
diff
changeset
|
567 |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
568 log.setLevel(logging.INFO if opts.v else logging.WARN) |
570
5037fa2c9983
fix how KC reads its graphs. switch to logging lib and add -v flag
drewp@bigasterisk.com
parents:
559
diff
changeset
|
569 |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
570 graph = SyncedGraph("keyboardcomposer") |
0 | 571 |
821 | 572 # i think this also needs delayed start (like subcomposer has), to have a valid graph |
573 # before setting any stuff from the ui | |
574 | |
0 | 575 root = Tk() |
734
d230824728aa
drag submasters out of keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
733
diff
changeset
|
576 initTkdnd(root.tk, 'tkdnd/trunk/') |
810 | 577 |
815
d7f1f868eb6c
toplevel window pos is saved in the graph. Patch conflicts no longer break as hard, but they don't exactly reset themselves right yet eiher
drewp@bigasterisk.com
parents:
814
diff
changeset
|
578 session = clientsession.getUri('keyboardcomposer', opts) |
d7f1f868eb6c
toplevel window pos is saved in the graph. Patch conflicts no longer break as hard, but they don't exactly reset themselves right yet eiher
drewp@bigasterisk.com
parents:
814
diff
changeset
|
579 |
888
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
580 graph.initiallySynced.addCallback( |
cad8207933d7
KC fix logging, startup after graph sync, display uri tails when there's no label
Drew Perttula <drewp@bigasterisk.com>
parents:
838
diff
changeset
|
581 lambda _: launch(opts, root, graph, session)) |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
582 |
808
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
583 if 0: # needs fixing, or maybe it's obsolete because other progs can just patch the rdf graph |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
584 import twisted.internet |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
585 try: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
586 reactor.listenTCP(networking.keyboardComposer.port, |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
587 server.Site(LevelServerHttp(kc.name_to_subbox))) |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
588 except twisted.internet.error.CannotListenError, e: |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
589 log.warn("Can't (and won't!) start level server:") |
a631e075a5bf
KC big rewrites, now multiple KC instances can sync with rdfdb
drewp@bigasterisk.com
parents:
801
diff
changeset
|
590 log.warn(e) |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
591 |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
592 root.protocol('WM_DELETE_WINDOW', reactor.stop) |
821 | 593 |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
594 tksupport.install(root,ms=10) |
356
c6aabf5bd3bc
big KC speedup from not reloading config.n3 constantly
Drew Perttula <drewp@bigasterisk.com>
parents:
351
diff
changeset
|
595 |
c6aabf5bd3bc
big KC speedup from not reloading config.n3 constantly
Drew Perttula <drewp@bigasterisk.com>
parents:
351
diff
changeset
|
596 |
359
bd8a89743226
KC optimizations, hw sliders now follow the active row
Drew Perttula <drewp@bigasterisk.com>
parents:
356
diff
changeset
|
597 # prof.watchPoint("/usr/lib/python2.4/site-packages/rdflib-2.3.3-py2.4-linux-i686.egg/rdflib/Graph.py", 615) |
799
fcf95ff23cc5
PersistentSubmaster split. keyboardcomposer now notices submaster changes
drewp@bigasterisk.com
parents:
745
diff
changeset
|
598 |
356
c6aabf5bd3bc
big KC speedup from not reloading config.n3 constantly
Drew Perttula <drewp@bigasterisk.com>
parents:
351
diff
changeset
|
599 prof.run(reactor.run, profile=False) |