changeset 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 f2dbb0b1fb35
children fd4f06a93c95
files bin/keyboardcomposer
diffstat 1 files changed, 48 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/bin/keyboardcomposer	Mon Jun 29 04:40:34 2009 +0000
+++ b/bin/keyboardcomposer	Mon Jun 29 04:57:53 2009 +0000
@@ -131,6 +131,52 @@
         self.sub_name.pack(side=LEFT)
 
         self.stop_frequent_update_time = 0
+                
+    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']), 
+                             graph.value(sub.uri, L9['order']), 
+                             sub)
+            for sub in self.submasters.get_all_subs())
+
+        for group, order, 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):
+                subtk.scale.draw_indicator_colors()
+                self.send_levels()
+                if rowcount == self.current_row:
+                    self.send_to_hw(sub.name, col + 1)
+
+            subtk.slider_var.trace('w', slider_changed)
+
+            # initial position
+            self.send_to_hw(sub.name, col + 1)
+            col = (col + 1) % 8
+            last_group = group
+
+    def draw_sub_slider(self, row, col, name, current_level):
+        subtk = SubmasterTk(row, name, current_level)
+        subtk.place(relx=col / 8, rely=0, relwidth=1 / 8, relheight=1)
+        self.setup_key_nudgers(subtk.scale)
+
+        self.slider_vars[name] = subtk.slider_var
+        return subtk
 
     def toggle_slider_connectedness(self):
         self.use_hw_sliders = not self.use_hw_sliders
@@ -140,6 +186,7 @@
             self.sliders.close()
         self.change_row(self.current_row)
         self.rows[self.current_row].focus()
+
     def connect_to_hw(self, hw_sliders):
         if hw_sliders:
             try:
@@ -169,6 +216,7 @@
 
         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:
@@ -243,44 +291,6 @@
         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']), 
-                             graph.value(sub.uri, L9['order']), 
-                             sub)
-            for sub in self.submasters.get_all_subs())
-
-        for group, order, 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):
-                subtk.scale.draw_indicator_colors()
-                self.send_levels()
-                if rowcount == self.current_row:
-                    self.send_to_hw(sub.name, col + 1)
-
-            subtk.slider_var.trace('w', slider_changed)
-
-            # initial position
-            self.send_to_hw(sub.name, col + 1)
-            col = (col + 1) % 8
-            last_group = group
 
     def send_to_hw(self, subName, hwNum):
         if isinstance(self.sliders, DummySliders):
@@ -303,13 +313,7 @@
         self.setup_key_nudgers(row)
         self.rows.append(row)
         return row
-    def draw_sub_slider(self, row, col, name, current_level):
-        subtk = SubmasterTk(row, name, current_level)
-        subtk.place(relx=col / 8, rely=0, relwidth=1 / 8, relheight=1)
-        self.setup_key_nudgers(subtk.scale)
 
-        self.slider_vars[name] = subtk.slider_var
-        return subtk
     def highlight_row(self, row):
         row = self.rows[row]
         row['bg'] = 'red'