Skip to content

Commit

Permalink
Pass 'hidden' property back from Chord view to libmapper graph. Now t…
Browse files Browse the repository at this point in the history
…hat saving is being handled by mappersession we need access to this property in the Python backend, since hidden devices must be omitted from generated session files.
  • Loading branch information
malloch committed Jul 12, 2023
1 parent 390da78 commit 61f3ebc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/views/ChordView.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ class ChordView extends View {
}
else
dev.hidden = true;
self.graph.devices.forEach(d => command.send("set_dev", { "name" : d.name,
"hidden" : d.hidden,
"publish" : false }));
self.showDevLabel(self, dev, e);
self.draw(0);
});
Expand Down
24 changes: 24 additions & 0 deletions webmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,28 @@ def set_map_properties(props, map):
map[key] = val
map.push()

def set_dev_properties(props):
print('set_dev_properties()', props)

# find dev by name
dev = graph.devices().filter(mpr.Property.NAME, props['name'])
if not dev:
return
dev = dev.next()

print('found dev: ', dev)
del props['name']

pub = False
if 'publish' in props:
publish = props['publish']
del props['publish']

# set metadata
for key in props:
dev.set_property(key, props[key], publish=pub)
dev.push()

def set_sig_properties(props):
# check how arbitrary metadata are set – can we use this instead?
print('set_sig_properties()', props)
Expand Down Expand Up @@ -455,6 +477,8 @@ def poll_and_push():

server.add_command_handler("subscribe", lambda x: subscribe(x))

server.add_command_handler("set_dev", lambda x: set_dev_properties(x))

server.add_command_handler("add_signals",
lambda x: ("add_signals", [sig_props(s) for s in graph.signals()]))

Expand Down

0 comments on commit 61f3ebc

Please sign in to comment.