Mute shortcut modifiers

This commit is contained in:
futpib 2018-11-21 02:09:10 +03:00
parent b609387e49
commit 810c77cc85
2 changed files with 35 additions and 30 deletions

View File

@ -820,10 +820,14 @@ class Graph extends React.Component {
this._requestedIcons.add(icon); this._requestedIcons.add(icon);
} }
onBackgroundMouseDown() { onBackgroundMouseDown(event) {
this.setState({ if (event.button === 1) {
contexted: backgroundSymbol, this.toggleAllMute(this.props.infos.sinks);
}); } else if (event.button === 2) {
this.setState({
contexted: backgroundSymbol,
});
}
} }
onSelectNode(selected) { onSelectNode(selected) {
@ -920,7 +924,7 @@ class Graph extends React.Component {
pais.forEach(pai => this.toggleMute(pai, !allMuted)); pais.forEach(pai => this.toggleMute(pai, !allMuted));
} }
toggleMute(pai, muted = !pai.muted, shift = false) { toggleMute(pai, muted = !pai.muted, sourceBiased = false) {
if (pai.muted === muted) { if (pai.muted === muted) {
return; return;
} }
@ -930,7 +934,7 @@ class Graph extends React.Component {
} else if (pai.type === 'sourceOutput') { } else if (pai.type === 'sourceOutput') {
this.props.setSourceOutputMuteByIndex(pai.index, muted); this.props.setSourceOutputMuteByIndex(pai.index, muted);
} else if (pai.type === 'sink') { } else if (pai.type === 'sink') {
if (shift) { if (sourceBiased) {
const sinkInputs = getSinkSinkInputs(pai)({ pulse: this.props }); const sinkInputs = getSinkSinkInputs(pai)({ pulse: this.props });
this.toggleAllMute(sinkInputs); this.toggleAllMute(sinkInputs);
} else { } else {
@ -939,7 +943,7 @@ class Graph extends React.Component {
} else if (pai.type === 'source') { } else if (pai.type === 'source') {
this.props.setSourceMute(pai.index, muted); this.props.setSourceMute(pai.index, muted);
} else if (pai.type === 'client') { } else if (pai.type === 'client') {
if (shift) { if (sourceBiased) {
const sourceOutputs = getClientSourceOutputs(pai)({ pulse: this.props }); const sourceOutputs = getClientSourceOutputs(pai)({ pulse: this.props });
this.toggleAllMute(sourceOutputs); this.toggleAllMute(sourceOutputs);
} else { } else {
@ -947,7 +951,7 @@ class Graph extends React.Component {
this.toggleAllMute(sinkInputs); this.toggleAllMute(sinkInputs);
} }
} else if (pai.type === 'module') { } else if (pai.type === 'module') {
if (shift) { if (sourceBiased) {
const sourceOutputs = getModuleSourceOutputs(pai)({ pulse: this.props }); const sourceOutputs = getModuleSourceOutputs(pai)({ pulse: this.props });
this.toggleAllMute(sourceOutputs); this.toggleAllMute(sourceOutputs);
} else { } else {
@ -1046,10 +1050,23 @@ class Graph extends React.Component {
}); });
} }
hotKeyMute() { hotKeyMute({ shiftKey: sourceBiased, ctrlKey: all }) {
if (!this.state.selected) { if (!this.state.selected) {
const defaultSink = getDefaultSinkPai({ pulse: this.props }); if (sourceBiased) {
this.toggleMute(defaultSink); if (all) {
this.toggleAllMute(this.props.infos.sources);
} else {
const defaultSource = getDefaultSourcePai({ pulse: this.props });
this.toggleMute(defaultSource);
}
} else {
if (all) { // eslint-disable-line no-lonely-if
this.toggleAllMute(this.props.infos.sinks);
} else {
const defaultSink = getDefaultSinkPai({ pulse: this.props });
this.toggleMute(defaultSink);
}
}
return; return;
} }
@ -1059,23 +1076,7 @@ class Graph extends React.Component {
return; return;
} }
this.toggleMute(pai); this.toggleMute(pai, undefined, sourceBiased);
}
hotKeyShiftMute() {
if (!this.state.selected) {
const defaultSource = getDefaultSourcePai({ pulse: this.props });
this.toggleMute(defaultSource);
return;
}
const pai = dgoToPai.get(this.state.selected);
if (!pai) {
return;
}
this.toggleMute(pai, undefined, true);
} }
_hotKeyVolume(direction) { _hotKeyVolume(direction) {

View File

@ -29,8 +29,12 @@ const keyMap = {
hotKeyVolumeDown: [ '/', '9' ], hotKeyVolumeDown: [ '/', '9' ],
hotKeyVolumeUp: [ '*', '0' ], hotKeyVolumeUp: [ '*', '0' ],
hotKeyMute: 'space', hotKeyMute: [
hotKeyShiftMute: 'shift+space', 'space',
'shift+space',
'ctrl+space',
'ctrl+shift+space',
],
hotKeySetAsDefault: 'f', hotKeySetAsDefault: 'f',