Skip to content

Commit

Permalink
feat(groups): freeze/unfreeze group
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelass committed Jul 31, 2023
1 parent a2390ff commit b37896f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ Colors a node depending on the node title (case-insensitive).
**Groups**

- Edit group > Color > Custom
- Edit group > freeze/unfreeze (pins group and child nodes)

![image](https://github.com/failfa-st/hyv/assets/1148334/7558fcfb-1733-4d78-904b-50891f29fa68)

**Screenshot from Nodes (similar for Groups)**

Expand Down
59 changes: 59 additions & 0 deletions extensions/groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Coded with love by Failfa.st
* LICENSE: AGPL 3.0
* https://github.com/failfa-st/failfast-comfyui-extensions/blob/main/LICENSE
*
* Visit https://github.com/failfa-st/failfast-comfyui-extensions for more info
*
* Homepage: https://failfa.st
* GitHub: https://github.com/failfa-st
* Discord: https://discord.com/invite/m3TBB9XEkb
*/
import { app } from "../scripts/app.js";
import { $el } from "../scripts/ui.js";

/**
* Render Shadow
*/

const groupsName = "Failfast.groups";

app.registerExtension({
name: groupsName,
async setup(app) {
const getGroupMenuOptions = LGraphCanvas.prototype.getGroupMenuOptions;
let move = null;
LGraphCanvas.prototype.getGroupMenuOptions = function (group) {
const menuOptions = getGroupMenuOptions.apply(this, arguments);
menuOptions.push(
null,
move
? {
content: "Unfreeze",
callback: () => {
group.recomputeInsideNodes();
group.move = move;
move = null;
group._nodes.forEach((node) => {
node.flags.pinned = false;
});
},
}
: {
content: "Freeze",
callback: () => {
group.recomputeInsideNodes();
move = group.move;
group.move = () => {};

group._nodes.forEach((node) => {
node.flags.pinned = true;
});
},
},
);

return menuOptions;
};
},
});

0 comments on commit b37896f

Please sign in to comment.