@@ -94,7 +94,7 @@ class ResolutionMasterCanvas {
9494 const sectionHeights = {
9595 actions : this . collapsedSections ?. actions ? 25 : 55 , // 25 for header, +30 for content
9696 scaling : this . collapsedSections ?. scaling ? 25 : 130 , // 25 for header, +105 for content
97- autoDetect : this . collapsedSections ?. autoDetect ? 25 : 90 , // 25 for header, +65 for content
97+ autoDetect : this . collapsedSections ?. autoDetect ? 25 : 125 , // 25 for header, +100 for content (3 rows)
9898 presets : this . collapsedSections ?. presets ? 25 : 55 // 25 for header, +30 for content
9999 } ;
100100
@@ -144,6 +144,7 @@ class ResolutionMasterCanvas {
144144 rescaleValue : 1.0 ,
145145 autoDetect : false ,
146146 autoFitOnChange : false ,
147+ autoResizeOnChange : false ,
147148 selectedCategory : "Standard" ,
148149 selectedPreset : null ,
149150 useCustomCalc : false ,
@@ -340,7 +341,7 @@ class ResolutionMasterCanvas {
340341
341342 collapsibleSection ( "Auto-Detect" , "autoDetect" , ( ctx , y , preview ) => {
342343 if ( ! preview ) return this . drawAutoDetectSection ( ctx , y ) ;
343- return 65 ;
344+ return 100 ;
344345 } ) ;
345346
346347 collapsibleSection ( "Presets" , "presets" , ( ctx , y , preview ) => {
@@ -790,7 +791,7 @@ class ResolutionMasterCanvas {
790791 ctx . textAlign = "left" ;
791792 ctx . fillText ( "Auto" , autoCheckboxX + checkboxWidth + 4 , currentY + 14 ) ;
792793
793- // Drugi rząd: Detected info (po lewej) + Auto-calc button + Calc checkbox (idealnie pod Auto-fit)
794+ // Drugi rząd: Detected info (po lewej) + Auto-Resize button + Auto checkbox
794795 currentY += 35 ;
795796
796797 // Klikalny napis "Detected" wycentrowany pod switchem Auto-detect
@@ -822,12 +823,27 @@ class ResolutionMasterCanvas {
822823 ctx . fillText ( detectedText , textX , currentY + 14 ) ;
823824 }
824825
825- // Auto-calc button idealnie pod Auto-fit button
826+ // Auto-Resize button pod Auto-fit button
827+ this . controls . autoResizeBtn = { x : autoFitStartX , y : currentY , w : autoFitWidth , h : 28 } ;
828+ this . drawButton ( ctx , autoFitStartX , currentY , autoFitWidth , 28 , "📐 Auto-Resize" , this . hoverElement === 'autoResizeBtn' ) ;
829+
830+ // Auto-Resize checkbox pod Auto checkbox
831+ this . controls . autoResizeCheckbox = { x : autoCheckboxX , y : currentY + 5 , w : checkboxWidth , h : 18 } ;
832+ this . drawCheckbox ( ctx , autoCheckboxX , currentY + 5 , checkboxWidth , props . autoResizeOnChange , this . hoverElement === 'autoResizeCheckbox' ) ;
833+
834+ ctx . fillStyle = "#ddd" ;
835+ ctx . font = "11px Arial" ;
836+ ctx . textAlign = "left" ;
837+ ctx . fillText ( "Auto" , autoCheckboxX + checkboxWidth + 4 , currentY + 14 ) ;
838+
839+ // Trzeci rząd: Auto-calc button + Calc checkbox
840+ currentY += 35 ;
841+
826842 this . controls . autoCalcBtn = { x : autoFitStartX , y : currentY , w : autoFitWidth , h : 28 } ;
827843 const calcEnabled = props . useCustomCalc && props . selectedCategory ;
828844 this . drawButton ( ctx , autoFitStartX , currentY , autoFitWidth , 28 , "⚡ Auto-calc" , this . hoverElement === 'autoCalcBtn' , ! calcEnabled ) ;
829845
830- // Calc checkbox idealnie pod Auto checkbox
846+ // Calc checkbox
831847 this . controls . customCalcCheckbox = { x : autoCheckboxX , y : currentY + 5 , w : checkboxWidth , h : 18 } ;
832848 this . drawCheckbox ( ctx , autoCheckboxX , currentY + 5 , checkboxWidth , props . useCustomCalc , this . hoverElement === 'customCalcCheckbox' ) ;
833849
@@ -836,7 +852,7 @@ class ResolutionMasterCanvas {
836852 ctx . textAlign = "left" ;
837853 ctx . fillText ( "Calc" , autoCheckboxX + checkboxWidth + 4 , currentY + 14 ) ;
838854
839- return 65 ;
855+ return 100 ;
840856 }
841857
842858 drawPresetSection ( ctx , y ) {
@@ -1468,6 +1484,7 @@ class ResolutionMasterCanvas {
14681484 resolutionBtn : ( ) => this . handleResolutionScale ( ) ,
14691485 megapixelsBtn : ( ) => this . handleMegapixelsScale ( ) ,
14701486 autoFitBtn : ( ) => this . handleAutoFit ( ) ,
1487+ autoResizeBtn : ( ) => this . handleAutoResize ( ) ,
14711488 autoCalcBtn : ( ) => this . handleAutoCalc ( ) ,
14721489 detectedInfo : ( ) => this . handleDetectedClick ( )
14731490 } ;
@@ -1490,6 +1507,8 @@ class ResolutionMasterCanvas {
14901507 const props = this . node . properties ;
14911508 if ( checkboxName === 'autoFitCheckbox' && props . selectedCategory ) {
14921509 props . autoFitOnChange = ! props . autoFitOnChange ;
1510+ } else if ( checkboxName === 'autoResizeCheckbox' ) {
1511+ props . autoResizeOnChange = ! props . autoResizeOnChange ;
14931512 } else if ( checkboxName === 'customCalcCheckbox' ) {
14941513 props . useCustomCalc = ! props . useCustomCalc ;
14951514 }
@@ -1878,10 +1897,7 @@ class ResolutionMasterCanvas {
18781897 }
18791898
18801899 handleScale ( ) {
1881- this . applyScaling (
1882- ( ) => this . node . properties . upscaleValue ,
1883- ( ) => { this . node . properties . upscaleValue = 1.0 ; }
1884- ) ;
1900+ this . applyScaling ( ( ) => this . node . properties . upscaleValue ) ;
18851901 }
18861902
18871903 handleResolutionScale ( ) {
@@ -1980,6 +1996,28 @@ class ResolutionMasterCanvas {
19801996 log . debug ( `Auto-calc applied: ${ currentWidth } x${ currentHeight } → ${ result . width } x${ result . height } (${ props . selectedCategory } )` ) ;
19811997 }
19821998
1999+ handleAutoResize ( ) {
2000+ // Funkcja Auto-Resize - stosuje skalowanie zgodnie z zaznaczonym radio button
2001+ const props = this . node . properties ;
2002+
2003+ if ( ! this . widthWidget || ! this . heightWidget ) {
2004+ log . debug ( "Auto-Resize: Width or height widget not found" ) ;
2005+ return ;
2006+ }
2007+
2008+ // Sprawdź który tryb skalowania jest zaznaczony i zastosuj odpowiednie skalowanie
2009+ if ( props . rescaleMode === 'manual' ) {
2010+ this . handleScale ( ) ;
2011+ log . debug ( `Auto-Resize: Applied manual scaling with factor ${ props . upscaleValue } ` ) ;
2012+ } else if ( props . rescaleMode === 'resolution' ) {
2013+ this . handleResolutionScale ( ) ;
2014+ log . debug ( `Auto-Resize: Applied resolution scaling to ${ props . targetResolution } p` ) ;
2015+ } else if ( props . rescaleMode === 'megapixels' ) {
2016+ this . handleMegapixelsScale ( ) ;
2017+ log . debug ( `Auto-Resize: Applied megapixels scaling to ${ props . targetMegapixels } MP` ) ;
2018+ }
2019+ }
2020+
19832021 handleDetectedClick ( ) {
19842022 // Funkcja obsługująca kliknięcie na napis "Detected" - nakłada oryginalne wymiary wykrytego zdjęcia
19852023 if ( ! this . detectedDimensions ) {
@@ -2363,6 +2401,11 @@ class ResolutionMasterCanvas {
23632401 this . setDimensions ( this . detectedDimensions . width , this . detectedDimensions . height ) ;
23642402 }
23652403
2404+ // Auto-Resize: Jeśli autoResizeOnChange jest włączone, zastosuj automatyczne skalowanie
2405+ if ( props . autoResizeOnChange ) {
2406+ this . handleAutoResize ( ) ;
2407+ }
2408+
23662409 app . graph . setDirtyCanvas ( true ) ;
23672410 }
23682411 }
0 commit comments