@@ -15,6 +15,7 @@ public class ThemedDocumentControlHandler : ThemedContainerHandler<TableLayout,
15
15
float startx ;
16
16
Size maxImageSize ;
17
17
PointF ? draggingLocation ;
18
+ bool useFixedTabHeight ;
18
19
19
20
Drawable tabDrawable ;
20
21
Panel contentPanel ;
@@ -223,6 +224,7 @@ public ThemedDocumentControlHandler()
223
224
mousePos = new PointF ( - 1 , - 1 ) ;
224
225
selectedIndex = - 1 ;
225
226
allowNavigationButtons = true ;
227
+ useFixedTabHeight = false ;
226
228
nextPrevWidth = 0 ;
227
229
startx = 0 ;
228
230
font = SystemFonts . Default ( ) ;
@@ -411,18 +413,29 @@ void CalculateTabHeight(bool force = false)
411
413
{
412
414
if ( ! force && ! Widget . Loaded )
413
415
return ;
414
- var scale = Widget . ParentWindow ? . Screen ? . Scale ?? 1f ;
415
- var fontHeight = ( int ) Math . Ceiling ( Font . Ascent * scale ) ;
416
+ var fontHeight = CalculateFontHeight ( ) ;
416
417
417
- var height = Math . Max ( maxImageSize . Height , fontHeight ) ;
418
+ var height = useFixedTabHeight ? fontHeight : Math . Max ( maxImageSize . Height , fontHeight ) ;
418
419
tabDrawable . Height = height + TabPadding . Vertical ; // 2 px padding at top and bottom
419
420
}
420
421
422
+ private int CalculateFontHeight ( )
423
+ {
424
+ var scale = Widget . ParentWindow ? . Screen ? . Scale ?? 1f ;
425
+ return ( int ) Math . Ceiling ( Font . Ascent * scale ) ;
426
+ }
427
+
421
428
void CalculateImageSizes ( bool force = false )
422
429
{
423
430
if ( ! force && ! Widget . Loaded )
424
431
return ;
425
- maxImageSize = Size . Empty ;
432
+
433
+ var fontHeight = CalculateFontHeight ( ) ;
434
+ maxImageSize = new Size ( fontHeight , fontHeight ) ;
435
+
436
+ if ( UseFixedTabHeight )
437
+ return ;
438
+
426
439
for ( int i = 0 ; i < pages . Count ; i ++ )
427
440
{
428
441
var img = pages [ i ] . Image ;
@@ -617,7 +630,7 @@ void CalculateTab(ThemedDocumentPageHandler tab, int i, ref float posx)
617
630
var textoffset = 0 ;
618
631
if ( tab . Image != null )
619
632
{
620
- textoffset = tab . Image . Size . Width + tabPadding . Left ;
633
+ textoffset = maxImageSize . Width + tabPadding . Left ;
621
634
size . Width += textoffset ;
622
635
}
623
636
@@ -631,7 +644,7 @@ void CalculateTab(ThemedDocumentPageHandler tab, int i, ref float posx)
631
644
632
645
tab . Rect = tabRect ;
633
646
634
- tab . CloseRect = new RectangleF ( tabRect . X + tab . Rect . Width - tabDrawable . Height / 4 - closesize , tabDrawable . Height / 4 , closesize , closesize ) ;
647
+ tab . CloseRect = new RectangleF ( tabRect . X + tab . Rect . Width - tabPadding . Right - closesize , tabDrawable . Height / 4 , closesize , closesize ) ;
635
648
tab . TextRect = new RectangleF ( tabRect . X + tabPadding . Left + textoffset , ( tabDrawable . Height - size . Height ) / 2 , textSize . Width , textSize . Height ) ;
636
649
637
650
posx += tab . Rect . Width ;
@@ -671,8 +684,10 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i)
671
684
g . FillRectangle ( backcolor , tabRect ) ;
672
685
if ( tab . Image != null )
673
686
{
674
- var imageSize = tab . Image . Size ;
675
- g . DrawImage ( tab . Image , tabRect . X + TabPadding . Left + ( maxImageSize . Width - imageSize . Width ) / 2 , ( tabDrawable . Height - imageSize . Height ) / 2 ) ;
687
+ g . SaveTransform ( ) ;
688
+ g . ImageInterpolation = ImageInterpolation . High ;
689
+ g . DrawImage ( tab . Image , tabRect . X + TabPadding . Left , ( tabDrawable . Height - maxImageSize . Height ) / 2 , maxImageSize . Width , maxImageSize . Height ) ;
690
+ g . RestoreTransform ( ) ;
676
691
}
677
692
g . DrawText ( Font , textcolor , textRect . Location , tab . Text ) ;
678
693
0 commit comments