Add an explosed action for fast toggler nodes to flip all toggles. Addresses #98
This commit is contained in:
@@ -89,6 +89,9 @@ export class BaseNodeModeChanger extends BaseAnyInputConnectedNode {
|
||||
forceWidgetOn(widget: IWidget, skipOtherNodeCheck?: boolean) {
|
||||
(widget as any).doModeChange(true, skipOtherNodeCheck);
|
||||
}
|
||||
forceWidgetToggle(widget: IWidget, skipOtherNodeCheck?: boolean) {
|
||||
(widget as any).doModeChange(!widget.value, skipOtherNodeCheck);
|
||||
}
|
||||
|
||||
|
||||
static override setUp<T extends RgthreeBaseNode>(clazz: new(title?: string) => T) {
|
||||
|
||||
@@ -9,8 +9,7 @@ const MODE_BYPASS = 4;
|
||||
const MODE_ALWAYS = 0;
|
||||
|
||||
class BypasserNode extends BaseNodeModeChanger {
|
||||
|
||||
static override exposedActions = ['Bypass all', 'Enable all'];
|
||||
static override exposedActions = ["Bypass all", "Enable all", "Toggle all"];
|
||||
|
||||
static override type = NodeTypesString.FAST_BYPASSER;
|
||||
static override title = NodeTypesString.FAST_BYPASSER;
|
||||
@@ -21,16 +20,19 @@ class BypasserNode extends BaseNodeModeChanger {
|
||||
super(title);
|
||||
}
|
||||
|
||||
|
||||
override async handleAction(action: string) {
|
||||
if (action === 'Bypass all') {
|
||||
if (action === "Bypass all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOff(widget, true);
|
||||
}
|
||||
} else if (action === 'Enable all') {
|
||||
} else if (action === "Enable all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOn(widget, true);
|
||||
}
|
||||
} else if (action === "Toggle all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetToggle(widget, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,4 +47,4 @@ app.registerExtension({
|
||||
(node as any)._tempWidth = node.size[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ export class FastGroupsBypasser extends FastGroupsMuter {
|
||||
static override type = NodeTypesString.FAST_GROUPS_BYPASSER;
|
||||
static override title = NodeTypesString.FAST_GROUPS_BYPASSER;
|
||||
|
||||
static override exposedActions = ["Bypass all", "Enable all"];
|
||||
static override exposedActions = ["Bypass all", "Enable all", "Toggle all"];
|
||||
|
||||
protected override helpActions = 'bypass and enable';
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ export class FastGroupsMuter extends RgthreeBaseNode {
|
||||
|
||||
override isVirtualNode = true;
|
||||
|
||||
static override exposedActions = ["Mute all", "Enable all"];
|
||||
static override exposedActions = ["Mute all", "Enable all", "Toggle all"];
|
||||
|
||||
readonly modeOn: number = LiteGraph.ALWAYS;
|
||||
readonly modeOff: number = LiteGraph.NEVER;
|
||||
@@ -559,6 +559,19 @@ export class FastGroupsMuter extends RgthreeBaseNode {
|
||||
for (const [index, widget] of this.widgets.entries()) {
|
||||
(widget as any)?.doModeChange(onlyOne && index > 0 ? false : true, true);
|
||||
}
|
||||
} else if (action === "Toggle all") {
|
||||
const onlyOne = this.properties?.[PROPERTY_RESTRICTION].includes(" one");
|
||||
let foundOne = false;
|
||||
for (const [index, widget] of this.widgets.entries()) {
|
||||
// If you have only one, then we'll stop at the first.
|
||||
let newValue: boolean = onlyOne && foundOne ? false : !widget.value;
|
||||
foundOne = foundOne || newValue;
|
||||
(widget as any)?.doModeChange(newValue, true);
|
||||
}
|
||||
// And if you have always one, then we'll flip the last
|
||||
if (!foundOne && this.properties?.[PROPERTY_RESTRICTION] === "always one") {
|
||||
(this.widgets[this.widgets.length - 1] as any)?.doModeChange(true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ const MODE_MUTE = 2;
|
||||
const MODE_ALWAYS = 0;
|
||||
|
||||
class MuterNode extends BaseNodeModeChanger {
|
||||
|
||||
static override exposedActions = ['Mute all', 'Enable all'];
|
||||
static override exposedActions = ["Mute all", "Enable all", "Toggle all"];
|
||||
|
||||
static override type = NodeTypesString.FAST_MUTER;
|
||||
static override title = NodeTypesString.FAST_MUTER;
|
||||
@@ -22,14 +21,18 @@ class MuterNode extends BaseNodeModeChanger {
|
||||
}
|
||||
|
||||
override async handleAction(action: string) {
|
||||
if (action === 'Mute all') {
|
||||
if (action === "Mute all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOff(widget, true);
|
||||
}
|
||||
} else if (action === 'Enable all') {
|
||||
} else if (action === "Enable all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOn(widget, true);
|
||||
}
|
||||
} else if (action === "Toggle all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetToggle(widget, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,4 +47,4 @@ app.registerExtension({
|
||||
(node as any)._tempWidth = node.size[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,6 +64,9 @@ export class BaseNodeModeChanger extends BaseAnyInputConnectedNode {
|
||||
forceWidgetOn(widget, skipOtherNodeCheck) {
|
||||
widget.doModeChange(true, skipOtherNodeCheck);
|
||||
}
|
||||
forceWidgetToggle(widget, skipOtherNodeCheck) {
|
||||
widget.doModeChange(!widget.value, skipOtherNodeCheck);
|
||||
}
|
||||
static setUp(clazz) {
|
||||
BaseAnyInputConnectedNode.setUp(clazz);
|
||||
}
|
||||
|
||||
@@ -10,19 +10,24 @@ class BypasserNode extends BaseNodeModeChanger {
|
||||
this.modeOff = MODE_BYPASS;
|
||||
}
|
||||
async handleAction(action) {
|
||||
if (action === 'Bypass all') {
|
||||
if (action === "Bypass all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOff(widget, true);
|
||||
}
|
||||
}
|
||||
else if (action === 'Enable all') {
|
||||
else if (action === "Enable all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOn(widget, true);
|
||||
}
|
||||
}
|
||||
else if (action === "Toggle all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetToggle(widget, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BypasserNode.exposedActions = ['Bypass all', 'Enable all'];
|
||||
BypasserNode.exposedActions = ["Bypass all", "Enable all", "Toggle all"];
|
||||
BypasserNode.type = NodeTypesString.FAST_BYPASSER;
|
||||
BypasserNode.title = NodeTypesString.FAST_BYPASSER;
|
||||
app.registerExtension({
|
||||
|
||||
@@ -15,7 +15,7 @@ export class FastGroupsBypasser extends FastGroupsMuter {
|
||||
}
|
||||
FastGroupsBypasser.type = NodeTypesString.FAST_GROUPS_BYPASSER;
|
||||
FastGroupsBypasser.title = NodeTypesString.FAST_GROUPS_BYPASSER;
|
||||
FastGroupsBypasser.exposedActions = ["Bypass all", "Enable all"];
|
||||
FastGroupsBypasser.exposedActions = ["Bypass all", "Enable all", "Toggle all"];
|
||||
app.registerExtension({
|
||||
name: "rgthree.FastGroupsBypasser",
|
||||
registerCustomNodes() {
|
||||
|
||||
@@ -416,7 +416,7 @@ export class FastGroupsMuter extends RgthreeBaseNode {
|
||||
return size;
|
||||
}
|
||||
async handleAction(action) {
|
||||
var _a, _b;
|
||||
var _a, _b, _c, _d, _e;
|
||||
if (action === "Mute all" || action === "Bypass all") {
|
||||
const alwaysOne = ((_a = this.properties) === null || _a === void 0 ? void 0 : _a[PROPERTY_RESTRICTION]) === "always one";
|
||||
for (const [index, widget] of this.widgets.entries()) {
|
||||
@@ -429,6 +429,18 @@ export class FastGroupsMuter extends RgthreeBaseNode {
|
||||
widget === null || widget === void 0 ? void 0 : widget.doModeChange(onlyOne && index > 0 ? false : true, true);
|
||||
}
|
||||
}
|
||||
else if (action === "Toggle all") {
|
||||
const onlyOne = (_c = this.properties) === null || _c === void 0 ? void 0 : _c[PROPERTY_RESTRICTION].includes(" one");
|
||||
let foundOne = false;
|
||||
for (const [index, widget] of this.widgets.entries()) {
|
||||
let newValue = onlyOne && foundOne ? false : !widget.value;
|
||||
foundOne = foundOne || newValue;
|
||||
widget === null || widget === void 0 ? void 0 : widget.doModeChange(newValue, true);
|
||||
}
|
||||
if (!foundOne && ((_d = this.properties) === null || _d === void 0 ? void 0 : _d[PROPERTY_RESTRICTION]) === "always one") {
|
||||
(_e = this.widgets[this.widgets.length - 1]) === null || _e === void 0 ? void 0 : _e.doModeChange(true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
getHelp() {
|
||||
return `
|
||||
@@ -503,7 +515,7 @@ export class FastGroupsMuter extends RgthreeBaseNode {
|
||||
}
|
||||
FastGroupsMuter.type = NodeTypesString.FAST_GROUPS_MUTER;
|
||||
FastGroupsMuter.title = NodeTypesString.FAST_GROUPS_MUTER;
|
||||
FastGroupsMuter.exposedActions = ["Mute all", "Enable all"];
|
||||
FastGroupsMuter.exposedActions = ["Mute all", "Enable all", "Toggle all"];
|
||||
FastGroupsMuter["@matchColors"] = { type: "string" };
|
||||
FastGroupsMuter["@matchTitle"] = { type: "string" };
|
||||
FastGroupsMuter["@showNav"] = { type: "boolean" };
|
||||
|
||||
@@ -10,19 +10,24 @@ class MuterNode extends BaseNodeModeChanger {
|
||||
this.modeOff = MODE_MUTE;
|
||||
}
|
||||
async handleAction(action) {
|
||||
if (action === 'Mute all') {
|
||||
if (action === "Mute all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOff(widget, true);
|
||||
}
|
||||
}
|
||||
else if (action === 'Enable all') {
|
||||
else if (action === "Enable all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetOn(widget, true);
|
||||
}
|
||||
}
|
||||
else if (action === "Toggle all") {
|
||||
for (const widget of this.widgets) {
|
||||
this.forceWidgetToggle(widget, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MuterNode.exposedActions = ['Mute all', 'Enable all'];
|
||||
MuterNode.exposedActions = ["Mute all", "Enable all", "Toggle all"];
|
||||
MuterNode.type = NodeTypesString.FAST_MUTER;
|
||||
MuterNode.title = NodeTypesString.FAST_MUTER;
|
||||
app.registerExtension({
|
||||
|
||||
Reference in New Issue
Block a user