File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ export declare class LGraph {
412412 /**
413413 * Positions every node in a more readable manner
414414 */
415- arrange ( margin ?: number ) : void ;
415+ arrange ( margin ?: number , layout ?: string ) : void ;
416416 /**
417417 * Returns the amount of time the graph has been running in milliseconds
418418 * @return number of milliseconds the graph has been running
Original file line number Diff line number Diff line change 8080 NO_TITLE : 1 ,
8181 TRANSPARENT_TITLE : 2 ,
8282 AUTOHIDE_TITLE : 3 ,
83+ VERTICAL_LAYOUT : "vertical" , // arrange nodes vertically
8384
8485 proxy : null , //used to redirect calls
8586 node_images_path : "" ,
11461147 * Positions every node in a more readable manner
11471148 * @method arrange
11481149 */
1149- LGraph . prototype . arrange = function ( margin ) {
1150+ LGraph . prototype . arrange = function ( margin , layout ) {
11501151 margin = margin || 100 ;
11511152
11521153 var nodes = this . computeExecutionOrder ( false , true ) ;
11711172 var y = margin + LiteGraph . NODE_TITLE_HEIGHT ;
11721173 for ( var j = 0 ; j < column . length ; ++ j ) {
11731174 var node = column [ j ] ;
1174- node . pos [ 0 ] = x ;
1175- node . pos [ 1 ] = y ;
1176- if ( node . size [ 0 ] > max_size ) {
1177- max_size = node . size [ 0 ] ;
1178- }
1179- y += node . size [ 1 ] + margin + LiteGraph . NODE_TITLE_HEIGHT ;
1175+ node . pos [ 0 ] = ( layout == LiteGraph . VERTICAL_LAYOUT ) ? y : x ;
1176+ node . pos [ 1 ] = ( layout == LiteGraph . VERTICAL_LAYOUT ) ? x : y ;
1177+ max_size_index = ( layout == LiteGraph . VERTICAL_LAYOUT ) ? 1 : 0 ;
1178+ if ( node . size [ max_size_index ] > max_size ) {
1179+ max_size = node . size [ max_size_index ] ;
1180+ }
1181+ node_size_index = ( layout == LiteGraph . VERTICAL_LAYOUT ) ? 0 : 1 ;
1182+ y += node . size [ node_size_index ] + margin + LiteGraph . NODE_TITLE_HEIGHT
11801183 }
11811184 x += max_size + margin ;
11821185 }
You can’t perform that action at this time.
0 commit comments