Changeset - 962f46713b63
[Not reviewed]
default
0 2 0
David McClosky - 18 years ago 2007-06-15 20:23:43
dmcc@bigasterisk.com
keyboardcomposer: sort subs by groups first, fix sub cmp
The "None" group goes first, then all groups sorted by names. Within groups,
subs are sorted by names. Subs sort by their __repr__, which could be a
problem in the future.
2 files changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
bin/keyboardcomposer
Show inline comments
 
@@ -203,25 +203,28 @@ class KeyboardComposer(Frame, SubClient)
 
            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()
 
        for sub in self.submasters.get_all_subs():
 
        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,
light9/Submaster.py
Show inline comments
 
@@ -164,25 +164,25 @@ class Submaster:
 
            keys_set[k] = 1
 
        all_keys = keys_set.keys()
 

	
 
        xfaded_sub = Submaster("xfade", temporary=1)
 
        for k in all_keys:
 
            xfaded_sub.set_level(k, 
 
                                 linear_fade(self.levels.get(k, 0),
 
                                             otherlevels.get(k, 0),
 
                                             amount))
 

	
 
        return xfaded_sub
 
    def __cmp__(self, other):
 
        raise NotImplementedError
 
        """Compare by sub repr (name, hopefully)"""
 
        return cmp(repr(self), repr(other))
 
    def __hash__(self):
 
        raise NotImplementedError
 
        return hash(repr(self))
 
                                            
 
def linear_fade(start, end, amount):
 
    """Fades between two floats by an amount.  amount is a float between
 
    0 and 1.  If amount is 0, it will return the start value.  If it is 1,
 
    the end value will be returned."""
 
    level = start + (amount * (end - start))
 
    return level
 

	
0 comments (0 inline, 0 general)