Mercurial > code > home > repos > light9
comparison bin/curvecalc @ 1275:b8e2b8acb02c
try to improve CC toggling
Ignore-this: 192efc19d36613bcf1e6cd5d4a9dbc58
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sun, 14 Jun 2015 07:37:59 +0000 |
parents | af7bf271aaae |
children | e4aafd2242aa |
comparison
equal
deleted
inserted
replaced
1274:7445bcd3349d | 1275:b8e2b8acb02c |
---|---|
73 graph.value(session, L9['currentSong']))) | 73 graph.value(session, L9['currentSong']))) |
74 graph.addHandler(updateTitle) | 74 graph.addHandler(updateTitle) |
75 | 75 |
76 songChoice = Observable(None) # to be connected with the session song | 76 songChoice = Observable(None) # to be connected with the session song |
77 | 77 |
78 def setSong(): | 78 self.registerGraphToSongChoice(wtree, session, graph, songChoice) |
79 songChoice(graph.value(session, L9['currentSong'])) | 79 self.registerSongChoiceToGraph(session, graph, songChoice) |
80 dispatcher.send("song_has_changed") | 80 self.current_player_song = self.registerCurrentPlayerSongToUi(wtree, graph, songChoice) |
81 graph.addHandler(setSong) | |
82 # next here, watch songChoice and patch the graph | |
83 def songToGraph(newSong): | |
84 if newSong is Local: | |
85 raise NotImplementedError('what do i patch') | |
86 graph.patchObject(context=session, subject=session, | |
87 predicate=L9['currentSong'], newObject=newSong) | |
88 songChoice.subscribe(songToGraph) | |
89 def current_player_song(song): | |
90 # (this is run on every frame) | |
91 ps = wtree.get_object("playerSong") | |
92 if URIRef(ps.get_uri()) != song: | |
93 print "update playerSong" | |
94 def setLabel(): | |
95 ps.set_label(graph.label(song)) | |
96 graph.addHandler(setLabel) | |
97 ps.set_uri(song) | |
98 if song != songChoice(): | |
99 if wtree.get_object("followPlayerSongChoice").get_active(): | |
100 songChoice(song) | |
101 | |
102 self.current_player_song = current_player_song | |
103 dispatcher.connect(current_player_song, "current_player_song") | |
104 | 81 |
105 ec = EditChoice(graph, songChoice, label="Editing song:") | 82 ec = EditChoice(graph, songChoice, label="Editing song:") |
106 wtree.get_object("currentSongEditChoice").add(ec) | 83 wtree.get_object("currentSongEditChoice").add(ec) |
107 ec.show() | 84 ec.show() |
108 | 85 |
114 self.setupNewSubZone() | 91 self.setupNewSubZone() |
115 self.acceptDragsOnCurveViews() | 92 self.acceptDragsOnCurveViews() |
116 | 93 |
117 # may not work | 94 # may not work |
118 wtree.get_object("paned1").set_position(600) | 95 wtree.get_object("paned1").set_position(600) |
96 | |
97 def registerGraphToSongChoice(self, wtree, session, graph, songChoice): | |
98 def setSong(): | |
99 current = graph.value(session, L9['currentSong']) | |
100 if not wtree.get_object("followPlayerSongChoice").get_active(): | |
101 songChoice(current) | |
102 dispatcher.send("song_has_changed") | |
103 graph.addHandler(setSong) | |
104 | |
105 def registerSongChoiceToGraph(self, session, graph, songChoice): | |
106 def songToGraph(newSong): | |
107 if newSong is Local: | |
108 raise NotImplementedError('what do i patch') | |
109 log.debug('songToGraph is going to set to %r', newSong) | |
110 import traceback; traceback.print_stack() | |
111 graph.patchObject(context=session, subject=session, | |
112 predicate=L9['currentSong'], newObject=newSong) | |
113 songChoice.subscribe(songToGraph) | |
114 | |
115 def registerCurrentPlayerSongToUi(self, wtree, graph, songChoice): | |
116 """current_player_song 'song' param -> playerSong ui | |
117 and | |
118 current_player_song 'song' param -> songChoice, if you're in autofollow | |
119 """ | |
120 def current_player_song(song): | |
121 # (this is run on every frame) | |
122 ps = wtree.get_object("playerSong") | |
123 if URIRef(ps.get_uri()) != song: | |
124 log.debug("update playerSong to %s", ps.get_uri()) | |
125 def setLabel(): | |
126 ps.set_label(graph.label(song)) | |
127 graph.addHandler(setLabel) | |
128 ps.set_uri(song) | |
129 if song != songChoice(): | |
130 log.debug('song %s != songChoice %s', song, songChoice()) | |
131 if wtree.get_object("followPlayerSongChoice").get_active(): | |
132 log.debug('followPlayerSongChoice is on') | |
133 songChoice(song) | |
134 | |
135 dispatcher.connect(current_player_song, "current_player_song") | |
136 return current_player_song | |
119 | 137 |
120 def setupNewSubZone(self): | 138 def setupNewSubZone(self): |
121 self.wtree.get_object("newSubZone").drag_dest_set( | 139 self.wtree.get_object("newSubZone").drag_dest_set( |
122 flags=Gtk.DestDefaults.ALL, | 140 flags=Gtk.DestDefaults.ALL, |
123 targets=[Gtk.TargetEntry('text/uri-list', 0, 0)], | 141 targets=[Gtk.TargetEntry('text/uri-list', 0, 0)], |