This commit is contained in:
tamat
2021-07-02 17:11:08 +02:00
15 changed files with 13467 additions and 1241 deletions

23
src/litegraph.d.ts vendored
View File

@@ -284,19 +284,23 @@ export const LiteGraph: {
/**
* Returns a list of node types matching one category
* @param category category name
* @return array with all the node classes
* @method getNodeTypesInCategory
* @param {String} category category name
* @param {String} filter only nodes with ctor.filter equal can be shown
* @return {Array} array with all the node classes
*/
getNodeTypesInCategory(
category: string,
filter: any
filter: string
): LGraphNodeConstructor[];
/**
* Returns a list with all the node type categories
* @return array with all the names of the categories
*/
getNodeTypesCategories(): string[];
* @method getNodeTypesCategories
* @param {String} filter only nodes with ctor.filter equal can be shown
* @return {Array} array with all the names of the categories
*/
getNodeTypesCategories(filter: string): string[];
/** debug purposes: reloads all the js scripts that matches a wildcard */
reloadNodes(folder_wildcard: string): void;
@@ -347,6 +351,7 @@ export declare class LGraph {
constructor(o?: object);
filter: string;
catch_errors: boolean;
/** custom data */
config: object;
@@ -529,6 +534,8 @@ export declare class LGraph {
removeOutput(name: string): boolean;
triggerInput(name: string, value: any): void;
setCallback(name: string, func: (...args: any[]) => any): void;
beforeChange(info?: LGraphNode): void;
afterChange(info?: LGraphNode): void;
connectionChange(node: LGraphNode): void;
/** returns if the graph is in live mode */
isLive(): boolean;
@@ -1125,6 +1132,8 @@ export declare class LGraphCanvas {
}
);
static active_canvas: HTMLCanvasElement;
allow_dragcanvas: boolean;
allow_dragnodes: boolean;
/** allow to control widgets, buttons, collapse, etc */
@@ -1459,7 +1468,7 @@ declare class ContextMenu {
): void;
static isCursorOverElement(event: MouseEvent, element: HTMLElement): void;
static closeAllContextMenus(window: Window): void;
constructor(values: ContextMenuItem[], options?: IContextMenuOptions);
constructor(values: ContextMenuItem[], options?: IContextMenuOptions, window?: Window);
options: IContextMenuOptions;
parentMenu?: ContextMenu;
lock: boolean;

View File

@@ -417,7 +417,11 @@
}
}
return this.auto_sort_node_types ? r.sort() : r;
if (this.auto_sort_node_types) {
r.sort((a, b) => a.title.localeCompare(b.title));
}
return r;
},
/**
@@ -8850,16 +8854,15 @@ LGraphNode.prototype.executeAction = function(action)
//inside widget
switch (w.type) {
case "button":
if (event.type === "mousemove") {
break;
}
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
if (event.type === "mousedown") {
if (w.callback) {
setTimeout(function() {
w.callback(w, that, node, pos, event);
}, 20);
}
w.clicked = true;
this.dirty_canvas = true;
}
break;
case "slider":
var range = w.options.max - w.options.min;
@@ -10281,7 +10284,7 @@ LGraphNode.prototype.executeAction = function(action)
var elem = document.createElement("div");
elem.className = "property";
elem.innerHTML = "<span class='property_name'></span><span class='property_value'></span>";
elem.querySelector(".property_name").innerText = name;
elem.querySelector(".property_name").innerText = options.label || name;
var value_element = elem.querySelector(".property_value");
value_element.innerText = str_value;
elem.dataset["property"] = name;
@@ -10325,7 +10328,7 @@ LGraphNode.prototype.executeAction = function(action)
innerChange(propname, v);
});
}
else if (type == "enum" || type == "combo")
else if (type == "enum" || type == "combo") {
var str_value = LGraphCanvas.getPropertyPrintableValue( value, options.values );
value_element.innerText = str_value;
@@ -10347,6 +10350,7 @@ LGraphNode.prototype.executeAction = function(action)
return false;
}
});
}
root.content.appendChild(elem);

View File

@@ -734,7 +734,7 @@
// Texture Webcam *****************************************
function ImageWebcam() {
this.addOutput("Webcam", "image");
this.properties = { facingMode: "user" };
this.properties = { filterFacingMode: false, facingMode: "user" };
this.boxcolor = "black";
this.frame = 0;
}
@@ -744,8 +744,8 @@
ImageWebcam.is_webcam_open = false;
ImageWebcam.prototype.openStream = function() {
if (!navigator.getUserMedia) {
//console.log('getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags');
if (!navigator.mediaDevices.getUserMedia) {
console.log('getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags');
return;
}
@@ -754,7 +754,7 @@
// Not showing vendor prefixes.
var constraints = {
audio: false,
video: { facingMode: this.properties.facingMode }
video: !this.properties.filterFacingMode ? true : { facingMode: this.properties.facingMode }
};
navigator.mediaDevices
.getUserMedia(constraints)

View File

@@ -3,7 +3,7 @@
//Converter
function Converter() {
this.addInput("in", "*");
this.addInput("in", "");
this.addOutput("out");
this.size = [80, 30];
}