@@ -497,16 +497,7 @@ class ResolutionMasterCanvas {
497497 h : valueAreaHeight
498498 } ;
499499
500- // Draw background for width value area if hovered
501- if ( this . hoverElement === 'widthValueArea' ) {
502- ctx . fillStyle = "rgba(136, 153, 255, 0.2)" ;
503- ctx . strokeStyle = "rgba(136, 153, 255, 0.5)" ;
504- ctx . lineWidth = 1 ;
505- ctx . beginPath ( ) ;
506- ctx . roundRect ( valueAreaX , y_offset_1 - valueAreaHeight / 2 , valueAreaWidth , valueAreaHeight , 4 ) ;
507- ctx . fill ( ) ;
508- ctx . stroke ( ) ;
509- }
500+ this . drawValueAreaHoverBackground ( ctx , 'widthValueArea' , valueAreaX , y_offset_1 - valueAreaHeight / 2 , valueAreaWidth , valueAreaHeight , [ 136 , 153 , 255 ] ) ;
510501
511502 ctx . fillStyle = this . hoverElement === 'widthValueArea' ? "#89F" : "#89F" ;
512503 ctx . fillText ( this . widthWidget . value . toString ( ) , node . size [ 0 ] - 20 , y_offset_1 ) ;
@@ -519,16 +510,7 @@ class ResolutionMasterCanvas {
519510 h : valueAreaHeight
520511 } ;
521512
522- // Draw background for height value area if hovered
523- if ( this . hoverElement === 'heightValueArea' ) {
524- ctx . fillStyle = "rgba(248, 136, 153, 0.2)" ;
525- ctx . strokeStyle = "rgba(248, 136, 153, 0.5)" ;
526- ctx . lineWidth = 1 ;
527- ctx . beginPath ( ) ;
528- ctx . roundRect ( valueAreaX , y_offset_2 - valueAreaHeight / 2 , valueAreaWidth , valueAreaHeight , 4 ) ;
529- ctx . fill ( ) ;
530- ctx . stroke ( ) ;
531- }
513+ this . drawValueAreaHoverBackground ( ctx , 'heightValueArea' , valueAreaX , y_offset_2 - valueAreaHeight / 2 , valueAreaWidth , valueAreaHeight , [ 248 , 136 , 153 ] ) ;
532514
533515 ctx . fillStyle = this . hoverElement === 'heightValueArea' ? "#F89" : "#F89" ;
534516 ctx . fillText ( this . heightWidget . value . toString ( ) , node . size [ 0 ] - 20 , y_offset_2 ) ;
@@ -545,16 +527,7 @@ class ResolutionMasterCanvas {
545527 h : valueAreaHeight
546528 } ;
547529
548- // Draw background for batch size value area if hovered
549- if ( this . hoverElement === 'batchSizeValueArea' ) {
550- ctx . fillStyle = "rgba(255, 136, 187, 0.2)" ;
551- ctx . strokeStyle = "rgba(255, 136, 187, 0.5)" ;
552- ctx . lineWidth = 1 ;
553- ctx . beginPath ( ) ;
554- ctx . roundRect ( batchSizeAreaX , y_offset_4 - valueAreaHeight / 2 , batchSizeAreaWidth , valueAreaHeight , 4 ) ;
555- ctx . fill ( ) ;
556- ctx . stroke ( ) ;
557- }
530+ this . drawValueAreaHoverBackground ( ctx , 'batchSizeValueArea' , batchSizeAreaX , y_offset_4 - valueAreaHeight / 2 , batchSizeAreaWidth , valueAreaHeight , [ 255 , 136 , 187 ] ) ;
558531
559532 ctx . fillStyle = this . hoverElement === 'batchSizeValueArea' ? "#FAB" : "#F8B" ;
560533 ctx . fillText ( this . batchSizeWidget . value . toString ( ) , node . size [ 0 ] - 20 , y_offset_4 ) ;
@@ -596,22 +569,13 @@ class ResolutionMasterCanvas {
596569 const snapValueX = sliderX + sliderWidth + gap ;
597570 this . controls . snapValueArea = { x : snapValueX , y, w : valueWidth , h : 28 } ;
598571
599- // Draw background for snap value area if hovered
600- if ( this . hoverElement === 'snapValueArea' ) {
601- ctx . fillStyle = "rgba(100, 150, 255, 0.2)" ;
602- ctx . strokeStyle = "rgba(100, 150, 255, 0.5)" ;
603- ctx . lineWidth = 1 ;
604- ctx . beginPath ( ) ;
605- ctx . roundRect ( snapValueX , y , valueWidth , 28 , 4 ) ;
606- ctx . fill ( ) ;
607- ctx . stroke ( ) ;
608- }
572+ this . drawValueAreaHoverBackground ( ctx , 'snapValueArea' , snapValueX , y , valueWidth , 28 , [ 100 , 150 , 255 ] ) ;
609573
610574 ctx . fillStyle = this . hoverElement === 'snapValueArea' ? "#5af" : "#ccc" ;
611575 ctx . font = "12px Arial" ;
612576 ctx . textAlign = "left" ;
613577 ctx . textBaseline = "middle" ;
614- ctx . fillText ( props . snapValue . toString ( ) , snapValueX , y + 14 ) ;
578+ ctx . fillText ( props . snapValue . toString ( ) , snapValueX + 10 , y + 14 ) ;
615579 }
616580
617581 draw2DCanvas ( ctx , x , y , w , h ) {
@@ -877,16 +841,7 @@ class ResolutionMasterCanvas {
877841 // Definiuj obszar klikalny dla napisu "Detected" (wycentrowany pod switchem)
878842 this . controls . detectedInfo = { x : textX - 5 , y : currentY + 2 , w : textWidth + 10 , h : 24 } ;
879843
880- // Rysuj tło jeśli hover
881- if ( this . hoverElement === 'detectedInfo' ) {
882- ctx . fillStyle = "rgba(95, 255, 95, 0.2)" ;
883- ctx . strokeStyle = "rgba(95, 255, 95, 0.5)" ;
884- ctx . lineWidth = 1 ;
885- ctx . beginPath ( ) ;
886- ctx . roundRect ( textX - 5 , currentY + 2 , textWidth + 10 , 20 , 4 ) ;
887- ctx . fill ( ) ;
888- ctx . stroke ( ) ;
889- }
844+ this . drawValueAreaHoverBackground ( ctx , 'detectedInfo' , textX - 5 , currentY + 2 , textWidth + 10 , 20 , [ 95 , 255 , 95 ] ) ;
890845
891846 ctx . fillStyle = this . hoverElement === 'detectedInfo' ? "#7f7" : "#5f5" ;
892847 ctx . textAlign = "left" ;
@@ -1146,7 +1101,8 @@ class ResolutionMasterCanvas {
11461101 ctx . roundRect ( x , y + h / 2 - 3 , w , 6 , 3 ) ;
11471102 ctx . fill ( ) ;
11481103
1149- const pos = ( value - min ) / ( max - min ) ;
1104+ // Clamp position to [0, 1] range to prevent marker from going outside UI bounds
1105+ const pos = Math . max ( 0 , Math . min ( 1 , ( value - min ) / ( max - min ) ) ) ;
11501106 const knobX = x + w * pos ;
11511107 const knobY = y + h / 2 ;
11521108
@@ -1254,6 +1210,18 @@ class ResolutionMasterCanvas {
12541210 ctx . fillText ( text , x + w / 2 , y + h / 2 + 1 ) ;
12551211 }
12561212
1213+ drawValueAreaHoverBackground ( ctx , controlName , x , y , w , h , color , borderRadius = 4 ) {
1214+ if ( this . hoverElement === controlName ) {
1215+ ctx . fillStyle = `rgba(${ color [ 0 ] } , ${ color [ 1 ] } , ${ color [ 2 ] } , 0.2)` ;
1216+ ctx . strokeStyle = `rgba(${ color [ 0 ] } , ${ color [ 1 ] } , ${ color [ 2 ] } , 0.5)` ;
1217+ ctx . lineWidth = 1 ;
1218+ ctx . beginPath ( ) ;
1219+ ctx . roundRect ( x , y , w , h , borderRadius ) ;
1220+ ctx . fill ( ) ;
1221+ ctx . stroke ( ) ;
1222+ }
1223+ }
1224+
12571225 drawTooltip ( ctx ) {
12581226 if ( ! this . tooltipMousePos || ! this . tooltips [ this . tooltipElement ] ) {
12591227 log . debug ( "Tooltip draw failed: missing mouse pos or tooltip text" ) ;
@@ -1742,16 +1710,7 @@ class ResolutionMasterCanvas {
17421710 const valueAreaControl = config . buttonControl . replace ( 'Btn' , 'ValueArea' ) ;
17431711 this . controls [ valueAreaControl ] = { x : currentX , y, w : layout . valueWidth , h : 28 } ;
17441712
1745- // Draw background for value area if hovered
1746- if ( this . hoverElement === valueAreaControl ) {
1747- ctx . fillStyle = "rgba(100, 150, 255, 0.2)" ;
1748- ctx . strokeStyle = "rgba(100, 150, 255, 0.5)" ;
1749- ctx . lineWidth = 1 ;
1750- ctx . beginPath ( ) ;
1751- ctx . roundRect ( currentX , y , layout . valueWidth , 28 , 4 ) ;
1752- ctx . fill ( ) ;
1753- ctx . stroke ( ) ;
1754- }
1713+ this . drawValueAreaHoverBackground ( ctx , valueAreaControl , currentX , y , layout . valueWidth , 28 , [ 100 , 150 , 255 ] ) ;
17551714
17561715 // Draw value text
17571716 this . setCanvasTextStyle ( ctx , {
0 commit comments