@@ -27,7 +27,7 @@ class ResolutionMasterCanvas {
2727 this . _isInitializing = true ; // Flag to prevent setDirtyCanvas during init
2828 this . _pendingCanvasUpdate = false ;
2929 this . _isApplyingAutoSize = false ;
30- this . userPreferredHeight = null ;
30+ this . userPreferredHeight = this . getStoredPreferredHeight ( ) ;
3131 this . hoverElement = null ;
3232 this . scrollOffset = 0 ;
3333 this . dropdownOpen = null ;
@@ -101,7 +101,7 @@ class ResolutionMasterCanvas {
101101 this . node . size [ 0 ] = 330 ;
102102 }
103103 const neededHeight = this . calculateNeededHeight ( ) ;
104- const preferredHeight = this . userPreferredHeight ?? 0 ;
104+ const preferredHeight = this . userPreferredHeight ?? this . getStoredPreferredHeight ( ) ?? 0 ;
105105 const targetHeight = Math . max ( neededHeight , preferredHeight , this . node . min_size [ 1 ] ) ;
106106
107107 if ( Math . abs ( this . node . size [ 1 ] - targetHeight ) > 1 ) {
@@ -191,6 +191,8 @@ class ResolutionMasterCanvas {
191191 section_autoDetect_collapsed : false ,
192192 section_presets_collapsed : false ,
193193 section_extraControls_collapsed : false ,
194+ preferred_compact_height : null ,
195+ preferred_expanded_height : null ,
194196 dropdown_resolution_expanded : false ,
195197 dropdown_category_expanded : false ,
196198 dropdown_preset_expanded : false ,
@@ -374,7 +376,7 @@ class ResolutionMasterCanvas {
374376 } ;
375377 node . onResize = function ( ) {
376378 if ( ! self . _isApplyingAutoSize ) {
377- self . userPreferredHeight = Math . max ( this . size [ 1 ] , this . min_size [ 1 ] ) ;
379+ self . storePreferredHeight ( this . size [ 1 ] ) ;
378380 }
379381 self . ensureMinimumSize ( ) ;
380382 app . graph . setDirtyCanvas ( true ) ;
@@ -411,6 +413,7 @@ class ResolutionMasterCanvas {
411413 presets : this . properties . section_presets_collapsed ,
412414 extraControls : this . properties . section_extraControls_collapsed
413415 } ;
416+ self . userPreferredHeight = self . getStoredPreferredHeight ( ) ;
414417 self . applyCompactSlotLabels ( ) ;
415418
416419 // Update internal position from saved properties
@@ -619,41 +622,17 @@ class ResolutionMasterCanvas {
619622 const valueAreaHeight = 20 ;
620623 const valueAreaX = node . size [ 0 ] - valueAreaWidth - 5 ;
621624 const batchSizeAreaX = node . size [ 0 ] - batchSizeAreaWidth - 5 ;
622- this . controls . widthValueArea = {
623- x : valueAreaX ,
624- y : y_offset_1 - valueAreaHeight / 2 ,
625- w : valueAreaWidth ,
626- h : valueAreaHeight
627- } ;
628-
629- this . drawValueAreaHoverBackground ( ctx , 'widthValueArea' , valueAreaX , y_offset_1 - valueAreaHeight / 2 , valueAreaWidth , valueAreaHeight , [ 136 , 153 , 255 ] ) ;
630-
631- ctx . fillStyle = this . hoverElement === 'widthValueArea' ? "#89F" : "#89F" ;
632- ctx . fillText ( this . widthWidget . value . toString ( ) , node . size [ 0 ] - 20 , y_offset_1 ) ;
633- this . controls . heightValueArea = {
634- x : valueAreaX ,
635- y : y_offset_2 - valueAreaHeight / 2 ,
636- w : valueAreaWidth ,
637- h : valueAreaHeight
638- } ;
639-
640- this . drawValueAreaHoverBackground ( ctx , 'heightValueArea' , valueAreaX , y_offset_2 - valueAreaHeight / 2 , valueAreaWidth , valueAreaHeight , [ 248 , 136 , 153 ] ) ;
641-
642- ctx . fillStyle = this . hoverElement === 'heightValueArea' ? "#F89" : "#F89" ;
643- ctx . fillText ( this . heightWidget . value . toString ( ) , node . size [ 0 ] - 20 , y_offset_2 ) ;
625+ this . drawOutputValueArea ( ctx , 'widthValueArea' , valueAreaX , y_offset_1 - valueAreaHeight / 2 ,
626+ valueAreaWidth , valueAreaHeight , this . widthWidget . value . toString ( ) , y_offset_1 ,
627+ [ 136 , 153 , 255 ] , "#89F" , "#89F" ) ;
628+ this . drawOutputValueArea ( ctx , 'heightValueArea' , valueAreaX , y_offset_2 - valueAreaHeight / 2 ,
629+ valueAreaWidth , valueAreaHeight , this . heightWidget . value . toString ( ) , y_offset_2 ,
630+ [ 248 , 136 , 153 ] , "#F89" , "#F89" ) ;
644631 ctx . fillStyle = "#9F8" ;
645632 ctx . fillText ( props . rescaleValue . toFixed ( 2 ) , node . size [ 0 ] - 20 , y_offset_3 ) ;
646- this . controls . batchSizeValueArea = {
647- x : batchSizeAreaX ,
648- y : y_offset_4 - valueAreaHeight / 2 ,
649- w : batchSizeAreaWidth ,
650- h : valueAreaHeight
651- } ;
652-
653- this . drawValueAreaHoverBackground ( ctx , 'batchSizeValueArea' , batchSizeAreaX , y_offset_4 - valueAreaHeight / 2 , batchSizeAreaWidth , valueAreaHeight , [ 255 , 136 , 187 ] ) ;
654-
655- ctx . fillStyle = this . hoverElement === 'batchSizeValueArea' ? "#FAB" : "#F8B" ;
656- ctx . fillText ( this . batchSizeWidget . value . toString ( ) , node . size [ 0 ] - 20 , y_offset_4 ) ;
633+ this . drawOutputValueArea ( ctx , 'batchSizeValueArea' , batchSizeAreaX , y_offset_4 - valueAreaHeight / 2 ,
634+ batchSizeAreaWidth , valueAreaHeight , this . batchSizeWidget . value . toString ( ) , y_offset_4 ,
635+ [ 255 , 136 , 187 ] , "#FAB" , "#F8B" ) ;
657636 const y_offset_5 = 5 + ( LiteGraph . NODE_SLOT_HEIGHT * 4.5 ) ;
658637
659638 // Create clickable area for LAT selector
@@ -686,6 +665,31 @@ class ResolutionMasterCanvas {
686665 }
687666 }
688667 }
668+
669+ getPreferredHeightPropertyKey ( isCompact = this . collapsedSections ?. extraControls ) {
670+ return isCompact ? 'preferred_compact_height' : 'preferred_expanded_height' ;
671+ }
672+
673+ getStoredPreferredHeight ( isCompact = this . collapsedSections ?. extraControls ) {
674+ const value = Number ( this . node . properties ?. [ this . getPreferredHeightPropertyKey ( isCompact ) ] ) ;
675+ return Number . isFinite ( value ) && value > 0 ? value : null ;
676+ }
677+
678+ storePreferredHeight ( height = this . node . size ?. [ 1 ] , isCompact = this . collapsedSections ?. extraControls ) {
679+ const value = Math . max ( Number ( height ) || 0 , this . node . min_size ?. [ 1 ] || 0 ) ;
680+ if ( value > 0 ) {
681+ this . node . properties [ this . getPreferredHeightPropertyKey ( isCompact ) ] = value ;
682+ }
683+ this . userPreferredHeight = value || null ;
684+ }
685+
686+ drawOutputValueArea ( ctx , controlName , x , y , w , h , text , textY , hoverColor , activeTextColor , textColor ) {
687+ const node = this . node ;
688+ this . controls [ controlName ] = { x, y, w, h } ;
689+ this . drawValueAreaHoverBackground ( ctx , controlName , x , y , w , h , hoverColor ) ;
690+ ctx . fillStyle = this . hoverElement === controlName ? activeTextColor : textColor ;
691+ ctx . fillText ( text , node . size [ 0 ] - 20 , textY ) ;
692+ }
689693
690694 drawPrimaryControls ( ctx , y ) {
691695 const node = this . node ;
@@ -997,18 +1001,19 @@ class ResolutionMasterCanvas {
9971001 this . drawToggle ( ctx , toggleX , actionY + 3 , showToggleWidth , 22 , props . showCalcInfo , "Show" , this . hoverElement === 'calcInfoToggle' ) ;
9981002 ctx . globalAlpha = previousAlpha ;
9991003
1000- const checkboxX = toggleX + showToggleWidth + 4 ;
1001- this . controls [ action . checkbox ] = { x : checkboxX , y : actionY + 5 , w : checkboxWidth , h : 18 } ;
1002- this . drawCheckbox ( ctx , checkboxX , actionY + 5 , checkboxWidth , action . checked , this . hoverElement === action . checkbox , action . disabled ) ;
1004+ this . drawAutoDetectActionCheckbox ( ctx , action , toggleX + showToggleWidth + 4 , actionY , checkboxWidth ) ;
10031005 } else {
1004- const checkboxX = x + buttonWidth + 4 ;
1005- this . controls [ action . checkbox ] = { x : checkboxX , y : actionY + 5 , w : checkboxWidth , h : 18 } ;
1006- this . drawCheckbox ( ctx , checkboxX , actionY + 5 , checkboxWidth , action . checked , this . hoverElement === action . checkbox , action . disabled ) ;
1006+ this . drawAutoDetectActionCheckbox ( ctx , action , x + buttonWidth + 4 , actionY , checkboxWidth ) ;
10071007 }
10081008 } ) ;
10091009
10101010 return 110 ;
10111011 }
1012+
1013+ drawAutoDetectActionCheckbox ( ctx , action , x , y , size ) {
1014+ this . controls [ action . checkbox ] = { x, y : y + 5 , w : size , h : 18 } ;
1015+ this . drawCheckbox ( ctx , x , y + 5 , size , action . checked , this . hoverElement === action . checkbox , action . disabled ) ;
1016+ }
10121017
10131018 drawPresetSection ( ctx , y ) {
10141019 const node = this . node ;
@@ -1767,9 +1772,15 @@ class ResolutionMasterCanvas {
17671772
17681773 handleSectionHeaderClick ( headerKey ) {
17691774 const sectionKey = headerKey . replace ( 'Header' , '' ) ;
1775+ if ( sectionKey === 'extraControls' ) {
1776+ this . storePreferredHeight ( this . node . size [ 1 ] , this . collapsedSections . extraControls ) ;
1777+ }
17701778 this . collapsedSections [ sectionKey ] = ! this . collapsedSections [ sectionKey ] ;
17711779 const propertyKey = `section_${ sectionKey } _collapsed` ;
17721780 this . node . properties [ propertyKey ] = this . collapsedSections [ sectionKey ] ;
1781+ if ( sectionKey === 'extraControls' ) {
1782+ this . userPreferredHeight = this . getStoredPreferredHeight ( this . collapsedSections . extraControls ) ;
1783+ }
17731784 app . graph . setDirtyCanvas ( true , true ) ;
17741785
17751786 log . debug ( `Section ${ sectionKey } ${ this . collapsedSections [ sectionKey ] ? 'collapsed' : 'expanded' } ` ) ;
0 commit comments