Changeset - b74c50018564
[Not reviewed]
default
0 1 0
David McClosky - 18 years ago 2007-06-15 20:36:41
dmcc@bigasterisk.com
upper button lights indicate "dead"ness
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
bin/keyboardcomposer
Show inline comments
 
@@ -134,98 +134,102 @@ class KeyboardComposer(Frame, SubClient)
 
            # another what a hack!
 
            keylabel = Label(keyhintrow, text='%s\n%s' % (upkey, downkey), 
 
                width=1, font=('Arial', 10), bg='red', fg='white', anchor='c')
 
            keylabel.pack(side=LEFT, expand=1, fill=X)
 
            col += 1
 

	
 
        keyhintrow.pack(fill=X, expand=0)
 
        self.keyhints = keyhintrow
 
    def setup_key_nudgers(self, tkobject):
 
        for d, keys in nudge_keys.items():
 
            for key in keys:
 
                # lowercase makes full=0
 
                keysym = "<KeyPress-%s>" % key
 
                tkobject.bind(keysym, \
 
                    lambda evt, num=keys.index(key), d=d: \
 
                        self.got_nudger(num, d))
 

	
 
                # uppercase makes full=1
 
                keysym = "<KeyPress-%s>" % key.upper()
 
                keysym = keysym.replace('SEMICOLON', 'colon')
 
                tkobject.bind(keysym, \
 
                    lambda evt, num=keys.index(key), d=d: \
 
                        self.got_nudger(num, d, full=1))
 

	
 
        # Row changing:
 
        # Page dn, C-n, and ] do down
 
        # Page up, C-p, and ' do up
 
        for key in '<Prior> <Next> <Control-n> <Control-p> ' \
 
                   '<Key-bracketright> <Key-apostrophe>'.split():
 
            tkobject.bind(key, self.change_row)
 

	
 
    def change_row(self, event):
 
        diff = 1
 
        if event.keysym in ('Prior', 'p', 'bracketright'):
 
            diff = -1
 
        old_row = self.current_row
 
        self.current_row += diff
 
        self.current_row = max(0, self.current_row)
 
        self.current_row = min(len(self.rows) - 1, self.current_row)
 
        self.unhighlight_row(old_row)
 
        self.highlight_row(self.current_row)
 
        row = self.rows[self.current_row]
 
        self.keyhints.pack_configure(before=row)
 

	
 
        
 
        for col in range(8):
 
            try:
 
                subtk = self.slider_table[(self.current_row, col)]
 
                self.sliders.valueOut("button-upper%d" % (col + 1), 127)
 
            except KeyError:
 
                pass # unfilled bottom row has holes
 
                # unfilled bottom row has holes (plus rows with incomplete
 
                # groups
 
                self.sliders.valueOut("button-upper%d" % (col + 1), 0)
 
                continue
 
            self.send_to_hw(subtk.name, col + 1)
 

	
 
            
 
    def got_nudger(self, number, direction, full=0):
 
        subtk = self.slider_table[(self.current_row, number)]
 
        if direction == 'up':
 
            if full:
 
                subtk.scale.fade(1)
 
            else:
 
                subtk.scale.increase()
 
        else:
 
            if full:
 
                subtk.scale.fade(0)
 
            else:
 
                subtk.scale.decrease()
 

	
 
    def hw_slider_moved(self, col, value):
 
        value = int(value * 100) / 100
 
        try:
 
            subtk = self.slider_table[(self.current_row, col)]
 
        except KeyError:
 
            return # no slider assigned at that column
 
        subtk.scale.set(value)
 
                
 
    def draw_sliders(self):
 
        self.tk_focusFollowsMouse()
 

	
 
        rowcount = -1
 
        col = 0
 
        last_group = None
 
        graph = showconfig.getGraph()
 
        withgroups = sorted((graph.value(sub.uri, L9['group']), sub)
 
            for sub in self.submasters.get_all_subs())
 

	
 
        for group, sub in withgroups:
 
            group = graph.value(sub.uri, L9['group'])
 

	
 
            if col == 0 or group != last_group: # make new row
 
                row = self.make_row()
 
                rowcount += 1
 
                col = 0
 
            current_level = self.current_sub_levels.get(sub.name, 0)
 
            subtk = self.draw_sub_slider(row, col, sub.name, current_level)
 
            self.slider_table[(rowcount, col)] = subtk
 
            self.name_to_subtk[sub.name] = subtk
 

	
 
            def slider_changed(x, y, z, subtk=subtk,
 
                               col=col, sub=sub, rowcount=rowcount):
0 comments (0 inline, 0 general)